window: Turn grab_op_begin / grab_op_ended into vfuncs

And move the grab_resize_popup management to the X11 window class,
as this is only used under X11.
This commit is contained in:
Jasper St. Pierre 2014-04-29 15:55:55 -04:00
parent 7726001d43
commit 575963bee7
4 changed files with 85 additions and 42 deletions

View File

@ -462,8 +462,6 @@ struct _MetaWindow
/* Bypass compositor hints */ /* Bypass compositor hints */
guint bypass_compositor; guint bypass_compositor;
MetaResizePopup *grab_resize_popup;
}; };
struct _MetaWindowClass struct _MetaWindowClass
@ -479,6 +477,10 @@ struct _MetaWindowClass
void (*kill) (MetaWindow *window); void (*kill) (MetaWindow *window);
void (*focus) (MetaWindow *window, void (*focus) (MetaWindow *window,
guint32 timestamp); guint32 timestamp);
void (*grab_op_began) (MetaWindow *window,
MetaGrabOp op);
void (*grab_op_ended) (MetaWindow *window,
MetaGrabOp op);
void (*move_resize_internal) (MetaWindow *window, void (*move_resize_internal) (MetaWindow *window,
int gravity, int gravity,
MetaRectangle requested_rect, MetaRectangle requested_rect,

View File

@ -40,7 +40,6 @@
#include "place.h" #include "place.h"
#include <meta/prefs.h> #include <meta/prefs.h>
#include <meta/group.h> #include <meta/group.h>
#include "resizepopup.h"
#include "constraints.h" #include "constraints.h"
#include "mutter-enum-types.h" #include "mutter-enum-types.h"
#include "core.h" #include "core.h"
@ -194,6 +193,19 @@ prefs_changed_callback (MetaPreference pref,
} }
} }
static void
meta_window_real_grab_op_began (MetaWindow *window,
MetaGrabOp op)
{
}
static void
meta_window_real_grab_op_ended (MetaWindow *window,
MetaGrabOp op)
{
window->shaken_loose = FALSE;
}
static gboolean static gboolean
meta_window_real_update_struts (MetaWindow *window) meta_window_real_update_struts (MetaWindow *window)
{ {
@ -365,6 +377,8 @@ meta_window_class_init (MetaWindowClass *klass)
object_class->get_property = meta_window_get_property; object_class->get_property = meta_window_get_property;
object_class->set_property = meta_window_set_property; object_class->set_property = meta_window_set_property;
klass->grab_op_began = meta_window_real_grab_op_began;
klass->grab_op_ended = meta_window_real_grab_op_ended;
klass->update_struts = meta_window_real_update_struts; klass->update_struts = meta_window_real_update_struts;
klass->get_default_skip_hints = meta_window_real_get_default_skip_hints; klass->get_default_skip_hints = meta_window_real_get_default_skip_hints;
@ -4141,23 +4155,6 @@ meta_window_update_monitor (MetaWindow *window)
} }
} }
static void
meta_window_refresh_resize_popup (MetaWindow *window)
{
MetaRectangle rect;
meta_window_get_client_root_coords (window, &rect);
meta_ui_resize_popup_set (window->grab_resize_popup,
rect,
window->size_hints.base_width,
window->size_hints.base_height,
window->size_hints.width_inc,
window->size_hints.height_inc);
meta_ui_resize_popup_set_showing (window->grab_resize_popup, TRUE);
}
void void
meta_window_move_resize_internal (MetaWindow *window, meta_window_move_resize_internal (MetaWindow *window,
MetaMoveResizeFlags flags, MetaMoveResizeFlags flags,
@ -4334,9 +4331,6 @@ meta_window_move_resize_internal (MetaWindow *window,
meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n"); meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n");
} }
if (window->grab_resize_popup)
meta_window_refresh_resize_popup (window);
meta_window_update_monitor (window); meta_window_update_monitor (window);
/* Invariants leaving this function are: /* Invariants leaving this function are:
@ -8903,29 +8897,12 @@ void
meta_window_grab_op_began (MetaWindow *window, meta_window_grab_op_began (MetaWindow *window,
MetaGrabOp op) MetaGrabOp op)
{ {
if (meta_grab_op_is_resizing (op)) META_WINDOW_GET_CLASS (window)->grab_op_began (window, op);
{
if (window->sync_request_counter != None)
meta_window_create_sync_request_alarm (window);
if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
{
window->grab_resize_popup = meta_ui_resize_popup_new (window->display->xdisplay,
window->screen->number);
meta_window_refresh_resize_popup (window);
}
}
} }
void void
meta_window_grab_op_ended (MetaWindow *window, meta_window_grab_op_ended (MetaWindow *window,
MetaGrabOp op) MetaGrabOp op)
{ {
window->shaken_loose = FALSE; META_WINDOW_GET_CLASS (window)->grab_op_ended (window, op);
if (window->grab_resize_popup)
{
meta_ui_resize_popup_free (window->grab_resize_popup);
window->grab_resize_popup = NULL;
}
} }

View File

@ -50,6 +50,8 @@ struct _MetaWindowX11Private
guint using_net_wm_visible_name : 1; /* tracked so we can clear it */ guint using_net_wm_visible_name : 1; /* tracked so we can clear it */
Atom type_atom; Atom type_atom;
MetaResizePopup *grab_resize_popup;
}; };
G_END_DECLS G_END_DECLS

