2006-10-01 22:30:10 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 10:29:20 +00:00
|
|
|
/* Mutter X window decorations */
|
2001-05-31 06:42:58 +00:00
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
/*
|
2001-05-31 06:42:58 +00:00
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2004-08-27 02:17:49 +00:00
|
|
|
* Copyright (C) 2003, 2004 Red Hat, Inc.
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 14:58:50 +00:00
|
|
|
* Copyright (C) 2005 Elijah Newren
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2001-05-31 06:42:58 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2001-05-31 06:42:58 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2001-05-31 06:42:58 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-27 03:03:32 +00:00
|
|
|
#include <config.h>
|
2011-03-06 00:29:12 +00:00
|
|
|
#include "frame.h"
|
2003-01-28 15:07:43 +00:00
|
|
|
#include "bell.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/errors.h>
|
2009-01-29 14:16:01 +00:00
|
|
|
#include "keybindings-private.h"
|
2001-06-03 21:39:57 +00:00
|
|
|
|
2001-06-20 03:01:26 +00:00
|
|
|
#define EVENT_MASK (SubstructureRedirectMask | \
|
|
|
|
StructureNotifyMask | SubstructureNotifyMask | \
|
|
|
|
ExposureMask | \
|
|
|
|
ButtonPressMask | ButtonReleaseMask | \
|
|
|
|
PointerMotionMask | PointerMotionHintMask | \
|
2001-06-23 05:49:35 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask | \
|
2014-03-20 20:26:14 +00:00
|
|
|
FocusChangeMask)
|
2001-06-20 03:01:26 +00:00
|
|
|
|
2001-06-03 01:33:27 +00:00
|
|
|
void
|
|
|
|
meta_window_ensure_frame (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaFrame *frame;
|
|
|
|
XSetWindowAttributes attrs;
|
2003-11-16 04:19:18 +00:00
|
|
|
Visual *visual;
|
2009-06-13 20:45:32 +00:00
|
|
|
gulong create_serial;
|
2012-04-05 10:22:13 +00:00
|
|
|
MetaStackWindow stack_window;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-06-03 01:33:27 +00:00
|
|
|
if (window->frame)
|
|
|
|
return;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-06-03 01:33:27 +00:00
|
|
|
frame = g_new (MetaFrame, 1);
|
|
|
|
|
|
|
|
frame->window = window;
|
|
|
|
frame->xwindow = None;
|
|
|
|
|
2001-06-09 21:58:30 +00:00
|
|
|
frame->rect = window->rect;
|
|
|
|
frame->child_x = 0;
|
|
|
|
frame->child_y = 0;
|
|
|
|
frame->bottom_height = 0;
|
|
|
|
frame->right_width = 0;
|
2002-08-23 18:00:40 +00:00
|
|
|
frame->current_cursor = 0;
|
2001-06-09 21:58:30 +00:00
|
|
|
|
2003-01-28 15:07:43 +00:00
|
|
|
frame->is_flashing = FALSE;
|
2013-11-15 22:37:50 +00:00
|
|
|
frame->borders_cached = FALSE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-09-09 03:44:42 +00:00
|
|
|
meta_verbose ("Framing window %s: visual %s default, depth %d default depth %d\n",
|
|
|
|
window->desc,
|
|
|
|
XVisualIDFromVisual (window->xvisual) ==
|
|
|
|
XVisualIDFromVisual (window->screen->default_xvisual) ?
|
|
|
|
"is" : "is not",
|
|
|
|
window->depth, window->screen->default_depth);
|
2002-04-22 18:18:38 +00:00
|
|
|
meta_verbose ("Frame geometry %d,%d %dx%d\n",
|
|
|
|
frame->rect.x, frame->rect.y,
|
|
|
|
frame->rect.width, frame->rect.height);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-09-09 03:44:42 +00:00
|
|
|
/* Default depth/visual handles clients with weird visuals; they can
|
|
|
|
* always be children of the root depth/visual obviously, but
|
|
|
|
* e.g. DRI games can't be children of a parent that has the same
|
2004-08-27 02:17:49 +00:00
|
|
|
* visual as the client. NULL means default visual.
|
|
|
|
*
|
|
|
|
* We look for an ARGB visual if we can find one, otherwise use
|
|
|
|
* the default of NULL.
|
|
|
|
*/
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2004-08-27 02:17:49 +00:00
|
|
|
/* Special case for depth 32 windows (assumed to be ARGB),
|
2004-10-19 05:18:11 +00:00
|
|
|
* we use the window's visual. Otherwise we just use the system visual.
|
2001-09-09 03:44:42 +00:00
|
|
|
*/
|
2003-11-16 04:19:18 +00:00
|
|
|
if (window->depth == 32)
|
2004-08-27 02:17:49 +00:00
|
|
|
visual = window->xvisual;
|
|
|
|
else
|
2004-10-19 05:18:11 +00:00
|
|
|
visual = NULL;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
|
2003-11-16 04:19:18 +00:00
|
|
|
window->display->xdisplay,
|
|
|
|
visual,
|
|
|
|
frame->rect.x,
|
|
|
|
frame->rect.y,
|
2003-08-16 16:32:10 +00:00
|
|
|
frame->rect.width,
|
|
|
|
frame->rect.height,
|
2009-06-13 20:45:32 +00:00
|
|
|
frame->window->screen->number,
|
|
|
|
&create_serial);
|
2012-04-05 10:22:13 +00:00
|
|
|
stack_window.any.type = META_WINDOW_CLIENT_TYPE_X11;
|
|
|
|
stack_window.x11.xwindow = frame->xwindow;
|
2009-06-13 20:45:32 +00:00
|
|
|
meta_stack_tracker_record_add (window->screen->stack_tracker,
|
2012-04-05 10:22:13 +00:00
|
|
|
&stack_window,
|
2009-06-13 20:45:32 +00:00
|
|
|
create_serial);
|
2003-08-16 16:32:10 +00:00
|
|
|
|
2001-06-09 21:58:30 +00:00
|
|
|
meta_verbose ("Frame for %s is 0x%lx\n", frame->window->desc, frame->xwindow);
|
2003-08-16 16:32:10 +00:00
|
|
|
attrs.event_mask = EVENT_MASK;
|
|
|
|
XChangeWindowAttributes (window->display->xdisplay,
|
|
|
|
frame->xwindow, CWEventMask, &attrs);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
meta_display_register_x_window (window->display, &frame->xwindow, window);
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
2002-01-11 03:31:14 +00:00
|
|
|
if (window->mapped)
|
|
|
|
{
|
|
|
|
window->mapped = FALSE; /* the reparent will unmap the window,
|
|
|
|
* we don't want to take that as a withdraw
|
|
|
|
*/
|
2002-02-08 03:34:26 +00:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Incrementing unmaps_pending on %s for reparent\n", window->desc);
|
2002-01-11 03:31:14 +00:00
|
|
|
window->unmaps_pending += 1;
|
|
|
|
}
|
2001-09-09 03:44:42 +00:00
|
|
|
/* window was reparented to this position */
|
2001-06-11 05:47:51 +00:00
|
|
|
window->rect.x = 0;
|
|
|
|
window->rect.y = 0;
|
2001-09-09 03:44:42 +00:00
|
|
|
|
2012-04-05 10:22:13 +00:00
|
|
|
stack_window.x11.xwindow = window->xwindow;
|
2009-06-13 20:45:32 +00:00
|
|
|
meta_stack_tracker_record_remove (window->screen->stack_tracker,
|
2012-04-05 10:22:13 +00:00
|
|
|
&stack_window,
|
2009-06-13 20:45:32 +00:00
|
|
|
XNextRequest (window->display->xdisplay));
|
2001-05-31 06:42:58 +00:00
|
|
|
XReparentWindow (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
frame->xwindow,
|
2001-06-11 05:47:51 +00:00
|
|
|
window->rect.x,
|
|
|
|
window->rect.y);
|
2001-10-13 04:00:08 +00:00
|
|
|
/* FIXME handle this error */
|
2010-10-25 18:44:30 +00:00
|
|
|
meta_error_trap_pop (window->display);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
/* stick frame to the window */
|
2001-06-04 06:17:52 +00:00
|
|
|
window->frame = frame;
|
2011-03-20 21:15:47 +00:00
|
|
|
|
|
|
|
/* Now that frame->xwindow is registered with window, we can set its
|
2011-03-20 22:20:51 +00:00
|
|
|
* style and background.
|
2011-03-20 21:15:47 +00:00
|
|
|
*/
|
2011-03-20 22:20:51 +00:00
|
|
|
meta_ui_update_frame_style (window->screen->ui, frame->xwindow);
|
2011-03-20 21:15:47 +00:00
|
|
|
meta_ui_reset_frame_bg (window->screen->ui, frame->xwindow);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-06-20 03:01:26 +00:00
|
|
|
if (window->title)
|
|
|
|
meta_ui_set_frame_title (window->screen->ui,
|
|
|
|
window->frame->xwindow,
|
|
|
|
window->title);
|
2001-06-23 05:49:35 +00:00
|
|
|
|
|
|
|
/* Move keybindings to frame instead of window */
|
|
|
|
meta_window_grab_keys (window);
|
Always map the client and frame windows
Traditionally, WMs unmap windows when minimizing them, and map them
when restoring them or wanting to show them for other reasons, like
upon creation.
However, as metacity morphed into mutter, we optionally chose to keep
windows mapped for the lifetime of the window under the user option
"live-window-previews", which makes the code keep windows mapped so it
can show window preview for minimized windows in other places, like
Alt-Tab and Expose.
I removed this preference two years ago mechanically, by removing all
the if statements, but never went through and cleaned up the code so
that windows are simply mapped for the lifetime of the window -- the
"architecture" of the old code that maps and unmaps on show/hide was
still there.
Remove this now.
The one case we still need to be careful of is shaded windows, in which
we do still unmap the client window. In the future, we might want to
show previews of shaded windows in the overview and Alt-Tab. In that
we'd also keep shaded windows mapped, and could remove all unmap logic,
but we'd need a more complex method of showing the shaded titlebar, such
as using a different actor.
At the same time, simplify the compositor interface by removing
meta_compositor_window_[un]mapped API, and instead adding/removing the
window on-demand.
https://bugzilla.gnome.org/show_bug.cgi?id=720631
2014-02-02 00:06:51 +00:00
|
|
|
|
|
|
|
meta_ui_map_frame (frame->window->screen->ui, frame->xwindow);
|
2001-05-31 06:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_destroy_frame (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaFrame *frame;
|
2011-10-17 21:18:50 +00:00
|
|
|
MetaFrameBorders borders;
|
2012-04-05 10:22:13 +00:00
|
|
|
MetaStackWindow stack_window;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
if (window->frame == NULL)
|
|
|
|
return;
|
|
|
|
|
2003-12-26 02:42:38 +00:00
|
|
|
meta_verbose ("Unframing window %s\n", window->desc);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
frame = window->frame;
|
2011-10-17 21:18:50 +00:00
|
|
|
|
|
|
|
meta_frame_calc_borders (frame, &borders);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-01-28 15:07:43 +00:00
|
|
|
meta_bell_notify_frame_destroy (frame);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
/* Unparent the client window; it may be destroyed,
|
|
|
|
* thus the error trap.
|
|
|
|
*/
|
|
|
|
meta_error_trap_push (window->display);
|
2002-01-11 03:31:14 +00:00
|
|
|
if (window->mapped)
|
|
|
|
{
|
|
|
|
window->mapped = FALSE; /* Keep track of unmapping it, so we
|
|
|
|
* can identify a withdraw initiated
|
|
|
|
* by the client.
|
|
|
|
*/
|
2002-02-08 03:34:26 +00:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Incrementing unmaps_pending on %s for reparent back to root\n", window->desc);
|
2002-01-11 03:31:14 +00:00
|
|
|
window->unmaps_pending += 1;
|
|
|
|
}
|
2012-04-05 10:22:13 +00:00
|
|
|
stack_window.any.type = META_WINDOW_CLIENT_TYPE_X11;
|
|
|
|
stack_window.x11.xwindow = window->xwindow;
|
2009-06-13 20:45:32 +00:00
|
|
|
meta_stack_tracker_record_add (window->screen->stack_tracker,
|
2012-04-05 10:22:13 +00:00
|
|
|
&stack_window,
|
2009-06-13 20:45:32 +00:00
|
|
|
XNextRequest (window->display->xdisplay));
|
2001-05-31 06:42:58 +00:00
|
|
|
XReparentWindow (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
window->screen->xroot,
|
2007-04-12 04:02:57 +00:00
|
|
|
/* Using anything other than meta_window_get_position()
|
|
|
|
* coordinates here means we'll need to ensure a configure
|
|
|
|
* notify event is sent; see bug 399552.
|
|
|
|
*/
|
2011-10-17 21:18:50 +00:00
|
|
|
window->frame->rect.x + borders.invisible.left,
|
|
|
|
window->frame->rect.y + borders.invisible.top);
|
2010-10-25 18:44:30 +00:00
|
|
|
meta_error_trap_pop (window->display);
|
2001-05-31 06:42:58 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
meta_ui_destroy_frame_window (window->screen->ui, frame->xwindow);
|
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
meta_display_unregister_x_window (window->display,
|
|
|
|
frame->xwindow);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
window->frame = NULL;
|
2011-10-03 12:59:16 +00:00
|
|
|
if (window->frame_bounds)
|
|
|
|
{
|
|
|
|
cairo_region_destroy (window->frame_bounds);
|
|
|
|
window->frame_bounds = NULL;
|
|
|
|
}
|
2001-05-31 06:42:58 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
/* Move keybindings to window instead of frame */
|
|
|
|
meta_window_grab_keys (window);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
g_free (frame);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-06-04 06:17:52 +00:00
|
|
|
/* Put our state back where it should be */
|
Refactor thrice-duplicated queue code in window.c. Closes #376760.
2007-06-10 Thomas Thurman <thomas@thurman.org.uk>
Refactor thrice-duplicated queue code in window.c. Closes #376760.
* src/window.c (meta_window_queue, meta_window_unqueue):
New functions.
* src/window.[ch] (meta_window_unqueue_*, meta_window_queue_*):
Removed functions.
* src/window.c (meta_window_new_with_attrs, meta_window_free,
meta_window_flush_calc_showing, queue_calc_showing_func,
meta_window_minimize, meta_window_unminimize, meta_window_maximize,
meta_window_make_fullscreen, meta_window_shade,
meta_window_unshade, meta_window_move_resize_internal,
window_stick_impl, window_unstick_impl,
meta_window_client_message, process_property_notify): Modified to
use new queueing functions.
* src/window.c (idle_move_resize, idle_update_icon,
idle_calc_showing): update to receive queue number from pointer.
* src/window.h (MetaQueueType): new enum.
* src/window.h (MetaWindow): *_queued replaced with is_in_queue
bitfield.
* src/core.c (meta_core_queue_frame_resize):
* src/display.c (event_callback,
meta_display_queue_retheme_all_windows): Using new queueing functions.
* src/frame.c (meta_window_destroy_frame): Using new queueing functions.
* src/screen.c (queue_resize, meta_screen_resize_func,
queue_windows_showing): Using new queueing functions.
* src/window-props.c (reload_mwm_hints, reload_wm_hints,
reload_transient_for): Using new queueing functions.
* src/workspace.c (meta_workspace_add_window,
meta_workspace_remove_window, meta_workspace_queue_calc_showing,
meta_workspace_invalidate_work_area): Using new queueing functions.
svn path=/trunk/; revision=3236
2007-06-11 01:15:33 +00:00
|
|
|
meta_window_queue (window, META_QUEUE_CALC_SHOWING);
|
2009-02-05 01:06:15 +00:00
|
|
|
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
|
2001-05-31 06:42:58 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
|
|
|
|
MetaFrameFlags
|
|
|
|
meta_frame_get_flags (MetaFrame *frame)
|
|
|
|
{
|
|
|
|
MetaFrameFlags flags;
|
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
flags = 0;
|
2001-06-23 18:30:27 +00:00
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
if (frame->window->border_only)
|
|
|
|
{
|
|
|
|
; /* FIXME this may disable the _function_ as well as decor
|
|
|
|
* in some cases, which is sort of wrong.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= META_FRAME_ALLOWS_MENU;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
if (frame->window->has_close_func)
|
|
|
|
flags |= META_FRAME_ALLOWS_DELETE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
if (frame->window->has_maximize_func)
|
|
|
|
flags |= META_FRAME_ALLOWS_MAXIMIZE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
if (frame->window->has_minimize_func)
|
|
|
|
flags |= META_FRAME_ALLOWS_MINIMIZE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-06-22 03:23:02 +00:00
|
|
|
if (frame->window->has_shade_func)
|
|
|
|
flags |= META_FRAME_ALLOWS_SHADE;
|
2014-05-02 13:34:02 +00:00
|
|
|
}
|
|
|
|
|
2002-07-03 02:32:40 +00:00
|
|
|
if (META_WINDOW_ALLOWS_MOVE (frame->window))
|
2001-06-23 18:30:27 +00:00
|
|
|
flags |= META_FRAME_ALLOWS_MOVE;
|
2001-07-03 01:45:43 +00:00
|
|
|
|
2002-07-03 02:32:40 +00:00
|
|
|
if (META_WINDOW_ALLOWS_HORIZONTAL_RESIZE (frame->window))
|
|
|
|
flags |= META_FRAME_ALLOWS_HORIZONTAL_RESIZE;
|
|
|
|
|
|
|
|
if (META_WINDOW_ALLOWS_VERTICAL_RESIZE (frame->window))
|
|
|
|
flags |= META_FRAME_ALLOWS_VERTICAL_RESIZE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2010-09-10 09:55:20 +00:00
|
|
|
if (meta_window_appears_focused (frame->window))
|
2001-06-18 03:24:25 +00:00
|
|
|
flags |= META_FRAME_HAS_FOCUS;
|
|
|
|
|
|
|
|
if (frame->window->shaded)
|
|
|
|
flags |= META_FRAME_SHADED;
|
|
|
|
|
2011-02-28 10:41:23 +00:00
|
|
|
if (frame->window->on_all_workspaces_requested)
|
2001-06-18 03:24:25 +00:00
|
|
|
flags |= META_FRAME_STUCK;
|
2001-06-18 06:11:53 +00:00
|
|
|
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 14:58:50 +00:00
|
|
|
/* FIXME: Should we have some kind of UI for windows that are just vertically
|
|
|
|
* maximized or just horizontally maximized?
|
|
|
|
*/
|
|
|
|
if (META_WINDOW_MAXIMIZED (frame->window))
|
2002-06-08 06:07:21 +00:00
|
|
|
flags |= META_FRAME_MAXIMIZED;
|
|
|
|
|
2010-12-08 01:16:35 +00:00
|
|
|
if (META_WINDOW_TILED_LEFT (frame->window))
|
|
|
|
flags |= META_FRAME_TILED_LEFT;
|
|
|
|
|
|
|
|
if (META_WINDOW_TILED_RIGHT (frame->window))
|
|
|
|
flags |= META_FRAME_TILED_RIGHT;
|
|
|
|
|
2002-06-08 06:07:21 +00:00
|
|
|
if (frame->window->fullscreen)
|
|
|
|
flags |= META_FRAME_FULLSCREEN;
|
2001-06-23 06:54:28 +00:00
|
|
|
|
2003-01-28 15:07:43 +00:00
|
|
|
if (frame->is_flashing)
|
|
|
|
flags |= META_FRAME_IS_FLASHING;
|
|
|
|
|
Added "above" to the list of flags a frame can have, so that we know when
* common.h: Added "above" to the list of flags a frame can have, so
that we know when to mark it as always on top. Added six grab ops,
one to do and one to undo each of the three new titlebar buttons
(shade, above, stick). Added six new button functions, similarly.
(#96229)
* frame.c (meta_frame_get_flags): If a frame has the WM_STATE_ABOVE X
attribute, set META_FRAME_ABOVE in its flags.
* frames.c (meta_frames_apply_shapes): Allow variable amounts of
rounding. (#113162)
* frames.c (show_tip_now, meta_frames_paint_to_drawable, control_rect,
get_control): extend handling of existing buttons to the
3*2 new kinds of button. (#96229)
* frames.c (meta_frames_button_press_event): translate clicks on the 3*2
new kinds of button to the new grab ops. (#96229)
* frames.c (meta_frames_button_release_event): implement the various
actions for the 3*2 new kinds of button. (#96229)
* frames.c (meta_frames_update_prelit_control,
meta_frames_motion_notify_event): extend existing motion
notifications for buttons to the 3*2 new kinds of button. (#96229)
* frames.c (meta_frames_set_window_background): handle specified
background colours and alpha transparency. (#151261)
* frames.h (MetaFrameControl): New control types for the 3*2 new kinds
of button. (#96229)
* iconcache.[ch] (meta_read_icons): use theme's fallback icons if a
window has no icon; use metacity's fallback icons only if the theme
does not provide any. (#11363)
* iconcache.[ch] (meta_invalidate_default_icons (new function)): clear
icon cache on windows using default icons, and update them. (#11363)
* main.c (main): added \n to error message.
* prefs.c (button_function_from_string): extend for 3 new button
types. (#96229)
* prefs.c (button_opposite_function (new function)): return a button
function's inverse (shade -> unshade, etc) (#96229)
* prefs.c (update_button_layout): allocate space for a button's
inverse, if it has one. (#96229)
* theme-parser.c (ParseState): add state for fallback icons (#11363)
* theme-parser.c (ParseInfo): add format_version; remove
menu_icon_* (#114305)
* theme-parser.c (parse_positive_integer): add lookup for integer
constants (#331356)
* theme-parser.c (parse_rounding (new function)): parse window
rounding amount (#113162)
* theme-parser.c (parse_alpha): don't set error if the number can't
be parsed since it'll already be set; change tolerance in comparison
from 1e6 to 1e-6
* theme-parser.c (parse_color (new function)): parse colour, including
possible constant lookup.
* theme-parser.c (parse_toplevel_element): allow defining of various
new kinds of constant; allow
hide_buttons (#121639) and more detailed rounding attributes on
<frame_geometry> (#113162); allow background and alpha attributes on
<frame_style>; (#151261) remove support for <menu_icon> except as
stub; (#114305) add support for loading stock images (#113465); add
support for <fallback>. (#11363))
* theme-parser.c (parse_draw_op_element): add from and to attribute
for arcs. (#121603)
* theme-parser.c (parse_style_element): add check for theme version
supporting a button function. (#96229)
* theme-parser.c (parse_style_set_element): add ability for shaded
windows to be resizable (#114304)
* theme-parser.c (meta_theme_load): add theme versioning routine.
* theme.c ( meta_frame_layout_get_borders): return rectangles for
the new 3*2 kinds of button, except where they're
inapplicable. (#96229)
* theme.c (meta_frame_layout_calc_geometry): don't format buttons on
windows with no buttons (#121639); strip the 3*2 new kinds of button
correctly (#96229); allow variable amounts of rounding (#113162).
* theme.c (meta_frame_style_new): set alpha to 255 by
default. (#151261)
* theme.c (meta_frame_style_unref): free colour spec if
allocated. (#151261)
* theme.c (meta_frame_style_validate): it's only an error not to
include a button if that button is valid in the current
theme. (#96229)
* theme.c (button_rect): return rectangles for the new 3*2 kinds
of button. (#96229)
* theme.c (meta_frame_style_set_unref): free differently resizable
shaded styles. (#114304)
* theme.c (get_style): look up differently resizable styles
for shaded windows. (#114304)
* theme.c (free_menu_ops (removed function), get_menu_icon
(removed function), meta_theme_draw_menu_icon (removed function),
meta_menu_icon_type_from_string (removed function),
meta_menu_icon_type_to_string (removed function),
meta_theme_free, meta_theme_validate): removed menu icon code. (#114305)
* theme.c (meta_theme_load_image): add size_of_theme_icons
parameter. (#113465)
* theme.c (meta_theme_define_color_constant (new function),
meta_theme_lookup_color_constant (new function)): allow
definition of colour constants. (#129747)
* theme.c (meta_button_type_from_string, meta_button_type_to_string):
add the 3*2 new kinds of button. (#96229)
* theme.c (meta_theme_earliest_version_with_button (new function)):
return the theme version each button was introduced in. (#96229)
* theme.h ( MetaFrameLayout): add "hide_buttons" flag (#121639) and
corner radiuses. (#113162)
* theme.h (MetaFrameGeometry): add rectangles for the 3*2 new
buttons. (#96229)
* theme.h (MetaButtonType): the 3*2 new buttons. (#96229)
* theme.h (MetaFrameStyle): add window_background_color and
window_background_alpha so that we can specify background on a
<frame_style>. (#151261)
* theme.h (MetaFrameStyleSet): shaded_styles gets resize
dimension. (#114304)
* theme.h (MetaTheme): added format_version, color_constants
hash, (#129747) fallback_icon and fallback_mini_icon, (#11363)
and removed menu_icons. (#114305)
* theme.h (META_THEME_ALLOWS (new macro)): return whether a theme
supports a given feature. Also, several macros representing
new features in v2.
* ui.c (meta_ui_set_current_theme)): also invalidate default
icons. (#11363)
* window.[ch] (meta_window_update_icon_now)): became
non-static. (#11363)
2006-10-07 16:56:47 +00:00
|
|
|
if (frame->window->wm_state_above)
|
|
|
|
flags |= META_FRAME_ABOVE;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-06-18 06:11:53 +00:00
|
|
|
return flags;
|
2001-06-18 03:24:25 +00:00
|
|
|
}
|
|
|
|
|
2011-07-12 04:59:12 +00:00
|
|
|
void
|
|
|
|
meta_frame_borders_clear (MetaFrameBorders *self)
|
|
|
|
{
|
2011-07-12 04:55:50 +00:00
|
|
|
self->visible.top = self->invisible.top = self->total.top = 0;
|
|
|
|
self->visible.bottom = self->invisible.bottom = self->total.bottom = 0;
|
|
|
|
self->visible.left = self->invisible.left = self->total.left = 0;
|
|
|
|
self->visible.right = self->invisible.right = self->total.right = 0;
|
2011-07-12 04:59:12 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
void
|
2011-07-12 04:37:41 +00:00
|
|
|
meta_frame_calc_borders (MetaFrame *frame,
|
|
|
|
MetaFrameBorders *borders)
|
2001-06-18 03:24:25 +00:00
|
|
|
{
|
2012-03-13 03:11:07 +00:00
|
|
|
/* Save on if statements and potential uninitialized values
|
|
|
|
* in callers -- if there's no frame, then zero the borders. */
|
|
|
|
if (frame == NULL)
|
|
|
|
meta_frame_borders_clear (borders);
|
|
|
|
else
|
2013-11-15 22:37:50 +00:00
|
|
|
{
|
|
|
|
if (!frame->borders_cached)
|
|
|
|
{
|
|
|
|
meta_ui_get_frame_borders (frame->window->screen->ui,
|
|
|
|
frame->xwindow,
|
|
|
|
&frame->cached_borders);
|
|
|
|
frame->borders_cached = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*borders = frame->cached_borders;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frame_clear_cached_borders (MetaFrame *frame)
|
|
|
|
{
|
|
|
|
frame->borders_cached = FALSE;
|
2001-06-18 03:24:25 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 19:36:12 +00:00
|
|
|
gboolean
|
2001-06-10 03:17:15 +00:00
|
|
|
meta_frame_sync_to_window (MetaFrame *frame,
|
2002-01-19 23:59:11 +00:00
|
|
|
int resize_gravity,
|
2001-06-10 03:17:15 +00:00
|
|
|
gboolean need_move,
|
|
|
|
gboolean need_resize)
|
2001-06-03 01:33:27 +00:00
|
|
|
{
|
2002-02-24 19:58:27 +00:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Syncing frame geometry %d,%d %dx%d (SE: %d,%d)\n",
|
|
|
|
frame->rect.x, frame->rect.y,
|
|
|
|
frame->rect.width, frame->rect.height,
|
|
|
|
frame->rect.x + frame->rect.width,
|
|
|
|
frame->rect.y + frame->rect.height);
|
2001-06-10 03:17:15 +00:00
|
|
|
|
|
|
|
/* set bg to none to avoid flicker */
|
2001-06-18 03:24:25 +00:00
|
|
|
if (need_resize)
|
2002-05-31 00:02:54 +00:00
|
|
|
{
|
|
|
|
meta_ui_unflicker_frame_bg (frame->window->screen->ui,
|
|
|
|
frame->xwindow,
|
|
|
|
frame->rect.width,
|
|
|
|
frame->rect.height);
|
|
|
|
}
|
2003-01-05 07:51:02 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
meta_ui_move_resize_frame (frame->window->screen->ui,
|
|
|
|
frame->xwindow,
|
|
|
|
frame->rect.x,
|
|
|
|
frame->rect.y,
|
|
|
|
frame->rect.width,
|
|
|
|
frame->rect.height);
|
2001-06-03 21:39:57 +00:00
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
if (need_resize)
|
2002-05-09 22:34:00 +00:00
|
|
|
{
|
|
|
|
meta_ui_reset_frame_bg (frame->window->screen->ui,
|
|
|
|
frame->xwindow);
|
|
|
|
|
|
|
|
/* If we're interactively resizing the frame, repaint
|
|
|
|
* it immediately so we don't start to lag.
|
|
|
|
*/
|
|
|
|
if (frame->window->display->grab_window ==
|
|
|
|
frame->window)
|
|
|
|
meta_ui_repaint_frame (frame->window->screen->ui,
|
|
|
|
frame->xwindow);
|
|
|
|
}
|
2011-03-22 19:36:12 +00:00
|
|
|
|
|
|
|
return need_resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_region_t *
|
|
|
|
meta_frame_get_frame_bounds (MetaFrame *frame)
|
|
|
|
{
|
|
|
|
return meta_ui_get_frame_bounds (frame->window->screen->ui,
|
|
|
|
frame->xwindow,
|
|
|
|
frame->rect.width,
|
|
|
|
frame->rect.height);
|
2001-06-03 21:39:57 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 17:00:15 +00:00
|
|
|
void
|
|
|
|
meta_frame_get_mask (MetaFrame *frame,
|
|
|
|
cairo_t *cr)
|
|
|
|
{
|
|
|
|
meta_ui_get_frame_mask (frame->window->screen->ui, frame->xwindow,
|
|
|
|
frame->rect.width, frame->rect.height, cr);
|
|
|
|
}
|
|
|
|
|
2001-06-03 01:33:27 +00:00
|
|
|
void
|
|
|
|
meta_frame_queue_draw (MetaFrame *frame)
|
|
|
|
{
|
2001-06-18 03:24:25 +00:00
|
|
|
meta_ui_queue_frame_draw (frame->window->screen->ui,
|
|
|
|
frame->xwindow);
|
2001-06-09 06:08:44 +00:00
|
|
|
}
|
2002-08-23 18:00:40 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
void
|
|
|
|
meta_frame_set_screen_cursor (MetaFrame *frame,
|
|
|
|
MetaCursor cursor)
|
2002-08-23 18:00:40 +00:00
|
|
|
{
|
|
|
|
Cursor xcursor;
|
|
|
|
if (cursor == frame->current_cursor)
|
|
|
|
return;
|
|
|
|
frame->current_cursor = cursor;
|
|
|
|
if (cursor == META_CURSOR_DEFAULT)
|
|
|
|
XUndefineCursor (frame->window->display->xdisplay, frame->xwindow);
|
|
|
|
else
|
2014-05-02 13:34:02 +00:00
|
|
|
{
|
2002-08-23 18:00:40 +00:00
|
|
|
xcursor = meta_display_create_x_cursor (frame->window->display, cursor);
|
|
|
|
XDefineCursor (frame->window->display->xdisplay, frame->xwindow, xcursor);
|
2004-08-08 12:23:34 +00:00
|
|
|
XFlush (frame->window->display->xdisplay);
|
2002-08-23 18:00:40 +00:00
|
|
|
XFreeCursor (frame->window->display->xdisplay, xcursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-19 00:00:09 +00:00
|
|
|
Window
|
|
|
|
meta_frame_get_xwindow (MetaFrame *frame)
|
|
|
|
{
|
|
|
|
return frame->xwindow;
|
|
|
|
}
|