2014-01-23 16:33:53 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington, Anders Carlsson
|
|
|
|
* Copyright (C) 2002, 2003 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2003 Rob Adams
|
|
|
|
* Copyright (C) 2004-2006 Elijah Newren
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
#include "meta-x11-display-private.h"
|
2014-01-23 16:33:53 -05:00
|
|
|
#include "window-x11.h"
|
2014-03-18 11:20:22 -04:00
|
|
|
#include "window-x11-private.h"
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xlibint.h> /* For display->resource_mask */
|
2016-10-07 11:55:32 -04:00
|
|
|
#include <X11/Xlib-xcb.h>
|
|
|
|
|
|
|
|
#include <xcb/res.h>
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
2014-02-01 19:19:22 -05:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#include "core.h"
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
#include <meta/common.h>
|
|
|
|
#include <meta/errors.h>
|
|
|
|
#include <meta/prefs.h>
|
2014-03-02 17:27:50 -05:00
|
|
|
#include <meta/meta-cursor-tracker.h>
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
#include "frame.h"
|
2014-04-28 17:06:38 -04:00
|
|
|
#include "boxes-private.h"
|
2014-01-23 16:33:53 -05:00
|
|
|
#include "window-private.h"
|
|
|
|
#include "window-props.h"
|
|
|
|
#include "xprops.h"
|
2014-05-01 17:29:55 -04:00
|
|
|
#include "session.h"
|
|
|
|
#include "workspace-private.h"
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2016-12-12 21:37:11 -05:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2014-08-15 10:52:44 -04:00
|
|
|
#include "backends/x11/meta-backend-x11.h"
|
|
|
|
|
2014-03-18 11:20:22 -04:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaWindowX11, meta_window_x11, META_TYPE_WINDOW)
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_x11_init (MetaWindowX11 *window_x11)
|
|
|
|
{
|
|
|
|
window_x11->priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
}
|
|
|
|
|
2014-03-20 16:07:23 -04:00
|
|
|
static void
|
|
|
|
send_icccm_message (MetaWindow *window,
|
|
|
|
Atom atom,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
/* This comment and code are from twm, copyright
|
|
|
|
* Open Group, Evans & Sutherland, etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ICCCM Client Messages - Section 4.2.8 of the ICCCM dictates that all
|
|
|
|
* client messages will have the following form:
|
|
|
|
*
|
|
|
|
* event type ClientMessage
|
|
|
|
* message type _XA_WM_PROTOCOLS
|
|
|
|
* window tmp->w
|
|
|
|
* format 32
|
|
|
|
* data[0] message atom
|
|
|
|
* data[1] time stamp
|
|
|
|
*/
|
|
|
|
|
|
|
|
XClientMessageEvent ev;
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-03-20 16:07:23 -04:00
|
|
|
|
|
|
|
ev.type = ClientMessage;
|
|
|
|
ev.window = window->xwindow;
|
2017-08-26 12:26:30 -04:00
|
|
|
ev.message_type = x11_display->atom_WM_PROTOCOLS;
|
2014-03-20 16:07:23 -04:00
|
|
|
ev.format = 32;
|
|
|
|
ev.data.l[0] = atom;
|
|
|
|
ev.data.l[1] = timestamp;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XSendEvent (x11_display->xdisplay,
|
2014-03-20 16:07:23 -04:00
|
|
|
window->xwindow, False, 0, (XEvent*) &ev);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-20 16:07:23 -04:00
|
|
|
}
|
|
|
|
|
2014-03-19 09:36:15 -04:00
|
|
|
static Window
|
|
|
|
read_client_leader (MetaDisplay *display,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
Window retval = None;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
meta_prop_get_window (display->x11_display, xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
display->x11_display->atom_WM_CLIENT_LEADER,
|
2014-03-19 09:36:15 -04:00
|
|
|
&retval);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Window leader;
|
|
|
|
} ClientLeaderData;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
find_client_leader_func (MetaWindow *ancestor,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
ClientLeaderData *d;
|
|
|
|
|
|
|
|
d = data;
|
|
|
|
|
|
|
|
d->leader = read_client_leader (ancestor->display,
|
|
|
|
ancestor->xwindow);
|
|
|
|
|
|
|
|
/* keep going if no client leader found */
|
|
|
|
return d->leader == None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_sm_hints (MetaWindow *window)
|
|
|
|
{
|
|
|
|
Window leader;
|
|
|
|
|
|
|
|
window->xclient_leader = None;
|
|
|
|
window->sm_client_id = NULL;
|
|
|
|
|
|
|
|
/* If not on the current window, we can get the client
|
|
|
|
* leader from transient parents. If we find a client
|
|
|
|
* leader, we read the SM_CLIENT_ID from it.
|
|
|
|
*/
|
|
|
|
leader = read_client_leader (window->display, window->xwindow);
|
|
|
|
if (leader == None)
|
|
|
|
{
|
|
|
|
ClientLeaderData d;
|
|
|
|
d.leader = None;
|
|
|
|
meta_window_foreach_ancestor (window, find_client_leader_func,
|
|
|
|
&d);
|
|
|
|
leader = d.leader;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (leader != None)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
window->xclient_leader = leader;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (meta_prop_get_latin1_string (window->display->x11_display, leader,
|
2017-08-26 12:26:30 -04:00
|
|
|
window->display->x11_display->atom_SM_CLIENT_ID,
|
2014-03-19 09:36:15 -04:00
|
|
|
&str))
|
|
|
|
{
|
|
|
|
window->sm_client_id = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("Didn't find a client leader for %s\n", window->desc);
|
|
|
|
|
|
|
|
if (!meta_prefs_get_disable_workarounds ())
|
|
|
|
{
|
|
|
|
/* Some broken apps (kdelibs fault?) set SM_CLIENT_ID on the app
|
|
|
|
* instead of the client leader
|
|
|
|
*/
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = NULL;
|
2017-08-26 14:51:28 -04:00
|
|
|
if (meta_prop_get_latin1_string (window->display->x11_display, window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
window->display->x11_display->atom_SM_CLIENT_ID,
|
2014-03-19 09:36:15 -04:00
|
|
|
&str))
|
|
|
|
{
|
|
|
|
if (window->sm_client_id == NULL) /* first time through */
|
|
|
|
meta_warning ("Window %s sets SM_CLIENT_ID on itself, instead of on the WM_CLIENT_LEADER window as specified in the ICCCM.\n",
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
window->sm_client_id = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_verbose ("Window %s client leader: 0x%lx SM_CLIENT_ID: '%s'\n",
|
|
|
|
window->desc, window->xclient_leader,
|
|
|
|
window->sm_client_id ? window->sm_client_id : "none");
|
|
|
|
}
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
static void
|
|
|
|
send_configure_notify (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-05-20 09:19:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-03-19 10:30:12 -04:00
|
|
|
XEvent event;
|
|
|
|
|
2014-06-03 11:28:40 -04:00
|
|
|
g_assert (!window->override_redirect);
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
/* from twm */
|
|
|
|
|
|
|
|
event.type = ConfigureNotify;
|
2017-08-26 12:26:30 -04:00
|
|
|
event.xconfigure.display = x11_display->xdisplay;
|
2014-03-19 10:30:12 -04:00
|
|
|
event.xconfigure.event = window->xwindow;
|
|
|
|
event.xconfigure.window = window->xwindow;
|
2014-09-18 15:05:10 -04:00
|
|
|
event.xconfigure.x = priv->client_rect.x - priv->border_width;
|
|
|
|
event.xconfigure.y = priv->client_rect.y - priv->border_width;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
if (window->withdrawn)
|
|
|
|
{
|
|
|
|
MetaFrameBorders borders;
|
|
|
|
/* We reparent the client window and put it to the position
|
|
|
|
* where the visible top-left of the frame window currently is.
|
|
|
|
*/
|
|
|
|
|
|
|
|
meta_frame_calc_borders (window->frame, &borders);
|
|
|
|
|
|
|
|
event.xconfigure.x = window->frame->rect.x + borders.invisible.left;
|
|
|
|
event.xconfigure.y = window->frame->rect.y + borders.invisible.top;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Need to be in root window coordinates */
|
|
|
|
event.xconfigure.x += window->frame->rect.x;
|
|
|
|
event.xconfigure.y += window->frame->rect.y;
|
|
|
|
}
|
|
|
|
}
|
2014-05-20 17:47:10 -04:00
|
|
|
event.xconfigure.width = priv->client_rect.width;
|
|
|
|
event.xconfigure.height = priv->client_rect.height;
|
2014-05-20 09:19:10 -04:00
|
|
|
event.xconfigure.border_width = priv->border_width; /* requested not actual */
|
2014-03-19 10:30:12 -04:00
|
|
|
event.xconfigure.above = None; /* FIXME */
|
|
|
|
event.xconfigure.override_redirect = False;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Sending synthetic configure notify to %s with x: %d y: %d w: %d h: %d\n",
|
|
|
|
window->desc,
|
|
|
|
event.xconfigure.x, event.xconfigure.y,
|
|
|
|
event.xconfigure.width, event.xconfigure.height);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XSendEvent (x11_display->xdisplay,
|
2014-03-19 10:30:12 -04:00
|
|
|
window->xwindow,
|
|
|
|
False, StructureNotifyMask, &event);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
2014-05-01 17:39:25 -04:00
|
|
|
static void
|
|
|
|
adjust_for_gravity (MetaWindow *window,
|
|
|
|
gboolean coords_assume_border,
|
|
|
|
int gravity,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
2014-05-20 09:19:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-05-01 17:39:25 -04:00
|
|
|
int ref_x, ref_y;
|
|
|
|
int bw;
|
|
|
|
int child_x, child_y;
|
|
|
|
int frame_width, frame_height;
|
|
|
|
MetaFrameBorders borders;
|
|
|
|
|
2014-09-18 15:42:09 -04:00
|
|
|
/* We're computing position to pass to window_move, which is
|
|
|
|
* the position of the client window (StaticGravity basically)
|
|
|
|
*
|
|
|
|
* (see WM spec description of gravity computation, but note that
|
|
|
|
* their formulas assume we're honoring the border width, rather
|
|
|
|
* than compensating for having turned it off)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (gravity == StaticGravity)
|
|
|
|
return;
|
|
|
|
|
2014-05-01 17:39:25 -04:00
|
|
|
if (coords_assume_border)
|
2014-05-20 09:19:10 -04:00
|
|
|
bw = priv->border_width;
|
2014-05-01 17:39:25 -04:00
|
|
|
else
|
|
|
|
bw = 0;
|
|
|
|
|
|
|
|
meta_frame_calc_borders (window->frame, &borders);
|
|
|
|
|
|
|
|
child_x = borders.visible.left;
|
|
|
|
child_y = borders.visible.top;
|
|
|
|
frame_width = child_x + rect->width + borders.visible.right;
|
|
|
|
frame_height = child_y + rect->height + borders.visible.bottom;
|
|
|
|
|
|
|
|
/* Calculate the the reference point, which is the corner of the
|
|
|
|
* outer window specified by the gravity. So, NorthEastGravity
|
|
|
|
* would have the reference point as the top-right corner of the
|
|
|
|
* outer window. */
|
|
|
|
ref_x = rect->x;
|
|
|
|
ref_y = rect->y;
|
|
|
|
|
|
|
|
switch (gravity)
|
|
|
|
{
|
|
|
|
case NorthGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
ref_x += rect->width / 2 + bw;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
ref_x += rect->width + bw * 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (gravity)
|
|
|
|
{
|
|
|
|
case WestGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case EastGravity:
|
|
|
|
ref_y += rect->height / 2 + bw;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
ref_y += rect->height + bw * 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the top-left corner of the outer window from
|
|
|
|
* the reference point. */
|
|
|
|
|
|
|
|
rect->x = ref_x;
|
|
|
|
rect->y = ref_y;
|
|
|
|
|
|
|
|
switch (gravity)
|
|
|
|
{
|
|
|
|
case NorthGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
rect->x -= frame_width / 2;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
rect->x -= frame_width;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (gravity)
|
|
|
|
{
|
|
|
|
case WestGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case EastGravity:
|
|
|
|
rect->y -= frame_height / 2;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
rect->y -= frame_height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjust to get the top-left corner of the inner window. */
|
|
|
|
rect->x += child_x;
|
|
|
|
rect->y += child_y;
|
|
|
|
}
|
|
|
|
|
2014-05-01 17:29:55 -04:00
|
|
|
static void
|
|
|
|
meta_window_apply_session_info (MetaWindow *window,
|
|
|
|
const MetaWindowSessionInfo *info)
|
|
|
|
{
|
|
|
|
if (info->stack_position_set)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring stack position %d for window %s\n",
|
|
|
|
info->stack_position, window->desc);
|
|
|
|
|
|
|
|
/* FIXME well, I'm not sure how to do this. */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->minimized_set)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring minimized state %d for window %s\n",
|
|
|
|
info->minimized, window->desc);
|
|
|
|
|
2015-11-16 18:31:55 -05:00
|
|
|
if (info->minimized)
|
2014-05-01 17:29:55 -04:00
|
|
|
meta_window_minimize (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->maximized_set)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring maximized state %d for window %s\n",
|
|
|
|
info->maximized, window->desc);
|
|
|
|
|
|
|
|
if (window->has_maximize_func && info->maximized)
|
|
|
|
{
|
|
|
|
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
|
|
|
|
|
|
|
if (info->saved_rect_set)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring saved rect %d,%d %dx%d for window %s\n",
|
|
|
|
info->saved_rect.x,
|
|
|
|
info->saved_rect.y,
|
|
|
|
info->saved_rect.width,
|
|
|
|
info->saved_rect.height,
|
|
|
|
window->desc);
|
|
|
|
|
2016-01-10 09:16:09 -05:00
|
|
|
window->saved_rect.x = info->saved_rect.x;
|
|
|
|
window->saved_rect.y = info->saved_rect.y;
|
|
|
|
window->saved_rect.width = info->saved_rect.width;
|
|
|
|
window->saved_rect.height = info->saved_rect.height;
|
2014-05-01 17:29:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->on_all_workspaces_set)
|
|
|
|
{
|
|
|
|
window->on_all_workspaces_requested = info->on_all_workspaces;
|
2014-08-16 13:22:05 -04:00
|
|
|
meta_window_on_all_workspaces_changed (window);
|
2014-05-01 17:29:55 -04:00
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring sticky state %d for window %s\n",
|
|
|
|
window->on_all_workspaces_requested, window->desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->workspace_indices)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
GSList *spaces;
|
|
|
|
|
|
|
|
spaces = NULL;
|
|
|
|
|
|
|
|
tmp = info->workspace_indices;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWorkspace *space;
|
|
|
|
|
|
|
|
space =
|
|
|
|
meta_screen_get_workspace_by_index (window->screen,
|
|
|
|
GPOINTER_TO_INT (tmp->data));
|
|
|
|
|
|
|
|
if (space)
|
|
|
|
spaces = g_slist_prepend (spaces, space);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spaces)
|
|
|
|
{
|
2014-08-16 13:22:05 -04:00
|
|
|
/* XXX: What should we do if there's more than one workspace
|
|
|
|
* listed? We only support one workspace for each window.
|
|
|
|
*
|
|
|
|
* For now, just choose the first one.
|
2014-05-01 17:29:55 -04:00
|
|
|
*/
|
2014-08-16 13:22:05 -04:00
|
|
|
MetaWorkspace *workspace = spaces->data;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
2014-08-16 13:22:05 -04:00
|
|
|
meta_window_change_workspace (window, workspace);
|
2018-01-29 10:58:46 -05:00
|
|
|
window->initial_workspace_set = TRUE;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring saved window %s to workspace %d\n",
|
|
|
|
window->desc,
|
2014-08-16 13:22:05 -04:00
|
|
|
meta_workspace_index (workspace));
|
2014-05-01 17:29:55 -04:00
|
|
|
|
|
|
|
g_slist_free (spaces);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->geometry_set)
|
|
|
|
{
|
2014-05-01 17:39:25 -04:00
|
|
|
MetaRectangle rect;
|
2014-05-01 17:29:55 -04:00
|
|
|
MetaMoveResizeFlags flags;
|
2014-05-01 19:10:48 -04:00
|
|
|
int gravity;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
|
|
|
window->placed = TRUE; /* don't do placement algorithms later */
|
|
|
|
|
2014-05-01 17:39:25 -04:00
|
|
|
rect.x = info->rect.x;
|
|
|
|
rect.y = info->rect.y;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
2014-05-01 17:39:25 -04:00
|
|
|
rect.width = window->size_hints.base_width + info->rect.width * window->size_hints.width_inc;
|
|
|
|
rect.height = window->size_hints.base_height + info->rect.height * window->size_hints.height_inc;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
|
|
|
/* Force old gravity, ignoring anything now set */
|
|
|
|
window->size_hints.win_gravity = info->gravity;
|
2014-05-01 19:10:48 -04:00
|
|
|
gravity = window->size_hints.win_gravity;
|
2014-05-01 17:29:55 -04:00
|
|
|
|
2014-12-15 16:28:47 -05:00
|
|
|
flags = META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
2014-05-01 17:39:25 -04:00
|
|
|
|
2014-05-01 19:11:17 -04:00
|
|
|
adjust_for_gravity (window, FALSE, gravity, &rect);
|
2014-05-20 17:47:10 -04:00
|
|
|
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
2014-05-01 19:09:13 -04:00
|
|
|
meta_window_move_resize_internal (window, flags, gravity, rect);
|
2014-05-01 17:29:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 09:36:15 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_manage (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = window->display;
|
2014-07-14 12:01:22 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
|
|
|
meta_icon_cache_init (&priv->icon_cache);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
2017-08-26 12:56:44 -04:00
|
|
|
meta_x11_display_register_x_window (display->x11_display,
|
|
|
|
&window->xwindow,
|
|
|
|
window);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
|
|
|
/* assign the window to its group, or create a new group if needed */
|
|
|
|
window->group = NULL;
|
|
|
|
window->xgroup_leader = None;
|
|
|
|
meta_window_compute_group (window);
|
|
|
|
|
|
|
|
meta_window_load_initial_properties (window);
|
|
|
|
|
|
|
|
if (!window->override_redirect)
|
|
|
|
update_sm_hints (window); /* must come after transient_for */
|
|
|
|
|
2014-05-28 11:45:36 -04:00
|
|
|
if (window->decorated)
|
|
|
|
meta_window_ensure_frame (window);
|
|
|
|
|
2014-05-01 17:29:55 -04:00
|
|
|
/* Now try applying saved stuff from the session */
|
|
|
|
{
|
|
|
|
const MetaWindowSessionInfo *info;
|
|
|
|
|
|
|
|
info = meta_window_lookup_saved_state (window);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
meta_window_apply_session_info (window, info);
|
|
|
|
meta_window_release_saved_state (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 11:21:22 -04:00
|
|
|
/* For override-redirect windows, save the client rect
|
|
|
|
* directly. window->rect was assigned from the XWindowAttributes
|
|
|
|
* in the main meta_window_shared_new.
|
|
|
|
*
|
|
|
|
* For normal windows, do a full ConfigureRequest based on the
|
|
|
|
* window hints, as that's what the ICCCM says to do.
|
2014-05-01 17:29:55 -04:00
|
|
|
*/
|
2015-12-16 12:26:23 -05:00
|
|
|
priv->client_rect = window->rect;
|
|
|
|
window->buffer_rect = window->rect;
|
2014-06-03 11:21:22 -04:00
|
|
|
|
2015-12-16 12:26:23 -05:00
|
|
|
if (!window->override_redirect)
|
2014-05-01 17:39:25 -04:00
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
2014-05-28 11:43:11 -04:00
|
|
|
MetaMoveResizeFlags flags;
|
2014-05-01 19:10:48 -04:00
|
|
|
int gravity = window->size_hints.win_gravity;
|
2014-05-01 17:39:25 -04:00
|
|
|
|
|
|
|
rect.x = window->size_hints.x;
|
|
|
|
rect.y = window->size_hints.y;
|
|
|
|
rect.width = window->size_hints.width;
|
|
|
|
rect.height = window->size_hints.height;
|
|
|
|
|
2014-12-15 16:28:47 -05:00
|
|
|
flags = META_MOVE_RESIZE_CONFIGURE_REQUEST | META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
2014-05-28 11:43:11 -04:00
|
|
|
|
2014-05-01 19:11:17 -04:00
|
|
|
adjust_for_gravity (window, TRUE, gravity, &rect);
|
2014-05-20 17:47:10 -04:00
|
|
|
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
2014-05-01 19:09:13 -04:00
|
|
|
meta_window_move_resize_internal (window, flags, gravity, rect);
|
2014-05-01 17:39:25 -04:00
|
|
|
}
|
2014-10-12 19:12:26 -04:00
|
|
|
|
|
|
|
meta_window_x11_update_shape_region (window);
|
|
|
|
meta_window_x11_update_input_region (window);
|
2014-03-19 09:36:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_x11_unmanage (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-05-20 09:19:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
2014-04-29 16:59:54 -04:00
|
|
|
meta_window_x11_destroy_sync_request_alarm (window);
|
|
|
|
|
2014-03-19 09:36:15 -04:00
|
|
|
if (window->withdrawn)
|
|
|
|
{
|
|
|
|
/* We need to clean off the window's state so it
|
|
|
|
* won't be restored if the app maps it again.
|
|
|
|
*/
|
|
|
|
meta_verbose ("Cleaning state from window %s\n", window->desc);
|
2017-08-26 12:26:30 -04:00
|
|
|
XDeleteProperty (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_DESKTOP);
|
|
|
|
XDeleteProperty (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_STATE);
|
|
|
|
XDeleteProperty (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_FULLSCREEN_MONITORS);
|
2014-03-19 09:36:15 -04:00
|
|
|
meta_window_x11_set_wm_state (window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We need to put WM_STATE so that others will understand it on
|
|
|
|
* restart.
|
|
|
|
*/
|
|
|
|
if (!window->minimized)
|
|
|
|
meta_window_x11_set_wm_state (window);
|
|
|
|
|
|
|
|
/* If we're unmanaging a window that is not withdrawn, then
|
|
|
|
* either (a) mutter is exiting, in which case we need to map
|
|
|
|
* the window so the next WM will know that it's not Withdrawn,
|
|
|
|
* or (b) we want to create a new MetaWindow to replace the
|
|
|
|
* current one, which will happen automatically if we re-map
|
|
|
|
* the X Window.
|
|
|
|
*/
|
2017-08-26 12:26:30 -04:00
|
|
|
XMapWindow (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:56:44 -04:00
|
|
|
meta_x11_display_unregister_x_window (x11_display, window->xwindow);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
|
|
|
/* Put back anything we messed up */
|
2014-05-20 09:19:10 -04:00
|
|
|
if (priv->border_width != 0)
|
2017-08-26 12:26:30 -04:00
|
|
|
XSetWindowBorderWidth (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow,
|
2014-05-20 09:19:10 -04:00
|
|
|
priv->border_width);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
|
|
|
/* No save set */
|
2017-08-26 12:26:30 -04:00
|
|
|
XRemoveFromSaveSet (x11_display->xdisplay,
|
2014-03-19 09:36:15 -04:00
|
|
|
window->xwindow);
|
|
|
|
|
|
|
|
/* Even though the window is now unmanaged, we can't unselect events. This
|
|
|
|
* window might be a window from this process, like a GdkMenu, in
|
|
|
|
* which case it will have pointer events and so forth selected
|
|
|
|
* for it by GDK. There's no way to disentangle those events from the events
|
|
|
|
* we've selected. Even for a window from a different X client,
|
|
|
|
* GDK could also have selected events for it for IPC purposes, so we
|
|
|
|
* can't unselect in that case either.
|
|
|
|
*
|
|
|
|
* Similarly, we can't unselected for events on window->user_time_window.
|
|
|
|
* It might be our own GDK focus window, or it might be a window that a
|
|
|
|
* different client is using for multiple different things:
|
|
|
|
* _NET_WM_USER_TIME_WINDOW and IPC, perhaps.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (window->user_time_window != None)
|
|
|
|
{
|
2017-08-26 12:56:44 -04:00
|
|
|
meta_x11_display_unregister_x_window (x11_display,
|
|
|
|
window->user_time_window);
|
2014-03-19 09:36:15 -04:00
|
|
|
window->user_time_window = None;
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:28:53 -04:00
|
|
|
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
|
2017-08-26 12:26:30 -04:00
|
|
|
XShapeSelectInput (x11_display->xdisplay, window->xwindow, NoEventMask);
|
2014-03-19 09:36:15 -04:00
|
|
|
|
2014-04-24 16:00:28 -04:00
|
|
|
meta_window_ungrab_keys (window);
|
|
|
|
meta_display_ungrab_window_buttons (window->display, window->xwindow);
|
|
|
|
meta_display_ungrab_focus_window_button (window->display, window);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-05-28 11:45:36 -04:00
|
|
|
|
|
|
|
if (window->frame)
|
2014-06-03 11:28:40 -04:00
|
|
|
{
|
|
|
|
/* The XReparentWindow call in meta_window_destroy_frame() moves the
|
|
|
|
* window so we need to send a configure notify; see bug 399552. (We
|
|
|
|
* also do this just in case a window got unmaximized.)
|
|
|
|
*/
|
|
|
|
send_configure_notify (window);
|
|
|
|
|
|
|
|
meta_window_destroy_frame (window);
|
|
|
|
}
|
2014-03-19 09:36:15 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:12:44 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_ping (MetaWindow *window,
|
|
|
|
guint32 serial)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = window->display;
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
send_icccm_message (window, display->x11_display->atom__NET_WM_PING, serial);
|
2014-03-20 15:12:44 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:07:44 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_delete (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2014-03-20 15:07:44 -04:00
|
|
|
if (window->delete_window)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Deleting %s with delete_window request\n",
|
|
|
|
window->desc);
|
2017-08-26 12:26:30 -04:00
|
|
|
send_icccm_message (window, x11_display->atom_WM_DELETE_WINDOW, timestamp);
|
2014-03-20 15:07:44 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Deleting %s with explicit kill\n",
|
|
|
|
window->desc);
|
2017-08-26 12:26:30 -04:00
|
|
|
XKillClient (x11_display->xdisplay, window->xwindow);
|
2014-03-20 15:07:44 -04:00
|
|
|
}
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-20 15:07:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_x11_kill (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
|
|
|
|
2014-03-20 15:07:44 -04:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Disconnecting %s with XKillClient()\n",
|
|
|
|
window->desc);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XKillClient (x11_display->xdisplay, window->xwindow);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-20 15:07:44 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 16:06:24 -04:00
|
|
|
static void
|
|
|
|
request_take_focus (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = window->display;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_FOCUS, "WM_TAKE_FOCUS(%s, %u)\n",
|
|
|
|
window->desc, timestamp);
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
send_icccm_message (window, display->x11_display->atom_WM_TAKE_FOCUS, timestamp);
|
2014-03-20 16:06:24 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:16:57 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_focus (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
/* For output-only or shaded windows, focus the frame.
|
|
|
|
* This seems to result in the client window getting key events
|
|
|
|
* though, so I don't know if it's icccm-compliant.
|
|
|
|
*
|
|
|
|
* Still, we have to do this or keynav breaks for these windows.
|
|
|
|
*/
|
|
|
|
if (window->frame &&
|
|
|
|
(window->shaded ||
|
|
|
|
!(window->input || window->take_focus)))
|
|
|
|
{
|
2015-01-15 08:15:20 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing frame of %s\n", window->desc);
|
2017-08-26 14:51:28 -04:00
|
|
|
meta_x11_display_set_input_focus_window (window->display->x11_display,
|
|
|
|
window,
|
|
|
|
TRUE,
|
|
|
|
timestamp);
|
2014-03-20 15:16:57 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (window->input)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Setting input focus on %s since input = true\n",
|
|
|
|
window->desc);
|
2017-08-26 14:51:28 -04:00
|
|
|
meta_x11_display_set_input_focus_window (window->display->x11_display,
|
|
|
|
window,
|
|
|
|
FALSE,
|
|
|
|
timestamp);
|
2014-03-20 15:16:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (window->take_focus)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Sending WM_TAKE_FOCUS to %s since take_focus = true\n",
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
if (!window->input)
|
|
|
|
{
|
|
|
|
/* The "Globally Active Input" window case, where the window
|
|
|
|
* doesn't want us to call XSetInputFocus on it, but does
|
|
|
|
* want us to send a WM_TAKE_FOCUS.
|
|
|
|
*
|
|
|
|
* Normally, we want to just leave the focus undisturbed until
|
2015-01-15 08:22:59 -05:00
|
|
|
* the window responds to WM_TAKE_FOCUS, but if we're unmanaging
|
2014-03-20 15:16:57 -04:00
|
|
|
* the current focus window we *need* to move the focus away, so
|
|
|
|
* we focus the no_focus_window now (and set
|
|
|
|
* display->focus_window to that) before sending WM_TAKE_FOCUS.
|
|
|
|
*/
|
|
|
|
if (window->display->focus_window != NULL &&
|
|
|
|
window->display->focus_window->unmanaging)
|
2017-08-26 14:51:28 -04:00
|
|
|
meta_x11_display_focus_the_no_focus_window (window->display->x11_display,
|
|
|
|
timestamp);
|
2014-03-20 15:16:57 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 16:06:24 -04:00
|
|
|
request_take_focus (window, timestamp);
|
2014-03-20 15:16:57 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-20 17:47:10 -04:00
|
|
|
static void
|
|
|
|
meta_window_get_client_root_coords (MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
|
|
|
*rect = priv->client_rect;
|
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
rect->x += window->frame->rect.x;
|
|
|
|
rect->y += window->frame->rect.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:55:55 -04:00
|
|
|
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);
|
|
|
|
|
2014-12-29 20:20:07 -05:00
|
|
|
if (priv->showing_resize_popup)
|
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
|
|
|
int display_w, display_h;
|
|
|
|
|
|
|
|
meta_window_get_client_root_coords (window, &rect);
|
|
|
|
|
|
|
|
display_w = (rect.width - window->size_hints.base_width);
|
|
|
|
if (window->size_hints.width_inc > 0)
|
|
|
|
display_w /= window->size_hints.width_inc;
|
2014-04-29 15:55:55 -04:00
|
|
|
|
2014-12-29 20:20:07 -05:00
|
|
|
display_h = (rect.height - window->size_hints.base_height);
|
|
|
|
if (window->size_hints.height_inc > 0)
|
|
|
|
display_h /= window->size_hints.height_inc;
|
2014-04-29 15:55:55 -04:00
|
|
|
|
2014-12-29 20:20:07 -05:00
|
|
|
meta_display_show_resize_popup (window->display, TRUE, &rect, display_w, display_h);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_display_show_resize_popup (window->display, FALSE, NULL, 0, 0);
|
|
|
|
}
|
2014-04-29 15:55:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2014-04-29 16:59:54 -04:00
|
|
|
meta_window_x11_create_sync_request_alarm (window);
|
2014-04-29 15:55:55 -04:00
|
|
|
|
2015-03-18 17:51:05 -04:00
|
|
|
if (window->size_hints.width_inc > 2 || window->size_hints.height_inc > 2)
|
2014-04-29 15:55:55 -04:00
|
|
|
{
|
2014-12-29 20:20:07 -05:00
|
|
|
priv->showing_resize_popup = TRUE;
|
2014-04-29 15:55:55 -04:00
|
|
|
meta_window_refresh_resize_popup (window);
|
|
|
|
}
|
|
|
|
}
|
2014-05-20 15:52:38 -04:00
|
|
|
|
|
|
|
META_WINDOW_CLASS (meta_window_x11_parent_class)->grab_op_began (window, op);
|
2014-04-29 15:55:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-12-29 20:20:07 -05:00
|
|
|
if (priv->showing_resize_popup)
|
2014-04-29 15:55:55 -04:00
|
|
|
{
|
2014-12-29 20:20:07 -05:00
|
|
|
priv->showing_resize_popup = FALSE;
|
|
|
|
meta_window_refresh_resize_popup (window);
|
2014-04-29 15:55:55 -04:00
|
|
|
}
|
2014-05-20 15:52:38 -04:00
|
|
|
|
|
|
|
META_WINDOW_CLASS (meta_window_x11_parent_class)->grab_op_ended (window, op);
|
2014-04-29 15:55:55 -04:00
|
|
|
}
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
static void
|
|
|
|
update_net_frame_extents (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
unsigned long data[4];
|
|
|
|
MetaFrameBorders borders;
|
|
|
|
|
|
|
|
meta_frame_calc_borders (window->frame, &borders);
|
|
|
|
/* Left */
|
|
|
|
data[0] = borders.visible.left;
|
|
|
|
/* Right */
|
|
|
|
data[1] = borders.visible.right;
|
|
|
|
/* Top */
|
|
|
|
data[2] = borders.visible.top;
|
|
|
|
/* Bottom */
|
|
|
|
data[3] = borders.visible.bottom;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Setting _NET_FRAME_EXTENTS on managed window 0x%lx "
|
|
|
|
"to left = %lu, right = %lu, top = %lu, bottom = %lu\n",
|
|
|
|
window->xwindow, data[0], data[1], data[2], data[3]);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay, window->xwindow,
|
|
|
|
x11_display->atom__NET_FRAME_EXTENTS,
|
2014-03-19 10:30:12 -04:00
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 4);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
2017-08-18 19:21:37 -04:00
|
|
|
static void
|
|
|
|
update_gtk_edge_constraints (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2017-08-18 19:21:37 -04:00
|
|
|
MetaEdgeConstraint *constraints = window->edge_constraints;
|
|
|
|
unsigned long data[1];
|
|
|
|
|
|
|
|
/* Edge constraints */
|
|
|
|
data[0] = (constraints[0] != META_EDGE_CONSTRAINT_NONE ? 1 : 0) << 0 |
|
|
|
|
(constraints[0] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 1 |
|
|
|
|
(constraints[1] != META_EDGE_CONSTRAINT_NONE ? 1 : 0) << 2 |
|
|
|
|
(constraints[1] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 3 |
|
|
|
|
(constraints[2] != META_EDGE_CONSTRAINT_NONE ? 1 : 0) << 4 |
|
|
|
|
(constraints[2] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 5 |
|
|
|
|
(constraints[3] != META_EDGE_CONSTRAINT_NONE ? 1 : 0) << 6 |
|
|
|
|
(constraints[3] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 7;
|
|
|
|
|
|
|
|
meta_verbose ("Setting _GTK_EDGE_CONSTRAINTS to %lu\n", data[0]);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
2017-08-18 19:21:37 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__GTK_EDGE_CONSTRAINTS,
|
2017-08-18 19:21:37 -04:00
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(guchar*) data, 1);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2017-08-18 19:21:37 -04:00
|
|
|
}
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
static gboolean
|
|
|
|
sync_request_timeout (gpointer data)
|
|
|
|
{
|
|
|
|
MetaWindow *window = data;
|
|
|
|
|
|
|
|
window->sync_request_timeout_id = 0;
|
|
|
|
|
|
|
|
/* We have now waited for more than a second for the
|
|
|
|
* application to respond to the sync request
|
|
|
|
*/
|
|
|
|
window->disable_sync = TRUE;
|
|
|
|
|
|
|
|
/* Reset the wait serial, so we don't continue freezing
|
|
|
|
* window updates
|
|
|
|
*/
|
|
|
|
window->sync_request_wait_serial = 0;
|
2014-06-17 13:06:10 -04:00
|
|
|
meta_compositor_sync_updates_frozen (window->display->compositor, window);
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
if (window == window->display->grab_window &&
|
|
|
|
meta_grab_op_is_resizing (window->display->grab_op))
|
|
|
|
{
|
|
|
|
meta_window_update_resize (window,
|
|
|
|
window->display->grab_last_user_action_was_snap,
|
|
|
|
window->display->grab_latest_motion_x,
|
|
|
|
window->display->grab_latest_motion_y,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_sync_request (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-03-19 10:30:12 -04:00
|
|
|
XClientMessageEvent ev;
|
|
|
|
gint64 wait_serial;
|
|
|
|
|
|
|
|
/* For the old style of _NET_WM_SYNC_REQUEST_COUNTER, we just have to
|
|
|
|
* increase the value, but for the new "extended" style we need to
|
|
|
|
* pick an even (unfrozen) value sufficiently ahead of the last serial
|
|
|
|
* that we received from the client; the same code still works
|
|
|
|
* for the old style. The increment of 240 is specified by the EWMH
|
|
|
|
* and is (1 second) * (60fps) * (an increment of 4 per frame).
|
|
|
|
*/
|
|
|
|
wait_serial = window->sync_request_serial + 240;
|
|
|
|
|
|
|
|
window->sync_request_wait_serial = wait_serial;
|
|
|
|
|
|
|
|
ev.type = ClientMessage;
|
|
|
|
ev.window = window->xwindow;
|
2017-08-26 12:26:30 -04:00
|
|
|
ev.message_type = x11_display->atom_WM_PROTOCOLS;
|
2014-03-19 10:30:12 -04:00
|
|
|
ev.format = 32;
|
2017-08-26 12:26:30 -04:00
|
|
|
ev.data.l[0] = x11_display->atom__NET_WM_SYNC_REQUEST;
|
2014-03-19 10:30:12 -04:00
|
|
|
/* FIXME: meta_display_get_current_time() is bad, but since calls
|
|
|
|
* come from meta_window_move_resize_internal (which in turn come
|
|
|
|
* from all over), I'm not sure what we can do to fix it. Do we
|
|
|
|
* want to use _roundtrip, though?
|
|
|
|
*/
|
|
|
|
ev.data.l[1] = meta_display_get_current_time (window->display);
|
|
|
|
ev.data.l[2] = wait_serial & G_GUINT64_CONSTANT(0xffffffff);
|
|
|
|
ev.data.l[3] = wait_serial >> 32;
|
|
|
|
ev.data.l[4] = window->extended_sync_request_counter ? 1 : 0;
|
|
|
|
|
|
|
|
/* We don't need to trap errors here as we are already
|
|
|
|
* inside an error_trap_push()/pop() pair.
|
|
|
|
*/
|
2017-08-26 12:26:30 -04:00
|
|
|
XSendEvent (x11_display->xdisplay,
|
2014-03-19 10:30:12 -04:00
|
|
|
window->xwindow, False, 0, (XEvent*) &ev);
|
|
|
|
|
2015-03-12 13:41:57 -04:00
|
|
|
/* We give the window 1 sec to respond to _NET_WM_SYNC_REQUEST;
|
|
|
|
* if this time expires, we consider the window unresponsive
|
|
|
|
* and resize it unsynchonized.
|
|
|
|
*/
|
|
|
|
window->sync_request_timeout_id = g_timeout_add (1000,
|
|
|
|
sync_request_timeout,
|
|
|
|
window);
|
|
|
|
g_source_set_name_by_id (window->sync_request_timeout_id,
|
|
|
|
"[mutter] sync_request_timeout");
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-06-17 13:06:10 -04:00
|
|
|
meta_compositor_sync_updates_frozen (window->display->compositor, window);
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
2014-05-20 15:46:21 -04:00
|
|
|
static unsigned long
|
|
|
|
meta_window_get_net_wm_desktop (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
return 0xFFFFFFFF;
|
|
|
|
else
|
|
|
|
return meta_workspace_index (window->workspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_x11_current_workspace_changed (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-05-20 15:46:21 -04:00
|
|
|
/* FIXME if on more than one workspace, we claim to be "sticky",
|
|
|
|
* the WM spec doesn't say what to do here.
|
|
|
|
*/
|
|
|
|
unsigned long data[1];
|
|
|
|
|
|
|
|
if (window->workspace == NULL)
|
|
|
|
{
|
|
|
|
/* this happens when unmanaging windows */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
data[0] = meta_window_get_net_wm_desktop (window);
|
|
|
|
|
|
|
|
meta_verbose ("Setting _NET_WM_DESKTOP of %s to %lu\n",
|
|
|
|
window->desc, data[0]);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay, window->xwindow,
|
|
|
|
x11_display->atom__NET_WM_DESKTOP,
|
2014-05-20 15:46:21 -04:00
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 1);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-05-20 15:46:21 -04:00
|
|
|
}
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_move_resize_internal (MetaWindow *window,
|
|
|
|
int gravity,
|
2014-05-21 13:59:13 -04:00
|
|
|
MetaRectangle unconstrained_rect,
|
2014-03-19 10:30:12 -04:00
|
|
|
MetaRectangle constrained_rect,
|
|
|
|
MetaMoveResizeFlags flags,
|
|
|
|
MetaMoveResizeResultFlags *result)
|
|
|
|
{
|
2014-04-29 15:55:55 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-05-21 13:03:39 -04:00
|
|
|
MetaFrameBorders borders;
|
2014-05-20 17:47:10 -04:00
|
|
|
MetaRectangle client_rect;
|
2014-03-19 10:30:12 -04:00
|
|
|
int size_dx, size_dy;
|
|
|
|
XWindowChanges values;
|
|
|
|
unsigned int mask;
|
|
|
|
gboolean need_configure_notify;
|
|
|
|
gboolean need_move_client = FALSE;
|
|
|
|
gboolean need_move_frame = FALSE;
|
|
|
|
gboolean need_resize_client = FALSE;
|
|
|
|
gboolean need_resize_frame = FALSE;
|
|
|
|
gboolean frame_shape_changed = FALSE;
|
|
|
|
gboolean configure_frame_first;
|
|
|
|
|
|
|
|
gboolean is_configure_request;
|
|
|
|
|
2014-12-15 16:28:47 -05:00
|
|
|
is_configure_request = (flags & META_MOVE_RESIZE_CONFIGURE_REQUEST) != 0;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
meta_frame_calc_borders (window->frame, &borders);
|
|
|
|
|
2014-05-20 17:47:10 -04:00
|
|
|
size_dx = constrained_rect.x - window->rect.width;
|
|
|
|
size_dy = constrained_rect.y - window->rect.height;
|
2014-05-21 13:00:25 -04:00
|
|
|
|
2014-05-20 17:47:10 -04:00
|
|
|
window->rect = constrained_rect;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
int new_w, new_h;
|
2014-05-20 17:47:10 -04:00
|
|
|
int new_x, new_y;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-05-20 17:47:10 -04:00
|
|
|
/* Compute new frame size */
|
|
|
|
new_w = window->rect.width + borders.invisible.left + borders.invisible.right;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2015-03-13 08:52:05 -04:00
|
|
|
if (window->shaded)
|
|
|
|
new_h = borders.total.top + borders.total.bottom;
|
|
|
|
else
|
|
|
|
new_h = window->rect.height + borders.invisible.top + borders.invisible.bottom;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-05-21 12:24:03 -04:00
|
|
|
if (new_w != window->frame->rect.width ||
|
|
|
|
new_h != window->frame->rect.height)
|
|
|
|
{
|
|
|
|
need_resize_frame = TRUE;
|
|
|
|
window->frame->rect.width = new_w;
|
|
|
|
window->frame->rect.height = new_h;
|
|
|
|
}
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
/* Compute new frame coords */
|
2014-05-20 17:47:10 -04:00
|
|
|
new_x = window->rect.x - borders.invisible.left;
|
|
|
|
new_y = window->rect.y - borders.invisible.top;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-05-21 12:24:03 -04:00
|
|
|
if (new_x != window->frame->rect.x ||
|
|
|
|
new_y != window->frame->rect.y)
|
|
|
|
{
|
|
|
|
need_move_frame = TRUE;
|
|
|
|
window->frame->rect.x = new_x;
|
|
|
|
window->frame->rect.y = new_y;
|
|
|
|
}
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
2014-05-20 17:47:10 -04:00
|
|
|
|
|
|
|
/* Calculate the new client rect */
|
|
|
|
meta_window_frame_rect_to_client_rect (window, &constrained_rect, &client_rect);
|
|
|
|
|
|
|
|
/* The above client_rect is in root window coordinates. The
|
|
|
|
* values we need to pass to XConfigureWindow are in parent
|
|
|
|
* coordinates, so if the window is in a frame, we need to
|
|
|
|
* correct the x/y positions here. */
|
|
|
|
if (window->frame)
|
2014-03-19 10:30:12 -04:00
|
|
|
{
|
2014-05-20 17:47:10 -04:00
|
|
|
client_rect.x = borders.total.left;
|
|
|
|
client_rect.y = borders.total.top;
|
2014-05-21 12:52:44 -04:00
|
|
|
}
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-05-20 17:47:10 -04:00
|
|
|
if (client_rect.x != priv->client_rect.x ||
|
|
|
|
client_rect.y != priv->client_rect.y)
|
2014-05-21 12:52:44 -04:00
|
|
|
{
|
|
|
|
need_move_client = TRUE;
|
2014-05-20 17:47:10 -04:00
|
|
|
priv->client_rect.x = client_rect.x;
|
|
|
|
priv->client_rect.y = client_rect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client_rect.width != priv->client_rect.width ||
|
|
|
|
client_rect.height != priv->client_rect.height)
|
|
|
|
{
|
|
|
|
need_resize_client = TRUE;
|
|
|
|
priv->client_rect.width = client_rect.width;
|
|
|
|
priv->client_rect.height = client_rect.height;
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If frame extents have changed, fill in other frame fields and
|
|
|
|
change frame's extents property. */
|
|
|
|
if (window->frame &&
|
|
|
|
(window->frame->child_x != borders.total.left ||
|
|
|
|
window->frame->child_y != borders.total.top ||
|
|
|
|
window->frame->right_width != borders.total.right ||
|
|
|
|
window->frame->bottom_height != borders.total.bottom))
|
|
|
|
{
|
|
|
|
window->frame->child_x = borders.total.left;
|
|
|
|
window->frame->child_y = borders.total.top;
|
|
|
|
window->frame->right_width = borders.total.right;
|
|
|
|
window->frame->bottom_height = borders.total.bottom;
|
|
|
|
|
|
|
|
update_net_frame_extents (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See ICCCM 4.1.5 for when to send ConfigureNotify */
|
|
|
|
|
|
|
|
need_configure_notify = FALSE;
|
|
|
|
|
|
|
|
/* If this is a configure request and we change nothing, then we
|
|
|
|
* must send configure notify.
|
|
|
|
*/
|
|
|
|
if (is_configure_request &&
|
|
|
|
!(need_move_client || need_move_frame ||
|
|
|
|
need_resize_client || need_resize_frame ||
|
2014-05-20 09:19:10 -04:00
|
|
|
priv->border_width != 0))
|
2014-03-19 10:30:12 -04:00
|
|
|
need_configure_notify = TRUE;
|
|
|
|
|
|
|
|
/* We must send configure notify if we move but don't resize, since
|
|
|
|
* the client window may not get a real event
|
|
|
|
*/
|
|
|
|
if ((need_move_client || need_move_frame) &&
|
|
|
|
!(need_resize_client || need_resize_frame))
|
|
|
|
need_configure_notify = TRUE;
|
|
|
|
|
|
|
|
/* MapRequest events with a PPosition or UPosition hint with a frame
|
|
|
|
* are moved by mutter without resizing; send a configure notify
|
|
|
|
* in such cases. See #322840. (Note that window->constructing is
|
|
|
|
* only true iff this call is due to a MapRequest, and when
|
|
|
|
* PPosition/UPosition hints aren't set, mutter seems to send a
|
|
|
|
* ConfigureNotify anyway due to the above code.)
|
|
|
|
*/
|
|
|
|
if (window->constructing && window->frame &&
|
|
|
|
((window->size_hints.flags & PPosition) ||
|
|
|
|
(window->size_hints.flags & USPosition)))
|
|
|
|
need_configure_notify = TRUE;
|
|
|
|
|
|
|
|
/* The rest of this function syncs our new size/pos with X as
|
|
|
|
* efficiently as possible
|
|
|
|
*/
|
|
|
|
|
2014-05-21 13:43:12 -04:00
|
|
|
/* For nice effect, when growing the window we want to move/resize
|
|
|
|
* the frame first, when shrinking the window we want to move/resize
|
|
|
|
* the client first. If we grow one way and shrink the other,
|
|
|
|
* see which way we're moving "more"
|
|
|
|
*
|
|
|
|
* Mail from Owen subject "Suggestion: Gravity and resizing from the left"
|
|
|
|
* http://mail.gnome.org/archives/wm-spec-list/1999-November/msg00088.html
|
|
|
|
*
|
|
|
|
* An annoying fact you need to know in this code is that StaticGravity
|
|
|
|
* does nothing if you _only_ resize or _only_ move the frame;
|
|
|
|
* it must move _and_ resize, otherwise you get NorthWestGravity
|
|
|
|
* behavior. The move and resize must actually occur, it is not
|
|
|
|
* enough to set CWX | CWWidth but pass in the current size/pos.
|
|
|
|
*/
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
/* Normally, we configure the frame first depending on whether
|
|
|
|
* we grow the frame more than we shrink. The idea is to avoid
|
|
|
|
* messing up the window contents by having a temporary situation
|
|
|
|
* where the frame is smaller than the window. However, if we're
|
|
|
|
* cooperating with the client to create an atomic frame upate,
|
|
|
|
* and the window is redirected, then we should always update
|
|
|
|
* the frame first, since updating the frame will force a new
|
|
|
|
* backing pixmap to be allocated, and the old backing pixmap
|
|
|
|
* will be left undisturbed for us to paint to the screen until
|
|
|
|
* the client finishes redrawing.
|
|
|
|
*/
|
|
|
|
if (window->extended_sync_request_counter)
|
2014-05-21 13:00:25 -04:00
|
|
|
configure_frame_first = TRUE;
|
2014-03-19 10:30:12 -04:00
|
|
|
else
|
2014-05-21 13:00:25 -04:00
|
|
|
configure_frame_first = size_dx + size_dy >= 0;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
if (configure_frame_first && window->frame)
|
2015-01-01 00:27:53 -05:00
|
|
|
frame_shape_changed = meta_frame_sync_to_window (window->frame, need_resize_frame);
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
values.border_width = 0;
|
2014-05-20 17:47:10 -04:00
|
|
|
values.x = client_rect.x;
|
|
|
|
values.y = client_rect.y;
|
|
|
|
values.width = client_rect.width;
|
|
|
|
values.height = client_rect.height;
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
mask = 0;
|
2014-05-20 09:19:10 -04:00
|
|
|
if (is_configure_request && priv->border_width != 0)
|
2014-03-19 10:30:12 -04:00
|
|
|
mask |= CWBorderWidth; /* must force to 0 */
|
|
|
|
if (need_move_client)
|
|
|
|
mask |= (CWX | CWY);
|
|
|
|
if (need_resize_client)
|
|
|
|
mask |= (CWWidth | CWHeight);
|
|
|
|
|
|
|
|
if (mask != 0)
|
|
|
|
{
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (window->display->x11_display);
|
2014-03-19 10:30:12 -04:00
|
|
|
|
|
|
|
if (window == window->display->grab_window &&
|
|
|
|
meta_grab_op_is_resizing (window->display->grab_op) &&
|
|
|
|
!window->disable_sync &&
|
|
|
|
window->sync_request_counter != None &&
|
|
|
|
window->sync_request_alarm != None &&
|
|
|
|
window->sync_request_timeout_id == 0)
|
|
|
|
{
|
|
|
|
send_sync_request (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
XConfigureWindow (window->display->x11_display->xdisplay,
|
2014-03-19 10:30:12 -04:00
|
|
|
window->xwindow,
|
|
|
|
mask,
|
|
|
|
&values);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (window->display->x11_display);
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!configure_frame_first && window->frame)
|
2015-01-01 00:27:53 -05:00
|
|
|
frame_shape_changed = meta_frame_sync_to_window (window->frame, need_resize_frame);
|
2014-03-19 10:30:12 -04:00
|
|
|
|
2014-06-17 11:03:29 -04:00
|
|
|
if (window->frame)
|
|
|
|
window->buffer_rect = window->frame->rect;
|
|
|
|
else
|
|
|
|
window->buffer_rect = client_rect;
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
if (need_configure_notify)
|
|
|
|
send_configure_notify (window);
|
|
|
|
|
2014-12-29 20:20:07 -05:00
|
|
|
if (priv->showing_resize_popup)
|
2014-04-29 15:55:55 -04:00
|
|
|
meta_window_refresh_resize_popup (window);
|
|
|
|
|
2014-03-19 10:30:12 -04:00
|
|
|
if (frame_shape_changed)
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_FRAME_SHAPE_CHANGED;
|
|
|
|
if (need_move_client || need_move_frame)
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_MOVED;
|
|
|
|
if (need_resize_client || need_resize_frame)
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_RESIZED;
|
window: Let implementations finish state changes
In the old, synchronous X.org world, we could assume that
a state change always meant a synchronizing the window
geometry right after. After firing an operation that
would change the window state, such as maximizing or
tiling the window,
With Wayland, however, this is not valid anymore, since
Wayland is asynchronous. In this scenario, we call
meta_window_move_resize_internal() twice: when the user
executes an state-changing operation, and when the server
ACKs this operation. This breaks the previous assumptions,
and as a consequence, it breaks the GNOME Shell animations
in Wayland.
The solution is giving the MetaWindow control over the time
when the window geometry is synchronized with the compositor.
That is done by introducing a new result flag. Wayland asks
for a compositor sync after receiving an ACK from the server,
while X11 asks for it right away.
Fixes #78
2018-04-17 22:42:33 -04:00
|
|
|
if (flags & META_MOVE_RESIZE_STATE_CHANGED)
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_STATE_CHANGED;
|
2017-08-18 19:21:37 -04:00
|
|
|
|
|
|
|
update_gtk_edge_constraints (window);
|
2014-03-19 10:30:12 -04:00
|
|
|
}
|
|
|
|
|
2014-04-28 17:06:38 -04:00
|
|
|
static gboolean
|
|
|
|
meta_window_x11_update_struts (MetaWindow *window)
|
|
|
|
{
|
|
|
|
GSList *old_struts;
|
|
|
|
GSList *new_struts;
|
|
|
|
GSList *old_iter, *new_iter;
|
2015-06-23 18:09:07 -04:00
|
|
|
uint32_t *struts = NULL;
|
2014-04-28 17:06:38 -04:00
|
|
|
int nitems;
|
|
|
|
gboolean changed;
|
|
|
|
|
|
|
|
g_return_val_if_fail (!window->override_redirect, FALSE);
|
|
|
|
|
|
|
|
meta_verbose ("Updating struts for %s\n", window->desc);
|
|
|
|
|
|
|
|
old_struts = window->struts;
|
|
|
|
new_struts = NULL;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (meta_prop_get_cardinal_list (window->display->x11_display,
|
2014-04-28 17:06:38 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
window->display->x11_display->atom__NET_WM_STRUT_PARTIAL,
|
2014-04-28 17:06:38 -04:00
|
|
|
&struts, &nitems))
|
|
|
|
{
|
|
|
|
if (nitems != 12)
|
|
|
|
meta_verbose ("_NET_WM_STRUT_PARTIAL on %s has %d values instead "
|
|
|
|
"of 12\n",
|
|
|
|
window->desc, nitems);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Pull out the strut info for each side in the hint */
|
|
|
|
int i;
|
|
|
|
for (i=0; i<4; i++)
|
|
|
|
{
|
|
|
|
MetaStrut *temp;
|
|
|
|
int thickness, strut_begin, strut_end;
|
|
|
|
|
|
|
|
thickness = struts[i];
|
|
|
|
if (thickness == 0)
|
|
|
|
continue;
|
|
|
|
strut_begin = struts[4+(i*2)];
|
|
|
|
strut_end = struts[4+(i*2)+1];
|
|
|
|
|
|
|
|
temp = g_new (MetaStrut, 1);
|
|
|
|
temp->side = 1 << i; /* See MetaSide def. Matches nicely, eh? */
|
2017-08-26 12:37:29 -04:00
|
|
|
temp->rect = window->display->rect;
|
2014-04-28 17:06:38 -04:00
|
|
|
switch (temp->side)
|
|
|
|
{
|
|
|
|
case META_SIDE_RIGHT:
|
|
|
|
temp->rect.x = BOX_RIGHT(temp->rect) - thickness;
|
|
|
|
/* Intentionally fall through without breaking */
|
|
|
|
case META_SIDE_LEFT:
|
|
|
|
temp->rect.width = thickness;
|
|
|
|
temp->rect.y = strut_begin;
|
|
|
|
temp->rect.height = strut_end - strut_begin + 1;
|
|
|
|
break;
|
|
|
|
case META_SIDE_BOTTOM:
|
|
|
|
temp->rect.y = BOX_BOTTOM(temp->rect) - thickness;
|
|
|
|
/* Intentionally fall through without breaking */
|
|
|
|
case META_SIDE_TOP:
|
|
|
|
temp->rect.height = thickness;
|
|
|
|
temp->rect.x = strut_begin;
|
|
|
|
temp->rect.width = strut_end - strut_begin + 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
new_struts = g_slist_prepend (new_struts, temp);
|
|
|
|
}
|
|
|
|
|
2015-06-23 18:09:07 -04:00
|
|
|
meta_verbose ("_NET_WM_STRUT_PARTIAL struts %u %u %u %u for "
|
2014-04-28 17:06:38 -04:00
|
|
|
"window %s\n",
|
|
|
|
struts[0], struts[1], struts[2], struts[3],
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
meta_XFree (struts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("No _NET_WM_STRUT property for %s\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!new_struts &&
|
2017-08-26 14:51:28 -04:00
|
|
|
meta_prop_get_cardinal_list (window->display->x11_display,
|
2014-04-28 17:06:38 -04:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
window->display->x11_display->atom__NET_WM_STRUT,
|
2014-04-28 17:06:38 -04:00
|
|
|
&struts, &nitems))
|
|
|
|
{
|
|
|
|
if (nitems != 4)
|
|
|
|
meta_verbose ("_NET_WM_STRUT on %s has %d values instead of 4\n",
|
|
|
|
window->desc, nitems);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Pull out the strut info for each side in the hint */
|
|
|
|
int i;
|
|
|
|
for (i=0; i<4; i++)
|
|
|
|
{
|
|
|
|
MetaStrut *temp;
|
|
|
|
int thickness;
|
|
|
|
|
|
|
|
thickness = struts[i];
|
|
|
|
if (thickness == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
temp = g_new (MetaStrut, 1);
|
|
|
|
temp->side = 1 << i;
|
2017-08-26 12:37:29 -04:00
|
|
|
temp->rect = window->display->rect;
|
2014-04-28 17:06:38 -04:00
|
|
|
switch (temp->side)
|
|
|
|
{
|
|
|
|
case META_SIDE_RIGHT:
|
|
|
|
temp->rect.x = BOX_RIGHT(temp->rect) - thickness;
|
|
|
|
/* Intentionally fall through without breaking */
|
|
|
|
case META_SIDE_LEFT:
|
|
|
|
temp->rect.width = thickness;
|
|
|
|
break;
|
|
|
|
case META_SIDE_BOTTOM:
|
|
|
|
temp->rect.y = BOX_BOTTOM(temp->rect) - thickness;
|
|
|
|
/* Intentionally fall through without breaking */
|
|
|
|
case META_SIDE_TOP:
|
|
|
|
temp->rect.height = thickness;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
new_struts = g_slist_prepend (new_struts, temp);
|
|
|
|
}
|
|
|
|
|
2015-06-23 18:09:07 -04:00
|
|
|
meta_verbose ("_NET_WM_STRUT struts %u %u %u %u for window %s\n",
|
2014-04-28 17:06:38 -04:00
|
|
|
struts[0], struts[1], struts[2], struts[3],
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
meta_XFree (struts);
|
|
|
|
}
|
|
|
|
else if (!new_struts)
|
|
|
|
{
|
|
|
|
meta_verbose ("No _NET_WM_STRUT property for %s\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine whether old_struts and new_struts are the same */
|
|
|
|
old_iter = old_struts;
|
|
|
|
new_iter = new_struts;
|
|
|
|
while (old_iter && new_iter)
|
|
|
|
{
|
|
|
|
MetaStrut *old_strut = (MetaStrut*) old_iter->data;
|
|
|
|
MetaStrut *new_strut = (MetaStrut*) new_iter->data;
|
|
|
|
|
|
|
|
if (old_strut->side != new_strut->side ||
|
|
|
|
!meta_rectangle_equal (&old_strut->rect, &new_strut->rect))
|
|
|
|
break;
|
|
|
|
|
|
|
|
old_iter = old_iter->next;
|
|
|
|
new_iter = new_iter->next;
|
|
|
|
}
|
|
|
|
changed = (old_iter != NULL || new_iter != NULL);
|
|
|
|
|
|
|
|
/* Update appropriately */
|
|
|
|
meta_free_gslist_and_elements (old_struts);
|
|
|
|
window->struts = new_struts;
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2014-03-18 11:20:22 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_get_default_skip_hints (MetaWindow *window,
|
|
|
|
gboolean *skip_taskbar_out,
|
|
|
|
gboolean *skip_pager_out)
|
|
|
|
{
|
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
|
|
|
*skip_taskbar_out = priv->wm_state_skip_taskbar;
|
|
|
|
*skip_pager_out = priv->wm_state_skip_pager;
|
|
|
|
}
|
|
|
|
|
2014-07-14 12:01:22 -04:00
|
|
|
static gboolean
|
2014-12-31 23:39:36 -05:00
|
|
|
meta_window_x11_update_icon (MetaWindow *window,
|
|
|
|
cairo_surface_t **icon,
|
|
|
|
cairo_surface_t **mini_icon)
|
2014-07-14 12:01:22 -04:00
|
|
|
{
|
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
2017-08-26 14:54:39 -04:00
|
|
|
return meta_read_icons (window->display->x11_display,
|
2014-07-14 12:01:22 -04:00
|
|
|
window->xwindow,
|
|
|
|
&priv->icon_cache,
|
|
|
|
priv->wm_hints_pixmap,
|
|
|
|
priv->wm_hints_mask,
|
|
|
|
icon,
|
|
|
|
META_ICON_WIDTH, META_ICON_HEIGHT,
|
|
|
|
mini_icon,
|
|
|
|
META_MINI_ICON_WIDTH, META_MINI_ICON_HEIGHT);
|
|
|
|
}
|
|
|
|
|
2015-03-23 09:22:19 -04:00
|
|
|
static void
|
2017-07-13 00:38:02 -04:00
|
|
|
meta_window_x11_update_main_monitor (MetaWindow *window,
|
|
|
|
gboolean user_op)
|
2015-03-23 09:22:19 -04:00
|
|
|
{
|
2016-12-01 00:01:39 -05:00
|
|
|
window->monitor = meta_window_calculate_main_logical_monitor (window);
|
2015-03-23 09:22:19 -04:00
|
|
|
}
|
|
|
|
|
2015-03-02 22:13:05 -05:00
|
|
|
static void
|
2016-11-25 01:31:38 -05:00
|
|
|
meta_window_x11_main_monitor_changed (MetaWindow *window,
|
|
|
|
const MetaLogicalMonitor *old)
|
2015-03-02 22:13:05 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-07 11:55:32 -04:00
|
|
|
static uint32_t
|
|
|
|
meta_window_x11_get_client_pid (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
|
|
|
xcb_connection_t *xcb = XGetXCBConnection (x11_display->xdisplay);
|
2016-10-07 11:55:32 -04:00
|
|
|
xcb_res_client_id_spec_t spec = { 0 };
|
|
|
|
xcb_res_query_client_ids_cookie_t cookie;
|
|
|
|
xcb_res_query_client_ids_reply_t *reply = NULL;
|
|
|
|
|
|
|
|
spec.client = window->xwindow;
|
|
|
|
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
|
|
|
|
|
|
|
cookie = xcb_res_query_client_ids (xcb, 1, &spec);
|
|
|
|
reply = xcb_res_query_client_ids_reply (xcb, cookie, NULL);
|
|
|
|
|
|
|
|
if (reply == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t pid = 0, *value;
|
|
|
|
xcb_res_client_id_value_iterator_t it;
|
|
|
|
for (it = xcb_res_query_client_ids_ids_iterator (reply);
|
|
|
|
it.rem;
|
|
|
|
xcb_res_client_id_value_next (&it))
|
|
|
|
{
|
|
|
|
spec = it.data->spec;
|
|
|
|
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID)
|
|
|
|
{
|
|
|
|
value = xcb_res_client_id_value_value (it.data);
|
|
|
|
pid = *value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free (reply);
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
|
2017-03-17 08:34:52 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_force_restore_shortcuts (MetaWindow *window,
|
|
|
|
ClutterInputDevice *source)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Not needed on X11 because clients can use a keyboard grab
|
|
|
|
* to bypass the compositor shortcuts.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_window_x11_shortcuts_inhibited (MetaWindow *window,
|
|
|
|
ClutterInputDevice *source)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* On X11, we don't use a shortcuts inhibitor, clients just grab
|
|
|
|
* the keyboard.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
static gboolean
|
|
|
|
meta_window_x11_is_stackable (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return !window->override_redirect;
|
|
|
|
}
|
|
|
|
|
2014-03-18 11:20:22 -04:00
|
|
|
static void
|
|
|
|
meta_window_x11_class_init (MetaWindowX11Class *klass)
|
|
|
|
{
|
|
|
|
MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
|
|
|
|
|
2014-03-19 09:36:15 -04:00
|
|
|
window_class->manage = meta_window_x11_manage;
|
|
|
|
window_class->unmanage = meta_window_x11_unmanage;
|
2014-03-20 15:12:44 -04:00
|
|
|
window_class->ping = meta_window_x11_ping;
|
2014-03-20 15:07:44 -04:00
|
|
|
window_class->delete = meta_window_x11_delete;
|
|
|
|
window_class->kill = meta_window_x11_kill;
|
2014-03-20 15:16:57 -04:00
|
|
|
window_class->focus = meta_window_x11_focus;
|
2014-04-29 15:55:55 -04:00
|
|
|
window_class->grab_op_began = meta_window_x11_grab_op_began;
|
|
|
|
window_class->grab_op_ended = meta_window_x11_grab_op_ended;
|
2014-05-20 15:46:21 -04:00
|
|
|
window_class->current_workspace_changed = meta_window_x11_current_workspace_changed;
|
2014-03-19 10:30:12 -04:00
|
|
|
window_class->move_resize_internal = meta_window_x11_move_resize_internal;
|
2014-04-28 17:06:38 -04:00
|
|
|
window_class->update_struts = meta_window_x11_update_struts;
|
2014-03-18 11:20:22 -04:00
|
|
|
window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints;
|
2014-07-14 12:01:22 -04:00
|
|
|
window_class->update_icon = meta_window_x11_update_icon;
|
2015-03-23 09:22:19 -04:00
|
|
|
window_class->update_main_monitor = meta_window_x11_update_main_monitor;
|
2015-03-02 22:13:05 -05:00
|
|
|
window_class->main_monitor_changed = meta_window_x11_main_monitor_changed;
|
2016-10-07 11:55:32 -04:00
|
|
|
window_class->get_client_pid = meta_window_x11_get_client_pid;
|
2017-03-17 08:34:52 -04:00
|
|
|
window_class->force_restore_shortcuts = meta_window_x11_force_restore_shortcuts;
|
|
|
|
window_class->shortcuts_inhibited = meta_window_x11_shortcuts_inhibited;
|
2018-01-09 07:19:40 -05:00
|
|
|
window_class->is_stackable = meta_window_x11_is_stackable;
|
2014-03-18 11:20:22 -04:00
|
|
|
}
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
void
|
|
|
|
meta_window_x11_set_net_wm_state (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-03-18 13:07:50 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-01-23 16:33:53 -05:00
|
|
|
int i;
|
|
|
|
unsigned long data[13];
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if (window->shaded)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_SHADED;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
2014-03-18 13:07:50 -04:00
|
|
|
if (priv->wm_state_modal)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_MODAL;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->skip_pager)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_SKIP_PAGER;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->skip_taskbar)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_SKIP_TASKBAR;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->maximized_horizontally)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_MAXIMIZED_HORZ;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->maximized_vertically)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_MAXIMIZED_VERT;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_FULLSCREEN;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (!meta_window_showing_on_its_workspace (window) || window->shaded)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_HIDDEN;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->wm_state_above)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_ABOVE;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->wm_state_below)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_BELOW;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->wm_state_demands_attention)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_DEMANDS_ATTENTION;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->on_all_workspaces_requested)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_STICKY;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (meta_window_appears_focused (window))
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_STATE_FOCUSED;
|
2014-01-23 16:33:53 -05:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_verbose ("Setting _NET_WM_STATE with %d atoms\n", i);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay, window->xwindow,
|
|
|
|
x11_display->atom__NET_WM_STATE,
|
2014-01-23 16:33:53 -05:00
|
|
|
XA_ATOM,
|
|
|
|
32, PropModeReplace, (guchar*) data, i);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
2016-11-29 04:50:17 -05:00
|
|
|
if (meta_window_has_fullscreen_monitors (window))
|
2013-12-14 08:24:27 -05:00
|
|
|
{
|
2016-11-29 04:50:17 -05:00
|
|
|
data[0] =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_logical_monitor_to_xinerama_index (window->display->x11_display,
|
|
|
|
window->fullscreen_monitors.top);
|
2016-11-29 04:50:17 -05:00
|
|
|
data[1] =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_logical_monitor_to_xinerama_index (window->display->x11_display,
|
|
|
|
window->fullscreen_monitors.bottom);
|
2016-11-29 04:50:17 -05:00
|
|
|
data[2] =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_logical_monitor_to_xinerama_index (window->display->x11_display,
|
|
|
|
window->fullscreen_monitors.left);
|
2016-11-29 04:50:17 -05:00
|
|
|
data[3] =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_logical_monitor_to_xinerama_index (window->display->x11_display,
|
|
|
|
window->fullscreen_monitors.right);
|
2013-12-14 08:24:27 -05:00
|
|
|
|
|
|
|
meta_verbose ("Setting _NET_WM_FULLSCREEN_MONITORS\n");
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
2013-12-14 08:24:27 -05:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_FULLSCREEN_MONITORS,
|
2013-12-14 08:24:27 -05:00
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(guchar*) data, 4);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2013-12-14 08:24:27 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("Clearing _NET_WM_FULLSCREEN_MONITORS\n");
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XDeleteProperty (x11_display->xdisplay,
|
2013-12-14 08:24:27 -05:00
|
|
|
window->xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_FULLSCREEN_MONITORS);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2013-12-14 08:24:27 -05:00
|
|
|
}
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
2017-08-18 19:21:37 -04:00
|
|
|
|
|
|
|
/* Edge constraints */
|
|
|
|
update_gtk_edge_constraints (window);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static cairo_region_t *
|
|
|
|
region_create_from_x_rectangles (const XRectangle *rects,
|
|
|
|
int n_rects)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
cairo_rectangle_int_t *cairo_rects = g_newa (cairo_rectangle_int_t, n_rects);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i ++)
|
|
|
|
{
|
|
|
|
cairo_rects[i].x = rects[i].x;
|
|
|
|
cairo_rects[i].y = rects[i].y;
|
|
|
|
cairo_rects[i].width = rects[i].width;
|
|
|
|
cairo_rects[i].height = rects[i].height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cairo_region_create_rectangles (cairo_rects, n_rects);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_set_input_region (MetaWindow *window,
|
|
|
|
cairo_region_t *region)
|
|
|
|
{
|
2014-06-27 12:17:28 -04:00
|
|
|
if (cairo_region_equal (window->input_region, region))
|
|
|
|
return;
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
g_clear_pointer (&window->input_region, cairo_region_destroy);
|
|
|
|
|
|
|
|
if (region != NULL)
|
|
|
|
window->input_region = cairo_region_reference (region);
|
|
|
|
|
2014-03-18 17:06:42 -04:00
|
|
|
meta_compositor_window_shape_changed (window->display->compositor, window);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
|
2014-02-24 19:22:36 -05:00
|
|
|
#if 0
|
|
|
|
/* Print out a region; useful for debugging */
|
|
|
|
static void
|
|
|
|
print_region (cairo_region_t *region)
|
|
|
|
{
|
|
|
|
int n_rects;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (region);
|
|
|
|
g_print ("[");
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
cairo_region_get_rectangle (region, i, &rect);
|
|
|
|
g_print ("+%d+%dx%dx%d ",
|
|
|
|
rect.x, rect.y, rect.width, rect.height);
|
|
|
|
}
|
|
|
|
g_print ("]\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
void
|
|
|
|
meta_window_x11_update_input_region (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-01-23 16:33:53 -05:00
|
|
|
cairo_region_t *region = NULL;
|
2014-05-20 17:47:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2014-02-24 19:22:36 -05:00
|
|
|
/* Decorated windows don't have an input region, because
|
|
|
|
we don't shape the frame to match the client windows
|
|
|
|
(so the events are blocked by the frame anyway)
|
|
|
|
*/
|
|
|
|
if (window->decorated)
|
|
|
|
{
|
|
|
|
if (window->input_region)
|
|
|
|
meta_window_set_input_region (window, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:28:53 -04:00
|
|
|
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
/* Translate the set of XShape rectangles that we
|
|
|
|
* get from the X server to a cairo_region. */
|
|
|
|
XRectangle *rects = NULL;
|
2014-11-26 15:45:26 -05:00
|
|
|
int n_rects = -1, ordering;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
rects = XShapeGetRectangles (x11_display->xdisplay,
|
2014-01-23 16:33:53 -05:00
|
|
|
window->xwindow,
|
|
|
|
ShapeInput,
|
|
|
|
&n_rects,
|
|
|
|
&ordering);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2014-11-26 15:45:26 -05:00
|
|
|
/* XXX: The X Shape specification is quite unfortunately specified.
|
|
|
|
*
|
|
|
|
* By default, the window has a shape the same as its bounding region,
|
|
|
|
* which we consider "NULL".
|
|
|
|
*
|
|
|
|
* If the window sets an empty region, then we'll get n_rects as 0
|
|
|
|
* and rects as NULL, which we need to transform back into an empty
|
|
|
|
* region.
|
|
|
|
*
|
|
|
|
* It would be great to have a less-broken extension for this, but
|
|
|
|
* hey, it's X11!
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (n_rects == -1)
|
|
|
|
{
|
|
|
|
/* We had an error. */
|
|
|
|
region = NULL;
|
|
|
|
}
|
|
|
|
else if (n_rects == 0)
|
|
|
|
{
|
|
|
|
/* Client set an empty region. */
|
|
|
|
region = cairo_region_create ();
|
|
|
|
}
|
|
|
|
else if (n_rects == 1 &&
|
2016-01-22 21:25:02 -05:00
|
|
|
(rects[0].x == 0 &&
|
|
|
|
rects[0].y == 0 &&
|
|
|
|
rects[0].width == priv->client_rect.width &&
|
2014-11-26 15:45:26 -05:00
|
|
|
rects[0].height == priv->client_rect.height))
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2014-11-26 15:45:26 -05:00
|
|
|
/* This is the bounding region case. Keep the
|
|
|
|
* region as NULL. */
|
|
|
|
region = NULL;
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
2014-11-26 15:45:26 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Window has a custom shape. */
|
|
|
|
region = region_create_from_x_rectangles (rects, n_rects);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_XFree (rects);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (region != NULL)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t client_area;
|
|
|
|
|
|
|
|
client_area.x = 0;
|
|
|
|
client_area.y = 0;
|
2014-05-20 17:47:10 -04:00
|
|
|
client_area.width = priv->client_rect.width;
|
|
|
|
client_area.height = priv->client_rect.height;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
/* The shape we get back from the client may have coordinates
|
|
|
|
* outside of the frame. The X SHAPE Extension requires that
|
|
|
|
* the overall shape the client provides never exceeds the
|
|
|
|
* "bounding rectangle" of the window -- the shape that the
|
|
|
|
* window would have gotten if it was unshaped. In our case,
|
|
|
|
* this is simply the client area.
|
|
|
|
*/
|
|
|
|
cairo_region_intersect_rectangle (region, &client_area);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_set_input_region (window, region);
|
|
|
|
cairo_region_destroy (region);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_set_shape_region (MetaWindow *window,
|
|
|
|
cairo_region_t *region)
|
|
|
|
{
|
2014-06-27 12:17:28 -04:00
|
|
|
if (cairo_region_equal (window->shape_region, region))
|
|
|
|
return;
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
g_clear_pointer (&window->shape_region, cairo_region_destroy);
|
|
|
|
|
|
|
|
if (region != NULL)
|
|
|
|
window->shape_region = cairo_region_reference (region);
|
|
|
|
|
2014-03-18 17:06:42 -04:00
|
|
|
meta_compositor_window_shape_changed (window->display->compositor, window);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_update_shape_region (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-05-20 17:47:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-01-23 16:33:53 -05:00
|
|
|
cairo_region_t *region = NULL;
|
|
|
|
|
2017-08-26 12:28:53 -04:00
|
|
|
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
/* Translate the set of XShape rectangles that we
|
|
|
|
* get from the X server to a cairo_region. */
|
|
|
|
XRectangle *rects = NULL;
|
|
|
|
int n_rects, ordering;
|
|
|
|
|
|
|
|
int x_bounding, y_bounding, x_clip, y_clip;
|
|
|
|
unsigned w_bounding, h_bounding, w_clip, h_clip;
|
|
|
|
int bounding_shaped, clip_shaped;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XShapeQueryExtents (x11_display->xdisplay, window->xwindow,
|
2014-01-23 16:33:53 -05:00
|
|
|
&bounding_shaped, &x_bounding, &y_bounding,
|
|
|
|
&w_bounding, &h_bounding,
|
|
|
|
&clip_shaped, &x_clip, &y_clip,
|
|
|
|
&w_clip, &h_clip);
|
|
|
|
|
|
|
|
if (bounding_shaped)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
rects = XShapeGetRectangles (x11_display->xdisplay,
|
2014-01-23 16:33:53 -05:00
|
|
|
window->xwindow,
|
|
|
|
ShapeBounding,
|
|
|
|
&n_rects,
|
|
|
|
&ordering);
|
|
|
|
}
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
if (rects)
|
|
|
|
{
|
|
|
|
region = region_create_from_x_rectangles (rects, n_rects);
|
|
|
|
XFree (rects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region != NULL)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t client_area;
|
|
|
|
|
|
|
|
client_area.x = 0;
|
|
|
|
client_area.y = 0;
|
2014-05-20 17:47:10 -04:00
|
|
|
client_area.width = priv->client_rect.width;
|
|
|
|
client_area.height = priv->client_rect.height;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
/* The shape we get back from the client may have coordinates
|
|
|
|
* outside of the frame. The X SHAPE Extension requires that
|
|
|
|
* the overall shape the client provides never exceeds the
|
|
|
|
* "bounding rectangle" of the window -- the shape that the
|
|
|
|
* window would have gotten if it was unshaped. In our case,
|
|
|
|
* this is simply the client area.
|
|
|
|
*/
|
|
|
|
cairo_region_intersect_rectangle (region, &client_area);
|
2016-01-04 11:31:22 -05:00
|
|
|
/* Some applications might explicitly set their bounding region
|
|
|
|
* to the client area. Detect these cases, and throw out the
|
2018-02-15 03:18:26 -05:00
|
|
|
* bounding region in this case for decorated windows. */
|
|
|
|
if (window->decorated &&
|
|
|
|
cairo_region_contains_rectangle (region, &client_area) == CAIRO_REGION_OVERLAP_IN)
|
2016-01-04 11:31:22 -05:00
|
|
|
g_clear_pointer (®ion, cairo_region_destroy);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_set_shape_region (window, region);
|
|
|
|
cairo_region_destroy (region);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generally meta_window_same_application() is a better idea
|
|
|
|
* of "sameness", since it handles the case where multiple apps
|
|
|
|
* want to look like the same app or the same app wants to look
|
|
|
|
* like multiple apps, but in the case of workarounds for legacy
|
|
|
|
* applications (which likely aren't setting the group properly
|
|
|
|
* anyways), it may be desirable to check this as well.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
meta_window_same_client (MetaWindow *window,
|
|
|
|
MetaWindow *other_window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
int resource_mask = window->display->x11_display->xdisplay->resource_mask;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
return ((window->xwindow & ~resource_mask) ==
|
|
|
|
(other_window->xwindow & ~resource_mask));
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:15:42 -04:00
|
|
|
static void
|
|
|
|
meta_window_move_resize_request (MetaWindow *window,
|
|
|
|
guint value_mask,
|
|
|
|
int gravity,
|
|
|
|
int new_x,
|
|
|
|
int new_y,
|
|
|
|
int new_width,
|
|
|
|
int new_height)
|
|
|
|
{
|
|
|
|
int x, y, width, height;
|
|
|
|
gboolean allow_position_change;
|
|
|
|
gboolean in_grab_op;
|
|
|
|
MetaMoveResizeFlags flags;
|
|
|
|
|
|
|
|
/* We ignore configure requests while the user is moving/resizing
|
|
|
|
* the window, since these represent the app sucking and fighting
|
|
|
|
* the user, most likely due to a bug in the app (e.g. pfaedit
|
|
|
|
* seemed to do this)
|
|
|
|
*
|
|
|
|
* Still have to do the ConfigureNotify and all, but pretend the
|
|
|
|
* app asked for the current size/position instead of the new one.
|
|
|
|
*/
|
2014-08-15 12:52:47 -04:00
|
|
|
in_grab_op = (window->display->grab_window == window &&
|
|
|
|
meta_grab_op_is_mouse (window->display->grab_op));
|
2014-04-29 15:15:42 -04:00
|
|
|
|
|
|
|
/* it's essential to use only the explicitly-set fields,
|
|
|
|
* and otherwise use our current up-to-date position.
|
|
|
|
*
|
|
|
|
* Otherwise you get spurious position changes when the app changes
|
|
|
|
* size, for example, if window->rect is not in sync with the
|
|
|
|
* server-side position in effect when the configure request was
|
|
|
|
* generated.
|
|
|
|
*/
|
|
|
|
meta_window_get_gravity_position (window,
|
|
|
|
gravity,
|
|
|
|
&x, &y);
|
|
|
|
|
|
|
|
allow_position_change = FALSE;
|
|
|
|
|
|
|
|
if (meta_prefs_get_disable_workarounds ())
|
|
|
|
{
|
|
|
|
if (window->type == META_WINDOW_DIALOG ||
|
|
|
|
window->type == META_WINDOW_MODAL_DIALOG ||
|
|
|
|
window->type == META_WINDOW_SPLASHSCREEN)
|
|
|
|
; /* No position change for these */
|
|
|
|
else if ((window->size_hints.flags & PPosition) ||
|
|
|
|
/* USPosition is just stale if window is placed;
|
|
|
|
* no --geometry involved here.
|
|
|
|
*/
|
|
|
|
((window->size_hints.flags & USPosition) &&
|
|
|
|
!window->placed))
|
|
|
|
allow_position_change = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
allow_position_change = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_grab_op)
|
|
|
|
allow_position_change = FALSE;
|
|
|
|
|
|
|
|
if (allow_position_change)
|
|
|
|
{
|
|
|
|
if (value_mask & CWX)
|
|
|
|
x = new_x;
|
|
|
|
if (value_mask & CWY)
|
|
|
|
y = new_y;
|
|
|
|
if (value_mask & (CWX | CWY))
|
|
|
|
{
|
|
|
|
/* Once manually positioned, windows shouldn't be placed
|
|
|
|
* by the window manager.
|
|
|
|
*/
|
|
|
|
window->placed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Not allowing position change for window %s PPosition 0x%lx USPosition 0x%lx type %u\n",
|
|
|
|
window->desc, window->size_hints.flags & PPosition,
|
|
|
|
window->size_hints.flags & USPosition,
|
|
|
|
window->type);
|
|
|
|
}
|
|
|
|
|
|
|
|
width = window->rect.width;
|
|
|
|
height = window->rect.height;
|
|
|
|
if (!in_grab_op)
|
|
|
|
{
|
|
|
|
if (value_mask & CWWidth)
|
|
|
|
width = new_width;
|
|
|
|
|
|
|
|
if (value_mask & CWHeight)
|
|
|
|
height = new_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ICCCM 4.1.5 */
|
|
|
|
|
|
|
|
/* We're ignoring the value_mask here, since sizes
|
|
|
|
* not in the mask will be the current window geometry.
|
|
|
|
*/
|
|
|
|
window->size_hints.x = x;
|
|
|
|
window->size_hints.y = y;
|
|
|
|
window->size_hints.width = width;
|
|
|
|
window->size_hints.height = height;
|
|
|
|
|
|
|
|
/* NOTE: We consider ConfigureRequests to be "user" actions in one
|
|
|
|
* way, but not in another. Explanation of the two cases are in the
|
|
|
|
* next two big comments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The constraints code allows user actions to move windows
|
|
|
|
* offscreen, etc., and configure request actions would often send
|
|
|
|
* windows offscreen when users don't want it if not constrained
|
|
|
|
* (e.g. hitting a dropdown triangle in a fileselector to show more
|
|
|
|
* options, which makes the window bigger). Thus we do not set
|
2014-12-15 16:28:47 -05:00
|
|
|
* META_MOVE_RESIZE_USER_ACTION in flags to the
|
2014-04-29 15:15:42 -04:00
|
|
|
* meta_window_move_resize_internal() call.
|
|
|
|
*/
|
2014-12-15 16:28:47 -05:00
|
|
|
flags = META_MOVE_RESIZE_CONFIGURE_REQUEST;
|
2014-04-29 15:15:42 -04:00
|
|
|
if (value_mask & (CWX | CWY))
|
2014-12-15 16:28:47 -05:00
|
|
|
flags |= META_MOVE_RESIZE_MOVE_ACTION;
|
2014-04-29 15:15:42 -04:00
|
|
|
if (value_mask & (CWWidth | CWHeight))
|
2014-12-15 16:28:47 -05:00
|
|
|
flags |= META_MOVE_RESIZE_RESIZE_ACTION;
|
2014-04-29 15:15:42 -04:00
|
|
|
|
2014-12-15 16:28:47 -05:00
|
|
|
if (flags & (META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION))
|
2014-05-01 17:39:25 -04:00
|
|
|
{
|
2014-06-09 15:43:04 -04:00
|
|
|
MetaRectangle rect, monitor_rect;
|
2014-05-01 17:39:25 -04:00
|
|
|
|
|
|
|
rect.x = x;
|
|
|
|
rect.y = y;
|
|
|
|
rect.width = width;
|
|
|
|
rect.height = height;
|
|
|
|
|
2018-01-11 13:31:42 -05:00
|
|
|
if (window->monitor)
|
2014-06-09 15:43:04 -04:00
|
|
|
{
|
2017-08-26 15:22:34 -04:00
|
|
|
meta_display_get_monitor_geometry (window->display,
|
|
|
|
window->monitor->number,
|
|
|
|
&monitor_rect);
|
2018-01-11 13:31:42 -05:00
|
|
|
|
|
|
|
/* Workaround braindead legacy apps that don't know how to
|
|
|
|
* fullscreen themselves properly - don't get fooled by
|
|
|
|
* windows which hide their titlebar when maximized or which are
|
|
|
|
* client decorated; that's not the same as fullscreen, even
|
|
|
|
* if there are no struts making the workarea smaller than
|
|
|
|
* the monitor.
|
|
|
|
*/
|
|
|
|
if (meta_prefs_get_force_fullscreen() &&
|
|
|
|
!window->hide_titlebar_when_maximized &&
|
|
|
|
(window->decorated || !meta_window_is_client_decorated (window)) &&
|
|
|
|
meta_rectangle_equal (&rect, &monitor_rect) &&
|
|
|
|
window->has_fullscreen_func &&
|
|
|
|
!window->fullscreen)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
*/
|
|
|
|
meta_warning (
|
|
|
|
"Treating resize request of legacy application %s as a "
|
|
|
|
"fullscreen request\n",
|
|
|
|
window->desc);
|
|
|
|
meta_window_make_fullscreen_internal (window);
|
|
|
|
}
|
2014-06-09 15:43:04 -04:00
|
|
|
}
|
|
|
|
|
2014-05-01 19:11:17 -04:00
|
|
|
adjust_for_gravity (window, TRUE, gravity, &rect);
|
2014-05-20 17:47:10 -04:00
|
|
|
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
2014-05-01 19:09:13 -04:00
|
|
|
meta_window_move_resize_internal (window, flags, gravity, rect);
|
2014-05-01 17:39:25 -04:00
|
|
|
}
|
2014-04-29 15:15:42 -04:00
|
|
|
}
|
|
|
|
|
2017-09-29 10:57:22 -04:00
|
|
|
static void
|
|
|
|
restack_window (MetaWindow *window,
|
|
|
|
MetaWindow *sibling,
|
|
|
|
int direction)
|
|
|
|
{
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case Above:
|
|
|
|
if (sibling)
|
|
|
|
meta_window_stack_just_above (window, sibling);
|
|
|
|
else
|
|
|
|
meta_window_raise (window);
|
|
|
|
break;
|
|
|
|
case Below:
|
|
|
|
if (sibling)
|
|
|
|
meta_window_stack_just_below (window, sibling);
|
|
|
|
else
|
|
|
|
meta_window_lower (window);
|
|
|
|
break;
|
|
|
|
case TopIf:
|
|
|
|
case BottomIf:
|
|
|
|
case Opposite:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
gboolean
|
|
|
|
meta_window_x11_configure_request (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
2014-05-20 09:19:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
/* Note that x, y is the corner of the window border,
|
|
|
|
* and width, height is the size of the window inside
|
|
|
|
* its border, but that we always deny border requests
|
|
|
|
* and give windows a border of 0. But we save the
|
|
|
|
* requested border here.
|
|
|
|
*/
|
|
|
|
if (event->xconfigurerequest.value_mask & CWBorderWidth)
|
2014-05-20 09:19:10 -04:00
|
|
|
priv->border_width = event->xconfigurerequest.border_width;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
meta_window_move_resize_request(window,
|
|
|
|
event->xconfigurerequest.value_mask,
|
|
|
|
window->size_hints.win_gravity,
|
|
|
|
event->xconfigurerequest.x,
|
|
|
|
event->xconfigurerequest.y,
|
|
|
|
event->xconfigurerequest.width,
|
|
|
|
event->xconfigurerequest.height);
|
|
|
|
|
|
|
|
/* Handle stacking. We only handle raises/lowers, mostly because
|
|
|
|
* stack.c really can't deal with anything else. I guess we'll fix
|
|
|
|
* that if a client turns up that really requires it. Only a very
|
|
|
|
* few clients even require the raise/lower (and in fact all client
|
|
|
|
* attempts to deal with stacking order are essentially broken,
|
|
|
|
* since they have no idea what other clients are involved or how
|
|
|
|
* the stack looks).
|
|
|
|
*
|
|
|
|
* I'm pretty sure no interesting client uses TopIf, BottomIf, or
|
2017-09-29 10:57:22 -04:00
|
|
|
* Opposite anyway.
|
2014-01-23 16:33:53 -05:00
|
|
|
*/
|
|
|
|
if (event->xconfigurerequest.value_mask & CWStackMode)
|
|
|
|
{
|
|
|
|
MetaWindow *active_window;
|
|
|
|
active_window = window->display->focus_window;
|
|
|
|
if (meta_prefs_get_disable_workarounds ())
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
|
|
|
"%s sent an xconfigure stacking request; this is "
|
|
|
|
"broken behavior and the request is being ignored.\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
else if (active_window &&
|
|
|
|
!meta_window_same_application (window, active_window) &&
|
|
|
|
!meta_window_same_client (window, active_window) &&
|
|
|
|
XSERVER_TIME_IS_BEFORE (window->net_wm_user_time,
|
|
|
|
active_window->net_wm_user_time))
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
|
|
|
"Ignoring xconfigure stacking request from %s (with "
|
|
|
|
"user_time %u); currently active application is %s (with "
|
|
|
|
"user_time %u).\n",
|
|
|
|
window->desc,
|
|
|
|
window->net_wm_user_time,
|
|
|
|
active_window->desc,
|
|
|
|
active_window->net_wm_user_time);
|
|
|
|
if (event->xconfigurerequest.detail == Above)
|
|
|
|
meta_window_set_demands_attention(window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-29 10:57:22 -04:00
|
|
|
MetaWindow *sibling = NULL;
|
|
|
|
/* Handle Above/Below with a sibling set */
|
|
|
|
if (event->xconfigurerequest.above != None)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2017-09-29 10:57:22 -04:00
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
display = meta_window_get_display (window);
|
2017-08-26 12:56:44 -04:00
|
|
|
sibling = meta_x11_display_lookup_x_window (display->x11_display,
|
|
|
|
event->xconfigurerequest.above);
|
2017-09-29 10:57:22 -04:00
|
|
|
if (sibling == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
|
|
|
"xconfigure stacking request from window %s sibling %s stackmode %d\n",
|
|
|
|
window->desc, sibling->desc, event->xconfigurerequest.detail);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
2017-09-29 10:57:22 -04:00
|
|
|
restack_window (window, sibling, event->xconfigurerequest.detail);
|
2014-01-23 16:33:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
process_property_notify (MetaWindow *window,
|
|
|
|
XPropertyEvent *event)
|
|
|
|
{
|
|
|
|
Window xid = window->xwindow;
|
|
|
|
|
|
|
|
if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
char *property_name = XGetAtomName (window->display->x11_display->xdisplay,
|
2014-01-23 16:33:53 -05:00
|
|
|
event->atom);
|
|
|
|
|
|
|
|
meta_verbose ("Property notify on %s for %s\n",
|
|
|
|
window->desc, property_name);
|
|
|
|
XFree (property_name);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (event->atom == window->display->x11_display->atom__NET_WM_USER_TIME &&
|
2014-01-23 16:33:53 -05:00
|
|
|
window->user_time_window)
|
|
|
|
{
|
|
|
|
xid = window->user_time_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_reload_property_from_xwindow (window, xid, event->atom, FALSE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_window_x11_property_notify (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
return process_property_notify (window, &event->xproperty);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOP 1
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE 8
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
|
|
|
|
#define _NET_WM_MOVERESIZE_CANCEL 11
|
|
|
|
|
|
|
|
static int
|
|
|
|
query_pressed_buttons (MetaWindow *window)
|
|
|
|
{
|
2014-04-22 11:27:52 -04:00
|
|
|
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (window->screen);
|
2014-03-02 17:27:50 -05:00
|
|
|
ClutterModifierType mods;
|
2014-01-23 16:33:53 -05:00
|
|
|
int button = 0;
|
|
|
|
|
2014-04-22 11:27:52 -04:00
|
|
|
meta_cursor_tracker_get_pointer (tracker, NULL, NULL, &mods);
|
2014-03-02 17:27:50 -05:00
|
|
|
|
|
|
|
if (mods & CLUTTER_BUTTON1_MASK)
|
2014-01-23 16:33:53 -05:00
|
|
|
button |= 1 << 1;
|
2014-03-02 17:27:50 -05:00
|
|
|
if (mods & CLUTTER_BUTTON2_MASK)
|
2014-01-23 16:33:53 -05:00
|
|
|
button |= 1 << 2;
|
2014-03-02 17:27:50 -05:00
|
|
|
if (mods & CLUTTER_BUTTON3_MASK)
|
2014-01-23 16:33:53 -05:00
|
|
|
button |= 1 << 3;
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
2017-09-29 10:57:22 -04:00
|
|
|
static void
|
|
|
|
handle_net_restack_window (MetaDisplay *display,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
MetaWindow *window, *sibling = NULL;
|
|
|
|
|
|
|
|
/* Ignore if this does not come from a pager, see the WM spec
|
|
|
|
*/
|
|
|
|
if (event->xclient.data.l[0] != 2)
|
|
|
|
return;
|
|
|
|
|
2017-08-26 12:56:44 -04:00
|
|
|
window = meta_x11_display_lookup_x_window (display->x11_display,
|
|
|
|
event->xclient.window);
|
2017-09-29 10:57:22 -04:00
|
|
|
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
if (event->xclient.data.l[1])
|
2017-08-26 12:56:44 -04:00
|
|
|
sibling = meta_x11_display_lookup_x_window (display->x11_display,
|
|
|
|
event->xclient.data.l[1]);
|
2017-09-29 10:57:22 -04:00
|
|
|
|
|
|
|
restack_window (window, sibling, event->xclient.data.l[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 16:33:53 -05:00
|
|
|
gboolean
|
|
|
|
meta_window_x11_client_message (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-03-18 11:20:22 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-01-23 16:33:53 -05:00
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
display = window->display;
|
|
|
|
|
|
|
|
if (window->override_redirect)
|
|
|
|
{
|
|
|
|
/* Don't warn here: we could warn on any of the messages below,
|
|
|
|
* but we might also receive other client messages that are
|
|
|
|
* part of protocols we don't know anything about. So, silently
|
|
|
|
* ignoring is simplest.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_CLOSE_WINDOW)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
guint32 timestamp;
|
|
|
|
|
|
|
|
if (event->xclient.data.l[0] != 0)
|
|
|
|
timestamp = event->xclient.data.l[0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_warning ("Receiving a NET_CLOSE_WINDOW message for %s without "
|
|
|
|
"a timestamp! This means some buggy (outdated) "
|
|
|
|
"application is on the loose!\n",
|
|
|
|
window->desc);
|
|
|
|
timestamp = meta_display_get_current_time (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_delete (window, timestamp);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_DESKTOP)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
int space;
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
|
|
|
|
space = event->xclient.data.l[0];
|
|
|
|
|
|
|
|
meta_verbose ("Request to move %s to workspace %d\n",
|
|
|
|
window->desc, space);
|
|
|
|
|
|
|
|
workspace =
|
|
|
|
meta_screen_get_workspace_by_index (window->screen,
|
|
|
|
space);
|
|
|
|
|
|
|
|
if (workspace)
|
2015-06-25 10:58:08 -04:00
|
|
|
meta_window_change_workspace (window, workspace);
|
2014-01-23 16:33:53 -05:00
|
|
|
else if (space == (int) 0xFFFFFFFF)
|
2015-06-25 10:58:08 -04:00
|
|
|
meta_window_stick (window);
|
2014-01-23 16:33:53 -05:00
|
|
|
else
|
2015-06-25 10:58:08 -04:00
|
|
|
meta_verbose ("No such workspace %d for screen\n", space);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
meta_verbose ("Window %s now on_all_workspaces = %d\n",
|
|
|
|
window->desc, window->on_all_workspaces);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_STATE)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
gulong action;
|
|
|
|
Atom first;
|
|
|
|
Atom second;
|
|
|
|
|
|
|
|
action = event->xclient.data.l[0];
|
|
|
|
first = event->xclient.data.l[1];
|
|
|
|
second = event->xclient.data.l[2];
|
|
|
|
|
|
|
|
if (meta_is_verbose ())
|
|
|
|
{
|
|
|
|
char *str1;
|
|
|
|
char *str2;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
str1 = XGetAtomName (x11_display->xdisplay, first);
|
2017-08-26 12:27:50 -04:00
|
|
|
if (meta_error_trap_pop_with_return (x11_display) != Success)
|
2014-01-23 16:33:53 -05:00
|
|
|
str1 = NULL;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
str2 = XGetAtomName (x11_display->xdisplay, second);
|
2017-08-26 12:27:50 -04:00
|
|
|
if (meta_error_trap_pop_with_return (x11_display) != Success)
|
2014-01-23 16:33:53 -05:00
|
|
|
str2 = NULL;
|
|
|
|
|
|
|
|
meta_verbose ("Request to change _NET_WM_STATE action %lu atom1: %s atom2: %s\n",
|
|
|
|
action,
|
|
|
|
str1 ? str1 : "(unknown)",
|
|
|
|
str2 ? str2 : "(unknown)");
|
|
|
|
|
|
|
|
meta_XFree (str1);
|
|
|
|
meta_XFree (str2);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_SHADED ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_SHADED)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
gboolean shade;
|
|
|
|
guint32 timestamp;
|
|
|
|
|
|
|
|
/* Stupid protocol has no timestamp; of course, shading
|
|
|
|
* sucks anyway so who really cares that we're forced to do
|
|
|
|
* a roundtrip here?
|
|
|
|
*/
|
|
|
|
timestamp = meta_display_get_current_time_roundtrip (window->display);
|
|
|
|
|
|
|
|
shade = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->shaded));
|
|
|
|
if (shade && window->has_shade_func)
|
|
|
|
meta_window_shade (window, timestamp);
|
|
|
|
else
|
|
|
|
meta_window_unshade (window, timestamp);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_FULLSCREEN ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_FULLSCREEN)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
gboolean make_fullscreen;
|
|
|
|
|
|
|
|
make_fullscreen = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->fullscreen));
|
|
|
|
if (make_fullscreen && window->has_fullscreen_func)
|
|
|
|
meta_window_make_fullscreen (window);
|
|
|
|
else
|
|
|
|
meta_window_unmake_fullscreen (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_MAXIMIZED_HORZ ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_MAXIMIZED_HORZ ||
|
|
|
|
first == x11_display->atom__NET_WM_STATE_MAXIMIZED_VERT ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_MAXIMIZED_VERT)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
gboolean max;
|
|
|
|
MetaMaximizeFlags directions = 0;
|
|
|
|
|
|
|
|
max = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE &&
|
|
|
|
!window->maximized_horizontally));
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_MAXIMIZED_HORZ ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_MAXIMIZED_HORZ)
|
2014-01-23 16:33:53 -05:00
|
|
|
directions |= META_MAXIMIZE_HORIZONTAL;
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_MAXIMIZED_VERT ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_MAXIMIZED_VERT)
|
2014-01-23 16:33:53 -05:00
|
|
|
directions |= META_MAXIMIZE_VERTICAL;
|
|
|
|
|
|
|
|
if (max && window->has_maximize_func)
|
|
|
|
{
|
|
|
|
if (meta_prefs_get_raise_on_click ())
|
|
|
|
meta_window_raise (window);
|
|
|
|
meta_window_maximize (window, directions);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (meta_prefs_get_raise_on_click ())
|
|
|
|
meta_window_raise (window);
|
|
|
|
meta_window_unmaximize (window, directions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_MODAL ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_MODAL)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2014-03-18 13:07:50 -04:00
|
|
|
priv->wm_state_modal =
|
2014-01-23 16:33:53 -05:00
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
2014-03-18 13:07:50 -04:00
|
|
|
(action == _NET_WM_STATE_TOGGLE && !priv->wm_state_modal);
|
2014-01-23 16:33:53 -05:00
|
|
|
|
2014-03-13 16:49:17 -04:00
|
|
|
meta_window_x11_recalc_window_type (window);
|
2014-01-23 16:33:53 -05:00
|
|
|
meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_SKIP_PAGER ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_SKIP_PAGER)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2014-03-18 11:20:22 -04:00
|
|
|
priv->wm_state_skip_pager =
|
2014-01-23 16:33:53 -05:00
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->skip_pager);
|
|
|
|
|
|
|
|
meta_window_recalc_features (window);
|
|
|
|
meta_window_x11_set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_SKIP_TASKBAR ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_SKIP_TASKBAR)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2014-03-18 11:20:22 -04:00
|
|
|
priv->wm_state_skip_taskbar =
|
2014-01-23 16:33:53 -05:00
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->skip_taskbar);
|
|
|
|
|
|
|
|
meta_window_recalc_features (window);
|
|
|
|
meta_window_x11_set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_ABOVE ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_ABOVE)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
if ((action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_demands_attention))
|
|
|
|
meta_window_make_above (window);
|
|
|
|
else
|
|
|
|
meta_window_unmake_above (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_BELOW ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_BELOW)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
window->wm_state_below =
|
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_below);
|
|
|
|
|
|
|
|
meta_window_update_layer (window);
|
|
|
|
meta_window_x11_set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_DEMANDS_ATTENTION ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_DEMANDS_ATTENTION)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
if ((action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_demands_attention))
|
|
|
|
meta_window_set_demands_attention (window);
|
|
|
|
else
|
|
|
|
meta_window_unset_demands_attention (window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (first == x11_display->atom__NET_WM_STATE_STICKY ||
|
|
|
|
second == x11_display->atom__NET_WM_STATE_STICKY)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
if ((action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->on_all_workspaces_requested))
|
|
|
|
meta_window_stick (window);
|
|
|
|
else
|
|
|
|
meta_window_unstick (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom_WM_CHANGE_STATE)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
meta_verbose ("WM_CHANGE_STATE client message, state: %ld\n",
|
|
|
|
event->xclient.data.l[0]);
|
2015-11-16 18:31:55 -05:00
|
|
|
if (event->xclient.data.l[0] == IconicState)
|
2014-01-23 16:33:53 -05:00
|
|
|
meta_window_minimize (window);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_MOVERESIZE)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
int x_root;
|
|
|
|
int y_root;
|
|
|
|
int action;
|
|
|
|
MetaGrabOp op;
|
|
|
|
int button;
|
|
|
|
guint32 timestamp;
|
|
|
|
|
|
|
|
/* _NET_WM_MOVERESIZE messages are almost certainly going to come from
|
|
|
|
* clients when users click on the fake "frame" that the client has,
|
|
|
|
* thus we should also treat such messages as though it were a
|
|
|
|
* "frame action".
|
|
|
|
*/
|
|
|
|
gboolean const frame_action = TRUE;
|
|
|
|
|
|
|
|
x_root = event->xclient.data.l[0];
|
|
|
|
y_root = event->xclient.data.l[1];
|
|
|
|
action = event->xclient.data.l[2];
|
|
|
|
button = event->xclient.data.l[3];
|
|
|
|
|
|
|
|
/* FIXME: What a braindead protocol; no timestamp?!? */
|
|
|
|
timestamp = meta_display_get_current_time_roundtrip (display);
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d, button %d\n",
|
|
|
|
window->desc,
|
|
|
|
x_root, y_root, action, button);
|
|
|
|
|
|
|
|
op = META_GRAB_OP_NONE;
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPLEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_NW;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOP:
|
|
|
|
op = META_GRAB_OP_RESIZING_N;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPRIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_NE;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_RIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_E;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_SE;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOM:
|
|
|
|
op = META_GRAB_OP_RESIZING_S;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_SW;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_LEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_W;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE:
|
|
|
|
op = META_GRAB_OP_MOVING;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_KEYBOARD:
|
|
|
|
op = META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE_KEYBOARD:
|
|
|
|
op = META_GRAB_OP_KEYBOARD_MOVING;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_CANCEL:
|
|
|
|
/* handled below */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == _NET_WM_MOVERESIZE_CANCEL)
|
|
|
|
{
|
|
|
|
meta_display_end_grab_op (window->display, timestamp);
|
|
|
|
}
|
|
|
|
else if (op != META_GRAB_OP_NONE &&
|
|
|
|
((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) ||
|
|
|
|
(window->has_resize_func && op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)))
|
|
|
|
{
|
|
|
|
meta_window_begin_grab_op (window, op, frame_action, timestamp);
|
|
|
|
}
|
|
|
|
else if (op != META_GRAB_OP_NONE &&
|
|
|
|
((window->has_move_func && op == META_GRAB_OP_MOVING) ||
|
|
|
|
(window->has_resize_func &&
|
|
|
|
(op != META_GRAB_OP_MOVING &&
|
|
|
|
op != META_GRAB_OP_KEYBOARD_MOVING))))
|
|
|
|
{
|
|
|
|
int button_mask;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Beginning move/resize with button = %d\n", button);
|
|
|
|
meta_display_begin_grab_op (window->display,
|
|
|
|
window->screen,
|
|
|
|
window,
|
|
|
|
op,
|
|
|
|
FALSE,
|
|
|
|
frame_action,
|
|
|
|
button, 0,
|
|
|
|
timestamp,
|
|
|
|
x_root,
|
|
|
|
y_root);
|
|
|
|
|
|
|
|
button_mask = query_pressed_buttons (window);
|
|
|
|
|
|
|
|
if (button == 0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* the button SHOULD already be included in the message
|
|
|
|
*/
|
|
|
|
if ((button_mask & (1 << 1)) != 0)
|
|
|
|
button = 1;
|
|
|
|
else if ((button_mask & (1 << 2)) != 0)
|
|
|
|
button = 2;
|
|
|
|
else if ((button_mask & (1 << 3)) != 0)
|
|
|
|
button = 3;
|
|
|
|
|
|
|
|
if (button != 0)
|
|
|
|
window->display->grab_button = button;
|
|
|
|
else
|
|
|
|
meta_display_end_grab_op (window->display,
|
|
|
|
timestamp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* There is a potential race here. If the user presses and
|
|
|
|
* releases their mouse button very fast, it's possible for
|
|
|
|
* both the ButtonPress and ButtonRelease to be sent to the
|
|
|
|
* client before it can get a chance to send _NET_WM_MOVERESIZE
|
|
|
|
* to us. When that happens, we'll become stuck in a grab
|
|
|
|
* state, as we haven't received a ButtonRelease to cancel the
|
|
|
|
* grab.
|
|
|
|
*
|
|
|
|
* We can solve this by querying after we take the explicit
|
|
|
|
* pointer grab -- if the button isn't pressed, we cancel the
|
|
|
|
* drag immediately.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((button_mask & (1 << button)) == 0)
|
|
|
|
meta_display_end_grab_op (window->display, timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_MOVERESIZE_WINDOW)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
int gravity;
|
|
|
|
guint value_mask;
|
|
|
|
|
|
|
|
gravity = (event->xclient.data.l[0] & 0xff);
|
|
|
|
value_mask = (event->xclient.data.l[0] & 0xf00) >> 8;
|
|
|
|
/* source = (event->xclient.data.l[0] & 0xf000) >> 12; */
|
|
|
|
|
|
|
|
if (gravity == 0)
|
|
|
|
gravity = window->size_hints.win_gravity;
|
|
|
|
|
|
|
|
meta_window_move_resize_request(window,
|
|
|
|
value_mask,
|
|
|
|
gravity,
|
|
|
|
event->xclient.data.l[1], /* x */
|
|
|
|
event->xclient.data.l[2], /* y */
|
|
|
|
event->xclient.data.l[3], /* width */
|
|
|
|
event->xclient.data.l[4]); /* height */
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_ACTIVE_WINDOW)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
|
|
|
MetaClientType source_indication;
|
|
|
|
guint32 timestamp;
|
|
|
|
|
|
|
|
meta_verbose ("_NET_ACTIVE_WINDOW request for window '%s', activating\n",
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
source_indication = event->xclient.data.l[0];
|
|
|
|
timestamp = event->xclient.data.l[1];
|
|
|
|
|
|
|
|
if (source_indication > META_CLIENT_TYPE_MAX_RECOGNIZED)
|
|
|
|
source_indication = META_CLIENT_TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
if (timestamp == 0)
|
|
|
|
{
|
|
|
|
/* Client using older EWMH _NET_ACTIVE_WINDOW without a timestamp */
|
|
|
|
meta_warning ("Buggy client sent a _NET_ACTIVE_WINDOW message with a "
|
|
|
|
"timestamp of 0 for %s\n",
|
|
|
|
window->desc);
|
|
|
|
timestamp = meta_display_get_current_time (display);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_activate_full (window, timestamp, source_indication, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_WM_FULLSCREEN_MONITORS)
|
2014-01-23 16:33:53 -05:00
|
|
|
{
|
2016-11-29 04:50:17 -05:00
|
|
|
MetaLogicalMonitor *top, *bottom, *left, *right;
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
meta_verbose ("_NET_WM_FULLSCREEN_MONITORS request for window '%s'\n",
|
|
|
|
window->desc);
|
|
|
|
|
2016-11-29 04:50:17 -05:00
|
|
|
top =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_xinerama_index_to_logical_monitor (window->display->x11_display,
|
|
|
|
event->xclient.data.l[0]);
|
2016-11-29 04:50:17 -05:00
|
|
|
bottom =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_xinerama_index_to_logical_monitor (window->display->x11_display,
|
|
|
|
event->xclient.data.l[1]);
|
2016-11-29 04:50:17 -05:00
|
|
|
left =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_xinerama_index_to_logical_monitor (window->display->x11_display,
|
|
|
|
event->xclient.data.l[2]);
|
2016-11-29 04:50:17 -05:00
|
|
|
right =
|
2017-08-26 15:28:04 -04:00
|
|
|
meta_x11_display_xinerama_index_to_logical_monitor (window->display->x11_display,
|
|
|
|
event->xclient.data.l[3]);
|
2014-01-23 16:33:53 -05:00
|
|
|
/* source_indication = event->xclient.data.l[4]; */
|
|
|
|
|
|
|
|
meta_window_update_fullscreen_monitors (window, top, bottom, left, right);
|
|
|
|
}
|
2014-03-13 17:13:22 -04:00
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__GTK_SHOW_WINDOW_MENU)
|
2014-03-13 17:13:22 -04:00
|
|
|
{
|
2014-05-22 08:35:11 -04:00
|
|
|
gulong x, y;
|
|
|
|
|
|
|
|
/* l[0] is device_id, which we don't use */
|
|
|
|
x = event->xclient.data.l[1];
|
|
|
|
y = event->xclient.data.l[2];
|
|
|
|
|
2014-05-23 17:14:51 -04:00
|
|
|
meta_window_show_menu (window, META_WINDOW_MENU_WM, x, y);
|
2014-03-13 17:13:22 -04:00
|
|
|
}
|
2017-09-29 10:57:22 -04:00
|
|
|
else if (event->xclient.message_type ==
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom__NET_RESTACK_WINDOW)
|
2017-09-29 10:57:22 -04:00
|
|
|
{
|
|
|
|
handle_net_restack_window (display, event);
|
|
|
|
}
|
2014-01-23 16:33:53 -05:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
set_wm_state_on_xwindow (MetaDisplay *display,
|
|
|
|
Window xwindow,
|
|
|
|
int state)
|
|
|
|
{
|
|
|
|
unsigned long data[2];
|
|
|
|
|
|
|
|
/* Mutter doesn't use icon windows, so data[1] should be None
|
|
|
|
* according to the ICCCM 2.0 Section 4.1.3.1.
|
|
|
|
*/
|
|
|
|
data[0] = state;
|
|
|
|
data[1] = None;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (display->x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (display->x11_display->xdisplay, xwindow,
|
|
|
|
display->x11_display->atom_WM_STATE,
|
|
|
|
display->x11_display->atom_WM_STATE,
|
2014-02-01 19:19:22 -05:00
|
|
|
32, PropModeReplace, (guchar*) data, 2);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (display->x11_display);
|
2014-02-01 19:19:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_set_wm_state (MetaWindow *window)
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
|
|
|
|
if (window->withdrawn)
|
|
|
|
state = WithdrawnState;
|
|
|
|
else if (window->iconic)
|
|
|
|
state = IconicState;
|
|
|
|
else
|
|
|
|
state = NormalState;
|
|
|
|
|
|
|
|
set_wm_state_on_xwindow (window->display, window->xwindow, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The MUTTER_WM_CLASS_FILTER environment variable is designed for
|
|
|
|
* performance and regression testing environments where we want to do
|
|
|
|
* tests with only a limited set of windows and ignore all other windows
|
|
|
|
*
|
|
|
|
* When it is set to a comma separated list of WM_CLASS class names, all
|
|
|
|
* windows not matching the list will be ignored.
|
|
|
|
*
|
|
|
|
* Returns TRUE if window has been filtered out and should be ignored.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
maybe_filter_xwindow (MetaDisplay *display,
|
|
|
|
Window xwindow,
|
|
|
|
gboolean must_be_viewable,
|
|
|
|
XWindowAttributes *attrs)
|
|
|
|
{
|
|
|
|
static char **filter_wm_classes = NULL;
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
XClassHint class_hint;
|
|
|
|
gboolean filtered;
|
|
|
|
Status success;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
const char *filter_string = g_getenv ("MUTTER_WM_CLASS_FILTER");
|
|
|
|
if (filter_string)
|
|
|
|
filter_wm_classes = g_strsplit (filter_string, ",", -1);
|
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!filter_wm_classes || !filter_wm_classes[0])
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
filtered = TRUE;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (display->x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
success = XGetClassHint (display->x11_display->xdisplay,
|
|
|
|
xwindow, &class_hint);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
for (i = 0; filter_wm_classes[i]; i++)
|
|
|
|
{
|
|
|
|
if (strcmp (class_hint.res_class, filter_wm_classes[i]) == 0)
|
|
|
|
{
|
|
|
|
filtered = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree (class_hint.res_name);
|
|
|
|
XFree (class_hint.res_class);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filtered)
|
|
|
|
{
|
|
|
|
/* We want to try and get the window managed by the next WM that come along,
|
|
|
|
* so we need to make sure that windows that are requested to be mapped while
|
|
|
|
* Mutter is running (!must_be_viewable), or windows already viewable at startup
|
|
|
|
* get a non-withdrawn WM_STATE property. Previously unmapped windows are left
|
|
|
|
* with whatever WM_STATE property they had.
|
|
|
|
*/
|
|
|
|
if (!must_be_viewable || attrs->map_state == IsViewable)
|
|
|
|
{
|
2015-06-23 18:32:07 -04:00
|
|
|
uint32_t old_state;
|
2014-02-01 19:19:22 -05:00
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (!meta_prop_get_cardinal_with_atom_type (display->x11_display, xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
display->x11_display->atom_WM_STATE,
|
|
|
|
display->x11_display->atom_WM_STATE,
|
2014-02-01 19:19:22 -05:00
|
|
|
&old_state))
|
|
|
|
old_state = WithdrawnState;
|
|
|
|
|
|
|
|
if (old_state == WithdrawnState)
|
|
|
|
set_wm_state_on_xwindow (display, xwindow, NormalState);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure filtered windows are hidden from view */
|
2017-08-26 12:26:30 -04:00
|
|
|
XUnmapWindow (display->x11_display->xdisplay, xwindow);
|
2014-02-01 19:19:22 -05:00
|
|
|
}
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (display->x11_display);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
return filtered;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2017-08-26 14:51:28 -04:00
|
|
|
is_our_xwindow (MetaX11Display *x11_display,
|
2014-02-01 19:19:22 -05:00
|
|
|
Window xwindow,
|
|
|
|
XWindowAttributes *attrs)
|
|
|
|
{
|
2017-08-26 14:51:28 -04:00
|
|
|
if (xwindow == x11_display->no_focus_window)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (xwindow == x11_display->wm_sn_selection_window)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (xwindow == x11_display->wm_cm_selection_window)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (xwindow == x11_display->guard_window)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (xwindow == x11_display->composite_overlay_window)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
2014-08-15 10:52:44 -04:00
|
|
|
{
|
2014-08-15 12:37:15 -04:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
|
|
|
|
if (META_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
if (xwindow == meta_backend_x11_get_xwindow (META_BACKEND_X11 (backend)))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-08-15 10:52:44 -04:00
|
|
|
}
|
|
|
|
|
2014-02-01 19:19:22 -05:00
|
|
|
/* Any windows created via meta_create_offscreen_window */
|
2014-02-03 17:01:34 -05:00
|
|
|
if (attrs->override_redirect && attrs->x == -100 && attrs->y == -100 && attrs->width == 1 && attrs->height == 1)
|
2014-02-01 19:19:22 -05:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_VERBOSE_MODE
|
|
|
|
static const char*
|
|
|
|
wm_state_to_string (int state)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case NormalState:
|
|
|
|
return "NormalState";
|
|
|
|
case IconicState:
|
|
|
|
return "IconicState";
|
|
|
|
case WithdrawnState:
|
|
|
|
return "WithdrawnState";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MetaWindow *
|
|
|
|
meta_window_x11_new (MetaDisplay *display,
|
|
|
|
Window xwindow,
|
|
|
|
gboolean must_be_viewable,
|
|
|
|
MetaCompEffect effect)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = display->x11_display;
|
2013-10-03 18:31:09 -04:00
|
|
|
MetaScreen *screen = display->screen;
|
2014-02-01 19:19:22 -05:00
|
|
|
XWindowAttributes attrs;
|
|
|
|
gulong existing_wm_state;
|
|
|
|
MetaWindow *window = NULL;
|
|
|
|
gulong event_mask;
|
|
|
|
|
|
|
|
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (meta_x11_display_xwindow_is_a_no_focus_window (x11_display, xwindow))
|
2014-02-01 19:19:22 -05:00
|
|
|
{
|
|
|
|
meta_verbose ("Not managing no_focus_window 0x%lx\n",
|
|
|
|
xwindow);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display); /* Push a trap over all of window
|
|
|
|
* creation, to reduce XSync() calls
|
|
|
|
*/
|
2014-02-01 19:19:22 -05:00
|
|
|
/*
|
|
|
|
* This function executes without any server grabs held. This means that
|
|
|
|
* the window could have already gone away, or could go away at any point,
|
|
|
|
* so we must be careful with X error handling.
|
|
|
|
*/
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (!XGetWindowAttributes (x11_display->xdisplay, xwindow, &attrs))
|
2014-02-01 19:19:22 -05:00
|
|
|
{
|
|
|
|
meta_verbose ("Failed to get attributes for window 0x%lx\n",
|
|
|
|
xwindow);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
if (attrs.root != x11_display->xroot)
|
2014-02-01 19:19:22 -05:00
|
|
|
{
|
2013-10-03 18:31:09 -04:00
|
|
|
meta_verbose ("Not on our screen\n");
|
|
|
|
goto error;
|
2014-02-01 19:19:22 -05:00
|
|
|
}
|
|
|
|
|
2017-10-15 16:44:11 -04:00
|
|
|
if (attrs.class == InputOnly)
|
|
|
|
{
|
|
|
|
meta_verbose ("Not managing InputOnly windows\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-08-26 14:51:28 -04:00
|
|
|
if (is_our_xwindow (x11_display, xwindow, &attrs))
|
2014-02-01 19:19:22 -05:00
|
|
|
{
|
|
|
|
meta_verbose ("Not managing our own windows\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maybe_filter_xwindow (display, xwindow, must_be_viewable, &attrs))
|
|
|
|
{
|
|
|
|
meta_verbose ("Not managing filtered window\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
existing_wm_state = WithdrawnState;
|
|
|
|
if (must_be_viewable && attrs.map_state != IsViewable)
|
|
|
|
{
|
|
|
|
/* Only manage if WM_STATE is IconicState or NormalState */
|
2015-06-23 18:32:07 -04:00
|
|
|
uint32_t state;
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
/* WM_STATE isn't a cardinal, it's type WM_STATE, but is an int */
|
2017-08-26 14:51:28 -04:00
|
|
|
if (!(meta_prop_get_cardinal_with_atom_type (x11_display, xwindow,
|
2017-08-26 12:26:30 -04:00
|
|
|
x11_display->atom_WM_STATE,
|
|
|
|
x11_display->atom_WM_STATE,
|
2014-02-01 19:19:22 -05:00
|
|
|
&state) &&
|
|
|
|
(state == IconicState || state == NormalState)))
|
|
|
|
{
|
|
|
|
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
existing_wm_state = state;
|
|
|
|
meta_verbose ("WM_STATE of %lx = %s\n", xwindow,
|
|
|
|
wm_state_to_string (existing_wm_state));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XAddToSaveSet can only be called on windows created by a different
|
|
|
|
* client. with Mutter we want to be able to create manageable windows
|
|
|
|
* from within the process (such as a dummy desktop window). As we do not
|
|
|
|
* want this call failing to prevent the window from being managed, we
|
|
|
|
* call this before creating the return-checked error trap.
|
|
|
|
*/
|
2017-08-26 12:26:30 -04:00
|
|
|
XAddToSaveSet (x11_display->xdisplay, xwindow);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
2014-03-20 16:26:14 -04:00
|
|
|
event_mask = PropertyChangeMask;
|
2014-02-01 19:19:22 -05:00
|
|
|
if (attrs.override_redirect)
|
|
|
|
event_mask |= StructureNotifyMask;
|
|
|
|
|
|
|
|
/* If the window is from this client (a menu, say) we need to augment
|
|
|
|
* the event mask, not replace it. For windows from other clients,
|
|
|
|
* attrs.your_event_mask will be empty at this point.
|
|
|
|
*/
|
2017-08-26 12:26:30 -04:00
|
|
|
XSelectInput (x11_display->xdisplay, xwindow, attrs.your_event_mask | event_mask);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
|
|
|
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
|
|
|
|
|
|
|
XISetMask (mask.mask, XI_Enter);
|
|
|
|
XISetMask (mask.mask, XI_Leave);
|
|
|
|
XISetMask (mask.mask, XI_FocusIn);
|
|
|
|
XISetMask (mask.mask, XI_FocusOut);
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
XISelectEvents (x11_display->xdisplay, xwindow, &mask, 1);
|
2014-02-01 19:19:22 -05:00
|
|
|
}
|
|
|
|
|
2017-08-26 12:28:53 -04:00
|
|
|
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
|
2017-08-26 12:26:30 -04:00
|
|
|
XShapeSelectInput (x11_display->xdisplay, xwindow, ShapeNotifyMask);
|
2014-02-24 19:29:50 -05:00
|
|
|
|
2014-02-01 19:19:22 -05:00
|
|
|
/* Get rid of any borders */
|
|
|
|
if (attrs.border_width != 0)
|
2017-08-26 12:26:30 -04:00
|
|
|
XSetWindowBorderWidth (x11_display->xdisplay, xwindow, 0);
|
2014-02-01 19:19:22 -05:00
|
|
|
|
|
|
|
/* Get rid of weird gravities */
|
|
|
|
if (attrs.win_gravity != NorthWestGravity)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes set_attrs;
|
|
|
|
|
|
|
|
set_attrs.win_gravity = NorthWestGravity;
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeWindowAttributes (x11_display->xdisplay,
|
2014-02-01 19:19:22 -05:00
|
|
|
xwindow,
|
|
|
|
CWWinGravity,
|
|
|
|
&set_attrs);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
if (meta_error_trap_pop_with_return (x11_display) != Success)
|
2014-02-01 19:19:22 -05:00
|
|
|
{
|
|
|
|
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
|
|
|
xwindow);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
window = _meta_window_shared_new (display,
|
|
|
|
screen,
|
|
|
|
META_WINDOW_CLIENT_TYPE_X11,
|
|
|
|
NULL,
|
|
|
|
xwindow,
|
|
|
|
existing_wm_state,
|
|
|
|
effect,
|
|
|
|
&attrs);
|
2014-04-24 16:00:28 -04:00
|
|
|
|
2014-05-20 09:19:10 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
|
|
|
priv->border_width = attrs.border_width;
|
|
|
|
|
2014-04-24 16:00:28 -04:00
|
|
|
meta_window_grab_keys (window);
|
|
|
|
if (window->type != META_WINDOW_DOCK && !window->override_redirect)
|
|
|
|
{
|
|
|
|
meta_display_grab_window_buttons (window->display, window->xwindow);
|
|
|
|
meta_display_grab_focus_window_button (window->display, window);
|
|
|
|
}
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display); /* pop the XSync()-reducing trap */
|
2014-02-01 19:19:22 -05:00
|
|
|
return window;
|
|
|
|
|
|
|
|
error:
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-02-01 19:19:22 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-03-13 16:49:17 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_recalc_window_type (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-03-18 13:07:50 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
2014-03-13 16:52:31 -04:00
|
|
|
MetaWindowType type;
|
2014-03-13 16:49:17 -04:00
|
|
|
|
2014-03-18 21:15:49 -04:00
|
|
|
if (priv->type_atom != None)
|
2014-03-13 16:49:17 -04:00
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_DESKTOP)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DESKTOP;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_DOCK)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DOCK;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_TOOLBAR)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_TOOLBAR;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_MENU)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_MENU;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_UTILITY)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_UTILITY;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_SPLASH)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_SPLASHSCREEN;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_DIALOG)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DIALOG;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_NORMAL)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_NORMAL;
|
2014-03-13 16:49:17 -04:00
|
|
|
/* The below are *typically* override-redirect windows, but the spec does
|
|
|
|
* not disallow using them for managed windows.
|
|
|
|
*/
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_DROPDOWN_MENU)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DROPDOWN_MENU;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_POPUP_MENU)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_POPUP_MENU;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_TOOLTIP)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_TOOLTIP;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_NOTIFICATION)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_NOTIFICATION;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_COMBO)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_COMBO;
|
2017-08-26 12:26:30 -04:00
|
|
|
else if (priv->type_atom == x11_display->atom__NET_WM_WINDOW_TYPE_DND)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DND;
|
2014-03-13 16:49:17 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char *atom_name;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fallback on a normal type, and print warning. Don't abort.
|
|
|
|
*/
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_NORMAL;
|
2014-03-13 16:49:17 -04:00
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
atom_name = XGetAtomName (x11_display->xdisplay,
|
2014-03-18 21:15:49 -04:00
|
|
|
priv->type_atom);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-03-13 16:49:17 -04:00
|
|
|
|
|
|
|
meta_warning ("Unrecognized type atom [%s] set for %s \n",
|
|
|
|
atom_name ? atom_name : "unknown",
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
if (atom_name)
|
|
|
|
XFree (atom_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (window->transient_for != NULL)
|
|
|
|
{
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_DIALOG;
|
2014-03-13 16:49:17 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_NORMAL;
|
2014-03-13 16:49:17 -04:00
|
|
|
}
|
|
|
|
|
2014-03-18 13:07:50 -04:00
|
|
|
if (type == META_WINDOW_DIALOG && priv->wm_state_modal)
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_MODAL_DIALOG;
|
2014-03-13 16:49:17 -04:00
|
|
|
|
|
|
|
/* We don't want to allow override-redirect windows to have decorated-window
|
|
|
|
* types since that's just confusing.
|
|
|
|
*/
|
|
|
|
if (window->override_redirect)
|
|
|
|
{
|
2014-06-07 05:48:55 -04:00
|
|
|
switch (type)
|
2014-03-13 16:49:17 -04:00
|
|
|
{
|
|
|
|
/* Decorated types */
|
|
|
|
case META_WINDOW_NORMAL:
|
|
|
|
case META_WINDOW_DIALOG:
|
|
|
|
case META_WINDOW_MODAL_DIALOG:
|
|
|
|
case META_WINDOW_MENU:
|
|
|
|
case META_WINDOW_UTILITY:
|
2014-03-13 16:52:31 -04:00
|
|
|
type = META_WINDOW_OVERRIDE_OTHER;
|
2014-03-13 16:49:17 -04:00
|
|
|
break;
|
|
|
|
/* Undecorated types, normally not override-redirect */
|
|
|
|
case META_WINDOW_DESKTOP:
|
|
|
|
case META_WINDOW_DOCK:
|
|
|
|
case META_WINDOW_TOOLBAR:
|
|
|
|
case META_WINDOW_SPLASHSCREEN:
|
|
|
|
/* Undecorated types, normally override-redirect types */
|
|
|
|
case META_WINDOW_DROPDOWN_MENU:
|
|
|
|
case META_WINDOW_POPUP_MENU:
|
|
|
|
case META_WINDOW_TOOLTIP:
|
|
|
|
case META_WINDOW_NOTIFICATION:
|
|
|
|
case META_WINDOW_COMBO:
|
|
|
|
case META_WINDOW_DND:
|
|
|
|
/* To complete enum */
|
|
|
|
case META_WINDOW_OVERRIDE_OTHER:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_verbose ("Calculated type %u for %s, old type %u\n",
|
2014-03-13 16:52:31 -04:00
|
|
|
type, window->desc, type);
|
|
|
|
meta_window_set_type (window, type);
|
2014-03-13 16:49:17 -04:00
|
|
|
}
|
2014-03-18 10:36:00 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_window_x11_configure_notify: (skip)
|
|
|
|
* @window: a #MetaWindow
|
|
|
|
* @event: a #XConfigureEvent
|
|
|
|
*
|
|
|
|
* This is used to notify us of an unrequested configuration
|
|
|
|
* (only applicable to override redirect windows)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_window_x11_configure_notify (MetaWindow *window,
|
|
|
|
XConfigureEvent *event)
|
|
|
|
{
|
2014-06-03 11:21:22 -04:00
|
|
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
|
|
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
|
|
|
|
2014-03-18 10:36:00 -04:00
|
|
|
g_assert (window->override_redirect);
|
|
|
|
g_assert (window->frame == NULL);
|
|
|
|
|
|
|
|
window->rect.x = event->x;
|
|
|
|
window->rect.y = event->y;
|
|
|
|
window->rect.width = event->width;
|
|
|
|
window->rect.height = event->height;
|
2014-06-03 11:21:22 -04:00
|
|
|
|
|
|
|
priv->client_rect = window->rect;
|
2014-06-17 11:03:29 -04:00
|
|
|
window->buffer_rect = window->rect;
|
2014-06-03 11:21:22 -04:00
|
|
|
|
2014-06-20 12:06:40 -04:00
|
|
|
meta_window_update_monitor (window, FALSE);
|
2014-03-18 10:36:00 -04:00
|
|
|
|
|
|
|
/* Whether an override-redirect window is considered fullscreen depends
|
|
|
|
* on its geometry.
|
|
|
|
*/
|
|
|
|
if (window->override_redirect)
|
2017-08-26 15:10:38 -04:00
|
|
|
meta_display_queue_check_fullscreen (window->display);
|
2014-03-18 10:36:00 -04:00
|
|
|
|
|
|
|
if (!event->override_redirect && !event->send_event)
|
|
|
|
meta_warning ("Unhandled change of windows override redirect status\n");
|
|
|
|
|
2014-03-18 17:06:42 -04:00
|
|
|
meta_compositor_sync_window_geometry (window->display->compositor, window, FALSE);
|
2014-03-18 10:36:00 -04:00
|
|
|
}
|
2014-04-29 15:18:40 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_set_allowed_actions_hint (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-04-29 15:18:40 -04:00
|
|
|
#define MAX_N_ACTIONS 12
|
|
|
|
unsigned long data[MAX_N_ACTIONS];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if (window->has_move_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_MOVE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->has_resize_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_RESIZE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->has_fullscreen_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_FULLSCREEN;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->has_minimize_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_MINIMIZE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->has_shade_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_SHADE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
/* sticky according to EWMH is different from mutter's sticky;
|
|
|
|
* mutter doesn't support EWMH sticky
|
|
|
|
*/
|
|
|
|
if (window->has_maximize_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_MAXIMIZE_HORZ;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_MAXIMIZE_VERT;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
/* We always allow this */
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_CHANGE_DESKTOP;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
if (window->has_close_func)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_CLOSE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* I guess we always allow above/below operations */
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_ABOVE;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
2017-08-26 12:26:30 -04:00
|
|
|
data[i] = x11_display->atom__NET_WM_ACTION_BELOW;
|
2014-04-29 15:18:40 -04:00
|
|
|
++i;
|
|
|
|
|
|
|
|
g_assert (i <= MAX_N_ACTIONS);
|
|
|
|
|
|
|
|
meta_verbose ("Setting _NET_WM_ALLOWED_ACTIONS with %d atoms\n", i);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 12:26:30 -04:00
|
|
|
XChangeProperty (x11_display->xdisplay, window->xwindow,
|
|
|
|
x11_display->atom__NET_WM_ALLOWED_ACTIONS,
|
2014-04-29 15:18:40 -04:00
|
|
|
XA_ATOM,
|
|
|
|
32, PropModeReplace, (guchar*) data, i);
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-04-29 15:18:40 -04:00
|
|
|
#undef MAX_N_ACTIONS
|
|
|
|
}
|
2014-04-29 16:59:54 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_create_sync_request_alarm (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
2014-04-29 16:59:54 -04:00
|
|
|
XSyncAlarmAttributes values;
|
|
|
|
XSyncValue init;
|
|
|
|
|
|
|
|
if (window->sync_request_counter == None ||
|
|
|
|
window->sync_request_alarm != None)
|
|
|
|
return;
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_push (x11_display);
|
2014-04-29 16:59:54 -04:00
|
|
|
|
|
|
|
/* In the new (extended style), the counter value is initialized by
|
|
|
|
* the client before mapping the window. In the old style, we're
|
|
|
|
* responsible for setting the initial value of the counter.
|
|
|
|
*/
|
|
|
|
if (window->extended_sync_request_counter)
|
|
|
|
{
|
2017-08-26 12:26:30 -04:00
|
|
|
if (!XSyncQueryCounter(x11_display->xdisplay,
|
2014-04-29 16:59:54 -04:00
|
|
|
window->sync_request_counter,
|
|
|
|
&init))
|
|
|
|
{
|
2017-08-26 12:27:50 -04:00
|
|
|
meta_error_trap_pop_with_return (x11_display);
|
2014-04-29 16:59:54 -04:00
|
|
|
window->sync_request_counter = None;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window->sync_request_serial =
|
|
|
|
XSyncValueLow32 (init) + ((gint64)XSyncValueHigh32 (init) << 32);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XSyncIntToValue (&init, 0);
|
2017-08-26 12:26:30 -04:00
|
|
|
XSyncSetCounter (x11_display->xdisplay,
|
2014-04-29 16:59:54 -04:00
|
|
|
window->sync_request_counter, init);
|
|
|
|
window->sync_request_serial = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
values.trigger.counter = window->sync_request_counter;
|
|
|
|
values.trigger.test_type = XSyncPositiveComparison;
|
|
|
|
|
|
|
|
/* Initialize to one greater than the current value */
|
|
|
|
values.trigger.value_type = XSyncRelative;
|
|
|
|
XSyncIntToValue (&values.trigger.wait_value, 1);
|
|
|
|
|
|
|
|
/* After triggering, increment test_value by this until
|
|
|
|
* until the test condition is false */
|
|
|
|
XSyncIntToValue (&values.delta, 1);
|
|
|
|
|
|
|
|
/* we want events (on by default anyway) */
|
|
|
|
values.events = True;
|
|
|
|
|
2017-08-26 12:26:30 -04:00
|
|
|
window->sync_request_alarm = XSyncCreateAlarm (x11_display->xdisplay,
|
2014-04-29 16:59:54 -04:00
|
|
|
XSyncCACounter |
|
|
|
|
XSyncCAValueType |
|
|
|
|
XSyncCAValue |
|
|
|
|
XSyncCATestType |
|
|
|
|
XSyncCADelta |
|
|
|
|
XSyncCAEvents,
|
|
|
|
&values);
|
|
|
|
|
2017-08-26 12:27:50 -04:00
|
|
|
if (meta_error_trap_pop_with_return (x11_display) == Success)
|
2017-08-26 12:56:44 -04:00
|
|
|
meta_x11_display_register_sync_alarm (x11_display, &window->sync_request_alarm, window);
|
2014-04-29 16:59:54 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
window->sync_request_alarm = None;
|
|
|
|
window->sync_request_counter = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_destroy_sync_request_alarm (MetaWindow *window)
|
|
|
|
{
|
2017-08-26 12:56:44 -04:00
|
|
|
MetaX11Display *x11_display = window->display->x11_display;
|
|
|
|
|
2014-04-29 16:59:54 -04:00
|
|
|
if (window->sync_request_alarm != None)
|
|
|
|
{
|
|
|
|
/* Has to be unregistered _before_ clearing the structure field */
|
2017-08-26 12:56:44 -04:00
|
|
|
meta_x11_display_unregister_sync_alarm (x11_display, window->sync_request_alarm);
|
|
|
|
XSyncDestroyAlarm (x11_display->xdisplay,
|
2014-04-29 16:59:54 -04:00
|
|
|
window->sync_request_alarm);
|
|
|
|
window->sync_request_alarm = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_x11_update_sync_request_counter (MetaWindow *window,
|
|
|
|
gint64 new_counter_value)
|
|
|
|
{
|
|
|
|
gboolean needs_frame_drawn = FALSE;
|
|
|
|
gboolean no_delay_frame = FALSE;
|
|
|
|
|
|
|
|
if (window->extended_sync_request_counter && new_counter_value % 2 == 0)
|
|
|
|
{
|
|
|
|
needs_frame_drawn = TRUE;
|
|
|
|
no_delay_frame = new_counter_value == window->sync_request_serial + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
window->sync_request_serial = new_counter_value;
|
2014-06-17 13:06:10 -04:00
|
|
|
meta_compositor_sync_updates_frozen (window->display->compositor, window);
|
2014-04-29 16:59:54 -04:00
|
|
|
|
2015-03-12 13:41:57 -04:00
|
|
|
if (window == window->display->grab_window &&
|
|
|
|
meta_grab_op_is_resizing (window->display->grab_op) &&
|
|
|
|
new_counter_value >= window->sync_request_wait_serial &&
|
|
|
|
(!window->extended_sync_request_counter || new_counter_value % 2 == 0) &&
|
|
|
|
window->sync_request_timeout_id)
|
2014-04-29 16:59:54 -04:00
|
|
|
{
|
2015-03-12 13:41:57 -04:00
|
|
|
meta_topic (META_DEBUG_RESIZING,
|
|
|
|
"Alarm event received last motion x = %d y = %d\n",
|
|
|
|
window->display->grab_latest_motion_x,
|
|
|
|
window->display->grab_latest_motion_y);
|
2014-04-29 16:59:54 -04:00
|
|
|
|
2015-03-12 13:41:57 -04:00
|
|
|
g_source_remove (window->sync_request_timeout_id);
|
|
|
|
window->sync_request_timeout_id = 0;
|
|
|
|
|
|
|
|
/* This means we are ready for another configure;
|
|
|
|
* no pointer round trip here, to keep in sync */
|
|
|
|
meta_window_update_resize (window,
|
|
|
|
window->display->grab_last_user_action_was_snap,
|
|
|
|
window->display->grab_latest_motion_x,
|
|
|
|
window->display->grab_latest_motion_y,
|
|
|
|
TRUE);
|
2014-04-29 16:59:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If sync was previously disabled, turn it back on and hope
|
|
|
|
* the application has come to its senses (maybe it was just
|
|
|
|
* busy with a pagefault or a long computation).
|
|
|
|
*/
|
|
|
|
window->disable_sync = FALSE;
|
|
|
|
|
|
|
|
if (needs_frame_drawn)
|
|
|
|
meta_compositor_queue_frame_drawn (window->display->compositor, window,
|
|
|
|
no_delay_frame);
|
|
|
|
}
|
2014-06-16 18:25:40 -04:00
|
|
|
|
|
|
|
Window
|
|
|
|
meta_window_x11_get_toplevel_xwindow (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return window->frame ? window->frame->xwindow : window->xwindow;
|
|
|
|
}
|