Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -rupN xfwm4-4.8.3/src/client.c xfwm4-4.8.3-tiling/src/client.c
- --- xfwm4-4.8.3/src/client.c 2011-12-19 14:22:19.000000000 -0500
- +++ xfwm4-4.8.3-tiling/src/client.c 2011-12-22 23:22:00.538436871 -0500
- @@ -107,7 +107,7 @@ struct _ButtonPressData
- /* Forward decl */
- static void
- clientUpdateIconPix (Client * c);
- -static void
- +void
- clientNewMaxSize (Client * c, XWindowChanges *wc);
- Display *
- @@ -2153,6 +2153,12 @@ clientFrameAll (ScreenInfo *screen_info)
- if ((attr.map_state == IsViewable) && (attr.root == screen_info->xroot))
- {
- Client *c = clientFrame (display_info, wins[i], TRUE);
- + // initial values for existing windows
- + if (c)
- + {
- + c->pretiling_height = -1;
- + c->pretiling_width = -1;
- + }
- if ((c) && ((screen_info->params->raise_on_click) || (screen_info->params->click_to_focus)))
- {
- clientGrabMouseButton (c);
- @@ -3232,7 +3238,7 @@ clientNewMaxState (Client * c, XWindowCh
- wc->height = c->old_height;
- }
- -static void
- +void
- clientNewMaxSize (Client * c, XWindowChanges *wc)
- {
- ScreenInfo *screen_info;
- @@ -3259,7 +3265,7 @@ clientNewMaxSize (Client * c, XWindowCha
- full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
- rect.y + rect.height) - full_y;
- - if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED))
- + if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) || FLAG_TEST (c->flags, CLIENT_FLAG_TILED))
- {
- /* Adjust size to the largest size available, not covering struts */
- clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
- diff -rupN xfwm4-4.8.3/src/client.h xfwm4-4.8.3-tiling/src/client.h
- --- xfwm4-4.8.3/src/client.h 2011-12-19 14:22:19.000000000 -0500
- +++ xfwm4-4.8.3-tiling/src/client.h 2011-12-22 23:22:00.538436871 -0500
- @@ -161,6 +161,7 @@
- #define CLIENT_FLAG_DEMANDS_ATTENTION (1L<<17)
- #define CLIENT_FLAG_HAS_SHAPE (1L<<18)
- #define CLIENT_FLAG_FULLSCREN_MONITORS (1L<<19)
- +#define CLIENT_FLAG_TILED (1L<<20)
- #define WM_FLAG_DELETE (1L<<0)
- #define WM_FLAG_INPUT (1L<<1)
- @@ -283,6 +284,8 @@ struct _Client
- gint old_y;
- gint old_width;
- gint old_height;
- + gint pretiling_width;
- + gint pretiling_height;
- gint fullscreen_old_x;
- gint fullscreen_old_y;
- gint fullscreen_old_width;
- @@ -338,6 +341,8 @@ struct _Client
- extern Client *clients;
- extern unsigned int client_count;
- +void clientNewMaxSize (Client * c,
- + XWindowChanges *wc);
- Display *clientGetXDisplay (Client *);
- void clientClearLastOpTime (Client *);
- void clientUpdateWinState (Client *,
- diff -rupN xfwm4-4.8.3/src/moveresize.c xfwm4-4.8.3-tiling/src/moveresize.c
- --- xfwm4-4.8.3/src/moveresize.c 2011-12-19 14:22:19.000000000 -0500
- +++ xfwm4-4.8.3-tiling/src/moveresize.c 2011-12-22 23:42:48.471676235 -0500
- @@ -874,6 +874,162 @@ clientMoveEventFilter (XEvent * xevent,
- c->x = passdata->ox + (xevent->xmotion.x_root - passdata->mx);
- c->y = passdata->oy + (xevent->xmotion.y_root - passdata->my);
- +
- + // if window is not maximized
- + if (!FLAG_TEST_ALL(c->flags, CLIENT_FLAG_MAXIMIZED))
- + {
- + // if user moved cursor to the edge of the screen
- + if (xevent->xmotion.x_root < TILING_EDGE
- + || xevent->xmotion.x_root > screen_info->width - TILING_EDGE
- + || xevent->xmotion.y_root < TILING_EDGE
- + || xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
- + {
- + // save pretiling sizes for future restore
- +
- + // initial values for pretiling_width and pretiling_height
- + // are set in functions:
- + // placement.c => clientInitPosition - for new windows
- + // client.c => clientFrameAll - for existing windows
- + // P.S. maybe it's a dirty hack :-)
- +
- + if (c->pretiling_width == -1)
- + c->pretiling_width = c->width;
- + if (c->pretiling_height == -1)
- + c->pretiling_height = c->height;
- +
- + // get information about maximum available space
- + FLAG_SET (c->flags, CLIENT_FLAG_TILED);
- + XWindowChanges wc;
- + clientNewMaxSize(c, &wc);
- +
- + //Top left
- + if (xevent->xmotion.x_root < TILING_EDGE
- + && xevent->xmotion.y_root < TILING_EDGE)
- + {
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- +
- + c->x = wc.x;
- + c->y = wc.y;
- +
- + }
- + //Top Right
- + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE
- + && xevent->xmotion.y_root < TILING_EDGE)
- + {
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- +
- + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
- + c->y = wc.y;
- + }
- + //Bottom Left
- + else if (xevent->xmotion.x_root < TILING_EDGE
- + && xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
- + {
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- +
- + c->x = wc.x;
- + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
- + }
- + //Bottom Right
- + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE
- + && xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
- + {
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- +
- + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
- + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
- + }
- + //Left
- + else if (xevent->xmotion.x_root < TILING_EDGE)
- + {
- + // wc.x = avialable screen x + 1 x left frame's width
- + // wc.width = available screen width - 1 x left frame's width - 1 x right frame's width
- +
- + c->x = wc.x;
- + c->y = wc.y;
- +
- + // we need to substract another two (left, right) frames' width
- + // because of two windows we have
- +
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = wc.height;
- + }
- + //Right
- + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE)
- + {
- + // see upper
- + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
- + c->height = wc.height;
- +
- + // c->width has to be first (left) window's width
- + // but two windows we have are equal,
- + // consequently we can use second windows's width
- +
- + // frameRight(c) + frameLeft(c) = width of frames between windows
- +
- + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
- + c->y = wc.y;
- + }
- + //Top
- + else if (xevent->xmotion.y_root < TILING_EDGE)
- + {
- + // see previous tilings' comments
- + c->x = wc.x;
- + c->y = wc.y;
- + c->width = wc.width;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- + }
- + //Bottom
- + else
- + {
- + // see previous tilings' comments
- + c->width = wc.width;
- + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
- + c->x = wc.x;
- + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
- + }
- + }
- + else
- + {
- + if (c->pretiling_width != -1)
- + {
- + // calculate x-resize ratio
- + double ratio_x = ((double) c->pretiling_width) / ((double) c->width);
- +
- + // restore pretiling size (by x)
- + c->width = c->pretiling_width;
- + c->pretiling_width = -1;
- +
- + // fix cursor position (by x)
- + passdata->mx *= ratio_x;
- + passdata->ox *= ratio_x;
- + }
- +
- + if (c->pretiling_height != -1)
- + {
- + // calculate y-resize ratio
- + double ratio_y = ((double) c->pretiling_height) / ((double) c->height);
- +
- + // restore pretiling size (by y)
- + c->height = c->pretiling_height;
- + c->pretiling_height = -1;
- +
- + // fix cursor position (by y)
- + passdata->my *= ratio_y;
- + passdata->oy *= ratio_y;
- + }
- +
- + FLAG_UNSET (c->flags, CLIENT_FLAG_TILED);
- +
- + }
- +
- + // we need it for our window to be not only moved, but resized too
- + passdata->move_resized = 1;
- + }
- clientSnapPosition (c, prev_x, prev_y);
- if (screen_info->params->restore_on_move)
- diff -rupN xfwm4-4.8.3/src/moveresize.h xfwm4-4.8.3-tiling/src/moveresize.h
- --- xfwm4-4.8.3/src/moveresize.h 2011-12-06 12:14:44.000000000 -0500
- +++ xfwm4-4.8.3-tiling/src/moveresize.h 2011-12-22 23:22:00.538436871 -0500
- @@ -31,6 +31,8 @@
- #include "screen.h"
- #include "client.h"
- +#define TILING_EDGE 10
- +
- #ifndef INC_MOVERESIZE_H
- #define INC_MOVERESIZE_H
- void clientSetWidth (Client *,
- diff -rupN xfwm4-4.8.3/src/placement.c xfwm4-4.8.3-tiling/src/placement.c
- --- xfwm4-4.8.3/src/placement.c 2011-12-19 14:22:19.000000000 -0500
- +++ xfwm4-4.8.3-tiling/src/placement.c 2011-12-22 23:22:00.538436871 -0500
- @@ -739,6 +739,10 @@ clientInitPosition (Client * c)
- {
- clientAutoMaximize (c, full_w, full_h);
- }
- +
- + // initial values for new windows
- + c->pretiling_width = -1;
- + c->pretiling_height = -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement