[compiz] Re: [PATCH] raise window key binding

moppsy moppsy at comcast.net
Wed Oct 11 07:00:06 PDT 2006


On Fri  9.Jun'06 at  6:52:40 +0000, moppsy at comcast.net wrote:
> With raise_on_click disabled, I wanted to be able to raise 
> a window with a button click sometimes.  It seemed logical 
> to do something like the lower window key binding.  
> So I did it.
> 
> It was quite simple, but here is the patch anyway.

I updated this patch to be more current.


-------------- next part --------------
diff --git a/include/compiz.h b/include/compiz.h
index b243f13..348eefd 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -545,7 +545,8 @@ #define COMP_DISPLAY_OPTION_TOGGLE_WINDO
 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT  51
 #define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS     52
 #define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED          53
-#define COMP_DISPLAY_OPTION_NUM                           54
+#define COMP_DISPLAY_OPTION_RAISE_WINDOW                  54
+#define COMP_DISPLAY_OPTION_NUM                           55
 
 typedef CompOption *(*GetDisplayOptionsProc) (CompDisplay *display,
 					      int	  *count);
diff --git a/src/display.c b/src/display.c
index c5cece1..dff9618 100644
--- a/src/display.c
+++ b/src/display.c
@@ -121,6 +121,9 @@ #define LOWER_WINDOW_MODIFIERS_DEFAULT C
 #define SHOW_DESKTOP_KEY_DEFAULT       "d"
 #define SHOW_DESKTOP_MODIFIERS_DEFAULT (CompAltMask | ControlMask)
 
+#define RAISE_WINDOW_BUTTON_DEFAULT    6
+#define RAISE_WINDOW_MODIFIERS_DEFAULT ControlMask
+
 #define OPACITY_INCREASE_BUTTON_DEFAULT    Button4
 #define OPACITY_INCREASE_MODIFIERS_DEFAULT CompAltMask
 
@@ -399,6 +402,25 @@ toggleSlowAnimations (CompDisplay     *d
 }
 
 static Bool
+raise (CompDisplay     *d,
+       CompAction      *action,
+       CompActionState state,
+       CompOption      *option,
+       int	       nOption)
+{
+    CompWindow *w;
+    Window     xid;
+
+    xid = getIntOptionNamed (option, nOption, "window", 0);
+
+    w = findTopLevelWindowAtDisplay (d, xid);
+    if (w)
+	raiseWindow (w);
+
+    return TRUE;
+}
+
+static Bool
 lower (CompDisplay     *d,
        CompAction      *action,
        CompActionState state,
@@ -948,6 +970,21 @@ #define COMMAND_OPTION(num, cname, rname
 	XKeysymToKeycode (display->display,
 			  XStringToKeysym (SLOW_ANIMATIONS_KEY_DEFAULT));
 
+    o = &display->opt[COMP_DISPLAY_OPTION_RAISE_WINDOW];
+    o->name			     = "raise_window";
+    o->shortDesc		     = N_("Raise Window");
+    o->longDesc			     = N_("Rasie window above other windows");
+    o->type			     = CompOptionTypeAction;
+    o->value.action.initiate	     = raise;
+    o->value.action.terminate        = 0;
+    o->value.action.bell	     = FALSE;
+    o->value.action.edgeMask	     = 0;
+    o->value.action.state	     = CompActionStateInitKey;
+    o->value.action.state	    |= CompActionStateInitButton;
+    o->value.action.type	     = CompBindingTypeButton;
+    o->value.action.button.modifiers = RAISE_WINDOW_MODIFIERS_DEFAULT;
+    o->value.action.button.button    = RAISE_WINDOW_BUTTON_DEFAULT;
+
     o = &display->opt[COMP_DISPLAY_OPTION_LOWER_WINDOW];
     o->name			     = "lower_window";
     o->shortDesc		     = N_("Lower Window");
@@ -1252,6 +1289,7 @@ setDisplayOption (CompDisplay     *displ
     case COMP_DISPLAY_OPTION_RUN_COMMAND10:
     case COMP_DISPLAY_OPTION_RUN_COMMAND11:
     case COMP_DISPLAY_OPTION_SLOW_ANIMATIONS:
+    case COMP_DISPLAY_OPTION_RAISE_WINDOW:
     case COMP_DISPLAY_OPTION_LOWER_WINDOW:
     case COMP_DISPLAY_OPTION_OPACITY_INCREASE:
     case COMP_DISPLAY_OPTION_OPACITY_DECREASE:
@@ -2351,6 +2389,7 @@ addScreenActions (CompDisplay *d, CompSc
     addScreenAction (s, &d->opt[COMP_DISPLAY_OPTION_RUN_COMMAND11].value.action);
     addScreenAction (s,
 		     &d->opt[COMP_DISPLAY_OPTION_SLOW_ANIMATIONS].value.action);
+    addScreenAction (s, &d->opt[COMP_DISPLAY_OPTION_RAISE_WINDOW].value.action);
     addScreenAction (s, &d->opt[COMP_DISPLAY_OPTION_LOWER_WINDOW].value.action);
     addScreenAction (s,
 		     &d->opt[COMP_DISPLAY_OPTION_OPACITY_INCREASE].value.action);
-- 
1.4.2.3



More information about the compiz mailing list