[Thread Prev][Thread Next]   >Date Index >Thread Index

[wmx] pl8: new mousebutton code

Sven Oliver Moll - Tue Feb 16 21:25:38 1999

Hello!

I've been hacking on wmx again:
this time the changes are:
- rewritten the handling of the mouse buttons, so you can now choose your
  own set (was needed because the command menu should be on the right mouse
  button here) during that the 'right' option in the dynamic configuration
  code was removed
- during that, the channel click area is now defined the in same way as the
  exit click area
- a glitch was fixed in dynamic config code error reporting.

The patch is against pl7.
The new tarball (wmx-5sec3pl8.tar.gz) is as usual at:
http://www.uni-hildesheim.de/~smol0999/wmx/

The code has not been heavily tested. Comments are as always very welcome.

Greetings from Germany,
SvOlli


diff -burN wmx-5sec3pl7/Buttons.C wmx-5sec3pl8/Buttons.C
--- wmx-5sec3pl7/Buttons.C	Thu Feb 11 09:40:58 1999
+++ wmx-5sec3pl8/Buttons.C	Tue Feb 16 20:53:00 1999
@@ -9,50 +9,129 @@
 void WindowManager::eventButton(XButtonEvent *e)
 {
     Client *c = windowToClient(e->window);
-
-    if (e->button == Button3 && m_channelChangeTime == 0) {
-	if (dConfig.rightCirculate())
+    int menu_type = 0;
+#define CLIENT_MENU_TYPE 1
+#define COMMAND_MENU_TYPE 2
+    
+    
+#if CONFIG_CHANNEL_SURF
+    if	((CONFIG_CHANNEL_CLICK_SIZE_X != 0 ? 
+	  (CONFIG_CHANNEL_CLICK_SIZE_X > 0 ? 
+	   (e->x < CONFIG_CHANNEL_CLICK_SIZE_X) : 
+	   (e->x > DisplayWidth(display(), screen())
+	             + CONFIG_CHANNEL_CLICK_SIZE_X)) : 1) &&
+	 (CONFIG_CHANNEL_CLICK_SIZE_Y != 0 ? 
+	  (CONFIG_CHANNEL_CLICK_SIZE_Y > 0 ? 
+	   (e->y < CONFIG_CHANNEL_CLICK_SIZE_Y) : 
+	   (e->y > DisplayHeight(display(), screen())
+	             + CONFIG_CHANNEL_CLICK_SIZE_Y)) : 1)) // Channel surf
+    {
+	switch (e->button)
+	{
+#if (CONFIG_CHANNEL_UP_MOUSE_BUTTON != 0)
+	 case CONFIG_CHANNEL_UP_MOUSE_BUTTON:
+	    if (m_channelChangeTime == 0)
+	      flipChannel(True, False, False,0);
+	    else 
+	      flipChannel(False, False, False, 0);
+	    break;
+#endif
+#if (CONFIG_CHANNEL_DOWN_MOUSE_BUTTON != 0)
+	 case CONFIG_CHANNEL_DOWN_MOUSE_BUTTON:
+	    if (m_channelChangeTime != 0)
+	      flipChannel(False, True, False, 0);
+	    break;
+#endif
+	 default:
+	    break;
+	}
+    }
+    else
+#endif
+      if (e->window == e->root) // CONTEXT = Root
+    {
+	switch (e->button)
+	{
+#if (CONFIG_CLIENT_MENU_MOUSE_BUTTON != 0)
+	 case CONFIG_CLIENT_MENU_MOUSE_BUTTON:		
+	    menu_type = CLIENT_MENU_TYPE;
+	    break;
+#endif
+#if (CONFIG_COMMAND_MENU_MOUSE_BUTTON != 0)
+	 case CONFIG_COMMAND_MENU_MOUSE_BUTTON:
+	    menu_type = COMMAND_MENU_TYPE;
+	    break;
+#endif
+#if ((CONFIG_WINDOWS_CIRCULATE_MOUSE_BUTTON != 0) && CONFIG_CIRCULATE_ON_ROOT)
+	 case CONFIG_CIRCULATE_MOUSE_BUTTON:
+#endif
 	circulate(e->window == e->root);
-	else if (dConfig.rightLower())
-	    if (e->window != e->root) c->lower();
-	return;
+	    break;
+	 default:
+	    break;
+	}
     }
 
-    if (e->window == e->root) {
-
-	if (e->button == Button1 && m_channelChangeTime == 0) {
-	    ClientMenu menu(this, (XEvent *)e);
-
-	} else if (e->x > DisplayWidth(display(), screen()) -
-		   CONFIG_CHANNEL_CLICK_SIZE &&
-		   e->y < CONFIG_CHANNEL_CLICK_SIZE) {
-
-	    if (e->button == Button2) {
-
-		if (m_channelChangeTime == 0) flipChannel(True, False, False,0);
-		else flipChannel(False, False, False, 0);
-
-	    } else if (e->button == Button1 && m_channelChangeTime != 0) {
+    if(c) // CONTEXT = Window
+    {
 
-		flipChannel(False, True, False, 0);
+	switch (e->button)
+	{
+#if ((CONFIG_WINDOW_CHANNEL_UP_MOUSE_BUTTON != 0) && (CONFIG_CHANNEL_SURF))
+	 case CONFIG_WINDOW_CHANNEL_UP_MOUSE_BUTTON:
+	    if (m_channelChangeTime == 0)
+	      flipChannel(True, False, False, 0);
+	    else
+	      flipChannel(False, False, False, c);
+	    break;
+#endif
+#if ((CONFIG_WINDOW_CHANNEL_DOWN_MOUSE_BUTTON != 0) && (CONFIG_CHANNEL_SURF))
+	 case CONFIG_WINDOW_CHANNEL_DOWN_MOUSE_BUTTON:
+	    if (m_channelChangeTime != 0)
+	      flipChannel(False, True, False, c);
+	    break;
+#endif
+#if (CONFIG_WINDOW_CIRCULATE_MOUSE_BUTTON != 0)
+	 case CONFIG_WINDOW_CIRCULATE_MOUSE_BUTTON:
+	    circulate(e->window == e->root);
+	    break;
+#endif
+#if (CONFIG_WINDOW_LOWER_MOUSE_BUTTON != 0)
+	 case CONFIG_WINDOW_LOWER_MOUSE_BUTTON:
+	    if (e->window != e->root)
+	      c->lower();
+	    break
+#endif
+#if (CONFIG_WINDOW_TOGGLEHEIGHT_MOUSE_BUTTON != 0)
+	 case CONFIG_WINDOW_TOGGLEHEIGHT_MOUSE_BUTTON:
+	    if (c->isFullHeight()) {
+		c->normalHeight();
+	    } else {
+		c->fullHeight();
+	    }
+	    break;
+#endif
+#if (CONFIG_WINDOW_ACTION_MOUSE_BUTTON != 0)
+	 case CONFIG_WINDOW_ACTION_MOUSE_BUTTON:
+	    c->eventButton(e);
+	    break;
+#endif
+	 default:
+	    break;
+	}	
 	    }
 
-	} else if (e->button == Button2 && m_channelChangeTime == 0) {
+    if(menu_type == CLIENT_MENU_TYPE)
+    {
+	ClientMenu menu(this, (XEvent *)e);
+    }
+    else if(menu_type == COMMAND_MENU_TYPE)
+    {
 	    dConfig.scan();
 	    CommandMenu menu(this, (XEvent *)e);
 	}
 
-    } else if (c) {
-
-	if (e->button == Button2 && CONFIG_CHANNEL_SURF) {
-	    if (m_channelChangeTime == 0) flipChannel(True, False, False, 0);
-	    else flipChannel(False, False, False, c);
 	    return;
-	}
-
-	c->eventButton(e);
-	return;
-    }
 }
 
 
@@ -246,7 +325,9 @@
 
     mapRaised();
 
-    if (e->button == Button1) {
+//    if (e->button == Button1) {
+    if (e->button == CONFIG_WINDOW_ACTION_MOUSE_BUTTON) {
+	    
 	if (m_border->hasWindow(e->window)) {
 
 	    m_border->eventButton(e);
diff -burN wmx-5sec3pl7/Config.C wmx-5sec3pl8/Config.C
--- wmx-5sec3pl7/Config.C	Wed Feb 10 22:31:34 1999
+++ wmx-5sec3pl8/Config.C	Tue Feb 16 21:08:55 1999
@@ -20,7 +20,6 @@
     char feedback;	// 0 = no , 1 = yes
     int  feeddelay;
     char disable;	// 0 = New Window option, 1 = no New
-    char rightBt;	// 0 = disable, 1 = circulate, 2 = lower
 };  
 
 DynamicConfig::DynamicConfig() : m_impl(new DynamicConfigImpl)
@@ -56,7 +55,6 @@
     m_impl->feedback	= DEFAULT_MAD_FEEDBACK;
     m_impl->feeddelay	= DEFAULT_FEEDBACK_DELAY;
     m_impl->disable	= DEFAULT_DISABLE_NEW_WINDOW_COMMAND;
-    m_impl->rightBt	= DEFAULT_RIGHT_MOUSE_BUTTON;
 
     scan(1);
 }
@@ -75,8 +73,6 @@
 char DynamicConfig::useFeedback() { return m_impl->feedback & 1; }
 int  DynamicConfig::feedbackDelay() { return m_impl->feeddelay; }
 char DynamicConfig::disableNew() { return m_impl->disable & 1; }
-char DynamicConfig::rightCirculate() { return m_impl->rightBt & 1; }
-char DynamicConfig::rightLower() { return m_impl->rightBt & 2; }
 
 void DynamicConfig::scan(char startup)
 {
@@ -132,14 +128,9 @@
 		if (OPTION(",")) m_impl->raisedelay = strtol(s, &s, 10);
 	    } else if (OPTION("follow")) m_impl->focus = 0;
 
-	if (OPTION("right:"))
-	    if (OPTION("off")) m_impl->rightBt = 0;
-	    else if (OPTION("circulate")) m_impl->rightBt = 1;
-	    else if (OPTION("lower")) m_impl->rightBt = 2;
-	
 	if (*s != '\0') {
 	    fprintf(stderr, "\nwmx: Dynamic configuration error: "
-		    "`%s' @ position %d", s, string - s);
+		    "`%s' @ position %d", s, s - string);
 	}
 
     } while (s = strtok(NULL, "/"));
diff -burN wmx-5sec3pl7/Config.h wmx-5sec3pl8/Config.h
--- wmx-5sec3pl7/Config.h	Thu Feb 11 09:32:45 1999
+++ wmx-5sec3pl8/Config.h	Tue Feb 16 21:01:40 1999
@@ -85,9 +85,24 @@
 #define DEFAULT_DISABLE_NEW_WINDOW_COMMAND 0
 // 0 = allow New window, 1 = don't
 
-// What to do on right mouse button
-#define DEFAULT_RIGHT_MOUSE_BUTTON 1
-// 0 = disable, 1 = circulate, 2 = lower
+// The Mouse Bindings
+// double assignment in one context fails compilation
+// in channel window (look below)
+#define CONFIG_CHANNEL_UP_MOUSE_BUTTON		Button2
+#define CONFIG_CHANNEL_DOWN_MOUSE_BUTTON	Button1
+
+// root space
+#define CONFIG_CLIENT_MENU_MOUSE_BUTTON		Button1
+#define CONFIG_COMMAND_MENU_MOUSE_BUTTON	Button3
+#define CONFIG_CIRCULATE_ON_ROOT		True
+
+// on window border
+#define CONFIG_WINDOW_CHANNEL_UP_MOUSE_BUTTON	Button2
+#define CONFIG_WINDOW_CHANNEL_DOWN_MOUSE_BUTTON	False
+#define CONFIG_WINDOW_LOWER_MOUSE_BUTTON	False
+#define CONFIG_WINDOW_ACTION_MOUSE_BUTTON	Button1
+#define CONFIG_WINDOW_TOGGLEHEIGHT_MOUSE_BUTTON	Button3
+#define CONFIG_WINDOW_CIRCULATE_MOUSE_BUTTON	False
 
 // Area where [exit wmx] is added (0 -> everywhere -# -> px from other side)
 #define CONFIG_EXIT_CLICK_SIZE_X 0
@@ -308,9 +323,11 @@
 // of the root window before the channel change happens.  Set
 // USE_CHANNEL_KEYS if you want Alt-F1, Alt-F2 etc for quick channel
 // changes, provided USE_KEYBOARD is also True.
+// CHANNEL_CLICK_SIZE is now defined the same way as EXIT_CLICK_SIZE
 
 #define CONFIG_CHANNEL_SURF       True
-#define CONFIG_CHANNEL_CLICK_SIZE 120
+#define CONFIG_CHANNEL_CLICK_SIZE_X -120
+#define CONFIG_CHANNEL_CLICK_SIZE_Y 120
 #define CONFIG_USE_CHANNEL_KEYS   True
 
 // FLIP_DELAY is the length of time the big green number stays in the
diff -burN wmx-5sec3pl7/Manager.C wmx-5sec3pl8/Manager.C
--- wmx-5sec3pl7/Manager.C	Thu Feb 11 18:20:12 1999
+++ wmx-5sec3pl8/Manager.C	Tue Feb 16 21:02:21 1999
@@ -38,7 +38,7 @@
     char *wmxdir = getenv("WMXDIR");
     
     fprintf(stderr, "\nwmx: Copyright (c) 1996-9 Chris Cannam."
-	    "  Fifth release (Patchlevel 6), Feb 1999\n"
+	    "  Fifth release (Patchlevel 8), Feb 1999\n"
 	    "     Parts derived from 9wm Copyright (c) 1994-96 David Hogan\n"
 	    "     Command menu code Copyright (c) 1997 Jeremy Fitzhardinge\n"
  	    "     Japanize code Copyright (c) 1998 Kazushi (Jam) Marukawa\n"

-- 
  _______
 (  /\           | No swords. No spells. Pistols, rockets, submachine guns,
__)v\/lli a.k.a. | laser weapons, and cunning are all the magic you need.
Sven Oliver Moll |   -- Package of Wasteland by Interplay (C64 Version)



Next: