mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
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.
This commit is contained in:
parent
5eacdf7af7
commit
17b56e9604
@ -74,13 +74,6 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
#define N_IGNORED_CROSSING_SERIALS 10
|
#define N_IGNORED_CROSSING_SERIALS 10
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
META_TILE_NONE,
|
|
||||||
META_TILE_LEFT,
|
|
||||||
META_TILE_RIGHT,
|
|
||||||
META_TILE_MAXIMIZED
|
|
||||||
} MetaTileMode;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* Normal interaction where you're interacting with windows.
|
/* Normal interaction where you're interacting with windows.
|
||||||
* Events go to windows normally. */
|
* Events go to windows normally. */
|
||||||
|
@ -593,8 +593,6 @@ void meta_window_unmanage (MetaWindow *window,
|
|||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_window_queue (MetaWindow *window,
|
void meta_window_queue (MetaWindow *window,
|
||||||
guint queuebits);
|
guint queuebits);
|
||||||
void meta_window_tile (MetaWindow *window,
|
|
||||||
MetaTileMode mode);
|
|
||||||
void meta_window_restore_tile (MetaWindow *window,
|
void meta_window_restore_tile (MetaWindow *window,
|
||||||
MetaTileMode mode,
|
MetaTileMode mode,
|
||||||
int width,
|
int width,
|
||||||
@ -712,7 +710,6 @@ void meta_window_update_for_monitors_changed (MetaWindow *window);
|
|||||||
void meta_window_on_all_workspaces_changed (MetaWindow *window);
|
void meta_window_on_all_workspaces_changed (MetaWindow *window);
|
||||||
|
|
||||||
gboolean meta_window_should_attach_to_parent (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);
|
void meta_window_compute_tile_match (MetaWindow *window);
|
||||||
|
|
||||||
|
@ -179,6 +179,7 @@ enum {
|
|||||||
PROP_GTK_APP_MENU_OBJECT_PATH,
|
PROP_GTK_APP_MENU_OBJECT_PATH,
|
||||||
PROP_GTK_MENUBAR_OBJECT_PATH,
|
PROP_GTK_MENUBAR_OBJECT_PATH,
|
||||||
PROP_ON_ALL_WORKSPACES,
|
PROP_ON_ALL_WORKSPACES,
|
||||||
|
PROP_TILE_MODE,
|
||||||
|
|
||||||
LAST_PROP,
|
LAST_PROP,
|
||||||
};
|
};
|
||||||
@ -399,6 +400,9 @@ meta_window_get_property(GObject *object,
|
|||||||
case PROP_ON_ALL_WORKSPACES:
|
case PROP_ON_ALL_WORKSPACES:
|
||||||
g_value_set_boolean (value, win->on_all_workspaces);
|
g_value_set_boolean (value, win->on_all_workspaces);
|
||||||
break;
|
break;
|
||||||
|
case PROP_TILE_MODE:
|
||||||
|
g_value_set_enum (value, win->tile_mode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -413,6 +417,9 @@ meta_window_set_property(GObject *object,
|
|||||||
{
|
{
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
case PROP_TILE_MODE:
|
||||||
|
meta_window_tile (META_WINDOW (object), g_value_get_enum (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -588,6 +595,13 @@ meta_window_class_init (MetaWindowClass *klass)
|
|||||||
"Whether the window is set to appear on all workspaces",
|
"Whether the window is set to appear on all workspaces",
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
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);
|
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->maximized_vertically = FALSE;
|
||||||
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_window_maximize_internal (window,
|
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
|
void
|
||||||
meta_window_tile (MetaWindow *window,
|
meta_window_tile (MetaWindow *window,
|
||||||
MetaTileMode tile_mode)
|
MetaTileMode tile_mode)
|
||||||
{
|
{
|
||||||
MetaMaximizeFlags directions;
|
MetaMaximizeFlags directions;
|
||||||
MetaRectangle old_frame_rect, old_buffer_rect;
|
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);
|
meta_window_get_tile_fraction (window, tile_mode, &window->tile_hfraction);
|
||||||
window->tile_mode = tile_mode;
|
window->tile_mode = tile_mode;
|
||||||
|
|
||||||
/* Don't do anything if no tiling is requested */
|
/* Don't do anything if no tiling is requested */
|
||||||
if (window->tile_mode == META_TILE_NONE)
|
if (window->tile_mode == META_TILE_NONE)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
if (window->tile_mode == META_TILE_MAXIMIZED)
|
if (window->tile_mode == META_TILE_MAXIMIZED)
|
||||||
directions = META_MAXIMIZE_BOTH;
|
directions = META_MAXIMIZE_BOTH;
|
||||||
@ -3126,6 +3152,10 @@ meta_window_tile (MetaWindow *window,
|
|||||||
|
|
||||||
if (window->frame)
|
if (window->frame)
|
||||||
meta_frame_queue_draw (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
|
void
|
||||||
@ -3144,6 +3174,15 @@ meta_window_can_tile_maximized (MetaWindow *window)
|
|||||||
return window->has_maximize_func;
|
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
|
gboolean
|
||||||
meta_window_can_tile_side_by_side (MetaWindow *window)
|
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;
|
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
|
static void
|
||||||
unmaximize_window_before_freeing (MetaWindow *window)
|
unmaximize_window_before_freeing (MetaWindow *window)
|
||||||
{
|
{
|
||||||
@ -3237,7 +3290,10 @@ meta_window_unmaximize (MetaWindow *window,
|
|||||||
meta_window_get_buffer_rect (window, &old_buffer_rect);
|
meta_window_get_buffer_rect (window, &old_buffer_rect);
|
||||||
|
|
||||||
if (unmaximize_vertically)
|
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,
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
"Unmaximizing %s%s\n",
|
"Unmaximizing %s%s\n",
|
||||||
|
@ -91,6 +91,21 @@ typedef enum {
|
|||||||
META_WINDOW_CLIENT_TYPE_X11
|
META_WINDOW_CLIENT_TYPE_X11
|
||||||
} MetaWindowClientType;
|
} 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_TYPE_WINDOW (meta_window_get_type ())
|
||||||
#define META_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WINDOW, MetaWindow))
|
#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))
|
#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);
|
gboolean meta_window_titlebar_is_onscreen (MetaWindow *window);
|
||||||
void meta_window_shove_titlebar_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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user