From: Dana Jansens Date: Mon, 28 Jul 2003 18:06:55 +0000 (+0000) Subject: make those apps stay/map on screen!! fuck stupid apps. thats right im talking to... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=950516124f49000bd8df0481df0c54a14a05b7f9;p=chaz%2Fopenbox make those apps stay/map on screen!! fuck stupid apps. thats right im talking to you mozilla and you too java. --- diff --git a/openbox/client.c b/openbox/client.c index a6830193..70873a43 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -300,7 +300,7 @@ void client_manage(Window window) dispatch_client(Event_Client_New, self, 0, 0); /* make sure the window is visible */ - client_move_onscreen(self); + client_move_onscreen(self, TRUE); screen_update_areas(); @@ -454,27 +454,61 @@ void client_unmanage(ObClient *self) client_set_list(); } -void client_move_onscreen(ObClient *self) +void client_move_onscreen(ObClient *self, gboolean rude) +{ + int x = self->area.x; + int y = self->area.y; + if (client_find_onscreen(self, &x, &y, + self->area.width, self->area.height, rude)) { + client_configure(self, OB_CORNER_TOPLEFT, x, y, + self->area.width, self->area.height, + TRUE, TRUE); + } +} + +gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h, + gboolean rude) { Rect *a; - int x = self->frame->area.x, y = self->frame->area.y; + int ox = *x, oy = *y; + + frame_client_gravity(self->frame, x, y); /* get where the frame + would be */ /* XXX watch for xinerama dead areas */ + a = screen_area(self->desktop); - if (x >= a->x + a->width - 1) - x = a->x + a->width - self->frame->area.width; - if (y >= a->y + a->height - 1) - y = a->y + a->height - self->frame->area.height; - if (x + self->frame->area.width - 1 < a->x) - x = a->x; - if (y + self->frame->area.height - 1< a->y) - y = a->y; - - frame_frame_gravity(self->frame, &x, &y); /* get where the client - should be */ - client_configure(self, OB_CORNER_TOPLEFT, x, y, - self->area.width, self->area.height, - TRUE, TRUE); + if (*x >= a->x + a->width - 1) + *x = a->x + a->width - self->frame->area.width; + if (*y >= a->y + a->height - 1) + *y = a->y + a->height - self->frame->area.height; + if (*x + self->frame->area.width - 1 < a->x) + *x = a->x; + if (*y + self->frame->area.height - 1 < a->y) + *y = a->y; + + if (rude) { + /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good. + Java can suck it too. */ + + /* dont let windows map/move into the strut unless they + are bigger than the available area */ + if (w <= a->width) { + if (*x < a->x) *x = a->x; + if (*x + w > a->x + a->width) + *x = a->x + a->width - w; + } + if (h <= a->height) { + if (*y < a->y) *y = a->y; + if (*y + h > a->y + a->height) + *y = a->y + a->height - h; + } + } + + frame_frame_gravity(self->frame, x, y); /* get where the client + should be */ + + return ox != *x || oy != *y; } static void client_toggle_border(ObClient *self, gboolean show) @@ -891,22 +925,7 @@ void client_update_normal_hints(ObClient *self) /* get the hints from the window */ if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) { - if (size.flags & (PPosition|USPosition)) { - Rect *a; - - /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good. - Java can suck it too. */ - - /* dont let windows map above/left into the strut unless they - are bigger than the available area */ - a = screen_area(self->desktop); - if (self->area.width <= a->width && self->area.x < a->x) - self->area.x = a->x; - if (self->area.height <= a->height && self->area.y < a->y) - self->area.y = a->y; - - self->positioned = TRUE; - } + self->positioned = !!(size.flags & (PPosition|USPosition)); if (size.flags & PWinGravity) { self->gravity = size.win_gravity; diff --git a/openbox/client.h b/openbox/client.h index 7001765f..4421f8fe 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -284,10 +284,28 @@ void client_configure(ObClient *self, ObCorner anchor, void client_reconfigure(ObClient *self); +/*! Finds coordinates to keep a client on the screen. + @param self The client + @param x The x coord of the client, may be changed. + @param y The y coord of the client, may be changed. + @param w The width of the client. + @param w The height of the client. + @param rude Be rude about it. If false, it is only moved if it is entirely + not visible. If true, then make sure the window is inside the + struts if possible. + @return true if the client was moved to be on-screen; false if not. +*/ +gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h, + gboolean rude); + /*! Moves a client so that it is on screen if it is entirely out of the viewable screen. + @param self The client to move + @param rude Be rude about it. If false, it is only moved if it is entirely + not visible. If true, then make sure the window is inside the + struts if possible. */ -void client_move_onscreen(ObClient *self); +void client_move_onscreen(ObClient *self, gboolean rude); /*! Fullscreen's or unfullscreen's the client window @param fs true if the window should be made fullscreen; false if it should diff --git a/openbox/event.c b/openbox/event.c index 4f9f61dc..a35c5258 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -725,7 +725,6 @@ static void event_handle_client(ObClient *client, XEvent *e) CWX | CWY)) { int x, y, w, h; ObCorner corner; - Rect *a; x = (e->xconfigurerequest.value_mask & CWX) ? e->xconfigurerequest.x : client->area.x; @@ -736,15 +735,15 @@ static void event_handle_client(ObClient *client, XEvent *e) h = (e->xconfigurerequest.value_mask & CWHeight) ? e->xconfigurerequest.height : client->area.height; - /* dont let windows move above/left into the strut unless they are - bigger than the available area */ - a = screen_area(client->desktop); - if (e->xconfigurerequest.value_mask & CWX && - w <= a->width && x < a->x) - x = a->x; - if (e->xconfigurerequest.value_mask & CWY && - h <= a->height && y < a->y) - y = a->y; + { + int newx = x; + int newy = y; + client_find_onscreen(client, &newx, &newy, w, h, TRUE); + if (e->xconfigurerequest.value_mask & CWX) + x = newx; + if (e->xconfigurerequest.value_mask & CWY) + y = newy; + } switch (client->gravity) { case NorthEastGravity: @@ -910,7 +909,6 @@ static void event_handle_client(ObClient *client, XEvent *e) } else if (msgtype == prop_atoms.net_moveresize_window) { int oldg = client->gravity; int tmpg, x, y, w, h; - Rect *a; if (e->xclient.data.l[0] & 0xff) tmpg = e->xclient.data.l[0] & 0xff; @@ -935,22 +933,16 @@ static void event_handle_client(ObClient *client, XEvent *e) h = client->area.y; client->gravity = tmpg; - /* get the frame position */ - frame_client_gravity(client->frame, &x, &y); - - /* dont let windows move above/left into the strut unless they are - bigger than the available area */ - a = screen_area(client->desktop); - if (e->xconfigurerequest.value_mask & CWX && - w <= a->width && x < a->x) - x = a->x; - if (e->xconfigurerequest.value_mask & CWY && - h <= a->height && y < a->y) - y = a->y; + { + int newx = x; + int newy = y; + client_find_onscreen(client, &newx, &newy, w, h, TRUE); + if (e->xclient.data.l[0] & 1 << 8) + x = newx; + if (e->xclient.data.l[0] & 1 << 9) + y = newy; + } - /* go back to the client position */ - frame_frame_gravity(client->frame, &x, &y); - client_configure(client, OB_CORNER_TOPLEFT, x, y, w, h, FALSE, TRUE); diff --git a/openbox/screen.c b/openbox/screen.c index 59212da1..b312aba9 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -357,7 +357,7 @@ void screen_resize() screen_update_areas(); for (it = client_list; it; it = it->next) - client_move_onscreen(it->data); + client_move_onscreen(it->data, FALSE); } void screen_set_num_desktops(guint num)