Want more features on Pastebin? Sign Up, it's FREE!
Guest

xfwm4-4.8.3-tiling-1.patch

By: ipha on Dec 22nd, 2011  |  syntax: Diff  |  size: 8.95 KB  |  views: 214  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff -rupN xfwm4-4.8.3/src/client.c xfwm4-4.8.3-tiling/src/client.c
  2. --- xfwm4-4.8.3/src/client.c    2011-12-19 14:22:19.000000000 -0500
  3. +++ xfwm4-4.8.3-tiling/src/client.c     2011-12-22 19:02:32.007663810 -0500
  4. @@ -107,7 +107,7 @@ struct _ButtonPressData
  5.  /* Forward decl */
  6.  static void
  7.  clientUpdateIconPix (Client * c);
  8. -static void
  9. +void
  10.  clientNewMaxSize (Client * c, XWindowChanges *wc);
  11.  
  12.  Display *
  13. @@ -2153,6 +2153,12 @@ clientFrameAll (ScreenInfo *screen_info)
  14.          if ((attr.map_state == IsViewable) && (attr.root == screen_info->xroot))
  15.          {
  16.              Client *c = clientFrame (display_info, wins[i], TRUE);
  17. +            // initial values for existing windows
  18. +            if (c)
  19. +            {
  20. +                c->pretiling_height = -1;
  21. +                c->pretiling_width = -1;
  22. +            }
  23.              if ((c) && ((screen_info->params->raise_on_click) || (screen_info->params->click_to_focus)))
  24.              {
  25.                  clientGrabMouseButton (c);
  26. @@ -3232,7 +3238,7 @@ clientNewMaxState (Client * c, XWindowCh
  27.      wc->height = c->old_height;
  28.  }
  29.  
  30. -static void
  31. +void
  32.  clientNewMaxSize (Client * c, XWindowChanges *wc)
  33.  {
  34.      ScreenInfo *screen_info;
  35. @@ -3259,7 +3265,7 @@ clientNewMaxSize (Client * c, XWindowCha
  36.      full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
  37.                    rect.y + rect.height) - full_y;
  38.  
  39. -    if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED))
  40. +    if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) || FLAG_TEST (c->flags, CLIENT_FLAG_TILED))
  41.      {
  42.          /* Adjust size to the largest size available, not covering struts */
  43.          clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
  44. diff -rupN xfwm4-4.8.3/src/client.h xfwm4-4.8.3-tiling/src/client.h
  45. --- xfwm4-4.8.3/src/client.h    2011-12-19 14:22:19.000000000 -0500
  46. +++ xfwm4-4.8.3-tiling/src/client.h     2011-12-22 19:06:33.423022616 -0500
  47. @@ -161,6 +161,7 @@
  48.  #define CLIENT_FLAG_DEMANDS_ATTENTION   (1L<<17)
  49.  #define CLIENT_FLAG_HAS_SHAPE           (1L<<18)
  50.  #define CLIENT_FLAG_FULLSCREN_MONITORS  (1L<<19)
  51. +#define CLIENT_FLAG_TILED               (1L<<20)
  52.  
  53.  #define WM_FLAG_DELETE                  (1L<<0)
  54.  #define WM_FLAG_INPUT                   (1L<<1)
  55. @@ -283,6 +284,8 @@ struct _Client
  56.      gint old_y;
  57.      gint old_width;
  58.      gint old_height;
  59. +    gint pretiling_width;
  60. +    gint pretiling_height;
  61.      gint fullscreen_old_x;
  62.      gint fullscreen_old_y;
  63.      gint fullscreen_old_width;
  64. @@ -338,6 +341,8 @@ struct _Client
  65.  extern Client *clients;
  66.  extern unsigned int client_count;
  67.  
  68. +void                     clientNewMaxSize                       (Client * c,
  69. +                                                                 XWindowChanges *wc);
  70.  Display                 *clientGetXDisplay                      (Client *);
  71.  void                     clientClearLastOpTime                  (Client *);
  72.  void                     clientUpdateWinState                   (Client *,
  73. diff -rupN xfwm4-4.8.3/src/moveresize.c xfwm4-4.8.3-tiling/src/moveresize.c
  74. --- xfwm4-4.8.3/src/moveresize.c        2011-12-19 14:22:19.000000000 -0500
  75. +++ xfwm4-4.8.3-tiling/src/moveresize.c 2011-12-22 19:10:09.008521356 -0500
  76. @@ -874,6 +874,117 @@ clientMoveEventFilter (XEvent * xevent,
  77.  
  78.          c->x = passdata->ox + (xevent->xmotion.x_root - passdata->mx);
  79.          c->y = passdata->oy + (xevent->xmotion.y_root - passdata->my);
  80. +        
  81. +        // if window is not maximized
  82. +        if (!FLAG_TEST_ALL(c->flags, CLIENT_FLAG_MAXIMIZED))
  83. +        {
  84. +            // if user moved cursor to the edge of the screen
  85. +            if (xevent->xmotion.x_root < TILING_EDGE
  86. +                || xevent->xmotion.x_root > screen_info->width - TILING_EDGE
  87. +                || xevent->xmotion.y_root < TILING_EDGE
  88. +                || xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
  89. +            {
  90. +                // save pretiling sizes for future restore
  91. +
  92. +                // initial values for pretiling_width and pretiling_height
  93. +                // are set in functions:
  94. +                //   placement.c => clientInitPosition - for new windows
  95. +                //   client.c => clientFrameAll        - for existing windows
  96. +                // P.S. maybe it's a dirty hack :-)
  97. +
  98. +                if (c->pretiling_width == -1)
  99. +                    c->pretiling_width = c->width;
  100. +                if (c->pretiling_height == -1)
  101. +                    c->pretiling_height = c->height;
  102. +
  103. +                // get information about maximum available space
  104. +                FLAG_SET (c->flags, CLIENT_FLAG_TILED);
  105. +                XWindowChanges wc;
  106. +                clientNewMaxSize(c, &wc);
  107. +
  108. +                if (xevent->xmotion.x_root < TILING_EDGE)
  109. +                {
  110. +                    // wc.x = avialable screen x + 1 x left frame's width
  111. +                    // wc.width = available screen width - 1 x left frame's width - 1 x right frame's width
  112. +
  113. +                    c->x = wc.x;
  114. +                    c->y = wc.y;
  115. +
  116. +                    // we need to substract another two (left, right) frames' width
  117. +                    // because of two windows we have
  118. +
  119. +                    c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
  120. +                    c->height = wc.height;
  121. +                }
  122. +                else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE)
  123. +                {
  124. +                    // see upper
  125. +                    c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
  126. +                    c->height = wc.height;
  127. +
  128. +                    // c->width has to be first (left) window's width
  129. +                    // but two windows we have are equal,
  130. +                    // consequently we can use second windows's width
  131. +
  132. +                    // frameRight(c) + frameLeft(c) = width of frames between windows
  133. +
  134. +                    c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
  135. +                    c->y = wc.y;
  136. +                }
  137. +                else if (xevent->xmotion.y_root < TILING_EDGE)
  138. +                {
  139. +                    // see previous tilings' comments
  140. +                    c->x = wc.x;
  141. +                    c->y = wc.y;
  142. +                    c->width = wc.width;
  143. +                    c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
  144. +                }
  145. +                else
  146. +                {
  147. +                    // see previous tilings' comments
  148. +                    c->width = wc.width;
  149. +                    c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
  150. +                    c->x = wc.x;
  151. +                    c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
  152. +                }
  153. +            }
  154. +            else
  155. +            {
  156. +                if (c->pretiling_width != -1)
  157. +                {
  158. +                    // calculate x-resize ratio
  159. +                    double ratio_x = ((double) c->pretiling_width) / ((double) c->width);
  160. +
  161. +                    // restore pretiling size (by x)
  162. +                    c->width = c->pretiling_width;
  163. +                    c->pretiling_width = -1;
  164. +
  165. +                    // fix cursor position (by x)
  166. +                    passdata->mx *= ratio_x;
  167. +                    passdata->ox *= ratio_x;
  168. +                }
  169. +
  170. +                if (c->pretiling_height != -1)
  171. +                {
  172. +                    // calculate y-resize ratio
  173. +                    double ratio_y = ((double) c->pretiling_height) / ((double) c->height);
  174. +
  175. +                    // restore pretiling size (by y)
  176. +                    c->height = c->pretiling_height;
  177. +                    c->pretiling_height = -1;
  178. +
  179. +                    // fix cursor position (by y)
  180. +                    passdata->my *= ratio_y;
  181. +                    passdata->oy *= ratio_y;
  182. +                }
  183. +
  184. +                FLAG_UNSET (c->flags, CLIENT_FLAG_TILED);
  185. +
  186. +            }
  187. +
  188. +            // we need it for our window to be not only moved, but resized too
  189. +            passdata->move_resized = 1;
  190. +        }
  191.  
  192.          clientSnapPosition (c, prev_x, prev_y);
  193.          if (screen_info->params->restore_on_move)
  194. diff -rupN xfwm4-4.8.3/src/moveresize.h xfwm4-4.8.3-tiling/src/moveresize.h
  195. --- xfwm4-4.8.3/src/moveresize.h        2011-12-06 12:14:44.000000000 -0500
  196. +++ xfwm4-4.8.3-tiling/src/moveresize.h 2011-12-22 19:09:08.468849329 -0500
  197. @@ -31,6 +31,8 @@
  198.  #include "screen.h"
  199.  #include "client.h"
  200.  
  201. +#define TILING_EDGE 10
  202. +
  203.  #ifndef INC_MOVERESIZE_H
  204.  #define INC_MOVERESIZE_H
  205.  void                     clientSetWidth                         (Client *,
  206. diff -rupN xfwm4-4.8.3/src/placement.c xfwm4-4.8.3-tiling/src/placement.c
  207. --- xfwm4-4.8.3/src/placement.c 2011-12-19 14:22:19.000000000 -0500
  208. +++ xfwm4-4.8.3-tiling/src/placement.c  2011-12-22 19:09:50.885286206 -0500
  209. @@ -739,6 +739,10 @@ clientInitPosition (Client * c)
  210.      {
  211.          clientAutoMaximize (c, full_w, full_h);
  212.      }
  213. +      
  214. +    // initial values for new windows
  215. +    c->pretiling_width = -1;
  216. +    c->pretiling_height = -1;
  217.  }
clone this paste RAW Paste Data