compositor: Add high level API to deal with MetaWindowDrag
This helper object (and the whole window drag operation) will be requested to the compositor instead of created directly, and only one of those can exist at a time, so the compositor will also safeguard that. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
parent
e6d0e0fda6
commit
fc4287cd20
2 changed files with 54 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "compositor/meta-compositor-view.h"
|
||||
#include "compositor/meta-plugin-manager.h"
|
||||
#include "compositor/meta-window-actor-private.h"
|
||||
#include "compositor/meta-window-drag.h"
|
||||
#include "meta/compositor.h"
|
||||
#include "meta/display.h"
|
||||
|
||||
|
@ -80,6 +81,13 @@ ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);
|
|||
|
||||
gboolean meta_compositor_is_switching_workspace (MetaCompositor *compositor);
|
||||
|
||||
gboolean meta_compositor_drag_window (MetaCompositor *compositor,
|
||||
MetaWindow *window,
|
||||
MetaGrabOp grab_op,
|
||||
uint32_t timestamp);
|
||||
|
||||
MetaWindowDrag * meta_compositor_get_current_window_drag (MetaCompositor *compositor);
|
||||
|
||||
void meta_compositor_grab_begin (MetaCompositor *compositor);
|
||||
|
||||
void meta_compositor_grab_end (MetaCompositor *compositor);
|
||||
|
|
|
@ -136,6 +136,8 @@ typedef struct _MetaCompositorPrivate
|
|||
|
||||
MetaPluginManager *plugin_mgr;
|
||||
|
||||
MetaWindowDrag *current_drag;
|
||||
|
||||
MetaLaters *laters;
|
||||
} MetaCompositorPrivate;
|
||||
|
||||
|
@ -1673,3 +1675,47 @@ meta_compositor_get_laters (MetaCompositor *compositor)
|
|||
priv = meta_compositor_get_instance_private (compositor);
|
||||
return priv->laters;
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_drag_ended (MetaWindowDrag *window_drag,
|
||||
MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
|
||||
g_assert (priv->current_drag == window_drag);
|
||||
g_clear_object (&priv->current_drag);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_compositor_drag_window (MetaCompositor *compositor,
|
||||
MetaWindow *window,
|
||||
MetaGrabOp grab_op,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
g_autoptr (MetaWindowDrag) window_drag = NULL;
|
||||
|
||||
if (priv->current_drag)
|
||||
return FALSE;
|
||||
|
||||
window_drag = meta_window_drag_new (window, grab_op);
|
||||
|
||||
if (!meta_window_drag_begin (window_drag, timestamp))
|
||||
return FALSE;
|
||||
|
||||
g_signal_connect (window_drag, "ended",
|
||||
G_CALLBACK (on_window_drag_ended), compositor);
|
||||
priv->current_drag = g_steal_pointer (&window_drag);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
MetaWindowDrag *
|
||||
meta_compositor_get_current_window_drag (MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
|
||||
return priv->current_drag;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue