summaryrefslogtreecommitdiff
blob: 842c60fd6d016f5aa349befc9b8690989b27ad0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
diff -urN blackbox-0.65.0/nls/C/Configmenu.m blackbox-0.65.0-wheel/nls/C/Configmenu.m
--- blackbox-0.65.0/nls/C/Configmenu.m	2002-07-17 15:50:57.000000000 -0500
+++ blackbox-0.65.0-wheel/nls/C/Configmenu.m	2002-09-23 17:51:52.000000000 -0500
@@ -4,6 +4,14 @@
 # Config Options
 $ #FocusModel
 # Focus Model
+$ #MouseWheel
+# Mouse Wheel
+$ #ChangesFocus
+# Changes Focus
+$ #ChangesWorkspace
+# Changes Workspace
+$ #ReverseScroll
+# Reverse Scroll
 $ #WindowPlacement
 # Window Placement
 $ #ImageDithering
diff -urN blackbox-0.65.0/src/Configmenu.cc blackbox-0.65.0-wheel/src/Configmenu.cc
--- blackbox-0.65.0/src/Configmenu.cc	2002-08-01 14:35:19.000000000 -0500
+++ blackbox-0.65.0-wheel/src/Configmenu.cc	2002-09-25 00:46:25.000000000 -0500
@@ -37,10 +37,13 @@
   setInternalMenu();
 
   focusmenu = new Focusmenu(this);
+  wheelmenu = new Wheelmenu(this);
   placementmenu = new Placementmenu(this);
-
+   
   insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
               "Focus Model"), focusmenu);
+  insert(i18n(ConfigmenuSet, ConfigmenuMouseWheel,
+              "Mouse Wheel"), wheelmenu);
   insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
               "Window Placement"), placementmenu);
   insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
@@ -57,17 +60,18 @@
               "Disable Bindings with Scroll Lock"), 6);
   update();
 
-  setItemSelected(2, getScreen()->getImageControl()->doDither());
-  setItemSelected(3, getScreen()->doOpaqueMove());
-  setItemSelected(4, getScreen()->doFullMax());
-  setItemSelected(5, getScreen()->doFocusNew());
-  setItemSelected(6, getScreen()->doFocusLast());
-  setItemSelected(7, getScreen()->allowScrollLock());
+  setItemSelected(3, getScreen()->getImageControl()->doDither());
+  setItemSelected(4, getScreen()->doOpaqueMove());
+  setItemSelected(5, getScreen()->doFullMax());
+  setItemSelected(6, getScreen()->doFocusNew());
+  setItemSelected(7, getScreen()->doFocusLast());
+  setItemSelected(8, getScreen()->allowScrollLock());
 }
 
 
 Configmenu::~Configmenu(void) {
   delete focusmenu;
+  delete wheelmenu;
   delete placementmenu;
 }
 
@@ -131,6 +135,7 @@
 
 void Configmenu::reconfigure(void) {
   focusmenu->reconfigure();
+  wheelmenu->reconfigure();
   placementmenu->reconfigure();
 
   Basemenu::reconfigure();
@@ -194,6 +199,53 @@
 }
 
 
+Configmenu::Wheelmenu::Wheelmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
+  setLabel(i18n(ConfigmenuSet, ConfigmenuMouseWheel, "Mouse Wheel"));
+  setInternalMenu();
+
+  insert(i18n(ConfigmenuSet, ConfigmenuChangesFocus, "Changes Focus"), 1);
+  insert(i18n(ConfigmenuSet, ConfigmenuChangesWorkspace, "Changes Workspace"), 2);
+  insert(i18n(ConfigmenuSet, ConfigmenuReverseScroll, "Reverse Scroll"), 3);  
+  update();
+
+  setItemSelected(0, getScreen()->isChangesFocus());
+  setItemSelected(1, ! getScreen()->isChangesFocus());
+  setItemSelected(2, getScreen()->isReverseScroll());
+}
+
+
+void Configmenu::Wheelmenu::itemSelected(int button, unsigned int index) {
+  if (button != 1)
+    return;
+
+  BasemenuItem *item = find(index);
+
+  if (!item->function())
+    return;
+
+  switch (item->function()) {
+  case 1: // mouse wheel changes focus
+    getScreen()->toggleMouseWheel(BScreen::ChangesFocus);
+    break;
+
+  case 2: // mouse wheel changes workspace
+    getScreen()->toggleMouseWheel(BScreen::ChangesWorkspace);
+    break;
+
+  case 3: // reverse scroll direction
+    if (getScreen()->isReverseScroll())
+      getScreen()->toggleScroll(BScreen::Normal);
+    else
+      getScreen()->toggleScroll(BScreen::Reverse);
+    break;
+  }
+
+  setItemSelected(0, getScreen()->isChangesFocus());
+  setItemSelected(1, ! getScreen()->isChangesFocus());
+  setItemSelected(2, getScreen()->isReverseScroll());
+}
+
+
 Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
   Basemenu(cm->getScreen()) {
   setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement"));
diff -urN blackbox-0.65.0/src/Configmenu.hh blackbox-0.65.0-wheel/src/Configmenu.hh
--- blackbox-0.65.0/src/Configmenu.hh	2002-08-01 14:36:21.000000000 -0500
+++ blackbox-0.65.0-wheel/src/Configmenu.hh	2002-09-23 03:08:31.000000000 -0500
@@ -45,6 +45,18 @@
     Focusmenu(Configmenu *cm);
   };
 
+  class Wheelmenu : public Basemenu {
+  private:
+    Wheelmenu(const Wheelmenu&);
+    Wheelmenu& operator=(const Wheelmenu&);
+
+  protected:
+    virtual void itemSelected(int button, unsigned int index);
+
+  public:
+    Wheelmenu(Configmenu *cm);
+  };
+
   class Placementmenu : public Basemenu {
   private:
     Placementmenu(const Placementmenu&);
@@ -59,9 +71,11 @@
   };
 
   Focusmenu *focusmenu;
+  Wheelmenu *wheelmenu;
   Placementmenu *placementmenu;
 
   friend class Focusmenu;
+  friend class Wheelmenu;
   friend class Placementmenu;
 
   Configmenu(const Configmenu&);
@@ -75,6 +89,7 @@
   virtual ~Configmenu(void);
 
   inline Basemenu *getFocusmenu(void) { return focusmenu; }
+  inline Basemenu *getWheelmenu(void) { return wheelmenu; }
   inline Basemenu *getPlacementmenu(void) { return placementmenu; }
 
   void reconfigure(void);
diff -urN blackbox-0.65.0/src/Screen.cc blackbox-0.65.0-wheel/src/Screen.cc
--- blackbox-0.65.0/src/Screen.cc	2002-09-04 12:15:58.000000000 -0500
+++ blackbox-0.65.0-wheel/src/Screen.cc	2002-09-25 02:49:54.000000000 -0500
@@ -997,6 +997,7 @@
   *(session_stack + i++) = workspacemenu->getWindowID();
 
   *(session_stack + i++) = configmenu->getFocusmenu()->getWindowID();
+  *(session_stack + i++) = configmenu->getWheelmenu()->getWindowID();
   *(session_stack + i++) = configmenu->getPlacementmenu()->getWindowID();
   *(session_stack + i++) = configmenu->getWindowID();
 
@@ -1120,7 +1121,7 @@
       focused->getScreen()->getScreenNumber() == getScreenNumber() &&
       current_workspace->getCount() > 1) {
     do {
-      next = current_workspace->getNextWindowInList(next);
+      next = current_workspace->getPrevWindowInList(next);
     } while(next != focused && ! next->setInputFocus());
 
     if (next != focused)
@@ -1741,6 +1742,46 @@
       blackbox->checkMenu();
       rootmenu->show();
     }
