[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Patch] Implementing a click-to-raise feature
When in floating mode or in floating layout the only way to bring one
window on top of another seems to be a focus switch through
focusnext/focusprev. The following patch implements a click-to-raise
feature.
--- patch-click-to-raise begins here ---
diff --git a/client.c b/client.c
index 4295f1b..cd13060 100644
--- a/client.c
+++ b/client.c
@@ -61,16 +61,28 @@ detachstack(Client * c)
/** Grab or ungrab buttons when a client is focused
* \param c client
* \param focused True if client is focused
+ * \param raised True if the client is above other clients
* \param modkey Mod key mask
* \param numlockmask Numlock mask
*/
-static void
-grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask)
+void
+grabbuttons(Client * c, Bool focused, Bool raised, KeySym modkey, unsigned int numlockmask)
{
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
if(focused)
{
+ if (!raised) {
+ XGrabButton(c->display, Button1, NoSymbol, c->win, False, BUTTONMASK,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(c->display, Button1, LockMask, c->win, False,
+ BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(c->display, Button1, numlockmask, c->win, False,
+ BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(c->display, Button1, numlockmask | LockMask,
+ c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+ }
+
XGrabButton(c->display, Button1, modkey, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button1, modkey | LockMask, c->win, False,
@@ -317,7 +329,7 @@ focus(Display *disp, Client * c, Bool selscreen, awesome_config *awesomeconf)
/* if a client was selected but it's not the current client, unfocus it */
if(sel && sel != c)
{
- grabbuttons(sel, False, awesomeconf->modkey, awesomeconf->numlockmask);
+ grabbuttons(sel, False, True, awesomeconf->modkey, awesomeconf->numlockmask);
XSetWindowBorder(sel->display, sel->win, awesomeconf->colors_normal[ColBorder].pixel);
setclienttrans(sel, awesomeconf->opacity_unfocused);
}
@@ -327,7 +339,7 @@ focus(Display *disp, Client * c, Bool selscreen, awesome_config *awesomeconf)
{
detachstack(c);
attachstack(c);
- grabbuttons(c, True, awesomeconf->modkey, awesomeconf->numlockmask);
+ grabbuttons(c, True, True, awesomeconf->modkey, awesomeconf->numlockmask);
}
if(!selscreen)
return;
@@ -434,7 +446,7 @@ manage(Display *disp, Window w, XWindowAttributes *wa, awesome_config *awesomeco
XShapeSelectInput(disp, w, ShapeNotifyMask);
set_shape(c);
}
- grabbuttons(c, False, awesomeconf->modkey, awesomeconf->numlockmask);
+ grabbuttons(c, False, True, awesomeconf->modkey, awesomeconf->numlockmask);
updatetitle(c);
move_client_to_screen(c, awesomeconf, False);
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success))
diff --git a/client.h b/client.h
index d6ee3ff..050b163 100644
--- a/client.h
+++ b/client.h
@@ -62,6 +62,7 @@ struct Client
Bool ftview;
};
+void grabbuttons(Client *, Bool, Bool, KeySym, unsigned int);
inline void attach(Client *); /* attaches c to global client list */
void ban(Client *); /* bans c */
void configure(Client *); /* send synthetic configure event */
diff --git a/event.c b/event.c
index 2c06af6..f15eb0b 100644
--- a/event.c
+++ b/event.c
@@ -193,9 +193,13 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
if((c = getclient(ev->window)))
{
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
- if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey)
- return;
- if(ev->button == Button1)
+ if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey) {
+ if (ev->button == Button1) {
+ restack(c->display, &awesomeconf[c->screen]);
+ grabbuttons(c, True, True, awesomeconf->modkey, awesomeconf->numlockmask);
+ }
+ }
+ else if(ev->button == Button1)
{
if(!IS_ARRANGE(layout_floating) && !c->isfloating)
uicb_togglefloating(e->xany.display, &awesomeconf[c->screen], NULL);
@@ -333,8 +337,11 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return;
- if((c = getclient(ev->window)))
+ if((c = getclient(ev->window))) {
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
+ if (sel)
+ grabbuttons(sel, True, False, awesomeconf->modkey, awesomeconf->numlockmask);
+ }
else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen))
--- patch-click-to-raise ends here ---
Cheers
\n\n
--
To unsubscribe, send mail to awesome-unsubscribe@xxxxxxxxxxxxx