diff --git a/src/client.c b/src/client.c index f57499389e675b57b1de63113745395da7a9b46f..7ac4656f0070b4b6bb41d0ed096b9b6aa8cba10f 100644 --- a/src/client.c +++ b/src/client.c @@ -1321,6 +1321,29 @@ void clientConfigure(Client * c, XWindowChanges * wc, int mask) } } +static inline void clientConstraintPos(Client *c) +{ + g_return_if_fail(c != NULL); + DBG("entering clientConstraintPos\n"); + DBG("client \"%s\" (%#lx)\n", c->name, c->window); + if (c->x + c->width < CLIENT_MIN_VISIBLE) + { + c->x = CLIENT_MIN_VISIBLE - c->width ; + } + else if (c->x > XDisplayWidth(dpy, screen) - CLIENT_MIN_VISIBLE) + { + c->x = XDisplayWidth(dpy, screen) - CLIENT_MIN_VISIBLE; + } + if (c->y + c->height < CLIENT_MIN_VISIBLE) + { + c->y = CLIENT_MIN_VISIBLE - c->height ; + } + else if (c->y > XDisplayHeight(dpy, screen) - CLIENT_MIN_VISIBLE) + { + c->y = XDisplayHeight(dpy, screen) - CLIENT_MIN_VISIBLE; + } +} + /* Compute rectangle overlap area */ static unsigned long overlap(int x0, int y0, int x1, int y1, int tx0, int ty0, int tx1, int ty1) { @@ -1363,6 +1386,22 @@ static void clientInitPosition(Client * c) if(c->size->flags & (PPosition | USPosition)) { + if (c->x + c->width < 5) + { + c->x = 5 - c->width ; + } + if (c->x > XDisplayWidth(dpy, screen)) + { + c->x = XDisplayWidth(dpy, screen) - 5; + } + if (c->y + c->height < 5) + { + c->y = 5 - c->height ; + } + if (c->y > XDisplayHeight(dpy, screen)) + { + c->y = XDisplayHeight(dpy, screen) - 5; + } return; } @@ -2289,6 +2328,7 @@ static GtkToXEventFilterStatus clientMove_event_filter(XEvent * xevent, gpointer c->y = c->y + 16; } } + clientConstraintPos(c); if(box_move) { clientDrawOutline(c); @@ -2376,7 +2416,7 @@ static GtkToXEventFilterStatus clientMove_event_filter(XEvent * xevent, gpointer } } } - + clientConstraintPos(c); if(box_move) { clientDrawOutline(c); diff --git a/src/client.h b/src/client.h index 9d297e6d5f2901b1bdd7ce95ffca5c922e590379..02855fc2aad9df0c8645ac6948fb0acfadf8f9f5 100644 --- a/src/client.h +++ b/src/client.h @@ -144,6 +144,8 @@ #define ACTION_SHADE 2 #define ACTION_HIDE 3 +#define CLIENT_MIN_VISIBLE 5 + typedef enum { UNSET, diff --git a/src/main.c b/src/main.c index ea1d05db5cc9a4c92fd615f06383366bc978906e..eac22fcbfb4b2f17bf3f4936c7fd3d4148996ff4 100644 --- a/src/main.c +++ b/src/main.c @@ -120,11 +120,11 @@ void initialize(int argc, char **argv) gtk_init(&argc, &argv); progname = argv[0]; - dpy = GDK_DISPLAY(); - root = GDK_ROOT_WINDOW(); + dpy = GDK_DISPLAY(); + root = GDK_ROOT_WINDOW(); screen = XDefaultScreen(dpy); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); + depth = DefaultDepth(dpy, screen); + cmap = DefaultColormap(dpy, screen); margins[MARGIN_TOP] = gnome_margins[MARGIN_TOP] = 0; margins[MARGIN_LEFT] = gnome_margins[MARGIN_LEFT] = 0; @@ -139,15 +139,15 @@ void initialize(int argc, char **argv) initGnomeHints(dpy); initNetHints(dpy); - root_cursor = XCreateFontCursor(dpy, XC_left_ptr); - move_cursor = XCreateFontCursor(dpy, XC_fleur); - resize_cursor[CORNER_TOP_LEFT] = XCreateFontCursor(dpy, XC_top_left_corner); - resize_cursor[CORNER_TOP_RIGHT] = XCreateFontCursor(dpy, XC_top_right_corner); - resize_cursor[CORNER_BOTTOM_LEFT] = XCreateFontCursor(dpy, XC_bottom_left_corner); + root_cursor = XCreateFontCursor(dpy, XC_left_ptr); + move_cursor = XCreateFontCursor(dpy, XC_fleur); + resize_cursor[CORNER_TOP_LEFT] = XCreateFontCursor(dpy, XC_top_left_corner); + resize_cursor[CORNER_TOP_RIGHT] = XCreateFontCursor(dpy, XC_top_right_corner); + resize_cursor[CORNER_BOTTOM_LEFT] = XCreateFontCursor(dpy, XC_bottom_left_corner); resize_cursor[CORNER_BOTTOM_RIGHT] = XCreateFontCursor(dpy, XC_bottom_right_corner); - resize_cursor[4 + SIDE_LEFT] = XCreateFontCursor(dpy, XC_left_side); - resize_cursor[4 + SIDE_RIGHT] = XCreateFontCursor(dpy, XC_right_side); - resize_cursor[4 + SIDE_BOTTOM] = XCreateFontCursor(dpy, XC_bottom_side); + resize_cursor[4 + SIDE_LEFT] = XCreateFontCursor(dpy, XC_left_side); + resize_cursor[4 + SIDE_RIGHT] = XCreateFontCursor(dpy, XC_right_side); + resize_cursor[4 + SIDE_BOTTOM] = XCreateFontCursor(dpy, XC_bottom_side); XDefineCursor(dpy, root, root_cursor);