mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
Implement side-by-side tiling
When dragging a window over a screen edge and dropping it there, maximize it vertically and scale it horizontally to cover the corresponding half of the current monitor. Whenever a "hot area" which triggers this behavior is entered, an indication of window's target size is displayed after a short delay to avoid distraction when moving a window between monitors. https://bugzilla.gnome.org/show_bug.cgi?id=606260
This commit is contained in:
@ -98,6 +98,7 @@ typedef enum
|
||||
PRIORITY_ENTIRELY_VISIBLE_ON_WORKAREA = 1,
|
||||
PRIORITY_SIZE_HINTS_INCREMENTS = 1,
|
||||
PRIORITY_MAXIMIZATION = 2,
|
||||
PRIORITY_TILING = 2,
|
||||
PRIORITY_FULLSCREEN = 2,
|
||||
PRIORITY_SIZE_HINTS_LIMITS = 3,
|
||||
PRIORITY_TITLEBAR_VISIBLE = 4,
|
||||
@ -148,6 +149,10 @@ static gboolean constrain_maximization (MetaWindow *window,
|
||||
ConstraintInfo *info,
|
||||
ConstraintPriority priority,
|
||||
gboolean check_only);
|
||||
static gboolean constrain_tiling (MetaWindow *window,
|
||||
ConstraintInfo *info,
|
||||
ConstraintPriority priority,
|
||||
gboolean check_only);
|
||||
static gboolean constrain_fullscreen (MetaWindow *window,
|
||||
ConstraintInfo *info,
|
||||
ConstraintPriority priority,
|
||||
@ -215,6 +220,7 @@ typedef struct {
|
||||
static const Constraint all_constraints[] = {
|
||||
{constrain_modal_dialog, "constrain_modal_dialog"},
|
||||
{constrain_maximization, "constrain_maximization"},
|
||||
{constrain_tiling, "constrain_tiling"},
|
||||
{constrain_fullscreen, "constrain_fullscreen"},
|
||||
{constrain_size_increments, "constrain_size_increments"},
|
||||
{constrain_size_limits, "constrain_size_limits"},
|
||||
@ -788,7 +794,8 @@ constrain_maximization (MetaWindow *window,
|
||||
return TRUE;
|
||||
|
||||
/* Determine whether constraint applies; exit if it doesn't */
|
||||
if (!window->maximized_horizontally && !window->maximized_vertically)
|
||||
if ((!window->maximized_horizontally && !window->maximized_vertically) ||
|
||||
META_WINDOW_TILED (window))
|
||||
return TRUE;
|
||||
|
||||
/* Calculate target_size = maximized size of (window + frame) */
|
||||
@ -856,6 +863,59 @@ constrain_maximization (MetaWindow *window,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
constrain_tiling (MetaWindow *window,
|
||||
ConstraintInfo *info,
|
||||
ConstraintPriority priority,
|
||||
gboolean check_only)
|
||||
{
|
||||
MetaRectangle target_size;
|
||||
MetaRectangle min_size, max_size;
|
||||
gboolean hminbad, vminbad;
|
||||
gboolean horiz_equal, vert_equal;
|
||||
gboolean constraint_already_satisfied;
|
||||
|
||||
if (priority > PRIORITY_TILING)
|
||||
return TRUE;
|
||||
|
||||
/* Determine whether constraint applies; exit if it doesn't */
|
||||
if (!META_WINDOW_TILED (window))
|
||||
return TRUE;
|
||||
|
||||
/* Calculate target_size - as the tile previews need this as well, we
|
||||
* use an external function for the actual calculation
|
||||
*/
|
||||
meta_window_get_current_tile_area (window, &target_size);
|
||||
unextend_by_frame (&target_size, info->fgeom);
|
||||
|
||||
/* Check min size constraints; max size constraints are ignored as for
|
||||
* maximized windows.
|
||||
*/
|
||||
get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
|
||||
hminbad = target_size.width < min_size.width;
|
||||
vminbad = target_size.height < min_size.height;
|
||||
if (hminbad || vminbad)
|
||||
return TRUE;
|
||||
|
||||
/* Determine whether constraint is already satisfied; exit if it is */
|
||||
horiz_equal = target_size.x == info->current.x &&
|
||||
target_size.width == info->current.width;
|
||||
vert_equal = target_size.y == info->current.y &&
|
||||
target_size.height == info->current.height;
|
||||
constraint_already_satisfied = horiz_equal && vert_equal;
|
||||
if (check_only || constraint_already_satisfied)
|
||||
return constraint_already_satisfied;
|
||||
|
||||
/*** Enforce constraint ***/
|
||||
info->current.x = target_size.x;
|
||||
info->current.width = target_size.width;
|
||||
info->current.y = target_size.y;
|
||||
info->current.height = target_size.height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
constrain_fullscreen (MetaWindow *window,
|
||||
ConstraintInfo *info,
|
||||
@ -907,7 +967,7 @@ constrain_size_increments (MetaWindow *window,
|
||||
|
||||
/* Determine whether constraint applies; exit if it doesn't */
|
||||
if (META_WINDOW_MAXIMIZED (window) || window->fullscreen ||
|
||||
info->action_type == ACTION_MOVE)
|
||||
META_WINDOW_TILED (window) || info->action_type == ACTION_MOVE)
|
||||
return TRUE;
|
||||
|
||||
/* Determine whether constraint is already satisfied; exit if it is */
|
||||
@ -1038,7 +1098,7 @@ constrain_aspect_ratio (MetaWindow *window,
|
||||
constraints_are_inconsistent = minr > maxr;
|
||||
if (constraints_are_inconsistent ||
|
||||
META_WINDOW_MAXIMIZED (window) || window->fullscreen ||
|
||||
info->action_type == ACTION_MOVE)
|
||||
META_WINDOW_TILED (window) || info->action_type == ACTION_MOVE)
|
||||
return TRUE;
|
||||
|
||||
/* Determine whether constraint is already satisfied; exit if it is. We
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "frame-private.h"
|
||||
#include "workspace-private.h"
|
||||
#include "prefs.h"
|
||||
#include "errors.h"
|
||||
|
||||
/* Looks up the MetaWindow representing the frame of the given X window.
|
||||
* Used as a helper function by a bunch of the functions below.
|
||||
@ -316,6 +317,40 @@ meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_lower_beneath_focus_window (Display *xdisplay,
|
||||
Window xwindow,
|
||||
guint32 timestamp)
|
||||
{
|
||||
XWindowChanges changes;
|
||||
MetaDisplay *display;
|
||||
MetaScreen *screen;
|
||||
MetaWindow *focus_window;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
screen = meta_display_screen_for_xwindow (display, xwindow);
|
||||
focus_window = meta_stack_get_top (screen->stack);
|
||||
|
||||
if (focus_window == NULL)
|
||||
return;
|
||||
|
||||
changes.stack_mode = Below;
|
||||
changes.sibling = focus_window->frame ? focus_window->frame->xwindow
|
||||
: focus_window->xwindow;
|
||||
|
||||
meta_stack_tracker_record_lower_below (screen->stack_tracker,
|
||||
xwindow,
|
||||
changes.sibling,
|
||||
XNextRequest (screen->display->xdisplay));
|
||||
|
||||
meta_error_trap_push (display);
|
||||
XConfigureWindow (xdisplay,
|
||||
xwindow,
|
||||
CWSibling | CWStackMode,
|
||||
&changes);
|
||||
meta_error_trap_pop (display, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_user_focus (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
|
@ -104,6 +104,7 @@ static char *cursor_theme = NULL;
|
||||
static int cursor_size = 24;
|
||||
static gboolean compositing_manager = FALSE;
|
||||
static gboolean resize_with_right_button = FALSE;
|
||||
static gboolean side_by_side_tiling = FALSE;
|
||||
static gboolean force_fullscreen = TRUE;
|
||||
|
||||
static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
|
||||
@ -422,6 +423,11 @@ static MetaBoolPreference preferences_bool[] =
|
||||
&resize_with_right_button,
|
||||
FALSE,
|
||||
},
|
||||
{ "/apps/metacity/general/side_by_side_tiling",
|
||||
META_PREF_SIDE_BY_SIDE_TILING,
|
||||
&side_by_side_tiling,
|
||||
FALSE,
|
||||
},
|
||||
{ "/apps/mutter/general/live_hidden_windows",
|
||||
META_PREF_LIVE_HIDDEN_WINDOWS,
|
||||
&live_hidden_windows,
|
||||
@ -2004,6 +2010,9 @@ meta_preference_to_string (MetaPreference pref)
|
||||
case META_PREF_RESIZE_WITH_RIGHT_BUTTON:
|
||||
return "RESIZE_WITH_RIGHT_BUTTON";
|
||||
|
||||
case META_PREF_SIDE_BY_SIDE_TILING:
|
||||
return "SIDE_BY_SIDE_TILING";
|
||||
|
||||
case META_PREF_FORCE_FULLSCREEN:
|
||||
return "FORCE_FULLSCREEN";
|
||||
|
||||
@ -2914,6 +2923,12 @@ meta_prefs_get_gnome_animations ()
|
||||
return gnome_animations;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_prefs_get_side_by_side_tiling ()
|
||||
{
|
||||
return side_by_side_tiling;
|
||||
}
|
||||
|
||||
MetaKeyBindingAction
|
||||
meta_prefs_get_keybinding_action (const char *name)
|
||||
{
|
||||
|
@ -82,6 +82,9 @@ struct _MetaScreen
|
||||
MetaRectangle rect; /* Size of screen; rect.x & rect.y are always 0 */
|
||||
MetaUI *ui;
|
||||
MetaTabPopup *tab_popup, *ws_popup;
|
||||
MetaTilePreview *tile_preview;
|
||||
|
||||
guint tile_preview_timeout_id;
|
||||
|
||||
MetaWorkspace *active_workspace;
|
||||
|
||||
@ -179,6 +182,9 @@ void meta_screen_workspace_popup_select (MetaScreen *screen,
|
||||
MetaWorkspace*meta_screen_workspace_popup_get_selected (MetaScreen *screen);
|
||||
void meta_screen_workspace_popup_destroy (MetaScreen *screen);
|
||||
|
||||
void meta_screen_tile_preview_update (MetaScreen *screen,
|
||||
gboolean delay);
|
||||
|
||||
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
|
||||
MetaWindow *not_this_one);
|
||||
|
||||
|
@ -770,6 +770,9 @@ meta_screen_new (MetaDisplay *display,
|
||||
|
||||
screen->tab_popup = NULL;
|
||||
screen->ws_popup = NULL;
|
||||
screen->tile_preview = NULL;
|
||||
|
||||
screen->tile_preview_timeout_id = 0;
|
||||
|
||||
screen->stack = meta_stack_new (screen);
|
||||
screen->stack_tracker = meta_stack_tracker_new (screen);
|
||||
@ -867,6 +870,12 @@ meta_screen_free (MetaScreen *screen,
|
||||
|
||||
if (screen->monitor_infos)
|
||||
g_free (screen->monitor_infos);
|
||||
|
||||
if (screen->tile_preview_timeout_id)
|
||||
g_source_remove (screen->tile_preview_timeout_id);
|
||||
|
||||
if (screen->tile_preview)
|
||||
meta_tile_preview_free (screen->tile_preview);
|
||||
|
||||
g_free (screen->screen_name);
|
||||
|
||||
@ -1743,6 +1752,69 @@ meta_screen_workspace_popup_destroy (MetaScreen *screen)
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_screen_tile_preview_update_timeout (gpointer data)
|
||||
{
|
||||
MetaScreen *screen = data;
|
||||
MetaWindow *window = screen->display->grab_window;
|
||||
gboolean composited = screen->display->compositor != NULL;
|
||||
|
||||
screen->tile_preview_timeout_id = 0;
|
||||
|
||||
if (!screen->tile_preview)
|
||||
{
|
||||
Window xwindow;
|
||||
gulong create_serial;
|
||||
|
||||
screen->tile_preview = meta_tile_preview_new (screen->number,
|
||||
composited);
|
||||
xwindow = meta_tile_preview_get_xwindow (screen->tile_preview,
|
||||
&create_serial);
|
||||
meta_stack_tracker_record_add (screen->stack_tracker,
|
||||
xwindow,
|
||||
create_serial);
|
||||
}
|
||||
|
||||
if (window
|
||||
&& !META_WINDOW_TILED (window)
|
||||
&& window->tile_mode != META_TILE_NONE)
|
||||
{
|
||||
MetaRectangle tile_rect;
|
||||
|
||||
meta_window_get_current_tile_area (window, &tile_rect);
|
||||
meta_tile_preview_show (screen->tile_preview, &tile_rect);
|
||||
}
|
||||
else
|
||||
meta_tile_preview_hide (screen->tile_preview);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define TILE_PREVIEW_TIMEOUT_MS 200
|
||||
|
||||
void
|
||||
meta_screen_tile_preview_update (MetaScreen *screen,
|
||||
gboolean delay)
|
||||
{
|
||||
if (delay)
|
||||
{
|
||||
if (screen->tile_preview_timeout_id > 0)
|
||||
return;
|
||||
|
||||
screen->tile_preview_timeout_id =
|
||||
g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
|
||||
meta_screen_tile_preview_update_timeout,
|
||||
screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (screen->tile_preview_timeout_id > 0)
|
||||
g_source_remove (screen->tile_preview_timeout_id);
|
||||
|
||||
meta_screen_tile_preview_update_timeout ((gpointer)screen);
|
||||
}
|
||||
}
|
||||
|
||||
MetaWindow*
|
||||
meta_screen_get_mouse_window (MetaScreen *screen,
|
||||
MetaWindow *not_this_one)
|
||||
|
@ -61,6 +61,12 @@ typedef enum {
|
||||
|
||||
#define NUMBER_OF_QUEUES 3
|
||||
|
||||
typedef enum {
|
||||
META_TILE_NONE,
|
||||
META_TILE_LEFT,
|
||||
META_TILE_RIGHT
|
||||
} MetaTileMode;
|
||||
|
||||
struct _MetaWindow
|
||||
{
|
||||
GObject parent_instance;
|
||||
@ -122,6 +128,11 @@ struct _MetaWindow
|
||||
guint maximize_vertically_after_placement : 1;
|
||||
guint minimize_after_placement : 1;
|
||||
|
||||
/* The current or requested tile mode. If maximized_vertically is true,
|
||||
* this is the current mode. If not, it is the mode which will be
|
||||
* requested after the window grab is released */
|
||||
guint tile_mode : 2;
|
||||
|
||||
/* Whether we're shaded */
|
||||
guint shaded : 1;
|
||||
|
||||
@ -398,8 +409,11 @@ struct _MetaWindowClass
|
||||
(w)->maximized_vertically)
|
||||
#define META_WINDOW_MAXIMIZED_VERTICALLY(w) ((w)->maximized_vertically)
|
||||
#define META_WINDOW_MAXIMIZED_HORIZONTALLY(w) ((w)->maximized_horizontally)
|
||||
#define META_WINDOW_TILED(w) ((w)->maximized_vertically && \
|
||||
!(w)->maximized_horizontally && \
|
||||
(w)->tile_mode != META_TILE_NONE)
|
||||
#define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->fullscreen)
|
||||
#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !META_WINDOW_MAXIMIZED (w) && !(w)->fullscreen && !(w)->shaded)
|
||||
#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !META_WINDOW_MAXIMIZED (w) && !META_WINDOW_TILED(w) && !(w)->fullscreen && !(w)->shaded)
|
||||
#define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \
|
||||
(((w)->size_hints.min_width < (w)->size_hints.max_width) || \
|
||||
((w)->size_hints.min_height < (w)->size_hints.max_height)))
|
||||
@ -563,6 +577,9 @@ void meta_window_get_work_area_for_monitor (MetaWindow *window,
|
||||
void meta_window_get_work_area_all_monitors (MetaWindow *window,
|
||||
MetaRectangle *area);
|
||||
|
||||
void meta_window_get_current_tile_area (MetaWindow *window,
|
||||
MetaRectangle *tile_area);
|
||||
|
||||
|
||||
gboolean meta_window_same_application (MetaWindow *window,
|
||||
MetaWindow *other_window);
|
||||
|
@ -772,6 +772,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
||||
window->require_on_single_monitor = TRUE;
|
||||
window->require_titlebar_visible = TRUE;
|
||||
window->on_all_workspaces = FALSE;
|
||||
window->tile_mode = META_TILE_NONE;
|
||||
window->shaded = FALSE;
|
||||
window->initially_iconic = FALSE;
|
||||
window->minimized = FALSE;
|
||||
@ -2970,7 +2971,7 @@ ensure_size_hints_satisfied (MetaRectangle *rect,
|
||||
static void
|
||||
meta_window_save_rect (MetaWindow *window)
|
||||
{
|
||||
if (!(META_WINDOW_MAXIMIZED (window) || window->fullscreen))
|
||||
if (!(META_WINDOW_MAXIMIZED (window) || META_WINDOW_TILED (window) || window->fullscreen))
|
||||
{
|
||||
/* save size/pos as appropriate args for move_resize */
|
||||
if (!window->maximized_horizontally)
|
||||
@ -3012,7 +3013,7 @@ force_save_user_window_placement (MetaWindow *window)
|
||||
static void
|
||||
save_user_window_placement (MetaWindow *window)
|
||||
{
|
||||
if (!(META_WINDOW_MAXIMIZED (window) || window->fullscreen))
|
||||
if (!(META_WINDOW_MAXIMIZED (window) || META_WINDOW_TILED (window) || window->fullscreen))
|
||||
{
|
||||
MetaRectangle user_rect;
|
||||
|
||||
@ -3082,6 +3083,7 @@ void
|
||||
meta_window_maximize (MetaWindow *window,
|
||||
MetaMaximizeFlags directions)
|
||||
{
|
||||
MetaRectangle *saved_rect = NULL;
|
||||
gboolean maximize_horizontally, maximize_vertically;
|
||||
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
@ -3120,9 +3122,16 @@ meta_window_maximize (MetaWindow *window,
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->tile_mode != META_TILE_NONE)
|
||||
{
|
||||
saved_rect = &window->saved_rect;
|
||||
|
||||
window->maximized_vertically = FALSE;
|
||||
}
|
||||
|
||||
meta_window_maximize_internal (window,
|
||||
directions,
|
||||
NULL);
|
||||
saved_rect);
|
||||
|
||||
if (window->display->compositor)
|
||||
{
|
||||
@ -3148,6 +3157,67 @@ meta_window_maximize (MetaWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_tile (MetaWindow *window)
|
||||
{
|
||||
/* Don't do anything if no tiling is requested */
|
||||
if (window->tile_mode == META_TILE_NONE)
|
||||
return;
|
||||
|
||||
meta_window_maximize_internal (window, META_MAXIMIZE_VERTICAL, NULL);
|
||||
meta_screen_tile_preview_update (window->screen, FALSE);
|
||||
|
||||
if (window->display->compositor)
|
||||
{
|
||||
MetaRectangle old_rect;
|
||||
MetaRectangle new_rect;
|
||||
|
||||
meta_window_get_outer_rect (window, &old_rect);
|
||||
|
||||
meta_window_move_resize_now (window);
|
||||
|
||||
meta_window_get_outer_rect (window, &new_rect);
|
||||
meta_compositor_maximize_window (window->display->compositor,
|
||||
window,
|
||||
&old_rect,
|
||||
&new_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* move_resize with new tiling constraints
|
||||
*/
|
||||
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_window_can_tile (MetaWindow *window)
|
||||
{
|
||||
const MetaMonitorInfo *monitor;
|
||||
MetaRectangle tile_area;
|
||||
|
||||
if (!META_WINDOW_ALLOWS_RESIZE (window))
|
||||
return FALSE;
|
||||
|
||||
monitor = meta_screen_get_current_monitor (window->screen);
|
||||
meta_window_get_work_area_for_monitor (window, monitor->number, &tile_area);
|
||||
|
||||
tile_area.width /= 2;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
MetaFrameGeometry fgeom;
|
||||
|
||||
meta_frame_calc_geometry (window->frame, &fgeom);
|
||||
|
||||
tile_area.width -= (fgeom.left_width + fgeom.right_width);
|
||||
tile_area.height -= (fgeom.top_height + fgeom.bottom_height);
|
||||
}
|
||||
|
||||
return tile_area.width >= window->size_hints.min_width &&
|
||||
tile_area.height >= window->size_hints.min_height;
|
||||
}
|
||||
|
||||
static void
|
||||
unmaximize_window_before_freeing (MetaWindow *window)
|
||||
{
|
||||
@ -3188,6 +3258,14 @@ meta_window_unmaximize (MetaWindow *window,
|
||||
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
/* Restore tiling if necessary */
|
||||
if (window->tile_mode != META_TILE_NONE)
|
||||
{
|
||||
window->maximized_horizontally = FALSE;
|
||||
meta_window_tile (window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* At least one of the two directions ought to be set */
|
||||
unmaximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL;
|
||||
unmaximize_vertically = directions & META_MAXIMIZE_VERTICAL;
|
||||
@ -3233,17 +3311,6 @@ meta_window_unmaximize (MetaWindow *window,
|
||||
*/
|
||||
ensure_size_hints_satisfied (&target_rect, &window->size_hints);
|
||||
|
||||
/* When we unmaximize, if we're doing a mouse move also we could
|
||||
* get the window suddenly jumping to the upper left corner of
|
||||
* the workspace, since that's where it was when the grab op
|
||||
* started. So we need to update the grab state.
|
||||
*/
|
||||
if (meta_grab_op_is_moving (window->display->grab_op) &&
|
||||
window->display->grab_window == window)
|
||||
{
|
||||
window->display->grab_anchor_window_pos = target_rect;
|
||||
}
|
||||
|
||||
if (window->display->compositor)
|
||||
{
|
||||
MetaRectangle old_rect, new_rect;
|
||||
@ -3277,6 +3344,19 @@ meta_window_unmaximize (MetaWindow *window,
|
||||
*/
|
||||
force_save_user_window_placement (window);
|
||||
|
||||
/* When we unmaximize, if we're doing a mouse move also we could
|
||||
* get the window suddenly jumping to the upper left corner of
|
||||
* the workspace, since that's where it was when the grab op
|
||||
* started. So we need to update the grab state. We have to do
|
||||
* it after the actual operation, as the window may have been moved
|
||||
* by constraints.
|
||||
*/
|
||||
if (meta_grab_op_is_moving (window->display->grab_op) &&
|
||||
window->display->grab_window == window)
|
||||
{
|
||||
window->display->grab_anchor_window_pos = window->user_rect;
|
||||
}
|
||||
|
||||
recalc_window_features (window);
|
||||
set_net_wm_state (window);
|
||||
}
|
||||
@ -7637,20 +7717,56 @@ update_move (MetaWindow *window,
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
/* shake loose (unmaximize) maximized window if dragged beyond the threshold
|
||||
* in the Y direction. You can't pull a window loose via X motion.
|
||||
/* Originally for detaching maximized windows, but we use this
|
||||
* for the zones at the sides of the monitor where trigger tiling
|
||||
* because it's about the right size
|
||||
*/
|
||||
|
||||
#define DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR 6
|
||||
shake_threshold = meta_ui_get_drag_threshold (window->screen->ui) *
|
||||
DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR;
|
||||
|
||||
if (META_WINDOW_MAXIMIZED (window) && ABS (dy) >= shake_threshold)
|
||||
if (meta_prefs_get_side_by_side_tiling () &&
|
||||
meta_window_can_tile (window))
|
||||
{
|
||||
const MetaMonitorInfo *monitor;
|
||||
MetaRectangle work_area;
|
||||
|
||||
/* For tiling we are interested in the work area of the monitor where
|
||||
* the pointer is located.
|
||||
* Also see comment in meta_window_get_current_tile_area()
|
||||
*/
|
||||
monitor = meta_screen_get_current_monitor (window->screen);
|
||||
meta_window_get_work_area_for_monitor (window,
|
||||
monitor->number,
|
||||
&work_area);
|
||||
|
||||
if (y >= monitor->rect.y &&
|
||||
y < (monitor->rect.y + monitor->rect.height))
|
||||
{
|
||||
/* check if cursor is near an edge of the work area */
|
||||
if (x >= monitor->rect.x && x < (work_area.x + shake_threshold))
|
||||
window->tile_mode = META_TILE_LEFT;
|
||||
else if (x >= work_area.x + work_area.width - shake_threshold &&
|
||||
x < (monitor->rect.x + monitor->rect.width))
|
||||
window->tile_mode = META_TILE_RIGHT;
|
||||
else
|
||||
window->tile_mode = META_TILE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/* shake loose (unmaximize) maximized or tiled window if dragged beyond
|
||||
* the threshold in the Y direction. Tiled windows can also be pulled
|
||||
* loose via X motion.
|
||||
*/
|
||||
|
||||
if ((META_WINDOW_MAXIMIZED (window) && ABS (dy) >= shake_threshold) ||
|
||||
(META_WINDOW_TILED (window) && (MAX (ABS (dx), ABS (dy)) >= shake_threshold)))
|
||||
{
|
||||
double prop;
|
||||
|
||||
/* Shake loose */
|
||||
window->shaken_loose = TRUE;
|
||||
window->shaken_loose = !META_WINDOW_TILED (window);
|
||||
window->tile_mode = META_TILE_NONE;
|
||||
|
||||
/* move the unmaximized window to the cursor */
|
||||
prop =
|
||||
@ -7677,10 +7793,12 @@ update_move (MetaWindow *window,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* remaximize window on another monitor if window has been shaken
|
||||
* loose or it is still maximized (then move straight)
|
||||
*/
|
||||
else if (window->shaken_loose || META_WINDOW_MAXIMIZED (window))
|
||||
else if ((window->shaken_loose || META_WINDOW_MAXIMIZED (window)) &&
|
||||
window->tile_mode == META_TILE_NONE)
|
||||
{
|
||||
const MetaMonitorInfo *wmonitor;
|
||||
MetaRectangle work_area;
|
||||
@ -7734,10 +7852,17 @@ update_move (MetaWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
/* Delay showing the tile preview slightly to make it more unlikely to
|
||||
* trigger it unwittingly, e.g. when shaking loose the window or moving
|
||||
* it to another monitor.
|
||||
*/
|
||||
meta_screen_tile_preview_update (window->screen,
|
||||
window->tile_mode != META_TILE_NONE);
|
||||
|
||||
meta_window_get_client_root_coords (window, &old);
|
||||
|
||||
/* Don't allow movement in the maximized directions */
|
||||
if (window->maximized_horizontally)
|
||||
/* Don't allow movement in the maximized directions or while tiled */
|
||||
if (window->maximized_horizontally || META_WINDOW_TILED (window))
|
||||
new_x = old.x;
|
||||
if (window->maximized_vertically)
|
||||
new_y = old.y;
|
||||
@ -8106,7 +8231,9 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
|
||||
{
|
||||
if (meta_grab_op_is_moving (window->display->grab_op))
|
||||
{
|
||||
if (event->xbutton.root == window->screen->xroot)
|
||||
if (window->tile_mode != META_TILE_NONE)
|
||||
meta_window_tile (window);
|
||||
else if (event->xbutton.root == window->screen->xroot)
|
||||
update_move (window, event->xbutton.state & ShiftMask,
|
||||
event->xbutton.x_root, event->xbutton.y_root);
|
||||
}
|
||||
@ -8264,6 +8391,29 @@ meta_window_get_work_area_all_monitors (MetaWindow *window,
|
||||
window->desc, area->x, area->y, area->width, area->height);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_get_current_tile_area (MetaWindow *window,
|
||||
MetaRectangle *tile_area)
|
||||
{
|
||||
const MetaMonitorInfo *monitor;
|
||||
|
||||
g_return_if_fail (window->tile_mode != META_TILE_NONE);
|
||||
|
||||
/* The definition of "current" of meta_window_get_work_area_current_monitor()
|
||||
* and meta_screen_get_current_monitor() is slightly different: the former
|
||||
* refers to the monitor which contains the largest part of the window, the
|
||||
* latter to the one where the pointer is located.
|
||||
*/
|
||||
monitor = meta_screen_get_current_monitor (window->screen);
|
||||
meta_window_get_work_area_for_monitor (window, monitor->number, tile_area);
|
||||
|
||||
if (window->tile_mode == META_TILE_LEFT ||
|
||||
window->tile_mode == META_TILE_RIGHT)
|
||||
tile_area->width /= 2;
|
||||
|
||||
if (window->tile_mode == META_TILE_RIGHT)
|
||||
tile_area->x += tile_area->width;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_window_same_application (MetaWindow *window,
|
||||
|
Reference in New Issue
Block a user