[mutter/wip/gbsneto/tiling-improvements: 8/8] [WIP] frames: Show double-arrow cursor on resizing two tiled windows



commit 75c11d09f04faf49ea05547e7d42bb3bbb25e852
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Jun 18 00:10:13 2017 -0300

    [WIP] frames: Show double-arrow cursor on resizing two tiled windows
    
    Warning!!! This patch make a pair of tiled windows
    simply not resize anymore! Don't assume it works.

 src/backends/meta-cursor.c        |    2 ++
 src/core/display-private.h        |    3 ++-
 src/core/display.c                |   11 ++++++++++-
 src/core/keybindings.c            |    2 +-
 src/core/window.c                 |    2 +-
 src/meta/common.h                 |    3 +++
 src/ui/frames.c                   |   16 ++++++++++++++--
 src/ui/frames.h                   |    1 +
 src/wayland/meta-window-wayland.c |    2 +-
 9 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
index 256b0ca..09adfbc 100644
--- a/src/backends/meta-cursor.c
+++ b/src/backends/meta-cursor.c
@@ -85,6 +85,8 @@ translate_meta_cursor (MetaCursor cursor)
       return "top_right_corner";
     case META_CURSOR_NW_RESIZE:
       return "top_left_corner";
+    case META_CURSOR_HORIZONTAL_RESIZE:
+      return "sb_h_double_arrow";
     case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
       return "fleur";
     case META_CURSOR_BUSY:
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 9e4518b..d501c9b 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -427,7 +427,8 @@ void meta_display_ping_window      (MetaWindow  *window,
 void meta_display_pong_for_serial  (MetaDisplay *display,
                                     guint32      serial);
 
-int meta_resize_gravity_from_grab_op (MetaGrabOp op);
+int meta_resize_gravity_from_grab_op (MetaWindow *window,
+                                      MetaGrabOp  op);
 
 gboolean meta_grab_op_is_moving   (MetaGrabOp op);
 gboolean meta_grab_op_is_resizing (MetaGrabOp op);
diff --git a/src/core/display.c b/src/core/display.c
index 32708de..ab85ee2 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1775,6 +1775,8 @@ meta_cursor_for_grab_op (MetaGrabOp op)
     case META_GRAB_OP_KEYBOARD_MOVING:
     case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
       return META_CURSOR_MOVE_OR_RESIZE_WINDOW;
+    case META_GRAB_OP_RESIZING_H:
+      return META_CURSOR_HORIZONTAL_RESIZE;
       break;
     default:
       break;
@@ -2604,7 +2606,8 @@ meta_display_get_tab_current (MetaDisplay   *display,
 }
 
 int
-meta_resize_gravity_from_grab_op (MetaGrabOp op)
+meta_resize_gravity_from_grab_op (MetaWindow *window,
+                                  MetaGrabOp  op)
 {
   int gravity;
 
@@ -2646,6 +2649,12 @@ meta_resize_gravity_from_grab_op (MetaGrabOp op)
     case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
       gravity = CenterGravity;
       break;
+    case META_GRAB_OP_RESIZING_H:
+      if (META_WINDOW_TILED_LEFT (window))
+        gravity = EastGravity;
+      else
+        gravity = WestGravity;
+      break;
     default:
       break;
     }
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 7366aa7..583b0c0 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2360,7 +2360,7 @@ process_keyboard_resize_grab (MetaDisplay     *display,
   width = frame_rect.width;
   height = frame_rect.height;
 
-  gravity = meta_resize_gravity_from_grab_op (display->grab_op);
+  gravity = meta_resize_gravity_from_grab_op (window, display->grab_op);
 
   smart_snap = (event->modifier_state & CLUTTER_SHIFT_MASK) != 0;
 
diff --git a/src/core/window.c b/src/core/window.c
index f52ab45..74d435f 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6078,7 +6078,7 @@ update_resize (MetaWindow *window,
     new_h = old.height;
 
   /* compute gravity of client during operation */
-  gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
+  gravity = meta_resize_gravity_from_grab_op (window, window->display->grab_op);
   g_assert (gravity >= 0);
 
   /* Do any edge resistance/snapping */
diff --git a/src/meta/common.h b/src/meta/common.h
index ba98756..4b23a3b 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -173,6 +173,7 @@ typedef enum
   META_GRAB_OP_RESIZING_S                 = META_GRAB_OP_WINDOW_BASE | _WGO_S,
   META_GRAB_OP_RESIZING_SE                = META_GRAB_OP_WINDOW_BASE | _WGO_S | _WGO_E,
   META_GRAB_OP_RESIZING_W                 = META_GRAB_OP_WINDOW_BASE |          _WGO_W,
+  META_GRAB_OP_RESIZING_H                 = META_GRAB_OP_WINDOW_BASE |          _WGO_W | _WGO_E,
   META_GRAB_OP_KEYBOARD_MOVING            = META_GRAB_OP_WINDOW_BASE |                   _WGO_K,
   META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN  = META_GRAB_OP_WINDOW_BASE |                   _WGO_K | _WGO_U,
   META_GRAB_OP_KEYBOARD_RESIZING_NW       = META_GRAB_OP_WINDOW_BASE | _WGO_N | _WGO_W | _WGO_K,
@@ -188,6 +189,7 @@ typedef enum
 /**
  * MetaCursor:
  * @META_CURSOR_DEFAULT: Default cursor
+ * @META_CURSOR_HORIZONTAL_RESIZE: Resize horizontally (east and west arrows)
  * @META_CURSOR_NORTH_RESIZE: Resize northern edge cursor
  * @META_CURSOR_SOUTH_RESIZE: Resize southern edge cursor
  * @META_CURSOR_WEST_RESIZE: Resize western edge cursor
@@ -210,6 +212,7 @@ typedef enum
 {
   META_CURSOR_NONE = 0,
   META_CURSOR_DEFAULT,
+  META_CURSOR_HORIZONTAL_RESIZE,
   META_CURSOR_NORTH_RESIZE,
   META_CURSOR_SOUTH_RESIZE,
   META_CURSOR_WEST_RESIZE,
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 129a9e5..bc0a37a 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -930,6 +930,9 @@ grab_op_from_resize_control (MetaFrameControl control)
       return META_GRAB_OP_RESIZING_E;
     case META_FRAME_CONTROL_RESIZE_W:
       return META_GRAB_OP_RESIZING_W;
+    case META_FRAME_CONTROL_RESIZE_H:
+      return META_GRAB_OP_RESIZING_H;
+      break;
     default:
       g_assert_not_reached ();
     }
@@ -1005,6 +1008,7 @@ meta_frame_left_click_event (MetaUIFrame *frame,
     case META_FRAME_CONTROL_RESIZE_NW:
     case META_FRAME_CONTROL_RESIZE_E:
     case META_FRAME_CONTROL_RESIZE_W:
+    case META_FRAME_CONTROL_RESIZE_H:
       meta_frames_try_grab_op (frame,
                                grab_op_from_resize_control (control),
                                event->x, event->y,
@@ -1174,6 +1178,9 @@ meta_ui_frame_update_prelit_control (MetaUIFrame     *frame,
       break;
     case META_FRAME_CONTROL_UNMAXIMIZE:
       break;
+    case META_FRAME_CONTROL_RESIZE_H:
+      cursor = META_CURSOR_HORIZONTAL_RESIZE;
+      break;
     case META_FRAME_CONTROL_RESIZE_SE:
       cursor = META_CURSOR_SE_RESIZE;
       break;
@@ -1569,6 +1576,8 @@ control_rect (MetaFrameControl control,
       break;
     case META_FRAME_CONTROL_RESIZE_E:
       break;
+    case META_FRAME_CONTROL_RESIZE_H:
+      break;
     case META_FRAME_CONTROL_NONE:
       break;
     case META_FRAME_CONTROL_CLIENT_AREA:
@@ -1589,6 +1598,7 @@ get_control (MetaUIFrame *frame, int root_x, int root_y)
   gboolean has_vert, has_horiz;
   gboolean has_north_resize;
   cairo_rectangle_int_t client;
+  gboolean tile_match_h;
   int x, y;
   int win_x, win_y;
 
@@ -1596,6 +1606,8 @@ get_control (MetaUIFrame *frame, int root_x, int root_y)
   x = root_x - win_x;
   y = root_y - win_y;
 
+  tile_match_h = frame->meta_window->tile_match != NULL;
+
   meta_window_get_client_area_rect (frame->meta_window, &client);
   if (POINT_IN_RECT (x, y, client))
     return META_FRAME_CONTROL_CLIENT_AREA;
@@ -1697,12 +1709,12 @@ get_control (MetaUIFrame *frame, int root_x, int root_y)
   else if (x <= fgeom.borders.total.left)
     {
       if (has_horiz || flags & META_FRAME_TILED_RIGHT)
-        return META_FRAME_CONTROL_RESIZE_W;
+        return tile_match_h ? META_FRAME_CONTROL_RESIZE_H : META_FRAME_CONTROL_RESIZE_W;
     }
   else if (x >= (fgeom.width - fgeom.borders.total.right))
     {
       if (has_horiz || flags & META_FRAME_TILED_LEFT)
-        return META_FRAME_CONTROL_RESIZE_E;
+        return tile_match_h ? META_FRAME_CONTROL_RESIZE_H : META_FRAME_CONTROL_RESIZE_E;
     }
 
   if (y >= fgeom.borders.total.top)
diff --git a/src/ui/frames.h b/src/ui/frames.h
index d9aaae2..40129c2 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -47,6 +47,7 @@ typedef enum
   META_FRAME_CONTROL_RESIZE_NW,
   META_FRAME_CONTROL_RESIZE_W,
   META_FRAME_CONTROL_RESIZE_E,
+  META_FRAME_CONTROL_RESIZE_H,
   META_FRAME_CONTROL_CLIENT_AREA
 } MetaFrameControl;
 
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index a1b239b..7cb48e0 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -679,7 +679,7 @@ meta_window_wayland_move_resize (MetaWindow        *window,
   if (rect.width != window->rect.width || rect.height != window->rect.height)
     flags |= META_MOVE_RESIZE_RESIZE_ACTION;
 
-  gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
+  gravity = meta_resize_gravity_from_grab_op (window, window->display->grab_op);
   meta_window_move_resize_internal (window, flags, gravity, rect);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]