diff --git a/client.c b/client.c index 13c3efa9..ba637957 100644 --- a/client.c +++ b/client.c @@ -546,27 +546,7 @@ client_resize(Client *c, area_t geometry) { if(!c->ismax) c->f_geometry = geometry; - - switch(c->titlebar.position) - { - case Top: - simplewindow_move_resize(c->titlebar.sw, - geometry.x, - geometry.y - c->titlebar.sw->geometry.height, - geometry.width, - c->titlebar.sw->geometry.height); - break; - case Bottom: - simplewindow_move_resize(c->titlebar.sw, - geometry.x, - geometry.y + geometry.height + 2 * c->border, - geometry.width, - c->titlebar.sw->geometry.height); - break; - default: - break; - } - titlebar_update(c); + titlebar_update_geometry_floating(c); } XConfigureWindow(globalconf.display, c->win, diff --git a/mouse.c b/mouse.c index fa66eb86..3010ae00 100644 --- a/mouse.c +++ b/mouse.c @@ -28,6 +28,7 @@ #include "event.h" #include "window.h" #include "client.h" +#include "titlebar.h" #include "layouts/floating.h" #include "layouts/tile.h" #include "common/xscreen.h" @@ -97,6 +98,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) { geometry.x = ocx + (ev.xmotion.x - x); geometry.y = ocy + (ev.xmotion.y - y); + if(abs(geometry.x) < globalconf.screens[screen].snap + area.x && geometry.x > area.x) geometry.x = area.x; else if(abs((area.x + area.width) - (geometry.x + c->geometry.width + 2 * c->border)) @@ -107,9 +109,14 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) else if(abs((area.y + area.height) - (geometry.y + c->geometry.height + 2 * c->border)) < globalconf.screens[screen].snap) geometry.y = area.y + area.height - c->geometry.height - 2 * c->border; + geometry.width = c->geometry.width; geometry.height = c->geometry.height; + client_resize(c, geometry); + + titlebar_update_geometry_floating(c); + while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev)); } else diff --git a/titlebar.c b/titlebar.c index d7f8ddb0..1194350d 100644 --- a/titlebar.c +++ b/titlebar.c @@ -56,6 +56,32 @@ titlebar_update(Client *c) draw_context_delete(ctx); } +void +titlebar_update_geometry_floating(Client *c) +{ + switch(c->titlebar.position) + { + default: + return; + case Top: + simplewindow_move_resize(c->titlebar.sw, + c->geometry.x, + c->geometry.y - c->titlebar.sw->geometry.height, + c->geometry.width, + c->titlebar.sw->geometry.height); + break; + case Bottom: + simplewindow_move_resize(c->titlebar.sw, + c->geometry.x, + c->geometry.y + c->geometry.height + 2 * c->border, + c->geometry.width, + c->titlebar.sw->geometry.height); + break; + } + + titlebar_update(c); +} + area_t titlebar_update_geometry(Client *c, area_t geometry) { diff --git a/titlebar.h b/titlebar.h index f817e7ba..be61c934 100644 --- a/titlebar.h +++ b/titlebar.h @@ -25,6 +25,7 @@ #include "structs.h" void titlebar_update(Client *); +void titlebar_update_geometry_floating(Client *); area_t titlebar_update_geometry(Client *, area_t); Uicb uicb_client_toggletitlebar;