diff --git a/docs/userguide b/docs/userguide index 8cde2939..36c30d62 100644 --- a/docs/userguide +++ b/docs/userguide @@ -206,6 +206,26 @@ umlauts or special characters 'and' having some comfortably reachable key bindings. For example, when typing, capslock+1 or capslock+2 for switching workspaces is totally convenient. Try it :-). +=== The floating modifier + +To move floating windows with your mouse, you can either grab their titlebar +or configure the so called floating modifier which you can then press and +click anywhere in the window itself. The most common setup is to configure +it as the same one you use for managing windows (Mod1 for example). Afterwards, +you can press Mod1, click into a window using your left mouse button and drag +it to the position you want it at. + +*Syntax*: +-------------------------------- +floating_modifier +-------------------------------- + +*Examples*: +-------------------------------- +floating_modifier Mod1 +-------------------------------- + + === Variables As you learned in the previous section about keyboard bindings, you will have diff --git a/i3.config b/i3.config index 19f3caee..816b364c 100644 --- a/i3.config +++ b/i3.config @@ -9,6 +9,9 @@ terminal /usr/bin/urxvt # ISO 10646 = Unicode font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 +# Use Mouse+Mod1 to drag floating windows to their wanted position +floating_modifier Mod1 + # Fullscreen (Mod1+f) bind Mod1+41 f diff --git a/include/config.h b/include/config.h index 330b194c..1e85d471 100644 --- a/include/config.h +++ b/include/config.h @@ -3,7 +3,7 @@ * * i3 - an improved dynamic tiling window manager * - * (c) 2009 Michael Stapelberg and contributors + * © 2009 Michael Stapelberg and contributors * * See file LICENSE for license information. * @@ -37,6 +37,10 @@ struct Config { const char *terminal; const char *font; + /** The modifier which needs to be pressed in combination with your mouse + * buttons to do things with floating windows (move, resize) */ + uint32_t floating_modifier; + /* Color codes are stored here */ struct config_client { struct Colortriple focused; diff --git a/src/config.c b/src/config.c index 197fd4e1..d55c2a75 100644 --- a/src/config.c +++ b/src/config.c @@ -215,6 +215,30 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath) continue; } + if (strcasecmp(key, "floating_modifier") == 0) { + char *walk = value; + uint32_t modifiers = 0; + + while (*walk != '\0') { + /* Need to check for Mod1-5, Ctrl, Shift, Mode_switch */ + CHECK_MODIFIER(SHIFT); + CHECK_MODIFIER(CONTROL); + CHECK_MODIFIER(MODE_SWITCH); + CHECK_MODIFIER(MOD1); + CHECK_MODIFIER(MOD2); + CHECK_MODIFIER(MOD3); + CHECK_MODIFIER(MOD4); + CHECK_MODIFIER(MOD5); + + /* No modifier found? Then we’re done with this step */ + break; + } + + LOG("Floating modifiers = %d\n", modifiers); + config.floating_modifier = modifiers; + continue; + } + /* assign window class[/window title] → workspace */ if (strcasecmp(key, "assign") == 0) { LOG("assign: \"%s\"\n", value); diff --git a/src/handlers.c b/src/handlers.c index 3930e1e7..11c8e576 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -302,9 +302,11 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ client = table_get(&by_parent, event->event); border_click = true; } - /* See if this was a click with Mod1. If so, we need to move around - * the client if it was floating. if not, we just process as usual. */ - if ((event->state & XCB_MOD_MASK_1) != 0) { + /* See if this was a click with the configured modifier. If so, we need + * to move around the client if it was floating. if not, we just process + * as usual. */ + if (config.floating_modifier != 0 && + (event->state & config.floating_modifier) != 0) { if (client == NULL) { LOG("Not handling, Mod1 was pressed and no client found\n"); return 1;