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();
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)
/* 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;
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
CWX | CWY)) {
int x, y, w, h;
ObCorner corner;
- Rect *a;
x = (e->xconfigurerequest.value_mask & CWX) ?
e->xconfigurerequest.x : client->area.x;
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:
} 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;
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);