[mutter/wip/gbsneto/tile-picker: 1/2] window: Export tiling as public API
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gbsneto/tile-picker: 1/2] window: Export tiling as public API
- Date: Fri, 5 Jan 2018 23:28:19 +0000 (UTC)
commit 17b56e96046f66e08b0eb97876cfc1ba5bcdd5e2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Dec 25 13:15:51 2017 -0200
window: Export tiling as public API
So that consumers of Mutter APIs can monitor the tile
mode of any given window. This commit also adds the
tile mode as a property of the window.
src/core/display-private.h | 7 -----
src/core/window-private.h | 3 --
src/core/window.c | 60 ++++++++++++++++++++++++++++++++++++++++++-
src/meta/window.h | 21 +++++++++++++++
4 files changed, 79 insertions(+), 12 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 9e4518b..84b494b 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -75,13 +75,6 @@ typedef enum {
#define N_IGNORED_CROSSING_SERIALS 10
typedef enum {
- META_TILE_NONE,
- META_TILE_LEFT,
- META_TILE_RIGHT,
- META_TILE_MAXIMIZED
-} MetaTileMode;
-
-typedef enum {
/* Normal interaction where you're interacting with windows.
* Events go to windows normally. */
META_EVENT_ROUTE_NORMAL,
diff --git a/src/core/window-private.h b/src/core/window-private.h
index df38b2e..0cb9cf9 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -593,8 +593,6 @@ void meta_window_unmanage (MetaWindow *window,
guint32 timestamp);
void meta_window_queue (MetaWindow *window,
guint queuebits);
-void meta_window_tile (MetaWindow *window,
- MetaTileMode mode);
void meta_window_restore_tile (MetaWindow *window,
MetaTileMode mode,
int width,
@@ -712,7 +710,6 @@ void meta_window_update_for_monitors_changed (MetaWindow *window);
void meta_window_on_all_workspaces_changed (MetaWindow *window);
gboolean meta_window_should_attach_to_parent (MetaWindow *window);
-gboolean meta_window_can_tile_side_by_side (MetaWindow *window);
void meta_window_compute_tile_match (MetaWindow *window);
diff --git a/src/core/window.c b/src/core/window.c
index 5f13bf1..806f6f4 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -179,6 +179,7 @@ enum {
PROP_GTK_APP_MENU_OBJECT_PATH,
PROP_GTK_MENUBAR_OBJECT_PATH,
PROP_ON_ALL_WORKSPACES,
+ PROP_TILE_MODE,
LAST_PROP,
};
@@ -399,6 +400,9 @@ meta_window_get_property(GObject *object,
case PROP_ON_ALL_WORKSPACES:
g_value_set_boolean (value, win->on_all_workspaces);
break;
+ case PROP_TILE_MODE:
+ g_value_set_enum (value, win->tile_mode);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -413,6 +417,9 @@ meta_window_set_property(GObject *object,
{
switch (prop_id)
{
+ case PROP_TILE_MODE:
+ meta_window_tile (META_WINDOW (object), g_value_get_enum (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -588,6 +595,13 @@ meta_window_class_init (MetaWindowClass *klass)
"Whether the window is set to appear on all workspaces",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ obj_props[PROP_TILE_MODE] =
+ g_param_spec_enum ("tile-mode",
+ "Tile mode",
+ "The tile state of the window",
+ META_TYPE_TILE_MODE,
+ META_TILE_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, obj_props);
@@ -2833,6 +2847,7 @@ meta_window_maximize (MetaWindow *window,
window->maximized_vertically = FALSE;
window->tile_mode = META_TILE_NONE;
+ g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_TILE_MODE]);
}
meta_window_maximize_internal (window,
@@ -3085,19 +3100,30 @@ update_edge_constraints (MetaWindow *window)
}
}
+
+/**
+ * meta_window_tile:
+ * @window: a #MetaWindow
+ * @tile_mode: the new #MetaTileMode
+ *
+ * Tiles @window according to @tile_mode.
+ */
void
meta_window_tile (MetaWindow *window,
MetaTileMode tile_mode)
{
MetaMaximizeFlags directions;
MetaRectangle old_frame_rect, old_buffer_rect;
+ gboolean should_notify;
+
+ should_notify = window->tile_mode != tile_mode;
meta_window_get_tile_fraction (window, tile_mode, &window->tile_hfraction);
window->tile_mode = tile_mode;
/* Don't do anything if no tiling is requested */
if (window->tile_mode == META_TILE_NONE)
- return;
+ goto out;
if (window->tile_mode == META_TILE_MAXIMIZED)
directions = META_MAXIMIZE_BOTH;
@@ -3126,6 +3152,10 @@ meta_window_tile (MetaWindow *window,
if (window->frame)
meta_frame_queue_draw (window->frame);
+
+out:
+ if (should_notify)
+ g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_TILE_MODE]);
}
void
@@ -3144,6 +3174,15 @@ meta_window_can_tile_maximized (MetaWindow *window)
return window->has_maximize_func;
}
+/**
+ * meta_window_can_tile_side_by_side:
+ * @window: a #MetaWindow
+ *
+ * Retrieves whether @window can be tiled horizontally.
+ *
+ * Returns: %TRUE if @window can be tiled horizontally, %FALSE
+ * otherwise.
+ */
gboolean
meta_window_can_tile_side_by_side (MetaWindow *window)
{
@@ -3169,6 +3208,20 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
client_rect.height >= window->size_hints.min_height;
}
+/**
+ * meta_window_get_tile_mode:
+ * @window: a #MetaWindow
+ *
+ * Retrieves the current tile mode of @window.
+ *
+ * Returns: a #MetaTileMode enum value
+ */
+MetaTileMode
+meta_window_get_tile_mode (MetaWindow *window)
+{
+ return window->tile_mode;
+}
+
static void
unmaximize_window_before_freeing (MetaWindow *window)
{
@@ -3237,7 +3290,10 @@ meta_window_unmaximize (MetaWindow *window,
meta_window_get_buffer_rect (window, &old_buffer_rect);
if (unmaximize_vertically)
- window->tile_mode = META_TILE_NONE;
+ {
+ window->tile_mode = META_TILE_NONE;
+ g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_TILE_MODE]);
+ }
meta_topic (META_DEBUG_WINDOW_OPS,
"Unmaximizing %s%s\n",
diff --git a/src/meta/window.h b/src/meta/window.h
index 09317e6..5377e73 100644
--- a/src/meta/window.h
+++ b/src/meta/window.h
@@ -91,6 +91,21 @@ typedef enum {
META_WINDOW_CLIENT_TYPE_X11
} MetaWindowClientType;
+
+/**
+ * MetaTileMode:
+ * @META_TILE_NONE: the window is not tiled
+ * @META_TILE_LEFT: the window is tiled at the left side of the monitor
+ * @META_TILE_RIGHT: the window is tiled at the right side of the monitor
+ * @META_TILE_MAXIMIZED: the window is maximized (i.e. both left and right sides)
+ */
+typedef enum {
+ META_TILE_NONE,
+ META_TILE_LEFT,
+ META_TILE_RIGHT,
+ META_TILE_MAXIMIZED
+} MetaTileMode;
+
#define META_TYPE_WINDOW (meta_window_get_type ())
#define META_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WINDOW, MetaWindow))
#define META_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_WINDOW, MetaWindowClass))
@@ -260,4 +275,10 @@ gboolean meta_window_is_client_decorated (MetaWindow *window);
gboolean meta_window_titlebar_is_onscreen (MetaWindow *window);
void meta_window_shove_titlebar_onscreen (MetaWindow *window);
+gboolean meta_window_can_tile_side_by_side (MetaWindow *window);
+MetaTileMode meta_window_get_tile_mode (MetaWindow *window);
+void meta_window_tile (MetaWindow *window,
+ MetaTileMode mode);
+
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]