From 66910ab422061fb94273cf44292566f90993b2db Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 25 Dec 2017 15:12:20 -0200 Subject: [PATCH] compositor: Introduce tile picker API Plugins might want to know when they should show a tile picker UI and, since we control the tiling state from the window manager side, we just need to tell the compositor when they should do that. This commit adds the necessary plumbing to let the compositor and plugins know when a tile picker should be shown. --- src/compositor/compositor.c | 8 ++++++++ src/compositor/meta-plugin-manager.c | 21 +++++++++++++++++++++ src/compositor/meta-plugin-manager.h | 5 +++++ src/core/window.c | 6 ++++++ src/meta/compositor.h | 4 ++++ src/meta/meta-plugin.h | 8 ++++++++ 6 files changed, 52 insertions(+) diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index aa49347c9..a7e7ca148 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -1456,6 +1456,14 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor) meta_plugin_manager_hide_tile_preview (compositor->plugin_mgr); } +void +meta_compositor_show_tile_picker (MetaCompositor *compositor, + MetaWindow *window, + int tile_monitor_number) +{ + meta_plugin_manager_show_tile_picker (compositor->plugin_mgr, window, tile_monitor_number); +} + void meta_compositor_show_window_menu (MetaCompositor *compositor, MetaWindow *window, diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c index 834f678dd..d1f3f4998 100644 --- a/src/compositor/meta-plugin-manager.c +++ b/src/compositor/meta-plugin-manager.c @@ -404,3 +404,24 @@ meta_plugin_manager_create_inhibit_shortcuts_dialog (MetaPluginManager *plugin_m return meta_inhibit_shortcuts_dialog_default_new (window); } + +gboolean +meta_plugin_manager_show_tile_picker (MetaPluginManager *plugin_mgr, + MetaWindow *window, + int tile_monitor_number) +{ + MetaPlugin *plugin = plugin_mgr->plugin; + MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); + MetaDisplay *display = plugin_mgr->compositor->display; + + if (display->display_opening) + return FALSE; + + if (klass->show_tile_picker) + { + klass->show_tile_picker (plugin, window, tile_monitor_number); + return TRUE; + } + + return FALSE; +} diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h index 19159032c..988c2ed35 100644 --- a/src/compositor/meta-plugin-manager.h +++ b/src/compositor/meta-plugin-manager.h @@ -98,4 +98,9 @@ MetaInhibitShortcutsDialog * meta_plugin_manager_create_inhibit_shortcuts_dialog (MetaPluginManager *plugin_mgr, MetaWindow *window); +gboolean meta_plugin_manager_show_tile_picker (MetaPluginManager *plugin_mgr, + MetaWindow *window, + int tile_monitor_number); + + #endif diff --git a/src/core/window.c b/src/core/window.c index 806f6f4fc..a8e369d6f 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -3153,6 +3153,12 @@ meta_window_tile (MetaWindow *window, if (window->frame) meta_frame_queue_draw (window->frame); + /* If the window doesn't have a tile match after being tiled, ask the + * compositor to show the tile picker. + */ + if (META_WINDOW_TILED_SIDE_BY_SIDE (window) && !window->tile_match) + meta_compositor_show_tile_picker (window->display->compositor, window, window->monitor->number); + out: if (should_notify) g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_TILE_MODE]); diff --git a/src/meta/compositor.h b/src/meta/compositor.h index f4de9b180..18b1a623e 100644 --- a/src/meta/compositor.h +++ b/src/meta/compositor.h @@ -122,6 +122,10 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor, MetaRectangle *tile_rect, int tile_monitor_number); void meta_compositor_hide_tile_preview (MetaCompositor *compositor); +void meta_compositor_show_tile_picker (MetaCompositor *compositor, + MetaWindow *window, + int tile_monitor_number); + void meta_compositor_show_window_menu (MetaCompositor *compositor, MetaWindow *window, MetaWindowMenuType menu, diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h index 73d94e5f0..deb20ed8a 100644 --- a/src/meta/meta-plugin.h +++ b/src/meta/meta-plugin.h @@ -251,6 +251,14 @@ struct _MetaPluginClass */ MetaInhibitShortcutsDialog * (* create_inhibit_shortcuts_dialog) (MetaPlugin *plugin, MetaWindow *window); + + /** + * MetaPluginClass::show_tile_picker: + * + */ + void * (* show_tile_picker) (MetaPlugin *plugin, + MetaWindow *window, + int tile_monitor_number); }; /**