Fix menu positioning bug
[wmaker-crm.git] / contrib / workspace_flip.patch
blob46d5f2fcae6eb43da3a61eff3fd52c917aab2f14
1 diff -Naur WindowMaker-0.65.0/src/WindowMaker.h wmaker-workspaceflip/src/WindowMaker.h
2 --- WindowMaker-0.65.0/src/WindowMaker.h Sat Apr 28 01:41:21 2001
3 +++ wmaker-workspaceflip/src/WindowMaker.h Sun Aug 12 12:51:14 2001
4 @@ -397,6 +397,8 @@
6 int raise_delay; /* delay for autoraise. 0 is disabled */
8 + int workspace_flip_delay; /* delay for workspace flipping, 0 is disabled */
9 +
10 int cmap_size; /* size of dithering colormap in colors
11 * per channel */
13 diff -Naur WindowMaker-0.65.0/src/defaults.c wmaker-workspaceflip/src/defaults.c
14 --- WindowMaker-0.65.0/src/defaults.c Fri May 11 00:16:49 2001
15 +++ wmaker-workspaceflip/src/defaults.c Sun Aug 12 12:51:14 2001
16 @@ -420,6 +420,9 @@
17 {"RaiseDelay", "0", NULL,
18 &wPreferences.raise_delay, getInt, NULL
20 + {"WorkspaceFlipDelay", "0", NULL,
21 + &wPreferences.workspace_flip_delay, getInt, NULL
22 + },
23 {"WindozeCycling", "YES", NULL,
24 &wPreferences.windows_cycling,getBool, NULL
26 diff -Naur WindowMaker-0.65.0/src/event.c wmaker-workspaceflip/src/event.c
27 --- WindowMaker-0.65.0/src/event.c Sat Apr 28 01:41:21 2001
28 +++ wmaker-workspaceflip/src/event.c Sun Aug 12 12:51:14 2001
29 @@ -1676,12 +1676,53 @@
33 +#define DEL_TIMER(timer) { \
34 + WMDeleteTimerHandler(timer); \
35 + timer = NULL; \
40 +static void
41 +flipRightWorkspace(void* data)
43 + WScreen *scr = (WScreen*)data;
44 + int x,y,tmp,last_workspace = scr->current_workspace;
45 + Window tmpw;
47 + DEL_TIMER(scr->workspace_flip_right_timer);
49 + XQueryPointer(dpy,scr->root_win,&tmpw,&tmpw,&x,&y,&tmp,&tmp,&tmp);
50 + if(x != scr->scr_width-1) return;
52 + wWorkspaceRelativeChange(scr, 1);
53 + if(last_workspace != scr->current_workspace)
54 + XWarpPointer(dpy,None,scr->root_win,0,0,0,0,1,y);
57 +static void
58 +flipLeftWorkspace(void* data)
60 + WScreen *scr = (WScreen*)data;
61 + int x,y,tmp,last_workspace = scr->current_workspace;
62 + Window tmpw;
64 + DEL_TIMER(scr->workspace_flip_left_timer);
66 + XQueryPointer(dpy,scr->root_win,&tmpw,&tmpw,&x,&y,&tmp,&tmp,&tmp);
67 + if(x != 0) return;
69 + wWorkspaceRelativeChange(scr, -1);
70 + if(last_workspace != scr->current_workspace)
71 + XWarpPointer(dpy,None,scr->root_win,0,0,0,0,scr->scr_width-2,y);
74 static void
75 handleMotionNotify(XEvent *event)
77 WMenu *menu;
78 WScreen *scr = wScreenForRootWindow(event->xmotion.root);
79 + int left,right;
81 if (wPreferences.scrollable_menus) {
82 if (scr->flags.jump_back_pending ||
83 @@ -1697,6 +1738,29 @@
84 wMenuScroll(menu, event);
88 + /* workspace flipping */
89 + if(!wPreferences.workspace_flip_delay) return;
91 + left = (event->xmotion.x_root == 0);
92 + right = (event->xmotion.x_root == scr->scr_width-1);
94 + if(right && !scr->workspace_flip_right_timer)
95 + scr->workspace_flip_right_timer =
96 + WMAddTimerHandler(wPreferences.workspace_flip_delay,
97 + flipRightWorkspace,scr);
99 + if(left && !scr->workspace_flip_left_timer)
100 + scr->workspace_flip_left_timer =
101 + WMAddTimerHandler(wPreferences.workspace_flip_delay,
102 + flipLeftWorkspace,scr);
104 + if(!right && scr->workspace_flip_right_timer)
105 + DEL_TIMER(scr->workspace_flip_right_timer);
107 + if(!left && scr->workspace_flip_left_timer)
108 + DEL_TIMER(scr->workspace_flip_left_timer);
110 #if 0
111 if (event->xmotion.subwindow == None)
112 return;
113 diff -Naur WindowMaker-0.65.0/src/screen.h wmaker-workspaceflip/src/screen.h
114 --- WindowMaker-0.65.0/src/screen.h Sun Apr 15 03:23:01 2001
115 +++ wmaker-workspaceflip/src/screen.h Sun Aug 12 12:51:14 2001
116 @@ -273,6 +273,10 @@
117 Window last_click_window;
118 int last_click_button;
120 + /* for workspace flipping when mouse hits edge */
121 + WMHandlerID *workspace_flip_left_timer;
122 + WMHandlerID *workspace_flip_right_timer;
124 /* balloon help data */
125 struct _WBalloon *balloon;