From af4e77405cad998daf10f8c3aa1b23b52a1d5121 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 14 Jun 2009 21:36:45 +0200 Subject: [PATCH] Mouse: Remove transparent_{move / resize} : new movement/resize mode with revert border. --- src/config.c | 3 --- src/config_struct.h | 2 -- src/event.c | 1 - src/mouse.c | 66 ++++++++++++++++++++++++++++++++++++++------- src/structs.h | 2 -- 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/config.c b/src/config.c index fa22835..f82c535 100644 --- a/src/config.c +++ b/src/config.c @@ -128,9 +128,6 @@ conf_misc_section(cfg_t *cfg_m) conf.font = alias_to_str(_strdup(cfg_getstr(cfg_m, "font"))); conf.raisefocus = cfg_getbool(cfg_m, "raisefocus"); conf.raiseswitch = cfg_getbool(cfg_m, "raiseswitch"); - conf.resize_transparent = cfg_getbool(cfg_m, "resize_transparent"); - conf.move_transparent = cfg_getbool(cfg_m, "move_transparent"); - return; } diff --git a/src/config_struct.h b/src/config_struct.h index 4143430..d11df15 100644 --- a/src/config_struct.h +++ b/src/config_struct.h @@ -42,8 +42,6 @@ cfg_opt_t misc_opts[] = CFG_STR("font", "sans-9", CFGF_NONE), CFG_BOOL("raisefocus", cfg_false, CFGF_NONE), CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE), - CFG_BOOL("resize_transparent", cfg_false, CFGF_NONE), - CFG_BOOL("move_transparent", cfg_false, CFGF_NONE), CFG_END() }; diff --git a/src/event.c b/src/event.c index b3ac6e5..6196c3e 100644 --- a/src/event.c +++ b/src/event.c @@ -259,7 +259,6 @@ configureevent(XConfigureRequestEvent *ev) CHECK(!c->state_fullscreen); } - /* Configure Request Part {{{ */ if((c= client_gb_win(ev->window))) { if(ev->value_mask & CWX) diff --git a/src/mouse.c b/src/mouse.c index ed8aa49..22521fd 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -44,6 +44,8 @@ mouse_move(Client *c) Window dw, sw; Client *sclient; XRectangle geo = c->geo, ogeo; + XGCValues xgc; + GC gci; XEvent ev; if(c->max || c->lmax || c->state_fullscreen || c->state_dock) @@ -56,6 +58,12 @@ mouse_move(Client *c) None, cursor[CurMove], CurrentTime) != GrabSuccess) return; + /* Set the GC for the rectangle */ + xgc.function = GXinvert; + xgc.subwindow_mode = IncludeInferiors; + xgc.line_width = BORDH; + gci = XCreateGC(dpy, ROOT, GCFunction|GCSubwindowMode|GCLineWidth, &xgc); + XQueryPointer(dpy, ROOT, &dw, &dw, &mx, &my, &dint, &dint, &duint); do @@ -79,7 +87,7 @@ mouse_move(Client *c) client_moveresize(sclient, ogeo, False); } - /* To move a client of one tag to another */ + /* To move a client from one tag to another */ XQueryPointer(dpy, infobar[selscreen].bar->win, &dw, &sw, &mx, &my, &dint, &dint, &duint); for(i = 1; i < conf.ntag[selscreen] + 1; ++i) @@ -96,11 +104,26 @@ mouse_move(Client *c) /* To move a client normally, in freelayout */ else { + XDrawRectangle(dpy, ROOT, gci, + geo.x, + geo.y - (TBARH - BORDH), + geo.width, + geo.height + (TBARH - BORDH)); + geo.x = (ocx + (ev.xmotion.x - mx)); geo.y = (ocy + (ev.xmotion.y - my)); - if(!conf.move_transparent) - client_moveresize(c, geo, False); + /* + * Need to draw 2 times the same rectangle because + * it is draw with the revert color; revert + revert = normal + */ + XDrawRectangle(dpy, ROOT, gci, + (ogeo.x = geo.x), + (ogeo.y = geo.y - (TBARH - BORDH)), + (ogeo.width = geo.width), + (ogeo.height = geo.height + (TBARH - BORDH))); + + frame_update(c); } } else if(ev.type == MapRequest @@ -110,9 +133,10 @@ mouse_move(Client *c) } while(ev.type != ButtonRelease); - if(!c->tile) - client_moveresize(c, geo, False); - + /* One time again to delete all the trace on the window */ + XDrawRectangle(dpy, ROOT, gci, ogeo.x, ogeo.y, ogeo.width, ogeo.height); + client_moveresize(c, geo, False); + frame_update(c); client_update_attributes(c); XUngrabPointer(dpy, CurrentTime); @@ -126,10 +150,12 @@ mouse_move(Client *c) void mouse_resize(Client *c) { - XRectangle geo = c->geo; + XRectangle geo = c->geo, ogeo = c->geo; XEvent ev; Window w; int d, u, omx, omy; + XGCValues xgc; + GC gci; float mwf = tags[selscreen][seltag[selscreen]].mwfact; if(c->max || c->lmax @@ -141,6 +167,13 @@ mouse_resize(Client *c) if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync, None, cursor[CurResize], CurrentTime) != GrabSuccess) return; + + /* Set the GC for the rectangle */ + xgc.function = GXinvert; + xgc.subwindow_mode = IncludeInferiors; + xgc.line_width = BORDH; + gci = XCreateGC(dpy, ROOT, GCFunction|GCSubwindowMode|GCLineWidth, &xgc); + do { XMaskEvent(dpy, MouseMask | ExposureMask | SubstructureRedirectMask, &ev); @@ -165,6 +198,12 @@ mouse_resize(Client *c) } else if(!c->tile) { + XDrawRectangle(dpy, ROOT, gci, + geo.x - BORDH / 2, + geo.y - (TBARH - (BORDH / 2)), + geo.width, + geo.height + (TBARH - BORDH)); + if((geo.width + ev.xmotion.x_root - omx) > 1) geo.width += ev.xmotion.x_root - omx; if((geo.height + ev.xmotion.y_root - omy) > 1) @@ -173,8 +212,13 @@ mouse_resize(Client *c) omx = ev.xmotion.x_root; omy = ev.xmotion.y_root; - if(!conf.resize_transparent) - client_moveresize(c, geo, True); + XDrawRectangle(dpy, ROOT, gci, + (ogeo.x = geo.x - BORDH / 2), + (ogeo.y = geo.y - (TBARH - (BORDH / 2))), + (ogeo.width = geo.width), + (ogeo.height = geo.height + (TBARH - BORDH))); + + frame_update(c); XSync(dpy, False); } @@ -186,7 +230,11 @@ mouse_resize(Client *c) while(ev.type != ButtonRelease); if(!c->tile) + { client_moveresize(c, geo, True); + XDrawRectangle(dpy, ROOT, gci, ogeo.x, ogeo.y, ogeo.width, ogeo.height); + frame_update(c); + } else tags[selscreen][seltag[selscreen]].layout.func(c->screen); diff --git a/src/structs.h b/src/structs.h index d971b4a..55459d1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -279,8 +279,6 @@ typedef struct char *font; Bool raisefocus; Bool raiseswitch; - Bool resize_transparent; - Bool move_transparent; struct { /*