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.
This commit is contained in:
Nikos Ntarmos 2007-10-11 07:46:28 +03:00 committed by Julien Danjou
parent 9b05a2b21f
commit 8401eee5f5
3 changed files with 29 additions and 9 deletions

View File

@ -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))

View File

@ -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 */

15
event.c
View File

@ -201,9 +201,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);
@ -341,8 +345,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))