From c496df9fc6565c6363c0e2a4db51f1c2d7516e23 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 19 Mar 2008 15:34:07 +0100 Subject: [PATCH] Add support for mouse bindings on titlebars --- awesomerc.in | 10 ++++++++++ common/configopts.c | 1 + config.c | 5 ++++- event.c | 5 +++++ structs.h | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/awesomerc.in b/awesomerc.in index 34136e012..47f602f37 100644 --- a/awesomerc.in +++ b/awesomerc.in @@ -182,6 +182,16 @@ mouse button = "3" command = "client_resizemouse" } + titlebar + { + button = "1" + command = "client_movemouse" + } + titlebar + { + button = "3" + command = "client_resizemouse" + } } keys diff --git a/common/configopts.c b/common/configopts.c index a9e908f37..f335ddc10 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -410,6 +410,7 @@ cfg_opt_t mouse_opts[] = { CFG_SEC((char *) "root", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "client", mouse_generic_opts, CFGF_MULTI), + CFG_SEC((char *) "titlebar", mouse_generic_opts, CFGF_MULTI), CFG_AWESOME_END() }; cfg_opt_t menu_opts[] = diff --git a/config.c b/config.c index 3ea31f5aa..5b20a1895 100644 --- a/config.c +++ b/config.c @@ -266,7 +266,7 @@ create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar) { widget = widget_new(statusbar, wptr); widget_list_append(&statusbar->widgets, widget); - widget->buttons = parse_mouse_bindings(wptr, "mouse", a_strcmp(cfg_name(wptr), "taglist")); + widget->buttons = parse_mouse_bindings(wptr, "mouse", a_strcmp(cfg_name(wptr), "taglist") ? True : False); } else warn("ignoring unknown widget: %s.\n", cfg_name(widgets + i)); @@ -534,6 +534,9 @@ config_parse(const char *confpatharg) /* Mouse: client windows click bindings */ globalconf.buttons.client = parse_mouse_bindings(cfg_mouse, "client", True); + /* Mouse: titlebar windows click bindings */ + globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", True); + /* Keys */ globalconf.numlockmask = get_numlockmask(globalconf.display); diff --git a/event.c b/event.c index 3b75847ce..48f3c8ba8 100644 --- a/event.c +++ b/event.c @@ -138,6 +138,10 @@ event_handle_buttonpress(XEvent *e) event_handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); } else + { + for(c = globalconf.clients; c; c = c->next) + if(c->titlebar.sw && c->titlebar.sw->window == ev->window) + event_handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.titlebar, NULL); for(screen = 0; screen < ScreenCount(e->xany.display); screen++) if(RootWindow(e->xany.display, screen) == ev->window && XQueryPointer(e->xany.display, @@ -150,6 +154,7 @@ event_handle_buttonpress(XEvent *e) globalconf.buttons.root, NULL); return; } + } } /** Handle XConfigureRequest events diff --git a/structs.h b/structs.h index f55818af5..fc5e0194e 100644 --- a/structs.h +++ b/structs.h @@ -324,6 +324,7 @@ struct AwesomeConf { Button *root; Button *client; + Button *titlebar; } buttons; /** Numlock mask */ unsigned int numlockmask;