]> git.pld-linux.org Git - packages/marco.git/blob - Allow-breaking-out-from-maximization-during-mouse.patch
new, version 1.5.2
[packages/marco.git] / Allow-breaking-out-from-maximization-during-mouse.patch
1 diff -upr marco-1.4.1-orig/src/core/display.c marco-1.4.1/src/core/display.c
2 --- marco-1.4.1-orig/src/core/display.c 2012-08-21 21:42:39.000000000 +0200
3 +++ marco-1.4.1/src/core/display.c      2012-08-25 14:51:42.021447065 +0200
4 @@ -3512,6 +3512,7 @@ meta_display_begin_grab_op (MetaDisplay
5  #endif
6    display->grab_was_cancelled = FALSE;
7    display->grab_frame_action = frame_action;
8 +  display->grab_resize_unmaximize = 0;
9  
10    if (display->grab_resize_timeout_id)
11      {
12 @@ -3753,11 +3754,20 @@ meta_display_end_grab_op (MetaDisplay *d
13                                display->grab_wireframe_rect.x,
14                                display->grab_wireframe_rect.y);
15            if (meta_grab_op_is_resizing (display->grab_op))
16 -            meta_window_resize_with_gravity (display->grab_window,
17 -                                             TRUE,
18 -                                             display->grab_wireframe_rect.width,
19 -                                             display->grab_wireframe_rect.height,
20 -                                             meta_resize_gravity_from_grab_op (display->grab_op));
21 +            {
22 +              if (display->grab_resize_unmaximize != 0)
23 +                meta_window_unmaximize_with_gravity (display->grab_window,
24 +                                                     display->grab_resize_unmaximize,
25 +                                                     display->grab_wireframe_rect.width,
26 +                                                     display->grab_wireframe_rect.height,
27 +                                                     meta_resize_gravity_from_grab_op (display->grab_op));
28 +              else
29 +                meta_window_resize_with_gravity (display->grab_window,
30 +                                                 TRUE,
31 +                                                 display->grab_wireframe_rect.width,
32 +                                                 display->grab_wireframe_rect.height,
33 +                                                 meta_resize_gravity_from_grab_op (display->grab_op));
34 +            }
35          }
36        meta_window_calc_showing (display->grab_window);
37      }
38 diff -upr marco-1.4.1-orig/src/core/display-private.h marco-1.4.1/src/core/display-private.h
39 --- marco-1.4.1-orig/src/core/display-private.h 2012-08-21 21:42:39.000000000 +0200
40 +++ marco-1.4.1/src/core/display-private.h      2012-08-25 14:48:47.159605550 +0200
41 @@ -163,6 +163,9 @@ struct _MetaDisplay {
42         guint       grab_wireframe_active : 1;
43         guint       grab_was_cancelled : 1;    /* Only used in wireframe mode */
44         guint       grab_frame_action : 1;
45 +    /* During a resize operation, the directions in which we've broken
46 +    * out of the initial maximization state */
47 +    guint       grab_resize_unmaximize : 2; /* MetaMaximizeFlags */
48         MetaRectangle grab_wireframe_rect;
49         MetaRectangle grab_wireframe_last_xor_rect;
50         MetaRectangle grab_initial_window_pos;
51 diff -upr marco-1.4.1-orig/src/core/window.c marco-1.4.1/src/core/window.c
52 --- marco-1.4.1-orig/src/core/window.c  2012-08-21 21:42:39.000000000 +0200
53 +++ marco-1.4.1/src/core/window.c       2012-08-25 15:11:22.636859026 +0200
54 @@ -2666,9 +2666,11 @@ unmaximize_window_before_freeing (MetaWi
55      }
56  }
57  
58 -void
59 -meta_window_unmaximize (MetaWindow        *window,
60 -                        MetaMaximizeFlags  directions)
61 +static void
62 +meta_window_unmaximize_internal (MetaWindow        *window,
63 +                                 MetaMaximizeFlags  directions,
64 +                                 MetaRectangle     *desired_rect,
65 +                                 int                gravity)
66  {
67    /* At least one of the two directions ought to be set */
68    gboolean unmaximize_horizontally, unmaximize_vertically;
69 @@ -2702,13 +2704,13 @@ meta_window_unmaximize (MetaWindow
70        meta_window_get_client_root_coords (window, &target_rect);
71        if (unmaximize_horizontally)
72          {
73 -          target_rect.x     = window->saved_rect.x;
74 -          target_rect.width = window->saved_rect.width;
75 +          target_rect.x     = desired_rect->x;
76 +          target_rect.width = desired_rect->width;
77          }
78        if (unmaximize_vertically)
79          {
80 -          target_rect.y      = window->saved_rect.y;
81 -          target_rect.height = window->saved_rect.height;
82 +          target_rect.y      = desired_rect->y;
83 +          target_rect.height = desired_rect->height;
84          }
85  
86        /* Window's size hints may have changed while maximized, making
87 @@ -2727,12 +2729,13 @@ meta_window_unmaximize (MetaWindow
88            window->display->grab_anchor_window_pos = target_rect;
89          }
90  
91 -      meta_window_move_resize (window,
92 -                               FALSE,
93 -                               target_rect.x,
94 -                               target_rect.y,
95 -                               target_rect.width,
96 -                               target_rect.height);
97 +      meta_window_move_resize_internal (window,
98 +                                        META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION,
99 +                                        gravity,
100 +                                        target_rect.x,
101 +                                        target_rect.y,
102 +                                        target_rect.width,
103 +                                        target_rect.height);
104  
105        /* Make sure user_rect is current.
106         */
107 @@ -2749,6 +2752,36 @@ meta_window_unmaximize (MetaWindow
108  }
109  
110  void
111 +meta_window_unmaximize (MetaWindow        *window,
112 +                        MetaMaximizeFlags  directions)
113 +{
114 +  meta_window_unmaximize_internal (window, directions, &window->saved_rect,
115 +                                   NorthWestGravity);
116 +}
117 +
118 +/* Like meta_window_unmaximize(), but instead of unmaximizing to the
119 + * saved position, we give the new desired size, and the gravity that
120 + * determines the positioning relationship between the area occupied
121 + * maximized and the new are. The arguments are similar to
122 + * meta_window_resize_with_gravity().
123 + */
124 +void
125 +meta_window_unmaximize_with_gravity (MetaWindow        *window,
126 +                                     MetaMaximizeFlags  directions,
127 +                                     int                new_width,
128 +                                     int                new_height,
129 +                                     int                gravity)
130 +{
131 +  MetaRectangle desired_rect;
132 +
133 +  meta_window_get_position (window, &desired_rect.x, &desired_rect.y);
134 +  desired_rect.width = new_width;
135 +  desired_rect.height = new_height;
136 +
137 +  meta_window_unmaximize_internal (window, directions, &desired_rect, gravity);
138 +}
139 +
140 +void
141  meta_window_make_above (MetaWindow  *window)
142  {
143    window->wm_state_above = TRUE;
144 @@ -7033,6 +7066,112 @@ update_resize_timeout (gpointer data)
145    return FALSE;
146  }
147  
148 +/* When resizing a maximized window by using alt-middle-drag (resizing
149 + * with the grips or the menu for a maximized window is not enabled),
150 + * the user can "break" out of the maximized state. This checks for
151 + * that possibility. During such a break-out resize the user can also
152 + * return to the previous maximization state by resizing back to near
153 + * the original size.
154 + */
155 +static MetaMaximizeFlags
156 +check_resize_unmaximize(MetaWindow *window,
157 +                        int         dx,
158 +                        int         dy)
159 +{
160 +  int threshold;
161 +  MetaMaximizeFlags new_unmaximize;
162 +
163 +#define DRAG_THRESHOLD_TO_RESIZE_THRESHOLD_FACTOR 3
164 +
165 +  threshold = meta_ui_get_drag_threshold (window->screen->ui) *
166 +    DRAG_THRESHOLD_TO_RESIZE_THRESHOLD_FACTOR;
167 +  new_unmaximize = 0;
168 +
169 +  if (window->maximized_horizontally ||
170 +      (window->display->grab_resize_unmaximize & META_MAXIMIZE_HORIZONTAL) != 0)
171 +    {
172 +      int x_amount;
173 +
174 +      /* We allow breaking out of maximization in either direction, to make
175 +       * the window larger than the monitor as well as smaller than the
176 +       * monitor. If we wanted to only allow resizing smaller than the
177 +       * monitor, we'd use - dx for NE/E/SE and dx for SW/W/NW.
178 +       */
179 +      switch (window->display->grab_op)
180 +        {
181 +        case META_GRAB_OP_RESIZING_NE:
182 +        case META_GRAB_OP_KEYBOARD_RESIZING_NE:
183 +        case META_GRAB_OP_RESIZING_E:
184 +        case META_GRAB_OP_KEYBOARD_RESIZING_E:
185 +        case META_GRAB_OP_RESIZING_SE:
186 +        case META_GRAB_OP_KEYBOARD_RESIZING_SE:
187 +        case META_GRAB_OP_RESIZING_SW:
188 +        case META_GRAB_OP_KEYBOARD_RESIZING_SW:
189 +        case META_GRAB_OP_RESIZING_W:
190 +        case META_GRAB_OP_KEYBOARD_RESIZING_W:
191 +        case META_GRAB_OP_RESIZING_NW:
192 +        case META_GRAB_OP_KEYBOARD_RESIZING_NW:
193 +          x_amount = dx < 0 ? - dx : dx;
194 +          break;
195 +        default:
196 +          x_amount = 0;
197 +          break;
198 +        }
199 +
200 +      if (x_amount > threshold)
201 +        new_unmaximize |= META_MAXIMIZE_HORIZONTAL;
202 +    }
203 +
204 +  if (window->maximized_vertically ||
205 +      (window->display->grab_resize_unmaximize & META_MAXIMIZE_VERTICAL) != 0)
206 +    {
207 +      int y_amount;
208 +
209 +      switch (window->display->grab_op)
210 +        {
211 +        case META_GRAB_OP_RESIZING_N:
212 +        case META_GRAB_OP_KEYBOARD_RESIZING_N:
213 +        case META_GRAB_OP_RESIZING_NE:
214 +        case META_GRAB_OP_KEYBOARD_RESIZING_NE:
215 +        case META_GRAB_OP_RESIZING_NW:
216 +        case META_GRAB_OP_KEYBOARD_RESIZING_NW:
217 +        case META_GRAB_OP_RESIZING_SE:
218 +        case META_GRAB_OP_KEYBOARD_RESIZING_SE:
219 +        case META_GRAB_OP_RESIZING_S:
220 +        case META_GRAB_OP_KEYBOARD_RESIZING_S:
221 +        case META_GRAB_OP_RESIZING_SW:
222 +        case META_GRAB_OP_KEYBOARD_RESIZING_SW:
223 +          y_amount = dy < 0 ? - dy : dy;
224 +          break;
225 +        default:
226 +          y_amount = 0;
227 +          break;
228 +        }
229 +
230 +      if (y_amount > threshold)
231 +        new_unmaximize |= META_MAXIMIZE_VERTICAL;
232 +    }
233 +
234 +  /* Marco doesn't have a full user interface for only horizontally or
235 +   * vertically maximized, so while only unmaximizing in the direction drags
236 +   * has some advantages, it will also confuse the user. So, we always
237 +   * unmaximize both ways if possible.
238 +   */
239 +  if (new_unmaximize != 0)
240 +    {
241 +      new_unmaximize = 0;
242 +
243 +      if (window->maximized_horizontally ||
244 +          (window->display->grab_resize_unmaximize & META_MAXIMIZE_HORIZONTAL) != 0)
245 +        new_unmaximize |= META_MAXIMIZE_HORIZONTAL;
246 +      if (window->maximized_vertically ||
247 +          (window->display->grab_resize_unmaximize & META_MAXIMIZE_VERTICAL) != 0)
248 +        new_unmaximize |= META_MAXIMIZE_VERTICAL;
249 +    }
250 +
251 +  return new_unmaximize;
252 +}
253 +
254  static void
255  update_resize (MetaWindow *window,
256                 gboolean    snap,
257 @@ -7045,6 +7184,7 @@ update_resize (MetaWindow *window,
258    MetaRectangle old;
259    int new_x, new_y;
260    double remaining;
261 +  MetaMaximizeFlags new_unmaximize;
262  
263    window->display->grab_latest_motion_x = x;
264    window->display->grab_latest_motion_y = y;
265 @@ -7233,6 +7373,8 @@ update_resize (MetaWindow *window,
266  
267    if (window->display->grab_wireframe_active)
268      {
269 +      MetaRectangle root_coords;
270 +
271        if ((new_x + new_w <= new_x) || (new_y + new_h <= new_y))
272          return;
273  
274 @@ -7242,16 +7384,56 @@ update_resize (MetaWindow *window,
275         * wireframe, but still resize it; however, that probably
276         * confuses broken clients that have problems with opaque
277         * resize, they probably don't track their visibility.
278 +       *
279 +       * We handle the basic constraints on maximized windows here
280 +       * to give the user feedback.
281         */
282 +
283 +      if (window->maximized_horizontally && (new_unmaximize & META_MAXIMIZE_HORIZONTAL) == 0)
284 +        {
285 +          meta_window_get_client_root_coords (window, &root_coords);
286 +          new_x = root_coords.x;
287 +          new_w = root_coords.width;
288 +        }
289 +      if (window->maximized_vertically && (new_unmaximize & META_MAXIMIZE_VERTICAL) == 0)
290 +        {
291 +          meta_window_get_client_root_coords (window, &root_coords);
292 +          new_y = root_coords.y;
293 +          new_h = root_coords.height;
294 +        }
295 +
296        meta_window_update_wireframe (window, new_x, new_y, new_w, new_h);
297      }
298    else
299      {
300 -      /* We don't need to update unless the specified width and height
301 -       * are actually different from what we had before.
302 -       */
303 -      if (old.width != new_w || old.height != new_h)
304 -        meta_window_resize_with_gravity (window, TRUE, new_w, new_h, gravity);
305 +      if (new_unmaximize == window->display->grab_resize_unmaximize)
306 +        {
307 +          /* We don't need to update unless the specified width and height
308 +           * are actually different from what we had before.
309 +           */
310 +          if (old.width != new_w || old.height != new_h)
311 +            {
312 +              if ((window->display->grab_resize_unmaximize == new_unmaximize))
313 +                meta_window_resize_with_gravity (window, TRUE, new_w, new_h, gravity);
314 +            }
315 +        }
316 +      else
317 +        {
318 +          if ((new_unmaximize & ~window->display->grab_resize_unmaximize) != 0)
319 +            {
320 +              meta_window_unmaximize_with_gravity (window,
321 +                                                   (new_unmaximize & ~window->display->grab_resize_unmaximize),
322 +                                                   new_w, new_h, gravity);
323 +            }
324 +
325 +          if ((window->display->grab_resize_unmaximize & ~new_unmaximize))
326 +            {
327 +              MetaRectangle saved_rect = window->saved_rect;
328 +              meta_window_maximize (window,
329 +                                    (window->display->grab_resize_unmaximize & ~new_unmaximize));
330 +              window->saved_rect = saved_rect;
331 +            }
332 +        }
333      }
334  
335    /* Store the latest resize time, if we actually resized. */
336 diff -upr marco-1.4.1-orig/src/core/window-private.h marco-1.4.1/src/core/window-private.h
337 --- marco-1.4.1-orig/src/core/window-private.h  2012-08-21 21:42:39.000000000 +0200
338 +++ marco-1.4.1/src/core/window-private.h       2012-08-25 14:53:44.522736630 +0200
339 @@ -412,6 +412,12 @@ void        meta_window_maximize_interna
340                                              MetaRectangle     *saved_rect);
341  void        meta_window_unmaximize         (MetaWindow        *window,
342                                              MetaMaximizeFlags  directions);
343 +void        meta_window_unmaximize_with_gravity (MetaWindow        *window,
344 +                                                 MetaMaximizeFlags  directions,
345 +                                                 int                new_width,
346 +                                                 int                new_height,
347 +                                                 int                gravity);
348 +void        meta_window_make_above         (MetaWindow  *window);
349  void        meta_window_make_above         (MetaWindow  *window);
350  void        meta_window_unmake_above       (MetaWindow  *window);
351  void        meta_window_shade              (MetaWindow  *window,
This page took 0.065898 seconds and 4 git commands to generate.