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:
parent
9b05a2b21f
commit
8401eee5f5
22
client.c
22
client.c
|
@ -61,16 +61,28 @@ detachstack(Client * c)
|
||||||
/** Grab or ungrab buttons when a client is focused
|
/** Grab or ungrab buttons when a client is focused
|
||||||
* \param c client
|
* \param c client
|
||||||
* \param focused True if client is focused
|
* \param focused True if client is focused
|
||||||
|
* \param raised True if the client is above other clients
|
||||||
* \param modkey Mod key mask
|
* \param modkey Mod key mask
|
||||||
* \param numlockmask Numlock mask
|
* \param numlockmask Numlock mask
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask)
|
grabbuttons(Client * c, Bool focused, Bool raised, KeySym modkey, unsigned int numlockmask)
|
||||||
{
|
{
|
||||||
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
||||||
|
|
||||||
if(focused)
|
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,
|
XGrabButton(c->display, Button1, modkey, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(c->display, Button1, modkey | LockMask, c->win, False,
|
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 a client was selected but it's not the current client, unfocus it */
|
||||||
if(sel && sel != c)
|
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);
|
XSetWindowBorder(sel->display, sel->win, awesomeconf->colors_normal[ColBorder].pixel);
|
||||||
setclienttrans(sel, awesomeconf->opacity_unfocused);
|
setclienttrans(sel, awesomeconf->opacity_unfocused);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +339,7 @@ focus(Display *disp, Client * c, Bool selscreen, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
grabbuttons(c, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
grabbuttons(c, True, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
||||||
}
|
}
|
||||||
if(!selscreen)
|
if(!selscreen)
|
||||||
return;
|
return;
|
||||||
|
@ -434,7 +446,7 @@ manage(Display *disp, Window w, XWindowAttributes *wa, awesome_config *awesomeco
|
||||||
XShapeSelectInput(disp, w, ShapeNotifyMask);
|
XShapeSelectInput(disp, w, ShapeNotifyMask);
|
||||||
set_shape(c);
|
set_shape(c);
|
||||||
}
|
}
|
||||||
grabbuttons(c, False, awesomeconf->modkey, awesomeconf->numlockmask);
|
grabbuttons(c, False, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
move_client_to_screen(c, awesomeconf, False);
|
move_client_to_screen(c, awesomeconf, False);
|
||||||
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success))
|
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success))
|
||||||
|
|
1
client.h
1
client.h
|
@ -62,6 +62,7 @@ struct Client
|
||||||
Bool ftview;
|
Bool ftview;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void grabbuttons(Client *, Bool, Bool, KeySym, unsigned int);
|
||||||
inline void attach(Client *); /* attaches c to global client list */
|
inline void attach(Client *); /* attaches c to global client list */
|
||||||
void ban(Client *); /* bans c */
|
void ban(Client *); /* bans c */
|
||||||
void configure(Client *); /* send synthetic configure event */
|
void configure(Client *); /* send synthetic configure event */
|
||||||
|
|
15
event.c
15
event.c
|
@ -201,9 +201,13 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
||||||
if((c = getclient(ev->window)))
|
if((c = getclient(ev->window)))
|
||||||
{
|
{
|
||||||
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
|
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
|
||||||
if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey)
|
if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey) {
|
||||||
return;
|
if (ev->button == Button1) {
|
||||||
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)
|
if(!IS_ARRANGE(layout_floating) && !c->isfloating)
|
||||||
uicb_togglefloating(e->xany.display, &awesomeconf[c->screen], NULL);
|
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)
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||||
return;
|
return;
|
||||||
if((c = getclient(ev->window)))
|
if((c = getclient(ev->window))) {
|
||||||
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
|
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
|
||||||
|
if (sel)
|
||||||
|
grabbuttons(sel, True, False, awesomeconf->modkey, awesomeconf->numlockmask);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||||
if(ev->window == RootWindow(e->xany.display, screen))
|
if(ev->window == RootWindow(e->xany.display, screen))
|
||||||
|
|
Loading…
Reference in New Issue