+
+  //mouse wheel up
+  } else if (xbutton->button == 4) {
+    if (this->isReverseScroll()) {
+      if (this->isChangesFocus())
+        this->nextFocus();
+      else
+        if (getCurrentWorkspaceID() >= getWorkspaceCount() - 1)
+          changeWorkspaceID(0);
+        else
+          changeWorkspaceID(getCurrentWorkspaceID() + 1);
+    } else {
+      if (this->isChangesFocus())
+        this->prevFocus();
+      else
+        if (getCurrentWorkspaceID() == 0)
+          changeWorkspaceID(getWorkspaceCount() - 1);
+        else
+          changeWorkspaceID(getCurrentWorkspaceID() - 1);
+    }
+
+  // mouse wheel down          
+  } else if (xbutton->button == 5) {
+    if (this->isReverseScroll()) {
+      if (this->isChangesFocus())
+        this->prevFocus();
+      else
+        if (getCurrentWorkspaceID() == 0)
+          changeWorkspaceID(getWorkspaceCount() - 1);
+        else
+          changeWorkspaceID(getCurrentWorkspaceID() - 1);
+    } else {
+      if (this->isChangesFocus())
+        this->nextFocus();
+      else
+        if (getCurrentWorkspaceID() >= getWorkspaceCount() - 1)
+          changeWorkspaceID(0);
+        else
+          changeWorkspaceID(getCurrentWorkspaceID() + 1);
+    }
   }
 }
 
@@ -1762,6 +1803,26 @@
 }
 
 
+void BScreen::toggleMouseWheel(MouseWheel model) {
+
+  if (model == ChangesFocus) {
+    saveChangesFocus(True);
+  } else {
+    saveChangesFocus(False);
+  }
+}
+
+
+void BScreen::toggleScroll(Scroll model) {
+
+  if (model == Normal) {
+    saveReverseScroll(False);
+  } else {
+    saveReverseScroll(True);
+  }
+}
+
+
 BTexture BScreen::readDatabaseTexture(const string &rname,
                                       const string &rclass,
                                       const string &default_color) {
diff -urN blackbox-0.65.0/src/Screen.hh blackbox-0.65.0-wheel/src/Screen.hh
--- blackbox-0.65.0/src/Screen.hh	2002-09-04 12:15:26.000000000 -0500
+++ blackbox-0.65.0-wheel/src/Screen.hh	2002-09-25 00:52:15.000000000 -0500
@@ -149,7 +149,8 @@
 
     bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
       auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
-      focus_new, focus_last, click_raise, allow_scroll_lock;
+      focus_new, focus_last, click_raise, allow_scroll_lock, changes_focus,
+      reverse_scroll;
     BColor border_color;
     XrmDatabase stylerc;
 
@@ -200,6 +201,8 @@
          WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
          WindowLower, WindowStick, WindowKill, SetStyle };
   enum FocusModel { SloppyFocus, ClickToFocus };
+  enum MouseWheel { ChangesFocus, ChangesWorkspace };
+  enum Scroll { Normal, Reverse };
 
   BScreen(Blackbox *bb, unsigned int scrn);
   ~BScreen(void);
@@ -210,6 +213,10 @@
   { return resource.toolbar_auto_hide; }
   inline bool isSloppyFocus(void) const
   { return resource.sloppy_focus; }
+  inline bool isChangesFocus(void) const
+  { return resource.changes_focus; }
+  inline bool isReverseScroll(void) const
+  { return resource.reverse_scroll; }
   inline bool isRootColormapInstalled(void) const
   { return root_colormap_installed; }
   inline bool doAutoRaise(void) const { return resource.auto_raise; }
@@ -284,6 +291,8 @@
 
   inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
   inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; }
+  inline void saveChangesFocus(bool s) { resource.changes_focus = s; }
+  inline void saveReverseScroll(bool s) { resource.reverse_scroll = s; }
   inline void saveAutoRaise(bool a) { resource.auto_raise = a; }
   inline void saveClickRaise(bool c) { resource.click_raise = c; }
   inline void saveWorkspaces(unsigned int w) { resource.workspaces = w; }
@@ -352,6 +361,8 @@
   void raiseFocus(void) const;
   void reconfigure(void);
   void toggleFocusModel(FocusModel model);
+  void toggleMouseWheel(MouseWheel model);
+  void toggleScroll(Scroll model);
   void rereadMenu(void);
   void shutdown(void);
   void showPosition(int x, int y);
diff -urN blackbox-0.65.0/src/Window.cc blackbox-0.65.0-wheel/src/Window.cc
--- blackbox-0.65.0/src/Window.cc	2002-09-17 10:23:35.000000000 -0500
+++ blackbox-0.65.0-wheel/src/Window.cc	2002-09-25 02:54:17.000000000 -0500
@@ -2663,6 +2663,12 @@
       XRaiseWindow(blackbox->getXDisplay(),
                    windowmenu->getSendToMenu()->getWindowID());
     }
+  } else if (be->button == 4)  { //mouse wheel shade
+    if ((be->window == frame.label || be->window == frame.title) && ! flags.shaded)
+      shade();
+  } else if (be->button == 5)  { //mouse wheel unshade
+    if ((be->window == frame.label || be->window == frame.title) && flags.shaded)
+    shade();
   }
 }
 
diff -urN blackbox-0.65.0/src/blackbox.cc blackbox-0.65.0-wheel/src/blackbox.cc
--- blackbox-0.65.0/src/blackbox.cc	2002-08-25 05:05:45.000000000 -0500
+++ blackbox-0.65.0-wheel/src/blackbox.cc	2002-09-24 18:16:57.000000000 -0500
@@ -1068,6 +1068,20 @@
             fmodel.c_str());
     XrmPutLineResource(&new_blackboxrc, rc_string);
 
+    string mwheel;
+    if (screen->isChangesFocus()) {
+      mwheel = "ChangesFocus";
+    } else {
+      mwheel = "ChangesWorkspace";
+    }
+    sprintf(rc_string, "session.screen%d.mouseWheel:  %s", screen_number,
+            mwheel.c_str());
+    XrmPutLineResource(&new_blackboxrc, rc_string);
+
+    sprintf(rc_string, "session.screen%d.reverseScroll: %s", screen_number,
+            ((screen->isReverseScroll()) ? "True" : "False"));
+    XrmPutLineResource(&new_blackboxrc, rc_string);
+
     sprintf(rc_string, "session.screen%d.workspaces:  %d", screen_number,
             screen->getWorkspaceCount());
     XrmPutLineResource(&new_blackboxrc, rc_string);
@@ -1380,6 +1394,27 @@
     }
   }
 
+  sprintf(name_lookup,  "session.screen%d.mouseWheel", screen_number);
+  sprintf(class_lookup, "Session.Screen%d.MouseWheel", screen_number);
+  screen->saveChangesFocus(True);
+  if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
+                     &value)) {
+    string mwheel = value.addr;
+
+    if (mwheel.find("ChangesWorkspace") != string::npos) {
+      screen->saveChangesFocus(False);
+    }
+  }
+
+  sprintf(name_lookup, "session.screen%d.reverseScroll", screen_number);
+  sprintf(class_lookup, "Session.Screen%d.ReverseScroll", screen_number);
+  screen->saveReverseScroll(False);
+  if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
+                     &value) &&
+      ! strncasecmp(value.addr, "true", value.size)) {
+    screen->saveReverseScroll(True);
+  }
+
   sprintf(name_lookup,  "session.screen%d.windowPlacement", screen_number);
   sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number);
   screen->savePlacementPolicy(BScreen::RowSmartPlacement);