View File

@ -44,6 +44,7 @@
#include "window-private.h" #include "window-private.h"
#include "window-props.h" #include "window-props.h"
#include "xprops.h" #include "xprops.h"
#include "resizepopup.h"
struct _MetaWindowX11Class struct _MetaWindowX11Class
{ {
@ -498,6 +499,60 @@ meta_window_x11_focus (MetaWindow *window,
} }
} }
static void
meta_window_refresh_resize_popup (MetaWindow *window)
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
MetaRectangle rect;
meta_window_get_client_root_coords (window, &rect);
meta_ui_resize_popup_set (priv->grab_resize_popup,
rect,
window->size_hints.base_width,
window->size_hints.base_height,
window->size_hints.width_inc,
window->size_hints.height_inc);
meta_ui_resize_popup_set_showing (priv->grab_resize_popup, TRUE);
}
static void
meta_window_x11_grab_op_began (MetaWindow *window,
MetaGrabOp op)
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
if (meta_grab_op_is_resizing (op))
{
if (window->sync_request_counter != None)
meta_window_create_sync_request_alarm (window);
if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
{
priv->grab_resize_popup = meta_ui_resize_popup_new (window->display->xdisplay,
window->screen->number);
meta_window_refresh_resize_popup (window);
}
}
}
static void
meta_window_x11_grab_op_ended (MetaWindow *window,
MetaGrabOp op)
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
if (priv->grab_resize_popup)
{
meta_ui_resize_popup_free (priv->grab_resize_popup);
priv->grab_resize_popup = NULL;
}
}
static void static void
update_net_frame_extents (MetaWindow *window) update_net_frame_extents (MetaWindow *window)
{ {
@ -619,6 +674,8 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
MetaMoveResizeFlags flags, MetaMoveResizeFlags flags,
MetaMoveResizeResultFlags *result) MetaMoveResizeResultFlags *result)
{ {
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
int root_x_nw, root_y_nw; int root_x_nw, root_y_nw;
int w, h; int w, h;
int client_move_x, client_move_y; int client_move_x, client_move_y;
@ -891,6 +948,9 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
if (need_configure_notify) if (need_configure_notify)
send_configure_notify (window); send_configure_notify (window);
if (priv->grab_resize_popup)
meta_window_refresh_resize_popup (window);
if (frame_shape_changed) if (frame_shape_changed)
*result |= META_MOVE_RESIZE_RESULT_FRAME_SHAPE_CHANGED; *result |= META_MOVE_RESIZE_RESULT_FRAME_SHAPE_CHANGED;
if (need_move_client || need_move_frame) if (need_move_client || need_move_frame)
@ -1085,6 +1145,8 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
window_class->delete = meta_window_x11_delete; window_class->delete = meta_window_x11_delete;
window_class->kill = meta_window_x11_kill; window_class->kill = meta_window_x11_kill;
window_class->focus = meta_window_x11_focus; window_class->focus = meta_window_x11_focus;
window_class->grab_op_began = meta_window_x11_grab_op_began;
window_class->grab_op_ended = meta_window_x11_grab_op_ended;
window_class->move_resize_internal = meta_window_x11_move_resize_internal; window_class->move_resize_internal = meta_window_x11_move_resize_internal;
window_class->update_struts = meta_window_x11_update_struts; window_class->update_struts = meta_window_x11_update_struts;
window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints; window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints;