Hi All

I have seen a few people asking for this, so I cobbled it together this weekend.

I think this patch needs some careful testing before moving it from next->master because in order for it to work, wmaker has to grab all CTRL+Mousebutton events which stops them from reaching the application. In effect, wmaker now has a monopoly on all MOD+Mousebutton and CTRL+Mousebutton events.
This definitely hurts some applications such as Google Earth, Blender, and even Xterm ("VT 
Fonts" menu is CTRL+Button3). This behavior can be disabled on a per application basis by 
using the "Do not bind mouse clicks" attribute, but then you also lose the MOD+Wheel 
functionality.

Anyway, since wmaker now controls all CTRL+Mousebutton events, I have also 
added actions for CTRL+Button1 and CTRL+Button3. This will now move a window 
backwards and forwards through the workspaces without changing the window 
position or size. I think I like this feature more than the CTRL+Wheel 
horizontal resize, and would maybe like to change it to CTRL+Wheel, but let's 
put it up for testing and see what people think.

Regards,

Johann Haarhoff
>From 1ed079d69ac7e566f187911c03a5bd9c8ee1e8db Mon Sep 17 00:00:00 2001
From: Johann Haarhoff <[email protected]>
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 9b2ecbc..618a5e9 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 6081036..ffe43ec 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);
                }
-- 
1.6.0.3

Reply via email to