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

[wmx] Patch for SunPowerSwitch.

Sven Oliver Moll - Fri Oct 15 14:37:16 1999

Hello!

I just implemented the SunPowerSwitch. It now behaves just like it does with
CDE's wm. It calls sys-suspend, which pops up a requester asking if you want to
suspend, shutdown or cancel.

Since there wmx contains some features that only make sence on a SUN machine,
how about some #ifdef's around these features and a seperate section in
Config.h? Please comment about that one. If there's a positive response I
volunteer to do this.

Greetings,
SvOlli
-- 
  _______
 (  /\           | Q:  I thought you said there were ten questions?
__)v\/lli a.k.a. | A:  There are now!
Sven Oliver Moll |   -- Jamie Zawinski
--- Config.h.orig	Thu Oct 14 00:03:50 1999
+++ Config.h	Thu Oct 14 00:14:33 1999
@@ -219,6 +219,8 @@
 #define CONFIG_QUICKHIDE_KEY	XK_F17
 #define CONFIG_QUICKHEIGHT_KEY	XK_F13
 #define CONFIG_QUICKRAISE_ALSO_LOWERS True 
+// Do you want to use SUN's Power Key?
+#define CONFIG_SUNPOWER_EXEC "/usr/openwin/bin/sys-suspend","/usr/openwin/bin/sys-syspend","-x",0
 
 
 // ==============================
--- Client.C.orig	Wed Oct 13 23:22:19 1999
+++ Client.C	Thu Oct 14 00:06:00 1999
@@ -9,6 +9,10 @@
 #include <X11/Xmu/Atoms.h>
 #endif
 
+#ifdef CONFIG_SUNPOWER_EXEC
+#include <X11/Sunkeysym.h>
+#endif
+
 const char *const Client::m_defaultLabel = "incognito";
 
 
@@ -205,6 +209,14 @@
 		     GrabModeAsync, GrabModeAsync);
 	}
 
+#ifdef CONFIG_SUNPOWER_EXEC
+	keycode = XKeysymToKeycode(display(), SunXK_PowerSwitch);
+	if (keycode) {
+	    XGrabKey(display(), keycode, 0, m_window, True,
+		     GrabModeAsync, GrabModeAsync);
+	}
+#endif
+	
 	if (CONFIG_USE_CHANNEL_KEYS) {
 	    for (i = 0; i < 12; ++i) {
 		keycode = XKeysymToKeycode(display(), XK_F1 + i);
--- Buttons.C.orig	Wed Oct 13 23:22:11 1999
+++ Buttons.C	Thu Oct 14 00:05:37 1999
@@ -4,6 +4,9 @@
 #include "Menu.h"
 #include <X11/keysym.h>
 #include <sys/time.h>
+#ifdef CONFIG_SUNPOWER_EXEC
+#include <X11/Sunkeysym.h>
+#endif
 
 
 void WindowManager::eventButton(XButtonEvent *e)
@@ -129,7 +132,14 @@
 	    } else {
 		c->fullHeight();
 	    }
-
+#ifdef CONFIG_SUNPOWER_EXEC
+	} else if (key == SunXK_PowerSwitch) {
+	    pid_t pid = fork();
+	    if(pid == 0)
+	    {
+		execl(CONFIG_SUNPOWER_EXEC);
+	    }
+#endif
 	} else if (ev->state & CONFIG_ALT_KEY_MASK) {
 
 	    if (key >= XK_F1 && key <= XK_F12 &&

Next: