window: Simplify resize_popup handling

This commit is contained in:
Jasper St. Pierre 2014-04-29 15:35:34 -04:00
parent e382a4b560
commit 7726001d43
4 changed files with 35 additions and 51 deletions

View File

@ -203,7 +203,6 @@ struct _MetaDisplay
MetaRectangle grab_initial_window_pos; MetaRectangle grab_initial_window_pos;
int grab_initial_x, grab_initial_y; /* These are only relevant for */ int grab_initial_x, grab_initial_y; /* These are only relevant for */
gboolean grab_threshold_movement_reached; /* raise_on_click == FALSE. */ gboolean grab_threshold_movement_reached; /* raise_on_click == FALSE. */
MetaResizePopup *grab_resize_popup;
GTimeVal grab_last_moveresize_time; GTimeVal grab_last_moveresize_time;
MetaEdgeResistanceData *grab_edge_resistance_data; MetaEdgeResistanceData *grab_edge_resistance_data;
unsigned int grab_last_user_action_was_snap; unsigned int grab_last_user_action_was_snap;

View File

@ -41,7 +41,6 @@
#include <meta/errors.h> #include <meta/errors.h>
#include "keybindings-private.h" #include "keybindings-private.h"
#include <meta/prefs.h> #include <meta/prefs.h>
#include "resizepopup.h"
#include "workspace-private.h" #include "workspace-private.h"
#include "bell.h" #include "bell.h"
#include <meta/compositor.h> #include <meta/compositor.h>
@ -557,7 +556,6 @@ meta_display_open (void)
the_display->grab_op = META_GRAB_OP_NONE; the_display->grab_op = META_GRAB_OP_NONE;
the_display->grab_window = NULL; the_display->grab_window = NULL;
the_display->grab_resize_popup = NULL;
the_display->grab_tile_mode = META_TILE_NONE; the_display->grab_tile_mode = META_TILE_NONE;
the_display->grab_tile_monitor_number = -1; the_display->grab_tile_monitor_number = -1;

View File

@ -462,6 +462,8 @@ struct _MetaWindow
/* Bypass compositor hints */ /* Bypass compositor hints */
guint bypass_compositor; guint bypass_compositor;
MetaResizePopup *grab_resize_popup;
}; };
struct _MetaWindowClass struct _MetaWindowClass
@ -650,8 +652,6 @@ gboolean meta_window_same_application (MetaWindow *window,
#define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \ #define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \
(((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g)) (((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g))
void meta_window_refresh_resize_popup (MetaWindow *window);
void meta_window_free_delete_dialog (MetaWindow *window); void meta_window_free_delete_dialog (MetaWindow *window);
void meta_window_create_sync_request_alarm (MetaWindow *window); void meta_window_create_sync_request_alarm (MetaWindow *window);

View File

@ -4141,6 +4141,23 @@ 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,
@ -4317,7 +4334,8 @@ 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");
} }
meta_window_refresh_resize_popup (window); if (window->grab_resize_popup)
meta_window_refresh_resize_popup (window);
meta_window_update_monitor (window); meta_window_update_monitor (window);
@ -7331,42 +7349,6 @@ meta_window_is_client_decorated (MetaWindow *window)
} }
} }
void
meta_window_refresh_resize_popup (MetaWindow *window)
{
if (!meta_grab_op_is_resizing (window->display->grab_op))
return;
if (window->display->grab_window != window)
return;
if (window->display->grab_resize_popup == NULL)
{
if (window->size_hints.width_inc > 1 ||
window->size_hints.height_inc > 1)
window->display->grab_resize_popup =
meta_ui_resize_popup_new (window->display->xdisplay,
window->screen->number);
}
if (window->display->grab_resize_popup != NULL)
{
MetaRectangle rect;
meta_window_get_client_root_coords (window, &rect);
meta_ui_resize_popup_set (window->display->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->display->grab_resize_popup,
TRUE);
}
}
/** /**
* meta_window_foreach_transient: * meta_window_foreach_transient:
* @window: a #MetaWindow * @window: a #MetaWindow
@ -8921,24 +8903,29 @@ 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) && if (meta_grab_op_is_resizing (op))
window->sync_request_counter != None) {
meta_window_create_sync_request_alarm (window); if (window->sync_request_counter != None)
meta_window_create_sync_request_alarm (window);
meta_window_refresh_resize_popup (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)
{ {
MetaDisplay *display = window->display;
window->shaken_loose = FALSE; window->shaken_loose = FALSE;
if (display->grab_resize_popup) if (window->grab_resize_popup)
{ {
meta_ui_resize_popup_free (display->grab_resize_popup); meta_ui_resize_popup_free (window->grab_resize_popup);
display->grab_resize_popup = NULL; window->grab_resize_popup = NULL;
} }
} }