From 744ccb85d2eaaa32febfb74fa18d15d7bb0c1c3a Mon Sep 17 00:00:00 2001 From: Johann Haarhoff Date: Sun, 14 Mar 2010 10:49:14 +0200 Subject: [PATCH] CTRL+Wheel Horizontal Resize + extras This patch constrains MOD+Wheel to vertical resize, and adds CTRL+Wheel horizontal resize. Two resize in both directions, you have to use CTRL+MOD+Wheel. To enable this functionality I have to grab all CTRL+Mousebutton events in wmaker, which stops them from reaching the application. This definitely hurts application functionality in some apps, for example the "VT Fonts" (CTRL+Button3) menu in xterm is no longer accessible. To stop this from happening use the "Do not bind mouse clicks" window attribute for the apps in which you want to disable this. Because wmaker now controls all CTRL+Mousebutton events, I also added CTRL+Button1 and CTRL+Button3 shortcuts that will move a window back and forth through your workspaces without changing its position or size. --- src/event.c | 2 +- src/window.c | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/event.c b/src/event.c index 9b2ecbcd..618a5e9e 100644 --- a/src/event.c +++ b/src/event.c @@ -765,7 +765,7 @@ static void handleButtonPress(XEvent * event) if (desc->parent_type == WCLASS_WINDOW) { XSync(dpy, 0); - if (event->xbutton.state & MOD_MASK) { + if (event->xbutton.state & ( MOD_MASK | ControlMask )) { XAllowEvents(dpy, AsyncPointer, CurrentTime); } diff --git a/src/window.c b/src/window.c index 6081036f..9bb14c07 100644 --- a/src/window.c +++ b/src/window.c @@ -2573,6 +2573,13 @@ void wWindowResetMouseGrabs(WWindow * wwin) wHackedGrabButton(AnyButton, MOD_MASK, wwin->client_win, True, ButtonPressMask | ButtonReleaseMask, GrabModeSync, GrabModeAsync, None, None); + // for CTRL + Wheel to Scroll Horiz, we have to grab CTRL as well + wHackedGrabButton(AnyButton, ControlMask, wwin->client_win, + True, ButtonPressMask | ButtonReleaseMask, + GrabModeSync, GrabModeAsync, None, None); + wHackedGrabButton(AnyButton, MOD_MASK | ControlMask, wwin->client_win, + True, ButtonPressMask | ButtonReleaseMask, + GrabModeSync, GrabModeAsync, None, None); } if (!wwin->flags.focused && !WFLAGP(wwin, no_focusable) @@ -2888,6 +2895,31 @@ static void frameMouseDown(WObjDescriptor *desc, XEvent *event) if (event->xbutton.button == Button1) wRaiseFrame(wwin->frame->core); + if (event->xbutton.state & ControlMask) { + if (event->xbutton.button == Button1) { + if (wwin->screen_ptr->current_workspace > 0) { + wWindowChangeWorkspace(wwin,wwin->screen_ptr->current_workspace - 1); + wWorkspaceRelativeChange(wwin->screen_ptr,-1); + } + } + if (event->xbutton.button == Button3) { + if (wwin->screen_ptr->current_workspace < (wwin->screen_ptr->workspace_count - 1) ) { + wWindowChangeWorkspace(wwin,wwin->screen_ptr->current_workspace + 1); + wWorkspaceRelativeChange(wwin->screen_ptr,1); + } + } + if (event->xbutton.button == Button4) { + new_width = wwin->client.width - resize_width_increment; + wWindowConstrainSize(wwin, &new_width, &wwin->client.height); + wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, wwin->client.height); + } + if (event->xbutton.button == Button5) { + new_width = wwin->client.width + resize_width_increment; + wWindowConstrainSize(wwin, &new_width, &wwin->client.height); + wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, wwin->client.height); + } + } + if (event->xbutton.state & MOD_MASK) { /* move the window */ if (XGrabPointer(dpy, wwin->client_win, False, @@ -2901,15 +2933,13 @@ static void frameMouseDown(WObjDescriptor *desc, XEvent *event) if (event->xbutton.button == Button3) { wMouseResizeWindow(wwin, event); } else if (event->xbutton.button == Button4) { - new_width = wwin->client.width - resize_width_increment; new_height = wwin->client.height - resize_height_increment; - wWindowConstrainSize(wwin, &new_width,&new_height); - wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, new_height); + wWindowConstrainSize(wwin, &wwin->client.width, &new_height); + wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, wwin->client.width, new_height); } else if (event->xbutton.button == Button5) { - new_width = wwin->client.width + resize_width_increment; new_height = wwin->client.height + resize_height_increment; - wWindowConstrainSize(wwin, &new_width,&new_height); - wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, new_width, new_height); + wWindowConstrainSize(wwin, &wwin->client.width, &new_height); + wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, wwin->client.width, new_height); } else if (event->xbutton.button == Button1 || event->xbutton.button == Button2) { wMouseMoveWindow(wwin, event); }