Compare commits
117 Commits
3.12.0-way
...
wip/ui-on-
Author | SHA1 | Date | |
---|---|---|---|
5bc7ae4095 | |||
1a78515606 | |||
4122257bce | |||
29f6e3bda5 | |||
bbcbf5820f | |||
ee7c58984a | |||
03e5bbf59f | |||
cc6becb163 | |||
e3b855a583 | |||
5d8dd0653e | |||
abe94827f5 | |||
72b88c929e | |||
4752776ebf | |||
c40868b239 | |||
a21e7a2188 | |||
371fba6843 | |||
be02fa1120 | |||
43730f1660 | |||
4f609dbf5e | |||
2a7d12ba14 | |||
c4c0b5f0ab | |||
8373c90cd8 | |||
eb5b54dd8b | |||
9653b79a35 | |||
e07bd15fc2 | |||
5cf0740b4e | |||
c540ddf59b | |||
a44295599c | |||
af272f2685 | |||
81d033ec73 | |||
e9ee984921 | |||
3c404c5db3 | |||
e4cd000cef | |||
6296fefea6 | |||
c1e3a6b742 | |||
dcd83b7365 | |||
617b00dfbd | |||
94692414cb | |||
ab6bc76bfd | |||
57803f1d59 | |||
67b6737b27 | |||
29396014fd | |||
899d4d8477 | |||
f1c7063ee7 | |||
216ff7ebe5 | |||
34cc5efb90 | |||
bce1d5117b | |||
d5552cc372 | |||
fd392cc1e7 | |||
b641d9d5a8 | |||
5bcc78498f | |||
521125b672 | |||
89b931435d | |||
e22e9f5df5 | |||
20547e3b63 | |||
2cf185b4e4 | |||
229360b248 | |||
ccced506ed | |||
28b9160c01 | |||
ba6584a0d7 | |||
2a0289a216 | |||
f6a73bcf22 | |||
59e064f610 | |||
ba131626c2 | |||
30ebf46aa4 | |||
da27735265 | |||
78dbf8cb56 | |||
f4e299ca46 | |||
f95f2b0c6d | |||
fe42a4eb4e | |||
565883dadb | |||
be60e4f6e7 | |||
fa60824096 | |||
0efb0b47eb | |||
0f810a4e21 | |||
383d4c7e4e | |||
21425b5833 | |||
863569b702 | |||
5f52f55916 | |||
0aec98cf02 | |||
b64d14ff4a | |||
08a8254deb | |||
11de01741c | |||
a7ea2cd365 | |||
a15a4faff0 | |||
b93176d89a | |||
f842ea6d15 | |||
422f2e5fe6 | |||
3961f291e4 | |||
61d8b35254 | |||
78457cf7b4 | |||
1e2bdcc3c5 | |||
490e1c8c3b | |||
9a751a95e3 | |||
afce448281 | |||
b2405b701a | |||
390c028da7 | |||
82e02e39d3 | |||
0f9b29b140 | |||
b367965f6c | |||
ed9dbf6aa2 | |||
e10fd19d24 | |||
f4f529385a | |||
3f70bdd331 | |||
6eeaf09ab7 | |||
cd905a34fb | |||
47aa583625 | |||
d7519f4ebc | |||
97ea4e8717 | |||
208296a619 | |||
cc0488f1e2 | |||
e30ed6892c | |||
d699b2409a | |||
ef65848d11 | |||
272676b896 | |||
44580ddb80 | |||
456e3e2429 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -75,7 +75,7 @@ src/mutter-enum-types.[ch]
|
||||
src/stamp-mutter-enum-types.h
|
||||
src/mutter-marshal.[ch]
|
||||
src/stamp-mutter-marshal.h
|
||||
src/meta-dbus-xrandr.[ch]
|
||||
src/meta-dbus-display-config.[ch]
|
||||
src/meta-dbus-idle-monitor.[ch]
|
||||
src/mutter-plugins.pc
|
||||
src/gtk-shell-protocol.c
|
||||
@ -108,3 +108,4 @@ ltoptions.m4
|
||||
ltsugar.m4
|
||||
ltversion.m4
|
||||
lt~obsolete.m4
|
||||
.dirstamp
|
||||
|
@ -16,7 +16,7 @@ AC_INIT([mutter], [mutter_version],
|
||||
AC_CONFIG_SRCDIR(src/core/display.c)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz tar-ustar])
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz tar-ustar subdir-objects])
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
|
||||
@ -133,7 +133,7 @@ AC_ARG_WITH([wayland-protocols],
|
||||
AC_ARG_WITH([xwayland-path],
|
||||
[AS_HELP_STRING([--with-xwayland-path], [Absolute path for an X Wayland server])],
|
||||
[XWAYLAND_PATH="$withval"],
|
||||
[XWAYLAND_PATH="$bindir/Xorg"])
|
||||
[XWAYLAND_PATH="$bindir/Xwayland"])
|
||||
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
|
||||
@ -480,7 +480,6 @@ mutter-wayland-$VERSION
|
||||
Session management: ${found_sm}
|
||||
Shape extension: ${found_shape}
|
||||
Xsync: ${found_xsync}
|
||||
Xcursor: ${have_xcursor}
|
||||
"
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@ INCLUDES= \
|
||||
$(MUTTER_CFLAGS) \
|
||||
-I$(top_builddir) \
|
||||
-I$(srcdir) \
|
||||
-I$(srcdir)/backends \
|
||||
-I$(srcdir)/core \
|
||||
-I$(srcdir)/ui \
|
||||
-I$(srcdir)/compositor \
|
||||
@ -34,22 +35,49 @@ INCLUDES= \
|
||||
|
||||
mutter_built_sources = \
|
||||
$(dbus_idle_built_sources) \
|
||||
$(dbus_xrandr_built_sources) \
|
||||
$(dbus_display_config_built_sources) \
|
||||
mutter-enum-types.h \
|
||||
mutter-enum-types.c \
|
||||
gtk-shell-protocol.c \
|
||||
gtk-shell-server-protocol.h \
|
||||
xdg-shell-protocol.c \
|
||||
xdg-shell-server-protocol.h \
|
||||
xserver-protocol.c \
|
||||
xserver-server-protocol.h
|
||||
xdg-shell-server-protocol.h
|
||||
|
||||
wayland_protocols = \
|
||||
wayland/protocol/gtk-shell.xml \
|
||||
wayland/protocol/xdg-shell.xml \
|
||||
wayland/protocol/xserver.xml
|
||||
wayland/protocol/xdg-shell.xml
|
||||
|
||||
libmutter_wayland_la_SOURCES = \
|
||||
backends/meta-backend.c \
|
||||
backends/meta-backend.h \
|
||||
backends/meta-cursor.c \
|
||||
backends/meta-cursor.h \
|
||||
backends/meta-cursor-private.h \
|
||||
backends/meta-cursor-tracker.c \
|
||||
backends/meta-cursor-tracker-private.h \
|
||||
backends/meta-idle-monitor.c \
|
||||
backends/meta-idle-monitor-private.h \
|
||||
backends/meta-idle-monitor-dbus.c \
|
||||
backends/meta-idle-monitor-dbus.h \
|
||||
backends/meta-monitor-config.c \
|
||||
backends/meta-monitor-config.h \
|
||||
backends/meta-monitor-manager.c \
|
||||
backends/meta-monitor-manager.h \
|
||||
backends/meta-monitor-manager-dummy.c \
|
||||
backends/meta-monitor-manager-dummy.h \
|
||||
backends/edid-parse.c \
|
||||
backends/edid.h \
|
||||
backends/native/meta-idle-monitor-native.c \
|
||||
backends/native/meta-idle-monitor-native.h \
|
||||
backends/native/meta-monitor-manager-kms.c \
|
||||
backends/native/meta-monitor-manager-kms.h \
|
||||
backends/native/meta-weston-launch.c \
|
||||
backends/native/meta-weston-launch.h \
|
||||
backends/x11/meta-idle-monitor-xsync.c \
|
||||
backends/x11/meta-idle-monitor-xsync.h \
|
||||
backends/x11/meta-monitor-manager-xrandr.c \
|
||||
backends/x11/meta-monitor-manager-xrandr.h \
|
||||
backends/x11/meta-xrandr-shared.h \
|
||||
core/above-tab-keycode.c \
|
||||
core/barrier.c \
|
||||
meta/barrier.h \
|
||||
@ -114,8 +142,6 @@ libmutter_wayland_la_SOURCES = \
|
||||
meta/display.h \
|
||||
core/edge-resistance.c \
|
||||
core/edge-resistance.h \
|
||||
core/edid-parse.c \
|
||||
core/edid.h \
|
||||
core/events.c \
|
||||
core/events.h \
|
||||
core/errors.c \
|
||||
@ -127,17 +153,6 @@ libmutter_wayland_la_SOURCES = \
|
||||
core/keybindings.c \
|
||||
core/keybindings-private.h \
|
||||
core/main.c \
|
||||
core/meta-cursor-tracker.c \
|
||||
core/meta-cursor-tracker-private.h \
|
||||
core/meta-idle-monitor.c \
|
||||
core/meta-idle-monitor-private.h \
|
||||
core/meta-xrandr-shared.h \
|
||||
core/monitor.c \
|
||||
core/monitor-config.c \
|
||||
core/monitor-kms.c \
|
||||
core/monitor-private.h \
|
||||
core/monitor-xrandr.c \
|
||||
core/mutter-Xatomtype.h \
|
||||
core/place.c \
|
||||
core/place.h \
|
||||
core/prefs.c \
|
||||
@ -192,11 +207,13 @@ libmutter_wayland_la_SOURCES = \
|
||||
x11/window-x11-private.h \
|
||||
x11/xprops.c \
|
||||
x11/xprops.h \
|
||||
x11/mutter-Xatomtype.h \
|
||||
wayland/meta-wayland.c \
|
||||
wayland/meta-wayland.h \
|
||||
wayland/meta-wayland-private.h \
|
||||
wayland/meta-xwayland-private.h \
|
||||
wayland/meta-xwayland.c \
|
||||
wayland/meta-xwayland.h \
|
||||
wayland/meta-xwayland-private.h \
|
||||
wayland/meta-wayland-data-device.c \
|
||||
wayland/meta-wayland-data-device.h \
|
||||
wayland/meta-wayland-keyboard.c \
|
||||
@ -211,8 +228,6 @@ libmutter_wayland_la_SOURCES = \
|
||||
wayland/meta-wayland-surface.h \
|
||||
wayland/meta-wayland-types.h \
|
||||
wayland/meta-wayland-versions.h \
|
||||
wayland/meta-weston-launch.c \
|
||||
wayland/meta-weston-launch.h \
|
||||
wayland/window-wayland.c \
|
||||
wayland/window-wayland.h
|
||||
|
||||
@ -271,7 +286,9 @@ mutter_wayland_LDADD = $(MUTTER_LIBS) libmutter-wayland.la
|
||||
|
||||
bin_PROGRAMS+=mutter-launch
|
||||
|
||||
mutter_launch_SOURCES = wayland/weston-launch.c wayland/weston-launch.h
|
||||
mutter_launch_SOURCES = \
|
||||
backends/native/weston-launch.c \
|
||||
backends/native/weston-launch.h
|
||||
|
||||
mutter_launch_CFLAGS = $(MUTTER_LAUNCH_CFLAGS) -DLIBDIR=\"$(libdir)\"
|
||||
mutter_launch_LDFLAGS = $(MUTTER_LAUNCH_LIBS) -lpam
|
||||
@ -373,7 +390,8 @@ EXTRA_DIST=$(desktopfiles_files) \
|
||||
libmutter-wayland.pc.in \
|
||||
mutter-enum-types.h.in \
|
||||
mutter-enum-types.c.in \
|
||||
xrandr.xml idle-monitor.xml
|
||||
org.gnome.Mutter.DisplayConfig.xml \
|
||||
org.gnome.Mutter.IdleMonitor.xml
|
||||
|
||||
BUILT_SOURCES = $(mutter_built_sources)
|
||||
MUTTER_STAMP_FILES = stamp-mutter-enum-types.h
|
||||
@ -398,23 +416,22 @@ mutter-enum-types.c: stamp-mutter-enum-types.h mutter-enum-types.c.in
|
||||
cp xgen-tetc mutter-enum-types.c && \
|
||||
rm -f xgen-tetc
|
||||
|
||||
dbus_xrandr_built_sources = meta-dbus-xrandr.c meta-dbus-xrandr.h
|
||||
dbus_display_config_built_sources = meta-dbus-display-config.c meta-dbus-display-config.h
|
||||
|
||||
$(dbus_xrandr_built_sources) : Makefile.am xrandr.xml
|
||||
$(dbus_display_config_built_sources) : Makefile.am org.gnome.Mutter.DisplayConfig.xml
|
||||
$(AM_V_GEN)gdbus-codegen \
|
||||
--interface-prefix org.gnome.Mutter \
|
||||
--c-namespace MetaDBus \
|
||||
--generate-c-code meta-dbus-xrandr \
|
||||
$(srcdir)/xrandr.xml
|
||||
--generate-c-code meta-dbus-display-config \
|
||||
$(srcdir)/org.gnome.Mutter.DisplayConfig.xml
|
||||
|
||||
|
||||
$(dbus_idle_built_sources) : Makefile.am idle-monitor.xml
|
||||
$(dbus_idle_built_sources) : Makefile.am org.gnome.Mutter.IdleMonitor.xml
|
||||
$(AM_V_GEN)gdbus-codegen \
|
||||
--interface-prefix org.gnome.Mutter \
|
||||
--c-namespace MetaDBus \
|
||||
--generate-c-code meta-dbus-idle-monitor \
|
||||
--c-generate-object-manager \
|
||||
$(srcdir)/idle-monitor.xml
|
||||
$(srcdir)/org.gnome.Mutter.IdleMonitor.xml
|
||||
|
||||
%-protocol.c : $(srcdir)/wayland/protocol/%.xml
|
||||
$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
|
||||
|
157
src/backends/meta-backend.c
Normal file
157
src/backends/meta-backend.c
Normal file
@ -0,0 +1,157 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-backend.h"
|
||||
#include <meta/main.h>
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include <clutter/x11/clutter-x11.h>
|
||||
|
||||
#include "backends/native/meta-weston-launch.h"
|
||||
#include <meta/util.h>
|
||||
|
||||
/* Mutter is responsible for pulling events off the X queue, so Clutter
|
||||
* doesn't need (and shouldn't) run its normal event source which polls
|
||||
* the X fd, but we do have to deal with dispatching events that accumulate
|
||||
* in the clutter queue. This happens, for example, when clutter generate
|
||||
* enter/leave events on mouse motion - several events are queued in the
|
||||
* clutter queue but only one dispatched. It could also happen because of
|
||||
* explicit calls to clutter_event_put(). We add a very simple custom
|
||||
* event loop source which is simply responsible for pulling events off
|
||||
* of the queue and dispatching them before we block for new events.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
event_prepare (GSource *source,
|
||||
gint *timeout_)
|
||||
{
|
||||
*timeout_ = -1;
|
||||
|
||||
return clutter_events_pending ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_check (GSource *source)
|
||||
{
|
||||
return clutter_events_pending ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_dispatch (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterEvent *event = clutter_event_get ();
|
||||
|
||||
if (event)
|
||||
{
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs event_funcs = {
|
||||
event_prepare,
|
||||
event_check,
|
||||
event_dispatch
|
||||
};
|
||||
|
||||
static MetaLauncher *launcher;
|
||||
|
||||
void
|
||||
meta_clutter_init (void)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
/* When running as an X11 compositor, we install our own event filter and
|
||||
* pass events to Clutter explicitly, so we need to prevent Clutter from
|
||||
* handling our events.
|
||||
*
|
||||
* However, when running as a Wayland compostior under X11 nested, Clutter
|
||||
* Clutter needs to see events related to its own window. We need to
|
||||
* eventually replace this with a proper frontend / backend split: Clutter
|
||||
* under nested is connecting to the "host X server" to get its events it
|
||||
* needs to put up a window, and GTK+ is connecting to the "inner X server".
|
||||
* The two would the same in the X11 compositor case, but not when running
|
||||
* XWayland as a Wayland compositor.
|
||||
*/
|
||||
if (!meta_is_wayland_compositor ())
|
||||
{
|
||||
clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
|
||||
clutter_x11_disable_event_retrieval ();
|
||||
}
|
||||
|
||||
/* If we're running on bare metal, we're a display server,
|
||||
* so start talking to weston-launch. */
|
||||
#if defined(CLUTTER_WINDOWING_EGL)
|
||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL))
|
||||
launcher = meta_launcher_new ();
|
||||
#endif
|
||||
|
||||
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
|
||||
g_error ("Unable to initialize Clutter.\n");
|
||||
|
||||
source = g_source_new (&event_funcs, sizeof (GSource));
|
||||
g_source_attach (source, NULL);
|
||||
g_source_unref (source);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_activate_vt (int vt, GError **error)
|
||||
{
|
||||
if (launcher)
|
||||
return meta_launcher_activate_vt (launcher, vt, error);
|
||||
else
|
||||
{
|
||||
g_debug ("Ignoring VT switch keybinding, not running as display server");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_activate_session:
|
||||
*
|
||||
* Tells mutter to activate the session. When mutter is a
|
||||
* Wayland compositor, this tells logind to switch over to
|
||||
* the new session.
|
||||
*/
|
||||
gboolean
|
||||
meta_activate_session (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!meta_launcher_activate_vt (launcher, -1, &error))
|
||||
{
|
||||
g_warning ("Could not activate session: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
34
src/backends/meta-backend.h
Normal file
34
src/backends/meta-backend.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#ifndef META_BACKEND_H
|
||||
#define META_BACKEND_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
void meta_clutter_init (void);
|
||||
|
||||
gboolean meta_activate_vt (int vt, GError **error);
|
||||
|
||||
#endif /* META_BACKEND_H */
|
50
src/backends/meta-cursor-private.h
Normal file
50
src/backends/meta-cursor-private.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef META_CURSOR_PRIVATE_H
|
||||
#define META_CURSOR_PRIVATE_H
|
||||
|
||||
#include "meta-cursor.h"
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
#include <gbm.h>
|
||||
|
||||
typedef struct {
|
||||
CoglTexture2D *texture;
|
||||
struct gbm_bo *bo;
|
||||
int hot_x, hot_y;
|
||||
} MetaCursorImage;
|
||||
|
||||
struct _MetaCursorReference {
|
||||
int ref_count;
|
||||
|
||||
MetaCursorImage image;
|
||||
};
|
||||
|
||||
CoglTexture *meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y);
|
||||
|
||||
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y);
|
||||
|
||||
#endif /* META_CURSOR_PRIVATE_H */
|
98
src/backends/meta-cursor-tracker-private.h
Normal file
98
src/backends/meta-cursor-tracker-private.h
Normal file
@ -0,0 +1,98 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef META_CURSOR_TRACKER_PRIVATE_H
|
||||
#define META_CURSOR_TRACKER_PRIVATE_H
|
||||
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "meta-cursor.h"
|
||||
|
||||
struct _MetaCursorTracker {
|
||||
GObject parent_instance;
|
||||
|
||||
MetaScreen *screen;
|
||||
|
||||
gboolean is_showing;
|
||||
gboolean has_hw_cursor;
|
||||
|
||||
/* The cursor tracker stores the cursor for the current grab
|
||||
* operation, the cursor for the window with pointer focus, and
|
||||
* the cursor for the root window, which contains either the
|
||||
* default arrow cursor or the 'busy' hourglass if we're launching
|
||||
* an app.
|
||||
*
|
||||
* We choose the first one available -- if there's a grab cursor,
|
||||
* we choose that cursor, if there's window cursor, we choose that,
|
||||
* otherwise we choose the root cursor.
|
||||
*
|
||||
* The displayed_cursor contains the chosen cursor.
|
||||
*/
|
||||
MetaCursorReference *displayed_cursor;
|
||||
|
||||
MetaCursorReference *grab_cursor;
|
||||
|
||||
/* Wayland clients can set a NULL buffer as their cursor
|
||||
* explicitly, which means that we shouldn't display anything.
|
||||
* So, we can't simply store a NULL in window_cursor to
|
||||
* determine an unset window cursor; we need an extra boolean.
|
||||
*/
|
||||
gboolean has_window_cursor;
|
||||
MetaCursorReference *window_cursor;
|
||||
|
||||
MetaCursorReference *root_cursor;
|
||||
|
||||
MetaCursorReference *theme_cursors[META_CURSOR_LAST];
|
||||
|
||||
int current_x, current_y;
|
||||
MetaRectangle current_rect;
|
||||
MetaRectangle previous_rect;
|
||||
gboolean previous_is_valid;
|
||||
|
||||
CoglPipeline *pipeline;
|
||||
int drm_fd;
|
||||
struct gbm_device *gbm;
|
||||
};
|
||||
|
||||
struct _MetaCursorTrackerClass {
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
gboolean meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
|
||||
XEvent *xevent);
|
||||
|
||||
void meta_cursor_tracker_set_grab_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor);
|
||||
void meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor);
|
||||
void meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker);
|
||||
void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor);
|
||||
|
||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||
int new_x,
|
||||
int new_y);
|
||||
void meta_cursor_tracker_paint (MetaCursorTracker *tracker);
|
||||
|
||||
void meta_cursor_tracker_force_update (MetaCursorTracker *tracker);
|
||||
|
||||
#endif
|
@ -41,77 +41,13 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include "meta-cursor-private.h"
|
||||
#include "meta-cursor-tracker-private.h"
|
||||
#include "screen-private.h"
|
||||
#include "monitor-private.h"
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
|
||||
#define META_WAYLAND_DEFAULT_CURSOR_HOTSPOT_X 7
|
||||
#define META_WAYLAND_DEFAULT_CURSOR_HOTSPOT_Y 4
|
||||
|
||||
typedef struct {
|
||||
CoglTexture2D *texture;
|
||||
struct gbm_bo *bo;
|
||||
int hot_x, hot_y;
|
||||
|
||||
int ref_count;
|
||||
} MetaCursorReference;
|
||||
|
||||
struct _MetaCursorTracker {
|
||||
GObject parent_instance;
|
||||
|
||||
MetaScreen *screen;
|
||||
|
||||
gboolean is_showing;
|
||||
gboolean has_hw_cursor;
|
||||
|
||||
/* The cursor tracker stores the cursor for the current grab
|
||||
* operation, the cursor for the window with pointer focus, and
|
||||
* the cursor for the root window, which contains either the
|
||||
* default arrow cursor or the 'busy' hourglass if we're launching
|
||||
* an app.
|
||||
*
|
||||
* We choose the first one available -- if there's a grab cursor,
|
||||
* we choose that cursor, if there's window cursor, we choose that,
|
||||
* otherwise we choose the root cursor.
|
||||
*
|
||||
* The displayed_cursor contains the chosen cursor.
|
||||
*/
|
||||
MetaCursorReference *displayed_cursor;
|
||||
|
||||
MetaCursorReference *grab_cursor;
|
||||
|
||||
/* Wayland clients can set a NULL buffer as their cursor
|
||||
* explicitly, which means that we shouldn't display anything.
|
||||
* So, we can't simply store a NULL in window_cursor to
|
||||
* determine an unset window cursor; we need an extra boolean.
|
||||
*/
|
||||
gboolean has_window_cursor;
|
||||
MetaCursorReference *window_cursor;
|
||||
|
||||
MetaCursorReference *root_cursor;
|
||||
|
||||
MetaCursorReference *default_cursors[META_CURSOR_LAST];
|
||||
|
||||
int current_x, current_y;
|
||||
MetaRectangle current_rect;
|
||||
MetaRectangle previous_rect;
|
||||
gboolean previous_is_valid;
|
||||
|
||||
CoglPipeline *pipeline;
|
||||
int drm_fd;
|
||||
struct gbm_device *gbm;
|
||||
};
|
||||
|
||||
struct _MetaCursorTrackerClass {
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaCursorTracker, meta_cursor_tracker, G_TYPE_OBJECT);
|
||||
|
||||
enum {
|
||||
@ -126,360 +62,6 @@ static void meta_cursor_tracker_set_crtc_has_hw_cursor (MetaCursorTracker *track
|
||||
gboolean has_hw_cursor);
|
||||
static void sync_cursor (MetaCursorTracker *tracker);
|
||||
|
||||
static MetaCursorReference *
|
||||
meta_cursor_reference_ref (MetaCursorReference *self)
|
||||
{
|
||||
g_assert (self->ref_count > 0);
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_reference_unref (MetaCursorReference *self)
|
||||
{
|
||||
self->ref_count--;
|
||||
|
||||
if (self->ref_count == 0)
|
||||
{
|
||||
cogl_object_unref (self->texture);
|
||||
if (self->bo)
|
||||
gbm_bo_destroy (self->bo);
|
||||
|
||||
g_slice_free (MetaCursorReference, self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
translate_meta_cursor (MetaCursor cursor,
|
||||
guint *glyph_out,
|
||||
const char **name_out)
|
||||
{
|
||||
guint glyph = XC_num_glyphs;
|
||||
const char *name = NULL;
|
||||
|
||||
switch (cursor)
|
||||
{
|
||||
case META_CURSOR_DEFAULT:
|
||||
glyph = XC_left_ptr;
|
||||
break;
|
||||
case META_CURSOR_NORTH_RESIZE:
|
||||
glyph = XC_top_side;
|
||||
break;
|
||||
case META_CURSOR_SOUTH_RESIZE:
|
||||
glyph = XC_bottom_side;
|
||||
break;
|
||||
case META_CURSOR_WEST_RESIZE:
|
||||
glyph = XC_left_side;
|
||||
break;
|
||||
case META_CURSOR_EAST_RESIZE:
|
||||
glyph = XC_right_side;
|
||||
break;
|
||||
case META_CURSOR_SE_RESIZE:
|
||||
glyph = XC_bottom_right_corner;
|
||||
break;
|
||||
case META_CURSOR_SW_RESIZE:
|
||||
glyph = XC_bottom_left_corner;
|
||||
break;
|
||||
case META_CURSOR_NE_RESIZE:
|
||||
glyph = XC_top_right_corner;
|
||||
break;
|
||||
case META_CURSOR_NW_RESIZE:
|
||||
glyph = XC_top_left_corner;
|
||||
break;
|
||||
case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
|
||||
glyph = XC_fleur;
|
||||
break;
|
||||
case META_CURSOR_BUSY:
|
||||
glyph = XC_watch;
|
||||
break;
|
||||
case META_CURSOR_DND_IN_DRAG:
|
||||
name = "dnd-none";
|
||||
break;
|
||||
case META_CURSOR_DND_MOVE:
|
||||
name = "dnd-move";
|
||||
break;
|
||||
case META_CURSOR_DND_COPY:
|
||||
name = "dnd-copy";
|
||||
break;
|
||||
case META_CURSOR_DND_UNSUPPORTED_TARGET:
|
||||
name = "dnd-none";
|
||||
break;
|
||||
case META_CURSOR_POINTING_HAND:
|
||||
glyph = XC_hand2;
|
||||
break;
|
||||
case META_CURSOR_CROSSHAIR:
|
||||
glyph = XC_crosshair;
|
||||
break;
|
||||
case META_CURSOR_IBEAM:
|
||||
glyph = XC_xterm;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
glyph = 0; /* silence compiler */
|
||||
break;
|
||||
}
|
||||
|
||||
*glyph_out = glyph;
|
||||
*name_out = name;
|
||||
}
|
||||
|
||||
static Cursor
|
||||
load_cursor_on_server (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
Cursor xcursor;
|
||||
guint glyph;
|
||||
const char *name;
|
||||
|
||||
translate_meta_cursor (cursor, &glyph, &name);
|
||||
|
||||
if (name != NULL)
|
||||
xcursor = XcursorLibraryLoadCursor (display->xdisplay, name);
|
||||
else
|
||||
xcursor = XCreateFontCursor (display->xdisplay, glyph);
|
||||
|
||||
return xcursor;
|
||||
}
|
||||
|
||||
Cursor
|
||||
meta_display_create_x_cursor (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
return load_cursor_on_server (display, cursor);
|
||||
}
|
||||
|
||||
static XcursorImage *
|
||||
load_cursor_on_client (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
XcursorImage *image;
|
||||
guint glyph;
|
||||
const char *name;
|
||||
const char *theme = XcursorGetTheme (display->xdisplay);
|
||||
int size = XcursorGetDefaultSize (display->xdisplay);
|
||||
|
||||
translate_meta_cursor (cursor, &glyph, &name);
|
||||
|
||||
if (name != NULL)
|
||||
image = XcursorLibraryLoadImage (name, theme, size);
|
||||
else
|
||||
image = XcursorShapeLoadImage (glyph, theme, size);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static MetaCursorReference *
|
||||
meta_cursor_reference_from_theme (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
XcursorImage *image;
|
||||
int width, height, rowstride;
|
||||
CoglPixelFormat cogl_format;
|
||||
uint32_t gbm_format;
|
||||
ClutterBackend *clutter_backend;
|
||||
CoglContext *cogl_context;
|
||||
MetaCursorReference *self;
|
||||
|
||||
image = load_cursor_on_client (tracker->screen->display, cursor);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
width = image->width;
|
||||
height = image->height;
|
||||
rowstride = width * 4;
|
||||
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
#else
|
||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
#endif
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
self->hot_x = image->xhot;
|
||||
self->hot_y = image->yhot;
|
||||
|
||||
clutter_backend = clutter_get_default_backend ();
|
||||
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||
self->texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width, height,
|
||||
cogl_format,
|
||||
rowstride,
|
||||
(uint8_t*)image->pixels,
|
||||
NULL);
|
||||
|
||||
if (tracker->gbm)
|
||||
{
|
||||
if (width > 64 || height > 64)
|
||||
{
|
||||
meta_warning ("Invalid theme cursor size (must be at most 64x64)\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (gbm_device_is_format_supported (tracker->gbm, gbm_format,
|
||||
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE))
|
||||
{
|
||||
uint32_t buf[64 * 64];
|
||||
int i;
|
||||
|
||||
self->bo = gbm_bo_create (tracker->gbm, 64, 64,
|
||||
gbm_format, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
|
||||
|
||||
memset (buf, 0, sizeof(buf));
|
||||
for (i = 0; i < height; i++)
|
||||
memcpy (buf + i * 64, image->pixels + i * width, width * 4);
|
||||
|
||||
gbm_bo_write (self->bo, buf, 64 * 64 * 4);
|
||||
}
|
||||
else
|
||||
meta_warning ("HW cursor for format %d not supported\n", gbm_format);
|
||||
}
|
||||
|
||||
out:
|
||||
XcursorImageDestroy (image);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static MetaCursorReference *
|
||||
meta_cursor_reference_take_texture (CoglTexture2D *texture)
|
||||
{
|
||||
MetaCursorReference *self;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
|
||||
self->texture = texture;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static MetaCursorReference *
|
||||
meta_cursor_reference_from_buffer (MetaCursorTracker *tracker,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
ClutterBackend *backend;
|
||||
CoglContext *cogl_context;
|
||||
MetaCursorReference *self;
|
||||
CoglPixelFormat cogl_format;
|
||||
struct wl_shm_buffer *shm_buffer;
|
||||
uint32_t gbm_format;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
self->hot_x = hot_x;
|
||||
self->hot_y = hot_y;
|
||||
|
||||
backend = clutter_get_default_backend ();
|
||||
cogl_context = clutter_backend_get_cogl_context (backend);
|
||||
|
||||
shm_buffer = wl_shm_buffer_get (buffer);
|
||||
if (shm_buffer)
|
||||
{
|
||||
int rowstride = wl_shm_buffer_get_stride (shm_buffer);
|
||||
int width = wl_shm_buffer_get_width (shm_buffer);
|
||||
int height = wl_shm_buffer_get_height (shm_buffer);
|
||||
|
||||
switch (wl_shm_buffer_get_format (shm_buffer))
|
||||
{
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB8888:
|
||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
gbm_format = GBM_FORMAT_XRGB8888;
|
||||
break;
|
||||
#else
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB8888:
|
||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
gbm_format = GBM_FORMAT_XRGB8888;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
self->texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width, height,
|
||||
cogl_format,
|
||||
rowstride,
|
||||
wl_shm_buffer_get_data (shm_buffer),
|
||||
NULL);
|
||||
|
||||
if (width > 64 || height > 64)
|
||||
{
|
||||
meta_warning ("Invalid cursor size (must be at most 64x64), falling back to software (GL) cursors\n");
|
||||
return self;
|
||||
}
|
||||
|
||||
if (tracker->gbm)
|
||||
{
|
||||
if (gbm_device_is_format_supported (tracker->gbm, gbm_format,
|
||||
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE))
|
||||
{
|
||||
uint8_t *data;
|
||||
uint8_t buf[4 * 64 * 64];
|
||||
int i;
|
||||
|
||||
self->bo = gbm_bo_create (tracker->gbm, 64, 64,
|
||||
gbm_format, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
|
||||
|
||||
data = wl_shm_buffer_get_data (shm_buffer);
|
||||
memset (buf, 0, sizeof(buf));
|
||||
for (i = 0; i < height; i++)
|
||||
memcpy (buf + i * 4 * 64, data + i * rowstride, 4 * width);
|
||||
|
||||
gbm_bo_write (self->bo, buf, 64 * 64 * 4);
|
||||
}
|
||||
else
|
||||
meta_warning ("HW cursor for format %d not supported\n", gbm_format);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int width, height;
|
||||
|
||||
self->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
||||
width = cogl_texture_get_width (COGL_TEXTURE (self->texture));
|
||||
height = cogl_texture_get_height (COGL_TEXTURE (self->texture));
|
||||
|
||||
/* HW cursors must be 64x64, but 64x64 is huge, and no cursor theme actually uses
|
||||
that, so themed cursors must be padded with transparent pixels to fill the
|
||||
overlay. This is trivial if we have CPU access to the data, but it's not
|
||||
possible if the buffer is in GPU memory (and possibly tiled too), so if we
|
||||
don't get the right size, we fallback to GL.
|
||||
*/
|
||||
if (width != 64 || height != 64)
|
||||
{
|
||||
meta_warning ("Invalid cursor size (must be 64x64), falling back to software (GL) cursors\n");
|
||||
return self;
|
||||
}
|
||||
|
||||
if (tracker->gbm)
|
||||
{
|
||||
self->bo = gbm_bo_import (tracker->gbm, GBM_BO_IMPORT_WL_BUFFER,
|
||||
buffer, GBM_BO_USE_CURSOR_64X64);
|
||||
if (!self->bo)
|
||||
meta_warning ("Importing HW cursor from wl_buffer failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_tracker_init (MetaCursorTracker *self)
|
||||
{
|
||||
@ -503,8 +85,8 @@ meta_cursor_tracker_finalize (GObject *object)
|
||||
meta_cursor_reference_unref (self->root_cursor);
|
||||
|
||||
for (i = 0; i < META_CURSOR_LAST; i++)
|
||||
if (self->default_cursors[i])
|
||||
meta_cursor_reference_unref (self->default_cursors[i]);
|
||||
if (self->theme_cursors[i])
|
||||
meta_cursor_reference_unref (self->theme_cursors[i]);
|
||||
|
||||
if (self->pipeline)
|
||||
cogl_object_unref (self->pipeline);
|
||||
@ -662,6 +244,22 @@ meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static MetaCursorReference *
|
||||
meta_cursor_reference_take_texture (CoglTexture2D *texture,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
MetaCursorReference *self;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
self->image.texture = texture;
|
||||
self->image.hot_x = hot_x;
|
||||
self->image.hot_y = hot_y;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_xfixes_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
@ -718,10 +316,9 @@ ensure_xfixes_cursor (MetaCursorTracker *tracker)
|
||||
|
||||
if (sprite != NULL)
|
||||
{
|
||||
MetaCursorReference *cursor = meta_cursor_reference_take_texture (sprite);
|
||||
cursor->hot_x = cursor_image->xhot;
|
||||
cursor->hot_y = cursor_image->yhot;
|
||||
|
||||
MetaCursorReference *cursor = meta_cursor_reference_take_texture (sprite,
|
||||
cursor_image->xhot,
|
||||
cursor_image->yhot);
|
||||
set_window_cursor (tracker, TRUE, cursor);
|
||||
}
|
||||
XFree (cursor_image);
|
||||
@ -741,7 +338,7 @@ meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
|
||||
ensure_xfixes_cursor (tracker);
|
||||
|
||||
if (tracker->displayed_cursor)
|
||||
return COGL_TEXTURE (tracker->displayed_cursor->texture);
|
||||
return meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, NULL, NULL);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@ -764,13 +361,7 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
|
||||
ensure_xfixes_cursor (tracker);
|
||||
|
||||
if (tracker->displayed_cursor)
|
||||
{
|
||||
MetaCursorReference *displayed_cursor = tracker->displayed_cursor;
|
||||
if (x)
|
||||
*x = displayed_cursor->hot_x;
|
||||
if (y)
|
||||
*y = displayed_cursor->hot_y;
|
||||
}
|
||||
meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, x, y);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
@ -780,43 +371,21 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
|
||||
}
|
||||
}
|
||||
|
||||
static MetaCursorReference *
|
||||
ensure_wayland_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
if (!tracker->default_cursors[cursor])
|
||||
{
|
||||
tracker->default_cursors[cursor] = meta_cursor_reference_from_theme (tracker, cursor);
|
||||
if (!tracker->default_cursors[cursor])
|
||||
meta_warning ("Failed to load cursor from theme\n");
|
||||
}
|
||||
|
||||
return meta_cursor_reference_ref (tracker->default_cursors[cursor]);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_set_grab_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor)
|
||||
meta_cursor_tracker_set_grab_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor)
|
||||
{
|
||||
g_clear_pointer (&tracker->grab_cursor, meta_cursor_reference_unref);
|
||||
if (cursor != META_CURSOR_DEFAULT)
|
||||
tracker->grab_cursor = ensure_wayland_cursor (tracker, cursor);
|
||||
if (cursor)
|
||||
tracker->grab_cursor = meta_cursor_reference_ref (cursor);
|
||||
|
||||
sync_cursor (tracker);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor)
|
||||
{
|
||||
MetaCursorReference *cursor;
|
||||
|
||||
if (buffer)
|
||||
cursor = meta_cursor_reference_from_buffer (tracker, buffer, hot_x, hot_y);
|
||||
else
|
||||
cursor = NULL;
|
||||
|
||||
set_window_cursor (tracker, TRUE, cursor);
|
||||
}
|
||||
|
||||
@ -827,26 +396,23 @@ meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker)
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor)
|
||||
meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorReference *cursor)
|
||||
{
|
||||
Cursor xcursor;
|
||||
MetaDisplay *display = tracker->screen->display;
|
||||
g_clear_pointer (&tracker->root_cursor, meta_cursor_reference_unref);
|
||||
if (cursor)
|
||||
tracker->root_cursor = meta_cursor_reference_ref (cursor);
|
||||
|
||||
/* First create a cursor for X11 applications that don't specify their own */
|
||||
xcursor = meta_display_create_x_cursor (display, cursor);
|
||||
sync_cursor (tracker);
|
||||
}
|
||||
|
||||
XDefineCursor (display->xdisplay, tracker->screen->xroot, xcursor);
|
||||
XFlush (display->xdisplay);
|
||||
XFreeCursor (display->xdisplay, xcursor);
|
||||
|
||||
/* Now update the real root cursor */
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
g_clear_pointer (&tracker->root_cursor, meta_cursor_reference_unref);
|
||||
tracker->root_cursor = ensure_wayland_cursor (tracker, cursor);
|
||||
sync_cursor (tracker);
|
||||
}
|
||||
static gboolean
|
||||
should_have_hw_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
if (tracker->displayed_cursor)
|
||||
return (meta_cursor_reference_get_gbm_bo (tracker->displayed_cursor, NULL, NULL) != NULL);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -857,7 +423,7 @@ update_hw_cursor (MetaCursorTracker *tracker)
|
||||
unsigned int i, n_crtcs;
|
||||
gboolean enabled;
|
||||
|
||||
enabled = tracker->displayed_cursor && tracker->displayed_cursor->bo != NULL;
|
||||
enabled = should_have_hw_cursor (tracker);
|
||||
tracker->has_hw_cursor = enabled;
|
||||
|
||||
monitors = meta_monitor_manager_get ();
|
||||
@ -918,6 +484,23 @@ get_displayed_cursor (MetaCursorTracker *tracker)
|
||||
return tracker->root_cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
update_displayed_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
if (tracker->displayed_cursor)
|
||||
{
|
||||
CoglTexture *texture = meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, NULL, NULL);
|
||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, texture);
|
||||
}
|
||||
else
|
||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, NULL);
|
||||
|
||||
update_hw_cursor (tracker);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sync_displayed_cursor (MetaCursorTracker *tracker)
|
||||
{
|
||||
@ -930,16 +513,7 @@ sync_displayed_cursor (MetaCursorTracker *tracker)
|
||||
if (displayed_cursor)
|
||||
tracker->displayed_cursor = meta_cursor_reference_ref (displayed_cursor);
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
if (displayed_cursor)
|
||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, COGL_TEXTURE (displayed_cursor->texture));
|
||||
else
|
||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, NULL);
|
||||
|
||||
update_hw_cursor (tracker);
|
||||
}
|
||||
|
||||
update_displayed_cursor (tracker);
|
||||
g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
|
||||
}
|
||||
|
||||
@ -952,14 +526,13 @@ meta_cursor_tracker_queue_redraw (MetaCursorTracker *tracker)
|
||||
|
||||
g_assert (meta_is_wayland_compositor ());
|
||||
|
||||
/* Clear the location the cursor was at before, if we need to. */
|
||||
if (tracker->previous_is_valid)
|
||||
{
|
||||
cairo_rectangle_int_t clip = {
|
||||
.x = tracker->previous_rect.x,
|
||||
.y = tracker->previous_rect.y,
|
||||
.width = tracker->previous_rect.width,
|
||||
.height = tracker->previous_rect.height
|
||||
};
|
||||
clip.x = tracker->previous_rect.x;
|
||||
clip.y = tracker->previous_rect.y;
|
||||
clip.width = tracker->previous_rect.width;
|
||||
clip.height = tracker->previous_rect.height;
|
||||
clutter_actor_queue_redraw_with_clip (stage, &clip);
|
||||
tracker->previous_is_valid = FALSE;
|
||||
}
|
||||
@ -984,10 +557,15 @@ sync_cursor (MetaCursorTracker *tracker)
|
||||
|
||||
if (displayed_cursor)
|
||||
{
|
||||
tracker->current_rect.x = tracker->current_x - displayed_cursor->hot_x;
|
||||
tracker->current_rect.y = tracker->current_y - displayed_cursor->hot_y;
|
||||
tracker->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (displayed_cursor->texture));
|
||||
tracker->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (displayed_cursor->texture));
|
||||
CoglTexture *texture;
|
||||
int hot_x, hot_y;
|
||||
|
||||
texture = meta_cursor_reference_get_cogl_texture (displayed_cursor, &hot_x, &hot_y);
|
||||
|
||||
tracker->current_rect.x = tracker->current_x - hot_x;
|
||||
tracker->current_rect.y = tracker->current_y - hot_y;
|
||||
tracker->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (texture));
|
||||
tracker->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (texture));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1048,15 +626,16 @@ meta_cursor_tracker_set_crtc_has_hw_cursor (MetaCursorTracker *tracker,
|
||||
if (has)
|
||||
{
|
||||
MetaCursorReference *displayed_cursor = tracker->displayed_cursor;
|
||||
struct gbm_bo *bo;
|
||||
union gbm_bo_handle handle;
|
||||
int width, height;
|
||||
int hot_x, hot_y;
|
||||
|
||||
handle = gbm_bo_get_handle (displayed_cursor->bo);
|
||||
width = gbm_bo_get_width (displayed_cursor->bo);
|
||||
height = gbm_bo_get_height (displayed_cursor->bo);
|
||||
hot_x = displayed_cursor->hot_x;
|
||||
hot_y = displayed_cursor->hot_y;
|
||||
bo = meta_cursor_reference_get_gbm_bo (displayed_cursor, &hot_x, &hot_y);
|
||||
|
||||
handle = gbm_bo_get_handle (bo);
|
||||
width = gbm_bo_get_width (bo);
|
||||
height = gbm_bo_get_height (bo);
|
||||
|
||||
drmModeSetCursor2 (tracker->drm_fd, crtc->crtc_id, handle.u32,
|
||||
width, height, hot_x, hot_y);
|
412
src/backends/meta-cursor.c
Normal file
412
src/backends/meta-cursor.c
Normal file
@ -0,0 +1,412 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-cursor-private.h"
|
||||
|
||||
#include <meta/errors.h>
|
||||
|
||||
#include "display-private.h"
|
||||
#include "screen-private.h"
|
||||
#include "meta-cursor-tracker-private.h" /* for tracker->gbm */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include <cogl/cogl-wayland-server.h>
|
||||
|
||||
MetaCursorReference *
|
||||
meta_cursor_reference_ref (MetaCursorReference *self)
|
||||
{
|
||||
g_assert (self->ref_count > 0);
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_image_free (MetaCursorImage *image)
|
||||
{
|
||||
cogl_object_unref (image->texture);
|
||||
if (image->bo)
|
||||
gbm_bo_destroy (image->bo);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_reference_free (MetaCursorReference *self)
|
||||
{
|
||||
meta_cursor_image_free (&self->image);
|
||||
g_slice_free (MetaCursorReference, self);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_reference_unref (MetaCursorReference *self)
|
||||
{
|
||||
self->ref_count--;
|
||||
|
||||
if (self->ref_count == 0)
|
||||
meta_cursor_reference_free (self);
|
||||
}
|
||||
|
||||
static void
|
||||
translate_meta_cursor (MetaCursor cursor,
|
||||
guint *glyph_out,
|
||||
const char **name_out)
|
||||
{
|
||||
guint glyph = XC_num_glyphs;
|
||||
const char *name = NULL;
|
||||
|
||||
switch (cursor)
|
||||
{
|
||||
case META_CURSOR_DEFAULT:
|
||||
glyph = XC_left_ptr;
|
||||
break;
|
||||
case META_CURSOR_NORTH_RESIZE:
|
||||
glyph = XC_top_side;
|
||||
break;
|
||||
case META_CURSOR_SOUTH_RESIZE:
|
||||
glyph = XC_bottom_side;
|
||||
break;
|
||||
case META_CURSOR_WEST_RESIZE:
|
||||
glyph = XC_left_side;
|
||||
break;
|
||||
case META_CURSOR_EAST_RESIZE:
|
||||
glyph = XC_right_side;
|
||||
break;
|
||||
case META_CURSOR_SE_RESIZE:
|
||||
glyph = XC_bottom_right_corner;
|
||||
break;
|
||||
case META_CURSOR_SW_RESIZE:
|
||||
glyph = XC_bottom_left_corner;
|
||||
break;
|
||||
case META_CURSOR_NE_RESIZE:
|
||||
glyph = XC_top_right_corner;
|
||||
break;
|
||||
case META_CURSOR_NW_RESIZE:
|
||||
glyph = XC_top_left_corner;
|
||||
break;
|
||||
case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
|
||||
glyph = XC_fleur;
|
||||
break;
|
||||
case META_CURSOR_BUSY:
|
||||
glyph = XC_watch;
|
||||
break;
|
||||
case META_CURSOR_DND_IN_DRAG:
|
||||
name = "dnd-none";
|
||||
break;
|
||||
case META_CURSOR_DND_MOVE:
|
||||
name = "dnd-move";
|
||||
break;
|
||||
case META_CURSOR_DND_COPY:
|
||||
name = "dnd-copy";
|
||||
break;
|
||||
case META_CURSOR_DND_UNSUPPORTED_TARGET:
|
||||
name = "dnd-none";
|
||||
break;
|
||||
case META_CURSOR_POINTING_HAND:
|
||||
glyph = XC_hand2;
|
||||
break;
|
||||
case META_CURSOR_CROSSHAIR:
|
||||
glyph = XC_crosshair;
|
||||
break;
|
||||
case META_CURSOR_IBEAM:
|
||||
glyph = XC_xterm;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
glyph = 0; /* silence compiler */
|
||||
break;
|
||||
}
|
||||
|
||||
*glyph_out = glyph;
|
||||
*name_out = name;
|
||||
}
|
||||
|
||||
static Cursor
|
||||
load_cursor_on_server (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
Cursor xcursor;
|
||||
guint glyph;
|
||||
const char *name;
|
||||
|
||||
translate_meta_cursor (cursor, &glyph, &name);
|
||||
|
||||
if (name != NULL)
|
||||
xcursor = XcursorLibraryLoadCursor (display->xdisplay, name);
|
||||
else
|
||||
xcursor = XCreateFontCursor (display->xdisplay, glyph);
|
||||
|
||||
return xcursor;
|
||||
}
|
||||
|
||||
Cursor
|
||||
meta_display_create_x_cursor (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
return load_cursor_on_server (display, cursor);
|
||||
}
|
||||
|
||||
static XcursorImage *
|
||||
load_cursor_on_client (MetaDisplay *display,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
XcursorImage *image;
|
||||
guint glyph;
|
||||
const char *name;
|
||||
const char *theme = XcursorGetTheme (display->xdisplay);
|
||||
int size = XcursorGetDefaultSize (display->xdisplay);
|
||||
|
||||
translate_meta_cursor (cursor, &glyph, &name);
|
||||
|
||||
if (name != NULL)
|
||||
image = XcursorLibraryLoadImage (name, theme, size);
|
||||
else
|
||||
image = XcursorShapeLoadImage (glyph, theme, size);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_image_load_gbm_buffer (struct gbm_device *gbm,
|
||||
MetaCursorImage *image,
|
||||
uint8_t *pixels,
|
||||
int width,
|
||||
int height,
|
||||
int rowstride,
|
||||
uint32_t gbm_format)
|
||||
{
|
||||
if (width > 64 || height > 64)
|
||||
{
|
||||
meta_warning ("Invalid theme cursor size (must be at most 64x64)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (gbm_device_is_format_supported (gbm, gbm_format,
|
||||
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE))
|
||||
{
|
||||
uint8_t buf[4 * 64 * 64];
|
||||
int i;
|
||||
|
||||
image->bo = gbm_bo_create (gbm, 64, 64,
|
||||
gbm_format, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
|
||||
|
||||
memset (buf, 0, sizeof(buf));
|
||||
for (i = 0; i < height; i++)
|
||||
memcpy (buf + i * 4 * 64, pixels + i * rowstride, width * 4);
|
||||
|
||||
gbm_bo_write (image->bo, buf, 64 * 64 * 4);
|
||||
}
|
||||
else
|
||||
meta_warning ("HW cursor for format %d not supported\n", gbm_format);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_image_load_from_xcursor_image (MetaCursorTracker *tracker,
|
||||
MetaCursorImage *image,
|
||||
XcursorImage *xc_image)
|
||||
{
|
||||
int width, height, rowstride;
|
||||
CoglPixelFormat cogl_format;
|
||||
uint32_t gbm_format;
|
||||
ClutterBackend *clutter_backend;
|
||||
CoglContext *cogl_context;
|
||||
|
||||
width = xc_image->width;
|
||||
height = xc_image->height;
|
||||
rowstride = width * 4;
|
||||
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
#else
|
||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
#endif
|
||||
|
||||
image->hot_x = xc_image->xhot;
|
||||
image->hot_y = xc_image->yhot;
|
||||
|
||||
clutter_backend = clutter_get_default_backend ();
|
||||
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||
image->texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width, height,
|
||||
cogl_format,
|
||||
rowstride,
|
||||
(uint8_t *) xc_image->pixels,
|
||||
NULL);
|
||||
|
||||
if (tracker->gbm)
|
||||
meta_cursor_image_load_gbm_buffer (tracker->gbm,
|
||||
image,
|
||||
(uint8_t *) xc_image->pixels,
|
||||
width, height, rowstride,
|
||||
gbm_format);
|
||||
}
|
||||
|
||||
MetaCursorReference *
|
||||
meta_cursor_reference_from_theme (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
MetaCursorReference *self;
|
||||
XcursorImage *image;
|
||||
|
||||
if (tracker->theme_cursors[cursor])
|
||||
return meta_cursor_reference_ref (tracker->theme_cursors[cursor]);
|
||||
|
||||
image = load_cursor_on_client (tracker->screen->display, cursor);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
meta_cursor_image_load_from_xcursor_image (tracker, &self->image, image);
|
||||
|
||||
XcursorImageDestroy (image);
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_image_load_from_buffer (MetaCursorTracker *tracker,
|
||||
MetaCursorImage *image,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
ClutterBackend *backend;
|
||||
CoglContext *cogl_context;
|
||||
struct wl_shm_buffer *shm_buffer;
|
||||
uint32_t gbm_format;
|
||||
int width, height;
|
||||
|
||||
image->hot_x = hot_x;
|
||||
image->hot_y = hot_y;
|
||||
|
||||
backend = clutter_get_default_backend ();
|
||||
cogl_context = clutter_backend_get_cogl_context (backend);
|
||||
|
||||
image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
||||
|
||||
width = cogl_texture_get_width (COGL_TEXTURE (image->texture));
|
||||
height = cogl_texture_get_height (COGL_TEXTURE (image->texture));
|
||||
|
||||
shm_buffer = wl_shm_buffer_get (buffer);
|
||||
if (shm_buffer)
|
||||
{
|
||||
if (tracker->gbm)
|
||||
{
|
||||
int rowstride = wl_shm_buffer_get_stride (shm_buffer);
|
||||
|
||||
switch (wl_shm_buffer_get_format (shm_buffer))
|
||||
{
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB8888:
|
||||
gbm_format = GBM_FORMAT_XRGB8888;
|
||||
break;
|
||||
#else
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB8888:
|
||||
gbm_format = GBM_FORMAT_XRGB8888;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
gbm_format = GBM_FORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
meta_cursor_image_load_gbm_buffer (tracker->gbm,
|
||||
image,
|
||||
(uint8_t *) wl_shm_buffer_get_data (shm_buffer),
|
||||
width, height, rowstride,
|
||||
gbm_format);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* HW cursors must be 64x64, but 64x64 is huge, and no cursor theme actually uses
|
||||
that, so themed cursors must be padded with transparent pixels to fill the
|
||||
overlay. This is trivial if we have CPU access to the data, but it's not
|
||||
possible if the buffer is in GPU memory (and possibly tiled too), so if we
|
||||
don't get the right size, we fallback to GL.
|
||||
*/
|
||||
if (width != 64 || height != 64)
|
||||
{
|
||||
meta_warning ("Invalid cursor size (must be 64x64), falling back to software (GL) cursors\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tracker->gbm)
|
||||
{
|
||||
image->bo = gbm_bo_import (tracker->gbm, GBM_BO_IMPORT_WL_BUFFER,
|
||||
buffer, GBM_BO_USE_CURSOR_64X64);
|
||||
if (!image->bo)
|
||||
meta_warning ("Importing HW cursor from wl_buffer failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MetaCursorReference *
|
||||
meta_cursor_reference_from_buffer (MetaCursorTracker *tracker,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
MetaCursorReference *self;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
meta_cursor_image_load_from_buffer (tracker, &self->image, buffer, hot_x, hot_y);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
CoglTexture *
|
||||
meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y)
|
||||
{
|
||||
if (hot_x)
|
||||
*hot_x = cursor->image.hot_x;
|
||||
if (hot_y)
|
||||
*hot_y = cursor->image.hot_y;
|
||||
return COGL_TEXTURE (cursor->image.texture);
|
||||
}
|
||||
|
||||
struct gbm_bo *
|
||||
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y)
|
||||
{
|
||||
if (hot_x)
|
||||
*hot_x = cursor->image.hot_x;
|
||||
if (hot_y)
|
||||
*hot_y = cursor->image.hot_y;
|
||||
return cursor->image.bo;
|
||||
}
|
42
src/backends/meta-cursor.h
Normal file
42
src/backends/meta-cursor.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef META_CURSOR_H
|
||||
#define META_CURSOR_H
|
||||
|
||||
typedef struct _MetaCursorReference MetaCursorReference;
|
||||
|
||||
MetaCursorReference * meta_cursor_reference_ref (MetaCursorReference *cursor);
|
||||
void meta_cursor_reference_unref (MetaCursorReference *cursor);
|
||||
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
#include <meta/common.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
MetaCursorReference * meta_cursor_reference_from_theme (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor);
|
||||
|
||||
MetaCursorReference * meta_cursor_reference_from_buffer (MetaCursorTracker *tracker,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y);
|
||||
|
||||
#endif /* META_CURSOR_H */
|
@ -16,7 +16,7 @@
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* This file is shared between mutter (src/core/meta-xrandr-shared.h)
|
||||
/* This file is shared between mutter (src/core/meta-display-config-shared.h)
|
||||
and gnome-desktop (libgnome-desktop/meta-xrandr-shared.h).
|
||||
|
||||
The canonical place for all changes is mutter.
|
||||
@ -24,8 +24,8 @@
|
||||
There should be no includes in this file.
|
||||
*/
|
||||
|
||||
#ifndef META_XRANDR_SHARED_H
|
||||
#define META_XRANDR_SHARED_H
|
||||
#ifndef META_DISPLAY_CONFIG_SHARED_H
|
||||
#define META_DISPLAY_CONFIG_SHARED_H
|
||||
|
||||
typedef enum {
|
||||
META_POWER_SAVE_UNSUPPORTED = -1,
|
||||
@ -35,4 +35,4 @@ typedef enum {
|
||||
META_POWER_SAVE_OFF,
|
||||
} MetaPowerSave;
|
||||
|
||||
#endif
|
||||
#endif /* META_DISPLAY_CONFIG_SHARED_H */
|
286
src/backends/meta-idle-monitor-dbus.c
Normal file
286
src/backends/meta-idle-monitor-dbus.c
Normal file
@ -0,0 +1,286 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-idle-monitor-dbus.h"
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
#include "meta-dbus-idle-monitor.h"
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include <meta/util.h>
|
||||
#include <meta/main.h> /* for meta_get_replace_current_wm () */
|
||||
|
||||
static gboolean
|
||||
handle_get_idletime (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
guint64 idletime;
|
||||
|
||||
idletime = meta_idle_monitor_get_idletime (monitor);
|
||||
meta_dbus_idle_monitor_complete_get_idletime (skeleton, invocation, idletime);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
MetaDBusIdleMonitor *dbus_monitor;
|
||||
MetaIdleMonitor *monitor;
|
||||
char *dbus_name;
|
||||
guint watch_id;
|
||||
guint name_watcher_id;
|
||||
} DBusWatch;
|
||||
|
||||
static void
|
||||
destroy_dbus_watch (gpointer data)
|
||||
{
|
||||
DBusWatch *watch = data;
|
||||
|
||||
g_object_unref (watch->dbus_monitor);
|
||||
g_object_unref (watch->monitor);
|
||||
g_free (watch->dbus_name);
|
||||
g_bus_unwatch_name (watch->name_watcher_id);
|
||||
|
||||
g_slice_free (DBusWatch, watch);
|
||||
}
|
||||
|
||||
static void
|
||||
dbus_idle_callback (MetaIdleMonitor *monitor,
|
||||
guint watch_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
DBusWatch *watch = user_data;
|
||||
GDBusInterfaceSkeleton *skeleton = G_DBUS_INTERFACE_SKELETON (watch->dbus_monitor);
|
||||
|
||||
g_dbus_connection_emit_signal (g_dbus_interface_skeleton_get_connection (skeleton),
|
||||
watch->dbus_name,
|
||||
g_dbus_interface_skeleton_get_object_path (skeleton),
|
||||
"org.gnome.Mutter.IdleMonitor",
|
||||
"WatchFired",
|
||||
g_variant_new ("(u)", watch_id),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
name_vanished_callback (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
DBusWatch *watch = user_data;
|
||||
|
||||
meta_idle_monitor_remove_watch (watch->monitor, watch->watch_id);
|
||||
}
|
||||
|
||||
static DBusWatch *
|
||||
make_dbus_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = g_slice_new (DBusWatch);
|
||||
watch->dbus_monitor = g_object_ref (skeleton);
|
||||
watch->monitor = g_object_ref (monitor);
|
||||
watch->dbus_name = g_strdup (g_dbus_method_invocation_get_sender (invocation));
|
||||
watch->name_watcher_id = g_bus_watch_name_on_connection (g_dbus_method_invocation_get_connection (invocation),
|
||||
watch->dbus_name,
|
||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||
NULL, /* appeared */
|
||||
name_vanished_callback,
|
||||
watch, NULL);
|
||||
|
||||
return watch;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_add_idle_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
guint64 interval,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = make_dbus_watch (skeleton, invocation, monitor);
|
||||
watch->watch_id = meta_idle_monitor_add_idle_watch (monitor, interval,
|
||||
dbus_idle_callback, watch, destroy_dbus_watch);
|
||||
|
||||
meta_dbus_idle_monitor_complete_add_idle_watch (skeleton, invocation, watch->watch_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_add_user_active_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = make_dbus_watch (skeleton, invocation, monitor);
|
||||
watch->watch_id = meta_idle_monitor_add_user_active_watch (monitor,
|
||||
dbus_idle_callback, watch,
|
||||
destroy_dbus_watch);
|
||||
|
||||
meta_dbus_idle_monitor_complete_add_user_active_watch (skeleton, invocation, watch->watch_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_remove_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
guint id,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
meta_idle_monitor_remove_watch (monitor, id);
|
||||
meta_dbus_idle_monitor_complete_remove_watch (skeleton, invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
create_monitor_skeleton (GDBusObjectManagerServer *manager,
|
||||
MetaIdleMonitor *monitor,
|
||||
const char *path)
|
||||
{
|
||||
MetaDBusIdleMonitor *skeleton;
|
||||
MetaDBusObjectSkeleton *object;
|
||||
|
||||
skeleton = meta_dbus_idle_monitor_skeleton_new ();
|
||||
g_signal_connect_object (skeleton, "handle-add-idle-watch",
|
||||
G_CALLBACK (handle_add_idle_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-add-user-active-watch",
|
||||
G_CALLBACK (handle_add_user_active_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-remove-watch",
|
||||
G_CALLBACK (handle_remove_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-get-idletime",
|
||||
G_CALLBACK (handle_get_idletime), monitor, 0);
|
||||
|
||||
object = meta_dbus_object_skeleton_new (path);
|
||||
meta_dbus_object_skeleton_set_idle_monitor (object, skeleton);
|
||||
|
||||
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_added (ClutterDeviceManager *device_manager,
|
||||
ClutterInputDevice *device,
|
||||
GDBusObjectManagerServer *manager)
|
||||
{
|
||||
|
||||
MetaIdleMonitor *monitor;
|
||||
int device_id;
|
||||
char *path;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
|
||||
|
||||
create_monitor_skeleton (manager, monitor, path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_removed (ClutterDeviceManager *device_manager,
|
||||
ClutterInputDevice *device,
|
||||
GDBusObjectManagerServer *manager)
|
||||
{
|
||||
int device_id;
|
||||
char *path;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
|
||||
g_dbus_object_manager_server_unexport (manager, path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
on_bus_acquired (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
GDBusObjectManagerServer *manager;
|
||||
ClutterDeviceManager *device_manager;
|
||||
MetaIdleMonitor *monitor;
|
||||
GSList *devices, *iter;
|
||||
char *path;
|
||||
|
||||
manager = g_dbus_object_manager_server_new ("/org/gnome/Mutter/IdleMonitor");
|
||||
|
||||
/* We never clear the core monitor, as that's supposed to cumulate idle times from
|
||||
all devices */
|
||||
monitor = meta_idle_monitor_get_core ();
|
||||
path = g_strdup ("/org/gnome/Mutter/IdleMonitor/Core");
|
||||
create_monitor_skeleton (manager, monitor, path);
|
||||
g_free (path);
|
||||
|
||||
device_manager = clutter_device_manager_get_default ();
|
||||
devices = clutter_device_manager_list_devices (device_manager);
|
||||
|
||||
for (iter = devices; iter; iter = iter->next)
|
||||
on_device_added (device_manager, iter->data, manager);
|
||||
|
||||
g_slist_free (devices);
|
||||
|
||||
g_signal_connect_object (device_manager, "device-added",
|
||||
G_CALLBACK (on_device_added), manager, 0);
|
||||
g_signal_connect_object (device_manager, "device-removed",
|
||||
G_CALLBACK (on_device_removed), manager, 0);
|
||||
|
||||
g_dbus_object_manager_server_set_connection (manager, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
on_name_acquired (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
meta_verbose ("Acquired name %s\n", name);
|
||||
}
|
||||
|
||||
static void
|
||||
on_name_lost (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
meta_verbose ("Lost or failed to acquire name %s\n", name);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_init_dbus (void)
|
||||
{
|
||||
static int dbus_name_id;
|
||||
|
||||
if (dbus_name_id > 0)
|
||||
return;
|
||||
|
||||
dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
||||
"org.gnome.Mutter.IdleMonitor",
|
||||
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
|
||||
(meta_get_replace_current_wm () ?
|
||||
G_BUS_NAME_OWNER_FLAGS_REPLACE : 0),
|
||||
on_bus_acquired,
|
||||
on_name_acquired,
|
||||
on_name_lost,
|
||||
NULL, NULL);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*
|
||||
@ -20,10 +20,9 @@
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
|
||||
void meta_idle_monitor_handle_xevent_all (XEvent *xevent);
|
||||
|
||||
void meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor);
|
||||
#ifndef META_IDLE_MONITOR_DBUS_H
|
||||
#define META_IDLE_MONITOR_DBUS_H
|
||||
|
||||
void meta_idle_monitor_init_dbus (void);
|
||||
|
||||
#endif
|
65
src/backends/meta-idle-monitor-private.h
Normal file
65
src/backends/meta-idle-monitor-private.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#ifndef META_IDLE_MONITOR_PRIVATE_H
|
||||
#define META_IDLE_MONITOR_PRIVATE_H
|
||||
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
#include "display-private.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/sync.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
guint id;
|
||||
MetaIdleMonitorWatchFunc callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify notify;
|
||||
guint64 timeout_msec;
|
||||
int idle_source_id;
|
||||
} MetaIdleMonitorWatch;
|
||||
|
||||
struct _MetaIdleMonitor
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GHashTable *watches;
|
||||
int device_id;
|
||||
};
|
||||
|
||||
struct _MetaIdleMonitorClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
gint64 (*get_idletime) (MetaIdleMonitor *monitor);
|
||||
MetaIdleMonitorWatch * (*make_watch) (MetaIdleMonitor *monitor,
|
||||
guint64 timeout_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
};
|
||||
|
||||
void _meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch);
|
||||
|
||||
#endif /* META_IDLE_MONITOR_PRIVATE_H */
|
367
src/backends/meta-idle-monitor.c
Normal file
367
src/backends/meta-idle-monitor.c
Normal file
@ -0,0 +1,367 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:idle-monitor
|
||||
* @title: MetaIdleMonitor
|
||||
* @short_description: Mutter idle counter (similar to X's IDLETIME)
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/sync.h>
|
||||
|
||||
#include <meta/util.h>
|
||||
#include <meta/main.h>
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "meta-idle-monitor-dbus.h"
|
||||
#include "backends/x11/meta-idle-monitor-xsync.h"
|
||||
#include "backends/native/meta-idle-monitor-native.h"
|
||||
|
||||
G_STATIC_ASSERT(sizeof(unsigned long) == sizeof(gpointer));
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DEVICE_ID,
|
||||
PROP_LAST,
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[PROP_LAST];
|
||||
|
||||
G_DEFINE_TYPE (MetaIdleMonitor, meta_idle_monitor, G_TYPE_OBJECT)
|
||||
|
||||
static MetaIdleMonitor *device_monitors[256];
|
||||
static int device_id_max;
|
||||
|
||||
void
|
||||
_meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
guint id;
|
||||
gboolean is_user_active_watch;
|
||||
|
||||
monitor = watch->monitor;
|
||||
g_object_ref (monitor);
|
||||
|
||||
if (watch->idle_source_id)
|
||||
{
|
||||
g_source_remove (watch->idle_source_id);
|
||||
watch->idle_source_id = 0;
|
||||
}
|
||||
|
||||
id = watch->id;
|
||||
is_user_active_watch = (watch->timeout_msec == 0);
|
||||
|
||||
if (watch->callback)
|
||||
watch->callback (monitor, id, watch->user_data);
|
||||
|
||||
if (is_user_active_watch)
|
||||
meta_idle_monitor_remove_watch (monitor, id);
|
||||
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_dispose (GObject *object)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
|
||||
g_clear_pointer (&monitor->watches, g_hash_table_destroy);
|
||||
|
||||
G_OBJECT_CLASS (meta_idle_monitor_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DEVICE_ID:
|
||||
g_value_set_int (value, monitor->device_id);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DEVICE_ID:
|
||||
monitor->device_id = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_class_init (MetaIdleMonitorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = meta_idle_monitor_dispose;
|
||||
object_class->get_property = meta_idle_monitor_get_property;
|
||||
object_class->set_property = meta_idle_monitor_set_property;
|
||||
|
||||
/**
|
||||
* MetaIdleMonitor:device_id:
|
||||
*
|
||||
* The device to listen to idletime on.
|
||||
*/
|
||||
obj_props[PROP_DEVICE_ID] =
|
||||
g_param_spec_int ("device-id",
|
||||
"Device ID",
|
||||
"The device to listen to idletime on",
|
||||
0, 255, 0,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_DEVICE_ID, obj_props[PROP_DEVICE_ID]);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_init (MetaIdleMonitor *monitor)
|
||||
{
|
||||
}
|
||||
|
||||
static GType
|
||||
get_idle_monitor_type (void)
|
||||
{
|
||||
if (meta_is_wayland_compositor ())
|
||||
return META_TYPE_IDLE_MONITOR_NATIVE;
|
||||
else
|
||||
return META_TYPE_IDLE_MONITOR_XSYNC;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_device_monitor (int device_id)
|
||||
{
|
||||
if (device_monitors[device_id])
|
||||
return;
|
||||
|
||||
device_monitors[device_id] = g_object_new (get_idle_monitor_type (),
|
||||
"device-id", device_id,
|
||||
NULL);
|
||||
device_id_max = MAX (device_id_max, device_id);
|
||||
}
|
||||
|
||||
/* FIXME -- destroy device monitors at some point */
|
||||
G_GNUC_UNUSED static void
|
||||
destroy_device_monitor (int device_id)
|
||||
{
|
||||
g_clear_object (&device_monitors[device_id]);
|
||||
if (device_id == device_id_max)
|
||||
device_id_max--;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_core:
|
||||
*
|
||||
* Returns: (transfer none): the #MetaIdleMonitor that tracks the server-global
|
||||
* idletime for all devices. To track device-specific idletime,
|
||||
* use meta_idle_monitor_get_for_device().
|
||||
*/
|
||||
MetaIdleMonitor *
|
||||
meta_idle_monitor_get_core (void)
|
||||
{
|
||||
ensure_device_monitor (0);
|
||||
return device_monitors[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_for_device:
|
||||
* @device_id: the device to get the idle time for.
|
||||
*
|
||||
* Returns: (transfer none): a new #MetaIdleMonitor that tracks the
|
||||
* device-specific idletime for @device. To track server-global idletime
|
||||
* for all devices, use meta_idle_monitor_get_core().
|
||||
*/
|
||||
MetaIdleMonitor *
|
||||
meta_idle_monitor_get_for_device (int device_id)
|
||||
{
|
||||
g_return_val_if_fail (device_id > 0 && device_id < 256, NULL);
|
||||
|
||||
ensure_device_monitor (device_id);
|
||||
return device_monitors[device_id];
|
||||
}
|
||||
|
||||
static MetaIdleMonitorWatch *
|
||||
make_watch (MetaIdleMonitor *monitor,
|
||||
guint64 timeout_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
watch = META_IDLE_MONITOR_GET_CLASS (monitor)->make_watch (monitor,
|
||||
timeout_msec,
|
||||
callback,
|
||||
user_data,
|
||||
notify);
|
||||
|
||||
g_hash_table_insert (monitor->watches,
|
||||
GUINT_TO_POINTER (watch->id),
|
||||
watch);
|
||||
return watch;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_add_idle_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @interval_msec: The idletime interval, in milliseconds
|
||||
* @callback: (allow-none): The callback to call when the user has
|
||||
* accumulated @interval_msec milliseconds of idle time.
|
||||
* @user_data: (allow-none): The user data to pass to the callback
|
||||
* @notify: A #GDestroyNotify
|
||||
*
|
||||
* Returns: a watch id
|
||||
*
|
||||
* Adds a watch for a specific idle time. The callback will be called
|
||||
* when the user has accumulated @interval_msec milliseconds of idle time.
|
||||
* This function will return an ID that can either be passed to
|
||||
* meta_idle_monitor_remove_watch(), or can be used to tell idle time
|
||||
* watches apart if you have more than one.
|
||||
*
|
||||
* Also note that this function will only care about positive transitions
|
||||
* (user's idle time exceeding a certain time). If you want to know about
|
||||
* when the user has become active, use
|
||||
* meta_idle_monitor_add_user_active_watch().
|
||||
*/
|
||||
guint
|
||||
meta_idle_monitor_add_idle_watch (MetaIdleMonitor *monitor,
|
||||
guint64 interval_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
g_return_val_if_fail (META_IS_IDLE_MONITOR (monitor), 0);
|
||||
g_return_val_if_fail (interval_msec > 0, 0);
|
||||
|
||||
watch = make_watch (monitor,
|
||||
interval_msec,
|
||||
callback,
|
||||
user_data,
|
||||
notify);
|
||||
|
||||
return watch->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_add_user_active_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @callback: (allow-none): The callback to call when the user is
|
||||
* active again.
|
||||
* @user_data: (allow-none): The user data to pass to the callback
|
||||
* @notify: A #GDestroyNotify
|
||||
*
|
||||
* Returns: a watch id
|
||||
*
|
||||
* Add a one-time watch to know when the user is active again.
|
||||
* Note that this watch is one-time and will de-activate after the
|
||||
* function is called, for efficiency purposes. It's most convenient
|
||||
* to call this when an idle watch, as added by
|
||||
* meta_idle_monitor_add_idle_watch(), has triggered.
|
||||
*/
|
||||
guint
|
||||
meta_idle_monitor_add_user_active_watch (MetaIdleMonitor *monitor,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
g_return_val_if_fail (META_IS_IDLE_MONITOR (monitor), 0);
|
||||
|
||||
watch = make_watch (monitor,
|
||||
0,
|
||||
callback,
|
||||
user_data,
|
||||
notify);
|
||||
|
||||
return watch->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_remove_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @id: A watch ID
|
||||
*
|
||||
* Removes an idle time watcher, previously added by
|
||||
* meta_idle_monitor_add_idle_watch() or
|
||||
* meta_idle_monitor_add_user_active_watch().
|
||||
*/
|
||||
void
|
||||
meta_idle_monitor_remove_watch (MetaIdleMonitor *monitor,
|
||||
guint id)
|
||||
{
|
||||
g_return_if_fail (META_IS_IDLE_MONITOR (monitor));
|
||||
|
||||
g_object_ref (monitor);
|
||||
g_hash_table_remove (monitor->watches,
|
||||
GUINT_TO_POINTER (id));
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_idletime:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
*
|
||||
* Returns: The current idle time, in milliseconds, or -1 for not supported
|
||||
*/
|
||||
gint64
|
||||
meta_idle_monitor_get_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
return META_IDLE_MONITOR_GET_CLASS (monitor)->get_idletime (monitor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_xsync_handle_xevent_all (XEvent *xevent)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
return;
|
||||
|
||||
for (i = 0; i <= device_id_max; i++)
|
||||
if (device_monitors[i])
|
||||
meta_idle_monitor_xsync_handle_xevent (device_monitors[i], (XSyncAlarmNotifyEvent*)xevent);
|
||||
}
|
@ -34,13 +34,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-monitor-config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include <libupower-glib/upower.h>
|
||||
|
||||
#include <meta/main.h>
|
||||
#include <meta/errors.h>
|
||||
#include "monitor-private.h"
|
||||
|
||||
/* These structures represent the intended/persistent configuration,
|
||||
as stored in the monitors.xml file.
|
55
src/backends/meta-monitor-config.h
Normal file
55
src/backends/meta-monitor-config.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
* Copyright (C) 2003 Rob Adams
|
||||
* Copyright (C) 2004-2006 Elijah Newren
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef META_MONITOR_CONFIG_H
|
||||
#define META_MONITOR_CONFIG_H
|
||||
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#define META_TYPE_MONITOR_CONFIG (meta_monitor_config_get_type ())
|
||||
#define META_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfig))
|
||||
#define META_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
||||
#define META_IS_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_CONFIG))
|
||||
#define META_IS_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_CONFIG))
|
||||
#define META_MONITOR_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
||||
|
||||
GType meta_monitor_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MetaMonitorConfig *meta_monitor_config_new (void);
|
||||
|
||||
gboolean meta_monitor_config_match_current (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
gboolean meta_monitor_config_apply_stored (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_config_make_default (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_config_update_current (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
void meta_monitor_config_make_persistent (MetaMonitorConfig *config);
|
||||
|
||||
void meta_monitor_config_restore_previous (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
#endif /* META_MONITOR_CONFIG_H */
|
227
src/backends/meta-monitor-manager-dummy.c
Normal file
227
src/backends/meta-monitor-manager-dummy.c
Normal file
@ -0,0 +1,227 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Havoc Pennington
|
||||
* Copyright (C) 2002, 2003 Red Hat Inc.
|
||||
* Some ICCCM manager selection code derived from fvwm2,
|
||||
* Copyright (C) 2001 Dominik Vogt, Matthias Clasen, and fvwm2 team
|
||||
* Copyright (C) 2003 Rob Adams
|
||||
* Copyright (C) 2004-2006 Elijah Newren
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include "meta-monitor-manager-dummy.h"
|
||||
|
||||
#define ALL_WL_TRANSFORMS ((1 << (WL_OUTPUT_TRANSFORM_FLIPPED_270 + 1)) - 1)
|
||||
|
||||
struct _MetaMonitorManagerDummy
|
||||
{
|
||||
MetaMonitorManager parent_instance;
|
||||
};
|
||||
|
||||
struct _MetaMonitorManagerDummyClass
|
||||
{
|
||||
MetaMonitorManagerClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaMonitorManagerDummy, meta_monitor_manager_dummy, META_TYPE_MONITOR_MANAGER);
|
||||
|
||||
static void
|
||||
meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
|
||||
{
|
||||
manager->max_screen_width = 65535;
|
||||
manager->max_screen_height = 65535;
|
||||
manager->screen_width = 1024;
|
||||
manager->screen_height = 768;
|
||||
|
||||
manager->modes = g_new0 (MetaMonitorMode, 1);
|
||||
manager->n_modes = 1;
|
||||
|
||||
manager->modes[0].mode_id = 0;
|
||||
manager->modes[0].width = 1024;
|
||||
manager->modes[0].height = 768;
|
||||
manager->modes[0].refresh_rate = 60.0;
|
||||
|
||||
manager->crtcs = g_new0 (MetaCRTC, 1);
|
||||
manager->n_crtcs = 1;
|
||||
|
||||
manager->crtcs[0].crtc_id = 1;
|
||||
manager->crtcs[0].rect.x = 0;
|
||||
manager->crtcs[0].rect.y = 0;
|
||||
manager->crtcs[0].rect.width = manager->modes[0].width;
|
||||
manager->crtcs[0].rect.height = manager->modes[0].height;
|
||||
manager->crtcs[0].current_mode = &manager->modes[0];
|
||||
manager->crtcs[0].transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
manager->crtcs[0].all_transforms = ALL_WL_TRANSFORMS;
|
||||
manager->crtcs[0].is_dirty = FALSE;
|
||||
manager->crtcs[0].logical_monitor = NULL;
|
||||
|
||||
manager->outputs = g_new0 (MetaOutput, 1);
|
||||
manager->n_outputs = 1;
|
||||
|
||||
manager->outputs[0].crtc = &manager->crtcs[0];
|
||||
manager->outputs[0].output_id = 1;
|
||||
manager->outputs[0].name = g_strdup ("LVDS");
|
||||
manager->outputs[0].vendor = g_strdup ("MetaProducts Inc.");
|
||||
manager->outputs[0].product = g_strdup ("unknown");
|
||||
manager->outputs[0].serial = g_strdup ("0xC0FFEE");
|
||||
manager->outputs[0].width_mm = 222;
|
||||
manager->outputs[0].height_mm = 125;
|
||||
manager->outputs[0].subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN;
|
||||
manager->outputs[0].preferred_mode = &manager->modes[0];
|
||||
manager->outputs[0].n_modes = 1;
|
||||
manager->outputs[0].modes = g_new0 (MetaMonitorMode *, 1);
|
||||
manager->outputs[0].modes[0] = &manager->modes[0];
|
||||
manager->outputs[0].n_possible_crtcs = 1;
|
||||
manager->outputs[0].possible_crtcs = g_new0 (MetaCRTC *, 1);
|
||||
manager->outputs[0].possible_crtcs[0] = &manager->crtcs[0];
|
||||
manager->outputs[0].n_possible_clones = 0;
|
||||
manager->outputs[0].possible_clones = g_new0 (MetaOutput *, 0);
|
||||
manager->outputs[0].backlight = -1;
|
||||
manager->outputs[0].backlight_min = 0;
|
||||
manager->outputs[0].backlight_max = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_dummy_apply_config (MetaMonitorManager *manager,
|
||||
MetaCRTCInfo **crtcs,
|
||||
unsigned int n_crtcs,
|
||||
MetaOutputInfo **outputs,
|
||||
unsigned int n_outputs)
|
||||
{
|
||||
unsigned i;
|
||||
int screen_width = 0, screen_height = 0;
|
||||
|
||||
for (i = 0; i < n_crtcs; i++)
|
||||
{
|
||||
MetaCRTCInfo *crtc_info = crtcs[i];
|
||||
MetaCRTC *crtc = crtc_info->crtc;
|
||||
crtc->is_dirty = TRUE;
|
||||
|
||||
if (crtc_info->mode == NULL)
|
||||
{
|
||||
crtc->rect.x = 0;
|
||||
crtc->rect.y = 0;
|
||||
crtc->rect.width = 0;
|
||||
crtc->rect.height = 0;
|
||||
crtc->current_mode = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaMonitorMode *mode;
|
||||
MetaOutput *output;
|
||||
int i, n_outputs;
|
||||
int width, height;
|
||||
|
||||
mode = crtc_info->mode;
|
||||
|
||||
if (meta_monitor_transform_is_rotated (crtc_info->transform))
|
||||
{
|
||||
width = mode->height;
|
||||
height = mode->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = mode->width;
|
||||
height = mode->height;
|
||||
}
|
||||
|
||||
crtc->rect.x = crtc_info->x;
|
||||
crtc->rect.y = crtc_info->y;
|
||||
crtc->rect.width = width;
|
||||
crtc->rect.height = height;
|
||||
crtc->current_mode = mode;
|
||||
crtc->transform = crtc_info->transform;
|
||||
|
||||
screen_width = MAX (screen_width, crtc_info->x + width);
|
||||
screen_height = MAX (screen_height, crtc_info->y + height);
|
||||
|
||||
n_outputs = crtc_info->outputs->len;
|
||||
for (i = 0; i < n_outputs; i++)
|
||||
{
|
||||
output = ((MetaOutput**)crtc_info->outputs->pdata)[i];
|
||||
|
||||
output->is_dirty = TRUE;
|
||||
output->crtc = crtc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < n_outputs; i++)
|
||||
{
|
||||
MetaOutputInfo *output_info = outputs[i];
|
||||
MetaOutput *output = output_info->output;
|
||||
|
||||
output->is_primary = output_info->is_primary;
|
||||
output->is_presentation = output_info->is_presentation;
|
||||
}
|
||||
|
||||
/* Disable CRTCs not mentioned in the list */
|
||||
for (i = 0; i < manager->n_crtcs; i++)
|
||||
{
|
||||
MetaCRTC *crtc = &manager->crtcs[i];
|
||||
|
||||
crtc->logical_monitor = NULL;
|
||||
|
||||
if (crtc->is_dirty)
|
||||
{
|
||||
crtc->is_dirty = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
crtc->rect.x = 0;
|
||||
crtc->rect.y = 0;
|
||||
crtc->rect.width = 0;
|
||||
crtc->rect.height = 0;
|
||||
crtc->current_mode = NULL;
|
||||
}
|
||||
|
||||
/* Disable outputs not mentioned in the list */
|
||||
for (i = 0; i < manager->n_outputs; i++)
|
||||
{
|
||||
MetaOutput *output = &manager->outputs[i];
|
||||
|
||||
if (output->is_dirty)
|
||||
{
|
||||
output->is_dirty = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
output->crtc = NULL;
|
||||
output->is_primary = FALSE;
|
||||
}
|
||||
|
||||
manager->screen_width = screen_width;
|
||||
manager->screen_height = screen_height;
|
||||
|
||||
meta_monitor_manager_rebuild_derived (manager);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass)
|
||||
{
|
||||
MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
|
||||
|
||||
manager_class->read_current = meta_monitor_manager_dummy_read_current;
|
||||
manager_class->apply_configuration = meta_monitor_manager_dummy_apply_config;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_dummy_init (MetaMonitorManagerDummy *manager)
|
||||
{
|
||||
}
|
40
src/backends/meta-monitor-manager-dummy.h
Normal file
40
src/backends/meta-monitor-manager-dummy.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
* Copyright (C) 2003 Rob Adams
|
||||
* Copyright (C) 2004-2006 Elijah Newren
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef META_MONITOR_MANAGER_DUMMY_H
|
||||
#define META_MONITOR_MANAGER_DUMMY_H
|
||||
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_DUMMY (meta_monitor_manager_dummy_get_type ())
|
||||
#define META_MONITOR_MANAGER_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_DUMMY, MetaMonitorManagerDummy))
|
||||
#define META_MONITOR_MANAGER_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_DUMMY, MetaMonitorManagerDummyClass))
|
||||
#define META_IS_MONITOR_MANAGER_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_DUMMY))
|
||||
#define META_IS_MONITOR_MANAGER_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_DUMMY))
|
||||
#define META_MONITOR_MANAGER_DUMMY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_DUMMY, MetaMonitorManagerDummyClass))
|
||||
|
||||
typedef struct _MetaMonitorManagerDummyClass MetaMonitorManagerDummyClass;
|
||||
typedef struct _MetaMonitorManagerDummy MetaMonitorManagerDummy;
|
||||
|
||||
GType meta_monitor_manager_dummy_get_type (void);
|
||||
|
||||
#endif /* META_MONITOR_MANAGER_DUMMY_H */
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@ -33,11 +35,10 @@
|
||||
#include <meta/main.h>
|
||||
#include "util-private.h"
|
||||
#include <meta/errors.h>
|
||||
#include "monitor-private.h"
|
||||
|
||||
#include "meta-dbus-xrandr.h"
|
||||
|
||||
#define ALL_WL_TRANSFORMS ((1 << (WL_OUTPUT_TRANSFORM_FLIPPED_270 + 1)) - 1)
|
||||
#include "meta-monitor-config.h"
|
||||
#include "backends/native/meta-monitor-manager-kms.h"
|
||||
#include "backends/x11/meta-monitor-manager-xrandr.h"
|
||||
#include "meta-monitor-manager-dummy.h"
|
||||
|
||||
enum {
|
||||
CONFIRM_DISPLAY_CHANGE,
|
||||
@ -54,196 +55,11 @@ static int signals[SIGNALS_LAST];
|
||||
|
||||
static void meta_monitor_manager_display_config_init (MetaDBusDisplayConfigIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (MetaMonitorManager, meta_monitor_manager, META_DBUS_TYPE_DISPLAY_CONFIG_SKELETON,
|
||||
G_IMPLEMENT_INTERFACE (META_DBUS_TYPE_DISPLAY_CONFIG, meta_monitor_manager_display_config_init));
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaMonitorManager, meta_monitor_manager, META_DBUS_TYPE_DISPLAY_CONFIG_SKELETON,
|
||||
G_IMPLEMENT_INTERFACE (META_DBUS_TYPE_DISPLAY_CONFIG, meta_monitor_manager_display_config_init));
|
||||
|
||||
static void initialize_dbus_interface (MetaMonitorManager *manager);
|
||||
|
||||
static void
|
||||
read_current_dummy (MetaMonitorManager *manager)
|
||||
{
|
||||
manager->max_screen_width = 65535;
|
||||
manager->max_screen_height = 65535;
|
||||
manager->screen_width = 1024;
|
||||
manager->screen_height = 768;
|
||||
|
||||
manager->modes = g_new0 (MetaMonitorMode, 1);
|
||||
manager->n_modes = 1;
|
||||
|
||||
manager->modes[0].mode_id = 0;
|
||||
manager->modes[0].width = 1024;
|
||||
manager->modes[0].height = 768;
|
||||
manager->modes[0].refresh_rate = 60.0;
|
||||
|
||||
manager->crtcs = g_new0 (MetaCRTC, 1);
|
||||
manager->n_crtcs = 1;
|
||||
|
||||
manager->crtcs[0].crtc_id = 1;
|
||||
manager->crtcs[0].rect.x = 0;
|
||||
manager->crtcs[0].rect.y = 0;
|
||||
manager->crtcs[0].rect.width = manager->modes[0].width;
|
||||
manager->crtcs[0].rect.height = manager->modes[0].height;
|
||||
manager->crtcs[0].current_mode = &manager->modes[0];
|
||||
manager->crtcs[0].transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
manager->crtcs[0].all_transforms = ALL_WL_TRANSFORMS;
|
||||
manager->crtcs[0].is_dirty = FALSE;
|
||||
manager->crtcs[0].logical_monitor = NULL;
|
||||
|
||||
manager->outputs = g_new0 (MetaOutput, 1);
|
||||
manager->n_outputs = 1;
|
||||
|
||||
manager->outputs[0].crtc = &manager->crtcs[0];
|
||||
manager->outputs[0].output_id = 1;
|
||||
manager->outputs[0].name = g_strdup ("LVDS");
|
||||
manager->outputs[0].vendor = g_strdup ("MetaProducts Inc.");
|
||||
manager->outputs[0].product = g_strdup ("unknown");
|
||||
manager->outputs[0].serial = g_strdup ("0xC0FFEE");
|
||||
manager->outputs[0].width_mm = 222;
|
||||
manager->outputs[0].height_mm = 125;
|
||||
manager->outputs[0].subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN;
|
||||
manager->outputs[0].preferred_mode = &manager->modes[0];
|
||||
manager->outputs[0].n_modes = 1;
|
||||
manager->outputs[0].modes = g_new0 (MetaMonitorMode *, 1);
|
||||
manager->outputs[0].modes[0] = &manager->modes[0];
|
||||
manager->outputs[0].n_possible_crtcs = 1;
|
||||
manager->outputs[0].possible_crtcs = g_new0 (MetaCRTC *, 1);
|
||||
manager->outputs[0].possible_crtcs[0] = &manager->crtcs[0];
|
||||
manager->outputs[0].n_possible_clones = 0;
|
||||
manager->outputs[0].possible_clones = g_new0 (MetaOutput *, 0);
|
||||
manager->outputs[0].backlight = -1;
|
||||
manager->outputs[0].backlight_min = 0;
|
||||
manager->outputs[0].backlight_max = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
apply_config_dummy (MetaMonitorManager *manager,
|
||||
MetaCRTCInfo **crtcs,
|
||||
unsigned int n_crtcs,
|
||||
MetaOutputInfo **outputs,
|
||||
unsigned int n_outputs)
|
||||
{
|
||||
unsigned i;
|
||||
int screen_width = 0, screen_height = 0;
|
||||
|
||||
for (i = 0; i < n_crtcs; i++)
|
||||
{
|
||||
MetaCRTCInfo *crtc_info = crtcs[i];
|
||||
MetaCRTC *crtc = crtc_info->crtc;
|
||||
crtc->is_dirty = TRUE;
|
||||
|
||||
if (crtc_info->mode == NULL)
|
||||
{
|
||||
crtc->rect.x = 0;
|
||||
crtc->rect.y = 0;
|
||||
crtc->rect.width = 0;
|
||||
crtc->rect.height = 0;
|
||||
crtc->current_mode = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaMonitorMode *mode;
|
||||
MetaOutput *output;
|
||||
int i, n_outputs;
|
||||
int width, height;
|
||||
|
||||
mode = crtc_info->mode;
|
||||
|
||||
if (meta_monitor_transform_is_rotated (crtc_info->transform))
|
||||
{
|
||||
width = mode->height;
|
||||
height = mode->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = mode->width;
|
||||
height = mode->height;
|
||||
}
|
||||
|
||||
crtc->rect.x = crtc_info->x;
|
||||
crtc->rect.y = crtc_info->y;
|
||||
crtc->rect.width = width;
|
||||
crtc->rect.height = height;
|
||||
crtc->current_mode = mode;
|
||||
crtc->transform = crtc_info->transform;
|
||||
|
||||
screen_width = MAX (screen_width, crtc_info->x + width);
|
||||
screen_height = MAX (screen_height, crtc_info->y + height);
|
||||
|
||||
n_outputs = crtc_info->outputs->len;
|
||||
for (i = 0; i < n_outputs; i++)
|
||||
{
|
||||
output = ((MetaOutput**)crtc_info->outputs->pdata)[i];
|
||||
|
||||
output->is_dirty = TRUE;
|
||||
output->crtc = crtc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < n_outputs; i++)
|
||||
{
|
||||
MetaOutputInfo *output_info = outputs[i];
|
||||
MetaOutput *output = output_info->output;
|
||||
|
||||
output->is_primary = output_info->is_primary;
|
||||
output->is_presentation = output_info->is_presentation;
|
||||
}
|
||||
|
||||
/* Disable CRTCs not mentioned in the list */
|
||||
for (i = 0; i < manager->n_crtcs; i++)
|
||||
{
|
||||
MetaCRTC *crtc = &manager->crtcs[i];
|
||||
|
||||
crtc->logical_monitor = NULL;
|
||||
|
||||
if (crtc->is_dirty)
|
||||
{
|
||||
crtc->is_dirty = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
crtc->rect.x = 0;
|
||||
crtc->rect.y = 0;
|
||||
crtc->rect.width = 0;
|
||||
crtc->rect.height = 0;
|
||||
crtc->current_mode = NULL;
|
||||
}
|
||||
|
||||
/* Disable outputs not mentioned in the list */
|
||||
for (i = 0; i < manager->n_outputs; i++)
|
||||
{
|
||||
MetaOutput *output = &manager->outputs[i];
|
||||
|
||||
if (output->is_dirty)
|
||||
{
|
||||
output->is_dirty = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
output->crtc = NULL;
|
||||
output->is_primary = FALSE;
|
||||
}
|
||||
|
||||
manager->screen_width = screen_width;
|
||||
manager->screen_height = screen_height;
|
||||
|
||||
meta_monitor_manager_rebuild_derived (manager);
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
read_edid_dummy (MetaMonitorManager *manager,
|
||||
MetaOutput *output)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_edid_file_dummy (MetaMonitorManager *manager,
|
||||
MetaOutput *output)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_init (MetaMonitorManager *manager)
|
||||
{
|
||||
@ -367,7 +183,7 @@ get_default_backend (void)
|
||||
* we're a nested configuration, so return the dummy
|
||||
* monitor setup. */
|
||||
if (meta_is_wayland_compositor ())
|
||||
return META_TYPE_MONITOR_MANAGER;
|
||||
return META_TYPE_MONITOR_MANAGER_DUMMY;
|
||||
else
|
||||
return META_TYPE_MONITOR_MANAGER_XRANDR;
|
||||
}
|
||||
@ -379,7 +195,7 @@ get_default_backend (void)
|
||||
/* Use the dummy implementation on Wayland for now.
|
||||
* In the future, we should support wl_fullscreen_output
|
||||
* which will have CRTC management in the protocol. */
|
||||
return META_TYPE_MONITOR_MANAGER;
|
||||
return META_TYPE_MONITOR_MANAGER_DUMMY;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -573,6 +389,20 @@ meta_monitor_manager_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
meta_monitor_manager_real_read_edid (MetaMonitorManager *manager,
|
||||
MetaOutput *output)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
meta_monitor_manager_real_get_edid_file (MetaMonitorManager *manager,
|
||||
MetaOutput *output)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
{
|
||||
@ -584,10 +414,8 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
object_class->dispose = meta_monitor_manager_dispose;
|
||||
object_class->finalize = meta_monitor_manager_finalize;
|
||||
|
||||
klass->read_current = read_current_dummy;
|
||||
klass->apply_configuration = apply_config_dummy;
|
||||
klass->get_edid_file = get_edid_file_dummy;
|
||||
klass->read_edid = read_edid_dummy;
|
||||
klass->get_edid_file = meta_monitor_manager_real_get_edid_file;
|
||||
klass->read_edid = meta_monitor_manager_real_read_edid;
|
||||
|
||||
signals[CONFIRM_DISPLAY_CHANGE] =
|
||||
g_signal_new ("confirm-display-change",
|
@ -43,9 +43,9 @@
|
||||
#include "stack-tracker.h"
|
||||
#include "ui.h"
|
||||
#include <wayland-server.h>
|
||||
#include "meta-xrandr-shared.h"
|
||||
|
||||
#include "meta-dbus-xrandr.h"
|
||||
#include "meta-display-config-shared.h"
|
||||
#include "meta-dbus-display-config.h"
|
||||
|
||||
typedef struct _MetaMonitorManagerClass MetaMonitorManagerClass;
|
||||
typedef struct _MetaMonitorManager MetaMonitorManager;
|
||||
@ -227,8 +227,6 @@ struct _MetaMonitorManager
|
||||
CRTCs refer to stuff that can drive outputs
|
||||
(like encoders, but less tied to the HW),
|
||||
while monitor_infos refer to logical ones.
|
||||
|
||||
See also the comment in monitor-private.h
|
||||
*/
|
||||
MetaOutput *outputs;
|
||||
unsigned int n_outputs;
|
||||
@ -335,57 +333,6 @@ void meta_monitor_manager_apply_configuration (MetaMonitorManager
|
||||
void meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
|
||||
gboolean ok);
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_XRANDR (meta_monitor_manager_xrandr_get_type ())
|
||||
#define META_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandr))
|
||||
#define META_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
||||
#define META_IS_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_XRANDR))
|
||||
#define META_IS_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_XRANDR))
|
||||
#define META_MONITOR_MANAGER_XRANDR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
||||
|
||||
typedef struct _MetaMonitorManagerXrandrClass MetaMonitorManagerXrandrClass;
|
||||
typedef struct _MetaMonitorManagerXrandr MetaMonitorManagerXrandr;
|
||||
|
||||
GType meta_monitor_manager_xrandr_get_type (void);
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_KMS (meta_monitor_manager_kms_get_type ())
|
||||
#define META_MONITOR_MANAGER_KMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKms))
|
||||
#define META_MONITOR_MANAGER_KMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKmsClass))
|
||||
#define META_IS_MONITOR_MANAGER_KMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_KMS))
|
||||
#define META_IS_MONITOR_MANAGER_KMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_KMS))
|
||||
#define META_MONITOR_MANAGER_KMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKmsClass))
|
||||
|
||||
typedef struct _MetaMonitorManagerKmsClass MetaMonitorManagerKmsClass;
|
||||
typedef struct _MetaMonitorManagerKms MetaMonitorManagerKms;
|
||||
|
||||
GType meta_monitor_manager_kms_get_type (void);
|
||||
|
||||
#define META_TYPE_MONITOR_CONFIG (meta_monitor_config_get_type ())
|
||||
#define META_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfig))
|
||||
#define META_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
||||
#define META_IS_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_CONFIG))
|
||||
#define META_IS_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_CONFIG))
|
||||
#define META_MONITOR_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
||||
|
||||
GType meta_monitor_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MetaMonitorConfig *meta_monitor_config_new (void);
|
||||
|
||||
gboolean meta_monitor_config_match_current (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
gboolean meta_monitor_config_apply_stored (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_config_make_default (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_config_update_current (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
void meta_monitor_config_make_persistent (MetaMonitorConfig *config);
|
||||
|
||||
void meta_monitor_config_restore_previous (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
||||
void meta_crtc_info_free (MetaCRTCInfo *info);
|
||||
void meta_output_info_free (MetaOutputInfo *info);
|
||||
|
219
src/backends/native/meta-idle-monitor-native.c
Normal file
219
src/backends/native/meta-idle-monitor-native.c
Normal file
@ -0,0 +1,219 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-idle-monitor-native.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
|
||||
#include <meta/util.h>
|
||||
#include "display-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct _MetaIdleMonitorNative
|
||||
{
|
||||
MetaIdleMonitor parent;
|
||||
|
||||
guint64 last_event_time;
|
||||
};
|
||||
|
||||
struct _MetaIdleMonitorNativeClass
|
||||
{
|
||||
MetaIdleMonitorClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
MetaIdleMonitorWatch base;
|
||||
|
||||
GSource *timeout_source;
|
||||
} MetaIdleMonitorWatchNative;
|
||||
|
||||
G_DEFINE_TYPE (MetaIdleMonitorNative, meta_idle_monitor_native, META_TYPE_IDLE_MONITOR)
|
||||
|
||||
static gint64
|
||||
meta_idle_monitor_native_get_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
MetaIdleMonitorNative *monitor_native = META_IDLE_MONITOR_NATIVE (monitor);
|
||||
|
||||
return (g_get_monotonic_time () - monitor_native->last_event_time) / 1000;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_next_watch_serial (void)
|
||||
{
|
||||
static guint32 serial = 0;
|
||||
g_atomic_int_inc (&serial);
|
||||
return serial;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
native_dispatch_timeout (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatchNative *watch_native = user_data;
|
||||
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_native;
|
||||
|
||||
_meta_idle_monitor_watch_fire (watch);
|
||||
g_source_set_ready_time (watch_native->timeout_source, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs native_source_funcs = {
|
||||
NULL, /* prepare */
|
||||
NULL, /* check */
|
||||
native_dispatch_timeout,
|
||||
NULL, /* finalize */
|
||||
};
|
||||
|
||||
static void
|
||||
free_watch (gpointer data)
|
||||
{
|
||||
MetaIdleMonitorWatchNative *watch_native = data;
|
||||
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_native;
|
||||
MetaIdleMonitor *monitor = watch->monitor;
|
||||
|
||||
g_object_ref (monitor);
|
||||
|
||||
if (watch->idle_source_id)
|
||||
{
|
||||
g_source_remove (watch->idle_source_id);
|
||||
watch->idle_source_id = 0;
|
||||
}
|
||||
|
||||
if (watch->notify != NULL)
|
||||
watch->notify (watch->user_data);
|
||||
|
||||
if (watch_native->timeout_source != NULL)
|
||||
g_source_destroy (watch_native->timeout_source);
|
||||
|
||||
g_object_unref (monitor);
|
||||
g_slice_free (MetaIdleMonitorWatchNative, watch_native);
|
||||
}
|
||||
|
||||
static MetaIdleMonitorWatch *
|
||||
meta_idle_monitor_native_make_watch (MetaIdleMonitor *monitor,
|
||||
guint64 timeout_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatchNative *watch_native;
|
||||
MetaIdleMonitorWatch *watch;
|
||||
MetaIdleMonitorNative *monitor_native = META_IDLE_MONITOR_NATIVE (monitor);
|
||||
|
||||
watch_native = g_slice_new0 (MetaIdleMonitorWatchNative);
|
||||
watch = (MetaIdleMonitorWatch *) watch_native;
|
||||
|
||||
watch->monitor = monitor;
|
||||
watch->id = get_next_watch_serial ();
|
||||
watch->callback = callback;
|
||||
watch->user_data = user_data;
|
||||
watch->notify = notify;
|
||||
watch->timeout_msec = timeout_msec;
|
||||
|
||||
if (timeout_msec != 0)
|
||||
{
|
||||
GSource *source = g_source_new (&native_source_funcs, sizeof (GSource));
|
||||
|
||||
g_source_set_callback (source, NULL, watch, NULL);
|
||||
g_source_set_ready_time (source, monitor_native->last_event_time + timeout_msec * 1000);
|
||||
g_source_attach (source, NULL);
|
||||
g_source_unref (source);
|
||||
|
||||
watch_native->timeout_source = source;
|
||||
}
|
||||
|
||||
return watch;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_native_class_init (MetaIdleMonitorNativeClass *klass)
|
||||
{
|
||||
MetaIdleMonitorClass *idle_monitor_class = META_IDLE_MONITOR_CLASS (klass);
|
||||
|
||||
idle_monitor_class->get_idletime = meta_idle_monitor_native_get_idletime;
|
||||
idle_monitor_class->make_watch = meta_idle_monitor_native_make_watch;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_native_init (MetaIdleMonitorNative *monitor_native)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_native);
|
||||
|
||||
monitor->watches = g_hash_table_new_full (NULL, NULL, NULL, free_watch);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
MetaIdleMonitorNative *monitor_native;
|
||||
GList *fired_watches;
|
||||
} CheckNativeClosure;
|
||||
|
||||
static gboolean
|
||||
check_native_watch (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatchNative *watch_native = value;
|
||||
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_native;
|
||||
CheckNativeClosure *closure = user_data;
|
||||
gboolean steal;
|
||||
|
||||
if (watch->timeout_msec == 0)
|
||||
{
|
||||
closure->fired_watches = g_list_prepend (closure->fired_watches, watch);
|
||||
steal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_source_set_ready_time (watch_native->timeout_source,
|
||||
closure->monitor_native->last_event_time +
|
||||
watch->timeout_msec * 1000);
|
||||
steal = FALSE;
|
||||
}
|
||||
|
||||
return steal;
|
||||
}
|
||||
|
||||
static void
|
||||
fire_native_watch (gpointer watch,
|
||||
gpointer data)
|
||||
{
|
||||
_meta_idle_monitor_watch_fire (watch);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_native_reset_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
MetaIdleMonitorNative *monitor_native = META_IDLE_MONITOR_NATIVE (monitor);
|
||||
CheckNativeClosure closure;
|
||||
|
||||
monitor_native->last_event_time = g_get_monotonic_time ();
|
||||
|
||||
closure.monitor_native = monitor_native;
|
||||
closure.fired_watches = NULL;
|
||||
g_hash_table_foreach_steal (monitor->watches, check_native_watch, &closure);
|
||||
|
||||
g_list_foreach (closure.fired_watches, fire_native_watch, NULL);
|
||||
g_list_free (closure.fired_watches);
|
||||
}
|
43
src/backends/native/meta-idle-monitor-native.h
Normal file
43
src/backends/native/meta-idle-monitor-native.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#ifndef META_IDLE_MONITOR_NATIVE_H
|
||||
#define META_IDLE_MONITOR_NATIVE_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
|
||||
#define META_TYPE_IDLE_MONITOR_NATIVE (meta_idle_monitor_native_get_type ())
|
||||
#define META_IDLE_MONITOR_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_IDLE_MONITOR_NATIVE, MetaIdleMonitorNative))
|
||||
#define META_IDLE_MONITOR_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_IDLE_MONITOR_NATIVE, MetaIdleMonitorNativeClass))
|
||||
#define META_IS_IDLE_MONITOR_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_IDLE_MONITOR_NATIVE))
|
||||
#define META_IS_IDLE_MONITOR_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_IDLE_MONITOR_NATIVE))
|
||||
#define META_IDLE_MONITOR_NATIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_IDLE_MONITOR_NATIVE, MetaIdleMonitorNativeClass))
|
||||
|
||||
typedef struct _MetaIdleMonitorNative MetaIdleMonitorNative;
|
||||
typedef struct _MetaIdleMonitorNativeClass MetaIdleMonitorNativeClass;
|
||||
|
||||
GType meta_idle_monitor_native_get_type (void);
|
||||
|
||||
void meta_idle_monitor_native_reset_idletime (MetaIdleMonitor *monitor);
|
||||
|
||||
#endif /* META_IDLE_MONITOR_NATIVE_H */
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-monitor-manager-kms.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <clutter/clutter.h>
|
||||
@ -36,7 +38,6 @@
|
||||
|
||||
#include <meta/main.h>
|
||||
#include <meta/errors.h>
|
||||
#include "monitor-private.h"
|
||||
#include "edid.h"
|
||||
|
||||
#define ALL_WL_TRANSFORMS ((1 << (WL_OUTPUT_TRANSFORM_FLIPPED_270 + 1)) - 1)
|
40
src/backends/native/meta-monitor-manager-kms.h
Normal file
40
src/backends/native/meta-monitor-manager-kms.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
* Copyright (C) 2003 Rob Adams
|
||||
* Copyright (C) 2004-2006 Elijah Newren
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef META_MONITOR_MANAGER_KMS_H
|
||||
#define META_MONITOR_MANAGER_KMS_H
|
||||
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_KMS (meta_monitor_manager_kms_get_type ())
|
||||
#define META_MONITOR_MANAGER_KMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKms))
|
||||
#define META_MONITOR_MANAGER_KMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKmsClass))
|
||||
#define META_IS_MONITOR_MANAGER_KMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_KMS))
|
||||
#define META_IS_MONITOR_MANAGER_KMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_KMS))
|
||||
#define META_MONITOR_MANAGER_KMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_KMS, MetaMonitorManagerKmsClass))
|
||||
|
||||
typedef struct _MetaMonitorManagerKmsClass MetaMonitorManagerKmsClass;
|
||||
typedef struct _MetaMonitorManagerKms MetaMonitorManagerKms;
|
||||
|
||||
GType meta_monitor_manager_kms_get_type (void);
|
||||
|
||||
#endif /* META_MONITOR_MANAGER_KMS_H */
|
@ -42,7 +42,7 @@
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "meta-wayland-private.h"
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
#include "meta-cursor-tracker-private.h"
|
||||
#include "meta-weston-launch.h"
|
||||
|
366
src/backends/x11/meta-idle-monitor-xsync.c
Normal file
366
src/backends/x11/meta-idle-monitor-xsync.c
Normal file
@ -0,0 +1,366 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-idle-monitor-xsync.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
|
||||
#include <meta/util.h>
|
||||
#include "display-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct _MetaIdleMonitorXSync
|
||||
{
|
||||
MetaIdleMonitor parent;
|
||||
|
||||
GHashTable *alarms;
|
||||
Display *display;
|
||||
XSyncCounter counter;
|
||||
XSyncAlarm user_active_alarm;
|
||||
};
|
||||
|
||||
struct _MetaIdleMonitorXSyncClass
|
||||
{
|
||||
MetaIdleMonitorClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
MetaIdleMonitorWatch base;
|
||||
|
||||
XSyncAlarm xalarm;
|
||||
} MetaIdleMonitorWatchXSync;
|
||||
|
||||
G_DEFINE_TYPE (MetaIdleMonitorXSync, meta_idle_monitor_xsync, META_TYPE_IDLE_MONITOR)
|
||||
|
||||
static gint64
|
||||
_xsyncvalue_to_int64 (XSyncValue value)
|
||||
{
|
||||
return ((guint64) XSyncValueHigh32 (value)) << 32
|
||||
| (guint64) XSyncValueLow32 (value);
|
||||
}
|
||||
|
||||
#define GUINT64_TO_XSYNCVALUE(value, ret) XSyncIntsToValue (ret, (value) & 0xFFFFFFFF, ((guint64)(value)) >> 32)
|
||||
|
||||
static XSyncAlarm
|
||||
_xsync_alarm_set (MetaIdleMonitorXSync *monitor_xsync,
|
||||
XSyncTestType test_type,
|
||||
guint64 interval,
|
||||
gboolean want_events)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
XSyncValue delta;
|
||||
guint flags;
|
||||
|
||||
flags = XSyncCACounter | XSyncCAValueType | XSyncCATestType |
|
||||
XSyncCAValue | XSyncCADelta | XSyncCAEvents;
|
||||
|
||||
XSyncIntToValue (&delta, 0);
|
||||
attr.trigger.counter = monitor_xsync->counter;
|
||||
attr.trigger.value_type = XSyncAbsolute;
|
||||
attr.delta = delta;
|
||||
attr.events = want_events;
|
||||
|
||||
GUINT64_TO_XSYNCVALUE (interval, &attr.trigger.wait_value);
|
||||
attr.trigger.test_type = test_type;
|
||||
return XSyncCreateAlarm (monitor_xsync->display, flags, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_alarm_rescheduled (Display *dpy,
|
||||
XSyncAlarm alarm)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
|
||||
/* Some versions of Xorg have an issue where alarms aren't
|
||||
* always rescheduled. Calling XSyncChangeAlarm, even
|
||||
* without any attributes, will reschedule the alarm. */
|
||||
XSyncChangeAlarm (dpy, alarm, 0, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
set_alarm_enabled (Display *dpy,
|
||||
XSyncAlarm alarm,
|
||||
gboolean enabled)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
attr.events = enabled;
|
||||
XSyncChangeAlarm (dpy, alarm, XSyncCAEvents, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
check_x11_watch (gpointer data,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatchXSync *watch_xsync = data;
|
||||
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_xsync;
|
||||
XSyncAlarm alarm = (XSyncAlarm) user_data;
|
||||
|
||||
if (watch_xsync->xalarm != alarm)
|
||||
return;
|
||||
|
||||
_meta_idle_monitor_watch_fire (watch);
|
||||
}
|
||||
|
||||
static char *
|
||||
counter_name_for_device (int device_id)
|
||||
{
|
||||
if (device_id > 0)
|
||||
return g_strdup_printf ("DEVICEIDLETIME %d", device_id);
|
||||
|
||||
return g_strdup ("IDLETIME");
|
||||
}
|
||||
|
||||
static XSyncCounter
|
||||
find_idletime_counter (MetaIdleMonitorXSync *monitor_xsync)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_xsync);
|
||||
int i;
|
||||
int ncounters;
|
||||
XSyncSystemCounter *counters;
|
||||
XSyncCounter counter = None;
|
||||
char *counter_name;
|
||||
|
||||
counter_name = counter_name_for_device (monitor->device_id);
|
||||
counters = XSyncListSystemCounters (monitor_xsync->display, &ncounters);
|
||||
for (i = 0; i < ncounters; i++)
|
||||
{
|
||||
if (counters[i].name != NULL && strcmp (counters[i].name, counter_name) == 0)
|
||||
{
|
||||
counter = counters[i].counter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XSyncFreeSystemCounterList (counters);
|
||||
g_free (counter_name);
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
static void
|
||||
init_xsync (MetaIdleMonitorXSync *monitor_xsync)
|
||||
{
|
||||
monitor_xsync->counter = find_idletime_counter (monitor_xsync);
|
||||
/* IDLETIME counter not found? */
|
||||
if (monitor_xsync->counter == None)
|
||||
{
|
||||
g_warning ("IDLETIME counter not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
monitor_xsync->user_active_alarm = _xsync_alarm_set (monitor_xsync, XSyncNegativeTransition, 1, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_xsync_dispose (GObject *object)
|
||||
{
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (object);
|
||||
|
||||
if (monitor_xsync->user_active_alarm != None)
|
||||
{
|
||||
XSyncDestroyAlarm (monitor_xsync->display, monitor_xsync->user_active_alarm);
|
||||
monitor_xsync->user_active_alarm = None;
|
||||
}
|
||||
|
||||
g_clear_pointer (&monitor_xsync->alarms, g_hash_table_destroy);
|
||||
|
||||
G_OBJECT_CLASS (meta_idle_monitor_xsync_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_xsync_constructed (GObject *object)
|
||||
{
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (object);
|
||||
|
||||
g_assert (!meta_is_wayland_compositor ());
|
||||
|
||||
monitor_xsync->display = meta_get_display ()->xdisplay;
|
||||
init_xsync (monitor_xsync);
|
||||
|
||||
G_OBJECT_CLASS (meta_idle_monitor_xsync_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static gint64
|
||||
meta_idle_monitor_xsync_get_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
|
||||
XSyncValue value;
|
||||
|
||||
if (!XSyncQueryCounter (monitor_xsync->display, monitor_xsync->counter, &value))
|
||||
return -1;
|
||||
|
||||
return _xsyncvalue_to_int64 (value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fire_watch_idle (gpointer data)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch = data;
|
||||
|
||||
watch->idle_source_id = 0;
|
||||
_meta_idle_monitor_watch_fire (watch);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_next_watch_serial (void)
|
||||
{
|
||||
static guint32 serial = 0;
|
||||
g_atomic_int_inc (&serial);
|
||||
return serial;
|
||||
}
|
||||
|
||||
static void
|
||||
free_watch (gpointer data)
|
||||
{
|
||||
MetaIdleMonitorWatchXSync *watch_xsync = data;
|
||||
MetaIdleMonitorWatch *watch = (MetaIdleMonitorWatch *) watch_xsync;
|
||||
MetaIdleMonitor *monitor = watch->monitor;
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
|
||||
|
||||
g_object_ref (monitor);
|
||||
|
||||
if (watch->idle_source_id)
|
||||
{
|
||||
g_source_remove (watch->idle_source_id);
|
||||
watch->idle_source_id = 0;
|
||||
}
|
||||
|
||||
if (watch->notify != NULL)
|
||||
watch->notify (watch->user_data);
|
||||
|
||||
if (watch_xsync->xalarm != monitor_xsync->user_active_alarm &&
|
||||
watch_xsync->xalarm != None)
|
||||
{
|
||||
XSyncDestroyAlarm (monitor_xsync->display, watch_xsync->xalarm);
|
||||
g_hash_table_remove (monitor_xsync->alarms, (gpointer) watch_xsync->xalarm);
|
||||
}
|
||||
|
||||
g_object_unref (monitor);
|
||||
g_slice_free (MetaIdleMonitorWatchXSync, watch_xsync);
|
||||
}
|
||||
|
||||
static MetaIdleMonitorWatch *
|
||||
meta_idle_monitor_xsync_make_watch (MetaIdleMonitor *monitor,
|
||||
guint64 timeout_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
|
||||
MetaIdleMonitorWatchXSync *watch_xsync;
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
watch_xsync = g_slice_new0 (MetaIdleMonitorWatchXSync);
|
||||
watch = (MetaIdleMonitorWatch *) watch_xsync;
|
||||
|
||||
watch->monitor = monitor;
|
||||
watch->id = get_next_watch_serial ();
|
||||
watch->callback = callback;
|
||||
watch->user_data = user_data;
|
||||
watch->notify = notify;
|
||||
watch->timeout_msec = timeout_msec;
|
||||
|
||||
if (monitor_xsync->user_active_alarm != None)
|
||||
{
|
||||
if (timeout_msec != 0)
|
||||
{
|
||||
watch_xsync->xalarm = _xsync_alarm_set (monitor_xsync, XSyncPositiveTransition, timeout_msec, TRUE);
|
||||
|
||||
g_hash_table_add (monitor_xsync->alarms, (gpointer) watch_xsync->xalarm);
|
||||
|
||||
if (meta_idle_monitor_get_idletime (monitor) > (gint64)timeout_msec)
|
||||
watch->idle_source_id = g_idle_add (fire_watch_idle, watch);
|
||||
}
|
||||
else
|
||||
{
|
||||
watch_xsync->xalarm = monitor_xsync->user_active_alarm;
|
||||
|
||||
set_alarm_enabled (monitor_xsync->display, monitor_xsync->user_active_alarm, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return watch;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_xsync_class_init (MetaIdleMonitorXSyncClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MetaIdleMonitorClass *idle_monitor_class = META_IDLE_MONITOR_CLASS (klass);
|
||||
|
||||
object_class->dispose = meta_idle_monitor_xsync_dispose;
|
||||
object_class->constructed = meta_idle_monitor_xsync_constructed;
|
||||
|
||||
idle_monitor_class->get_idletime = meta_idle_monitor_xsync_get_idletime;
|
||||
idle_monitor_class->make_watch = meta_idle_monitor_xsync_make_watch;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_xsync_init (MetaIdleMonitorXSync *monitor_xsync)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (monitor_xsync);
|
||||
|
||||
monitor->watches = g_hash_table_new_full (NULL, NULL, NULL, free_watch);
|
||||
monitor_xsync->alarms = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_xsync_handle_xevent (MetaIdleMonitor *monitor,
|
||||
XSyncAlarmNotifyEvent *alarm_event)
|
||||
{
|
||||
MetaIdleMonitorXSync *monitor_xsync = META_IDLE_MONITOR_XSYNC (monitor);
|
||||
XSyncAlarm alarm;
|
||||
GList *watches;
|
||||
gboolean has_alarm;
|
||||
|
||||
if (alarm_event->state != XSyncAlarmActive)
|
||||
return;
|
||||
|
||||
alarm = alarm_event->alarm;
|
||||
|
||||
has_alarm = FALSE;
|
||||
|
||||
if (alarm == monitor_xsync->user_active_alarm)
|
||||
{
|
||||
set_alarm_enabled (monitor_xsync->display,
|
||||
alarm,
|
||||
FALSE);
|
||||
has_alarm = TRUE;
|
||||
}
|
||||
else if (g_hash_table_contains (monitor_xsync->alarms, (gpointer) alarm))
|
||||
{
|
||||
ensure_alarm_rescheduled (monitor_xsync->display,
|
||||
alarm);
|
||||
has_alarm = TRUE;
|
||||
}
|
||||
|
||||
if (has_alarm)
|
||||
{
|
||||
watches = g_hash_table_get_values (monitor->watches);
|
||||
|
||||
g_list_foreach (watches, check_x11_watch, (gpointer) alarm);
|
||||
g_list_free (watches);
|
||||
}
|
||||
}
|
49
src/backends/x11/meta-idle-monitor-xsync.h
Normal file
49
src/backends/x11/meta-idle-monitor-xsync.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
#ifndef META_IDLE_MONITOR_XSYNC_H
|
||||
#define META_IDLE_MONITOR_XSYNC_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/sync.h>
|
||||
|
||||
#define META_TYPE_IDLE_MONITOR_XSYNC (meta_idle_monitor_xsync_get_type ())
|
||||
#define META_IDLE_MONITOR_XSYNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_IDLE_MONITOR_XSYNC, MetaIdleMonitorXSync))
|
||||
#define META_IDLE_MONITOR_XSYNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_IDLE_MONITOR_XSYNC, MetaIdleMonitorXSyncClass))
|
||||
#define META_IS_IDLE_MONITOR_XSYNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_IDLE_MONITOR_XSYNC))
|
||||
#define META_IS_IDLE_MONITOR_XSYNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_IDLE_MONITOR_XSYNC))
|
||||
#define META_IDLE_MONITOR_XSYNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_IDLE_MONITOR_XSYNC, MetaIdleMonitorXSyncClass))
|
||||
|
||||
typedef struct _MetaIdleMonitorXSync MetaIdleMonitorXSync;
|
||||
typedef struct _MetaIdleMonitorXSyncClass MetaIdleMonitorXSyncClass;
|
||||
|
||||
GType meta_idle_monitor_xsync_get_type (void);
|
||||
|
||||
void meta_idle_monitor_xsync_handle_xevent (MetaIdleMonitor *monitor,
|
||||
XSyncAlarmNotifyEvent *xevent);
|
||||
|
||||
void meta_idle_monitor_xsync_handle_xevent_all (XEvent *xevent);
|
||||
|
||||
#endif /* META_IDLE_MONITOR_XSYNC_H */
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-monitor-manager-xrandr.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
@ -36,9 +38,8 @@
|
||||
|
||||
#include <meta/main.h>
|
||||
#include <meta/errors.h>
|
||||
#include "monitor-private.h"
|
||||
|
||||
#include "edid.h"
|
||||
#include "meta-monitor-config.h"
|
||||
|
||||
#define ALL_WL_TRANSFORMS ((1 << (WL_OUTPUT_TRANSFORM_FLIPPED_270 + 1)) - 1)
|
||||
|
40
src/backends/x11/meta-monitor-manager-xrandr.h
Normal file
40
src/backends/x11/meta-monitor-manager-xrandr.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
* Copyright (C) 2003 Rob Adams
|
||||
* Copyright (C) 2004-2006 Elijah Newren
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef META_MONITOR_MANAGER_XRANDR_H
|
||||
#define META_MONITOR_MANAGER_XRANDR_H
|
||||
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER_XRANDR (meta_monitor_manager_xrandr_get_type ())
|
||||
#define META_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandr))
|
||||
#define META_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
||||
#define META_IS_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_XRANDR))
|
||||
#define META_IS_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_XRANDR))
|
||||
#define META_MONITOR_MANAGER_XRANDR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
||||
|
||||
typedef struct _MetaMonitorManagerXrandrClass MetaMonitorManagerXrandrClass;
|
||||
typedef struct _MetaMonitorManagerXrandr MetaMonitorManagerXrandr;
|
||||
|
||||
GType meta_monitor_manager_xrandr_get_type (void);
|
||||
|
||||
#endif /* META_MONITOR_MANAGER_XRANDR_H */
|
@ -11,8 +11,6 @@
|
||||
#include "meta-window-actor-private.h"
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
typedef struct _MetaCompScreen MetaCompScreen;
|
||||
|
||||
struct _MetaCompositor
|
||||
{
|
||||
MetaDisplay *display;
|
||||
@ -24,11 +22,6 @@ struct _MetaCompositor
|
||||
|
||||
guint server_time_is_monotonic_time : 1;
|
||||
guint no_mipmaps : 1;
|
||||
};
|
||||
|
||||
struct _MetaCompScreen
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
ClutterActor *stage, *window_group, *top_window_group;
|
||||
ClutterActor *background_actor;
|
||||
@ -50,13 +43,13 @@ struct _MetaCompScreen
|
||||
/* Wait 2ms after vblank before starting to draw next frame */
|
||||
#define META_SYNC_DELAY 2
|
||||
|
||||
void meta_switch_workspace_completed (MetaScreen *screen);
|
||||
void meta_switch_workspace_completed (MetaCompositor *compositor);
|
||||
|
||||
gboolean meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
gboolean meta_begin_modal_for_plugin (MetaCompositor *compositor,
|
||||
MetaPlugin *plugin,
|
||||
MetaModalOptions options,
|
||||
guint32 timestamp);
|
||||
void meta_end_modal_for_plugin (MetaScreen *screen,
|
||||
void meta_end_modal_for_plugin (MetaCompositor *compositor,
|
||||
MetaPlugin *plugin,
|
||||
guint32 timestamp);
|
||||
|
||||
|
@ -99,36 +99,34 @@ composite_at_least_version (MetaDisplay *display, int maj, int min)
|
||||
return (major > maj || (major == maj && minor >= min));
|
||||
}
|
||||
|
||||
static void sync_actor_stacking (MetaCompScreen *info);
|
||||
static void sync_actor_stacking (MetaCompositor *compositor);
|
||||
|
||||
static void
|
||||
meta_finish_workspace_switch (MetaCompScreen *info)
|
||||
meta_finish_workspace_switch (MetaCompositor *compositor)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
/* Finish hiding and showing actors for the new workspace */
|
||||
for (l = info->windows; l; l = l->next)
|
||||
for (l = compositor->windows; l; l = l->next)
|
||||
meta_window_actor_sync_visibility (l->data);
|
||||
|
||||
/* Fix up stacking order. */
|
||||
sync_actor_stacking (info);
|
||||
sync_actor_stacking (compositor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_switch_workspace_completed (MetaScreen *screen)
|
||||
meta_switch_workspace_completed (MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
/* FIXME -- must redo stacking order */
|
||||
info->switch_workspace_in_progress--;
|
||||
if (info->switch_workspace_in_progress < 0)
|
||||
compositor->switch_workspace_in_progress--;
|
||||
if (compositor->switch_workspace_in_progress < 0)
|
||||
{
|
||||
g_warning ("Error in workspace_switch accounting!");
|
||||
info->switch_workspace_in_progress = 0;
|
||||
compositor->switch_workspace_in_progress = 0;
|
||||
}
|
||||
|
||||
if (!info->switch_workspace_in_progress)
|
||||
meta_finish_workspace_switch (info);
|
||||
if (!compositor->switch_workspace_in_progress)
|
||||
meta_finish_workspace_switch (compositor);
|
||||
}
|
||||
|
||||
void
|
||||
@ -147,17 +145,17 @@ process_damage (MetaCompositor *compositor,
|
||||
}
|
||||
|
||||
static Window
|
||||
get_output_window (MetaScreen *screen)
|
||||
get_output_window (MetaCompositor *compositor)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
Window output, xroot;
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdisplay = display->xdisplay;
|
||||
Window output, xroot;
|
||||
XWindowAttributes attr;
|
||||
long event_mask;
|
||||
long event_mask;
|
||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
||||
|
||||
xroot = meta_screen_get_xroot (screen);
|
||||
xroot = display->screen->xroot;
|
||||
output = XCompositeGetOverlayWindow (xdisplay, xroot);
|
||||
|
||||
meta_core_add_old_event_mask (xdisplay, output, &mask);
|
||||
@ -182,6 +180,13 @@ get_output_window (MetaScreen *screen)
|
||||
return output;
|
||||
}
|
||||
|
||||
/* compat helper */
|
||||
static MetaCompositor *
|
||||
get_compositor_for_screen (MetaScreen *screen)
|
||||
{
|
||||
return screen->display->compositor;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_get_stage_for_screen:
|
||||
* @screen: a #MetaScreen
|
||||
@ -191,12 +196,8 @@ get_output_window (MetaScreen *screen)
|
||||
ClutterActor *
|
||||
meta_get_stage_for_screen (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return info->stage;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
return compositor->stage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,12 +209,8 @@ meta_get_stage_for_screen (MetaScreen *screen)
|
||||
ClutterActor *
|
||||
meta_get_window_group_for_screen (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return info->window_group;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
return compositor->window_group;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,12 +222,8 @@ meta_get_window_group_for_screen (MetaScreen *screen)
|
||||
ClutterActor *
|
||||
meta_get_top_window_group_for_screen (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return info->top_window_group;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
return compositor->top_window_group;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,12 +235,8 @@ meta_get_top_window_group_for_screen (MetaScreen *screen)
|
||||
GList *
|
||||
meta_get_window_actors (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return info->windows;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
return compositor->windows;
|
||||
}
|
||||
|
||||
void
|
||||
@ -261,10 +250,10 @@ meta_set_stage_input_region (MetaScreen *screen,
|
||||
*/
|
||||
if (!meta_is_wayland_compositor ())
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdpy = meta_display_get_xdisplay (display);
|
||||
Window xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
||||
MetaDisplay *display = screen->display;
|
||||
MetaCompositor *compositor = display->compositor;
|
||||
Display *xdpy = meta_display_get_xdisplay (display);
|
||||
Window xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
||||
|
||||
XFixesSetWindowShapeRegion (xdpy, xstage, ShapeInput, 0, 0, region);
|
||||
|
||||
@ -273,7 +262,7 @@ meta_set_stage_input_region (MetaScreen *screen,
|
||||
* it's not the user doing something, it's the environment changing under the user.
|
||||
*/
|
||||
meta_display_add_ignored_crossing_serial (display, XNextRequest (xdpy));
|
||||
XFixesSetWindowShapeRegion (xdpy, info->output, ShapeInput, 0, 0, region);
|
||||
XFixesSetWindowShapeRegion (xdpy, compositor->output, ShapeInput, 0, 0, region);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,15 +327,14 @@ meta_stage_is_focused (MetaScreen *screen)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
begin_modal_x11 (MetaScreen *screen,
|
||||
begin_modal_x11 (MetaCompositor *compositor,
|
||||
MetaPlugin *plugin,
|
||||
MetaModalOptions options,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdpy = meta_display_get_xdisplay (display);
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
Window grab_window = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
||||
Window grab_window = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
||||
int result;
|
||||
gboolean pointer_grabbed = FALSE;
|
||||
gboolean keyboard_grabbed = FALSE;
|
||||
@ -411,7 +399,7 @@ begin_modal_x11 (MetaScreen *screen,
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
meta_begin_modal_for_plugin (MetaCompositor *compositor,
|
||||
MetaPlugin *plugin,
|
||||
MetaModalOptions options,
|
||||
guint32 timestamp)
|
||||
@ -420,18 +408,17 @@ meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
* are significant differences in how we handle grabs that make it difficult to
|
||||
* merge the two.
|
||||
*/
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
|
||||
if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE)
|
||||
return FALSE;
|
||||
|
||||
if (!meta_is_wayland_compositor ())
|
||||
if (!begin_modal_x11 (screen, plugin, options, timestamp))
|
||||
if (!begin_modal_x11 (compositor, plugin, options, timestamp))
|
||||
return FALSE;
|
||||
|
||||
display->grab_op = META_GRAB_OP_COMPOSITOR;
|
||||
display->grab_window = NULL;
|
||||
display->grab_screen = screen;
|
||||
display->grab_have_pointer = TRUE;
|
||||
display->grab_have_keyboard = TRUE;
|
||||
|
||||
@ -442,18 +429,17 @@ meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
}
|
||||
|
||||
void
|
||||
meta_end_modal_for_plugin (MetaScreen *screen,
|
||||
meta_end_modal_for_plugin (MetaCompositor *compositor,
|
||||
MetaPlugin *plugin,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdpy = meta_display_get_xdisplay (display);
|
||||
|
||||
g_return_if_fail (is_modal (display));
|
||||
|
||||
display->grab_op = META_GRAB_OP_NONE;
|
||||
display->grab_window = NULL;
|
||||
display->grab_screen = NULL;
|
||||
display->grab_have_pointer = FALSE;
|
||||
display->grab_have_keyboard = FALSE;
|
||||
|
||||
@ -472,10 +458,10 @@ static void
|
||||
after_stage_paint (ClutterStage *stage,
|
||||
gpointer data)
|
||||
{
|
||||
MetaCompScreen *info = (MetaCompScreen*) data;
|
||||
MetaCompositor *compositor = data;
|
||||
GList *l;
|
||||
|
||||
for (l = info->windows; l; l = l->next)
|
||||
for (l = compositor->windows; l; l = l->next)
|
||||
meta_window_actor_post_paint (l->data);
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
@ -483,8 +469,7 @@ after_stage_paint (ClutterStage *stage,
|
||||
}
|
||||
|
||||
static void
|
||||
redirect_windows (MetaCompositor *compositor,
|
||||
MetaScreen *screen)
|
||||
redirect_windows (MetaScreen *screen)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
@ -506,7 +491,7 @@ redirect_windows (MetaCompositor *compositor,
|
||||
*/
|
||||
while (TRUE)
|
||||
{
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
||||
XSync (xdisplay, FALSE);
|
||||
|
||||
@ -527,48 +512,35 @@ redirect_windows (MetaCompositor *compositor,
|
||||
}
|
||||
|
||||
void
|
||||
meta_compositor_manage_screen (MetaCompositor *compositor,
|
||||
MetaScreen *screen)
|
||||
meta_compositor_manage (MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompScreen *info;
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
Window xwin = None;
|
||||
gint width, height;
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdisplay = display->xdisplay;
|
||||
MetaScreen *screen = display->screen;
|
||||
Window xwin = 0;
|
||||
gint width, height;
|
||||
MetaWaylandCompositor *wayland_compositor;
|
||||
|
||||
/* Check if the screen is already managed */
|
||||
if (meta_screen_get_compositor_data (screen))
|
||||
return;
|
||||
|
||||
info = g_new0 (MetaCompScreen, 1);
|
||||
info->screen = screen;
|
||||
|
||||
meta_screen_set_compositor_data (screen, info);
|
||||
|
||||
info->output = None;
|
||||
info->windows = NULL;
|
||||
|
||||
meta_screen_set_cm_selection (screen);
|
||||
meta_screen_set_cm_selection (display->screen);
|
||||
|
||||
/* We will have already created a stage if running as a wayland
|
||||
* compositor... */
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
wayland_compositor = meta_wayland_compositor_get_default ();
|
||||
info->stage = wayland_compositor->stage;
|
||||
compositor->stage = wayland_compositor->stage;
|
||||
|
||||
meta_screen_get_size (screen, &width, &height);
|
||||
clutter_actor_set_size (info->stage, width, height);
|
||||
clutter_actor_set_size (compositor->stage, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
info->stage = clutter_stage_new ();
|
||||
compositor->stage = clutter_stage_new ();
|
||||
|
||||
meta_screen_get_size (screen, &width, &height);
|
||||
clutter_actor_realize (info->stage);
|
||||
clutter_actor_realize (compositor->stage);
|
||||
|
||||
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
||||
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
||||
|
||||
XResizeWindow (xdisplay, xwin, width, height);
|
||||
|
||||
@ -602,30 +574,30 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
||||
}
|
||||
}
|
||||
|
||||
clutter_stage_set_paint_callback (CLUTTER_STAGE (info->stage),
|
||||
clutter_stage_set_paint_callback (CLUTTER_STAGE (compositor->stage),
|
||||
after_stage_paint,
|
||||
info,
|
||||
compositor,
|
||||
NULL);
|
||||
|
||||
clutter_stage_set_sync_delay (CLUTTER_STAGE (info->stage), META_SYNC_DELAY);
|
||||
clutter_stage_set_sync_delay (CLUTTER_STAGE (compositor->stage), META_SYNC_DELAY);
|
||||
|
||||
info->window_group = meta_window_group_new (screen);
|
||||
info->top_window_group = meta_window_group_new (screen);
|
||||
compositor->window_group = meta_window_group_new (screen);
|
||||
compositor->top_window_group = meta_window_group_new (screen);
|
||||
|
||||
clutter_actor_add_child (info->stage, info->window_group);
|
||||
clutter_actor_add_child (info->stage, info->top_window_group);
|
||||
clutter_actor_add_child (compositor->stage, compositor->window_group);
|
||||
clutter_actor_add_child (compositor->stage, compositor->top_window_group);
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
/* NB: When running as a wayland compositor we don't need an X
|
||||
* composite overlay window, and we don't need to play any input
|
||||
* region tricks to redirect events into clutter. */
|
||||
info->output = None;
|
||||
compositor->output = None;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->output = get_output_window (screen);
|
||||
XReparentWindow (xdisplay, xwin, info->output, 0, 0);
|
||||
compositor->output = get_output_window (compositor);
|
||||
XReparentWindow (xdisplay, xwin, compositor->output, 0, 0);
|
||||
|
||||
meta_empty_stage_input_region (screen);
|
||||
|
||||
@ -637,28 +609,27 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
||||
* because the X server will destroy the overlay window
|
||||
* when the last client using it exits.
|
||||
*/
|
||||
XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, None);
|
||||
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, None);
|
||||
|
||||
/* Map overlay window before redirecting windows offscreen so we catch their
|
||||
* contents until we show the stage.
|
||||
*/
|
||||
XMapWindow (xdisplay, info->output);
|
||||
XMapWindow (xdisplay, compositor->output);
|
||||
}
|
||||
|
||||
redirect_windows (compositor, screen);
|
||||
redirect_windows (display->screen);
|
||||
|
||||
info->plugin_mgr = meta_plugin_manager_new (screen);
|
||||
compositor->plugin_mgr = meta_plugin_manager_new (compositor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||
MetaScreen *screen)
|
||||
meta_compositor_unmanage (MetaCompositor *compositor)
|
||||
{
|
||||
if (!meta_is_wayland_compositor ())
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
Window xroot = meta_screen_get_xroot (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
Window xroot = display->screen->xroot;
|
||||
|
||||
/* This is the most important part of cleanup - we have to do this
|
||||
* before giving up the window manager selection or the next
|
||||
@ -669,7 +640,7 @@ meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||
|
||||
/**
|
||||
* meta_shape_cow_for_window:
|
||||
* @screen: A #MetaScreen
|
||||
* @compositor: A #MetaCompositor
|
||||
* @window: (allow-none): A #MetaWindow to shape the COW for
|
||||
*
|
||||
* Sets an bounding shape on the COW so that the given window
|
||||
@ -679,14 +650,14 @@ meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||
* of the COW, letting the raw window be seen through below.
|
||||
*/
|
||||
static void
|
||||
meta_shape_cow_for_window (MetaScreen *screen,
|
||||
meta_shape_cow_for_window (MetaCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (meta_screen_get_display (screen));
|
||||
MetaDisplay *display = compositor->display;
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
|
||||
if (window == NULL)
|
||||
XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, None);
|
||||
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, None);
|
||||
else
|
||||
{
|
||||
XserverRegion output_region;
|
||||
@ -701,7 +672,7 @@ meta_shape_cow_for_window (MetaScreen *screen,
|
||||
window_bounds.width = rect.width;
|
||||
window_bounds.height = rect.height;
|
||||
|
||||
meta_screen_get_size (screen, &width, &height);
|
||||
meta_screen_get_size (display->screen, &width, &height);
|
||||
screen_rect.x = 0;
|
||||
screen_rect.y = 0;
|
||||
screen_rect.width = width;
|
||||
@ -710,47 +681,45 @@ meta_shape_cow_for_window (MetaScreen *screen,
|
||||
output_region = XFixesCreateRegion (xdisplay, &window_bounds, 1);
|
||||
|
||||
XFixesInvertRegion (xdisplay, output_region, &screen_rect, output_region);
|
||||
XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, output_region);
|
||||
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, output_region);
|
||||
XFixesDestroyRegion (xdisplay, output_region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_unredirected_window (MetaCompScreen *info,
|
||||
set_unredirected_window (MetaCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
{
|
||||
if (info->unredirected_window == window)
|
||||
if (compositor->unredirected_window == window)
|
||||
return;
|
||||
|
||||
if (info->unredirected_window != NULL)
|
||||
if (compositor->unredirected_window != NULL)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (info->unredirected_window));
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (compositor->unredirected_window));
|
||||
meta_window_actor_set_unredirected (window_actor, FALSE);
|
||||
}
|
||||
|
||||
info->unredirected_window = window;
|
||||
compositor->unredirected_window = window;
|
||||
|
||||
if (info->unredirected_window != NULL)
|
||||
if (compositor->unredirected_window != NULL)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (info->unredirected_window));
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (compositor->unredirected_window));
|
||||
meta_window_actor_set_unredirected (window_actor, TRUE);
|
||||
}
|
||||
|
||||
meta_shape_cow_for_window (info->screen, info->unredirected_window);
|
||||
meta_shape_cow_for_window (compositor, compositor->unredirected_window);
|
||||
}
|
||||
|
||||
void
|
||||
meta_compositor_add_window (MetaCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
{
|
||||
MetaScreen *screen = meta_window_get_screen (window);
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
|
||||
meta_window_actor_new (window);
|
||||
sync_actor_stacking (info);
|
||||
sync_actor_stacking (compositor);
|
||||
|
||||
meta_error_trap_pop (display);
|
||||
}
|
||||
@ -760,11 +729,9 @@ meta_compositor_remove_window (MetaCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
||||
MetaScreen *screen = meta_window_get_screen (window);
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (info->unredirected_window == window)
|
||||
set_unredirected_window (info, NULL);
|
||||
if (compositor->unredirected_window == window)
|
||||
set_unredirected_window (compositor, NULL);
|
||||
|
||||
meta_window_actor_destroy (window_actor);
|
||||
}
|
||||
@ -881,11 +848,11 @@ event_is_passive_button_grab (MetaDisplay *display,
|
||||
* these events by pretending we got an event on the stage window.
|
||||
*/
|
||||
static void
|
||||
maybe_spoof_event_as_stage_event (MetaCompScreen *info,
|
||||
maybe_spoof_event_as_stage_event (MetaCompositor *compositor,
|
||||
MetaWindow *window,
|
||||
XEvent *event)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (info->screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
|
||||
if (event->type == GenericEvent &&
|
||||
event->xcookie.extension == display->xinput_opcode)
|
||||
@ -909,10 +876,10 @@ maybe_spoof_event_as_stage_event (MetaCompScreen *info,
|
||||
case XI_KeyRelease:
|
||||
/* If this is a GTK+ widget, like a window menu, let GTK+ handle
|
||||
* it as-is without mangling. */
|
||||
if (meta_ui_window_is_widget (info->screen->ui, device_event->event))
|
||||
if (meta_ui_window_is_widget (display->screen->ui, device_event->event))
|
||||
break;
|
||||
|
||||
device_event->event = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
||||
device_event->event = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
||||
device_event->event_x = device_event->root_x;
|
||||
device_event->event_y = device_event->root_y;
|
||||
break;
|
||||
@ -935,14 +902,10 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
{
|
||||
MetaDisplay *display = compositor->display;
|
||||
MetaScreen *screen = display->screens->data;
|
||||
MetaCompScreen *info;
|
||||
|
||||
info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (is_modal (display) && is_grabbed_event (compositor->display, event))
|
||||
if (is_modal (display) && is_grabbed_event (display, event))
|
||||
{
|
||||
meta_plugin_manager_xevent_filter (info->plugin_mgr, event);
|
||||
meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event);
|
||||
|
||||
/* We always consume events even if the plugin says it didn't handle them;
|
||||
* exclusive is exclusive */
|
||||
@ -950,9 +913,9 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
||||
}
|
||||
|
||||
if (!meta_is_wayland_compositor ())
|
||||
maybe_spoof_event_as_stage_event (info, window, event);
|
||||
maybe_spoof_event_as_stage_event (compositor, window, event);
|
||||
|
||||
if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
|
||||
if (meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event))
|
||||
return TRUE;
|
||||
|
||||
if (!meta_is_wayland_compositor () &&
|
||||
@ -967,7 +930,8 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
||||
window = meta_display_lookup_x_window (compositor->display, xwin);
|
||||
}
|
||||
|
||||
process_damage (compositor, (XDamageNotifyEvent *) event, window);
|
||||
if (window)
|
||||
process_damage (compositor, (XDamageNotifyEvent *) event, window);
|
||||
}
|
||||
|
||||
/* Clutter needs to know about MapNotify events otherwise it will
|
||||
@ -984,11 +948,9 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
||||
|
||||
gboolean
|
||||
meta_compositor_filter_keybinding (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaKeyBinding *binding)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
return meta_plugin_manager_filter_keybinding (info->plugin_mgr, binding);
|
||||
return meta_plugin_manager_filter_keybinding (compositor->plugin_mgr, binding);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1031,40 +993,35 @@ meta_compositor_unmaximize_window (MetaCompositor *compositor,
|
||||
|
||||
void
|
||||
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
MetaCompScreen *info;
|
||||
gint to_indx, from_indx;
|
||||
gint to_indx, from_indx;
|
||||
|
||||
info = meta_screen_get_compositor_data (screen);
|
||||
to_indx = meta_workspace_index (to);
|
||||
from_indx = meta_workspace_index (from);
|
||||
|
||||
if (!info) /* During startup before manage_screen() */
|
||||
return;
|
||||
compositor->switch_workspace_in_progress++;
|
||||
|
||||
info->switch_workspace_in_progress++;
|
||||
|
||||
if (!meta_plugin_manager_switch_workspace (info->plugin_mgr,
|
||||
from_indx, to_indx,
|
||||
if (!meta_plugin_manager_switch_workspace (compositor->plugin_mgr,
|
||||
from_indx,
|
||||
to_indx,
|
||||
direction))
|
||||
{
|
||||
info->switch_workspace_in_progress--;
|
||||
compositor->switch_workspace_in_progress--;
|
||||
|
||||
/* We have to explicitely call this to fix up stacking order of the
|
||||
* actors; this is because the abs stacking position of actors does not
|
||||
* necessarily change during the window hiding/unhiding, only their
|
||||
* relative position toward the destkop window.
|
||||
*/
|
||||
meta_finish_workspace_switch (info);
|
||||
meta_finish_workspace_switch (compositor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sync_actor_stacking (MetaCompScreen *info)
|
||||
sync_actor_stacking (MetaCompositor *compositor)
|
||||
{
|
||||
GList *children;
|
||||
GList *expected_window_node;
|
||||
@ -1080,7 +1037,7 @@ sync_actor_stacking (MetaCompScreen *info)
|
||||
* little effort to make sure we actually need to restack before
|
||||
* we go ahead and do it */
|
||||
|
||||
children = clutter_actor_get_children (info->window_group);
|
||||
children = clutter_actor_get_children (compositor->window_group);
|
||||
has_windows = FALSE;
|
||||
reordered = FALSE;
|
||||
|
||||
@ -1092,7 +1049,7 @@ sync_actor_stacking (MetaCompScreen *info)
|
||||
/* First we collect a list of all backgrounds, and check if they're at the
|
||||
* bottom. Then we check if the window actors are in the correct sequence */
|
||||
backgrounds = NULL;
|
||||
expected_window_node = info->windows;
|
||||
expected_window_node = compositor->windows;
|
||||
for (old = children; old != NULL; old = old->next)
|
||||
{
|
||||
ClutterActor *actor = old->data;
|
||||
@ -1130,7 +1087,7 @@ sync_actor_stacking (MetaCompScreen *info)
|
||||
* We reorder the actors even if they're not parented to the window group,
|
||||
* to allow stacking to work with intermediate actors (eg during effects)
|
||||
*/
|
||||
for (tmp = g_list_last (info->windows); tmp != NULL; tmp = tmp->prev)
|
||||
for (tmp = g_list_last (compositor->windows); tmp != NULL; tmp = tmp->prev)
|
||||
{
|
||||
ClutterActor *actor = tmp->data, *parent;
|
||||
|
||||
@ -1153,11 +1110,9 @@ sync_actor_stacking (MetaCompScreen *info)
|
||||
|
||||
void
|
||||
meta_compositor_sync_stack (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
GList *stack)
|
||||
{
|
||||
GList *old_stack;
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
/* This is painful because hidden windows that we are in the process
|
||||
* of animating out of existence. They'll be at the bottom of the
|
||||
@ -1167,8 +1122,8 @@ meta_compositor_sync_stack (MetaCompositor *compositor,
|
||||
|
||||
/* Sources: first window is the highest */
|
||||
stack = g_list_copy (stack); /* The new stack of MetaWindow */
|
||||
old_stack = g_list_reverse (info->windows); /* The old stack of MetaWindowActor */
|
||||
info->windows = NULL;
|
||||
old_stack = g_list_reverse (compositor->windows); /* The old stack of MetaWindowActor */
|
||||
compositor->windows = NULL;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
@ -1232,13 +1187,13 @@ meta_compositor_sync_stack (MetaCompositor *compositor,
|
||||
* be at the front of at least one, hopefully it will be
|
||||
* near the front of the other.)
|
||||
*/
|
||||
info->windows = g_list_prepend (info->windows, actor);
|
||||
compositor->windows = g_list_prepend (compositor->windows, actor);
|
||||
|
||||
stack = g_list_remove (stack, window);
|
||||
old_stack = g_list_remove (old_stack, actor);
|
||||
}
|
||||
|
||||
sync_actor_stacking (info);
|
||||
sync_actor_stacking (compositor);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1252,12 +1207,10 @@ meta_compositor_sync_window_geometry (MetaCompositor *compositor,
|
||||
|
||||
void
|
||||
meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
MetaDisplay *display = compositor->display;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
@ -1271,23 +1224,21 @@ meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
||||
show the right portions on the right screens.
|
||||
*/
|
||||
|
||||
clutter_actor_set_size (info->stage, width, height);
|
||||
clutter_actor_set_size (compositor->stage, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
Display *xdisplay;
|
||||
Window xwin;
|
||||
|
||||
g_return_if_fail (info);
|
||||
|
||||
xdisplay = meta_display_get_xdisplay (display);
|
||||
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
||||
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
||||
|
||||
XResizeWindow (xdisplay, xwin, width, height);
|
||||
}
|
||||
|
||||
meta_verbose ("Changed size for stage on screen %d to %dx%d\n",
|
||||
meta_screen_get_screen_number (screen),
|
||||
meta_screen_get_screen_number (display->screen),
|
||||
width, height);
|
||||
}
|
||||
|
||||
@ -1297,7 +1248,7 @@ frame_callback (CoglOnscreen *onscreen,
|
||||
CoglFrameInfo *frame_info,
|
||||
void *user_data)
|
||||
{
|
||||
MetaCompScreen *info = user_data;
|
||||
MetaCompositor *compositor = user_data;
|
||||
GList *l;
|
||||
|
||||
if (event == COGL_FRAME_EVENT_COMPLETE)
|
||||
@ -1328,38 +1279,38 @@ frame_callback (CoglOnscreen *onscreen,
|
||||
presentation_time = 0;
|
||||
}
|
||||
|
||||
for (l = info->windows; l; l = l->next)
|
||||
for (l = compositor->windows; l; l = l->next)
|
||||
meta_window_actor_frame_complete (l->data, frame_info, presentation_time);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pre_paint_windows (MetaCompScreen *info)
|
||||
pre_paint_windows (MetaCompositor *compositor)
|
||||
{
|
||||
GList *l;
|
||||
MetaWindowActor *top_window;
|
||||
|
||||
if (info->onscreen == NULL)
|
||||
if (compositor->onscreen == NULL)
|
||||
{
|
||||
info->onscreen = COGL_ONSCREEN (cogl_get_draw_framebuffer ());
|
||||
info->frame_closure = cogl_onscreen_add_frame_callback (info->onscreen,
|
||||
frame_callback,
|
||||
info,
|
||||
NULL);
|
||||
compositor->onscreen = COGL_ONSCREEN (cogl_get_draw_framebuffer ());
|
||||
compositor->frame_closure = cogl_onscreen_add_frame_callback (compositor->onscreen,
|
||||
frame_callback,
|
||||
compositor,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (info->windows == NULL)
|
||||
if (compositor->windows == NULL)
|
||||
return;
|
||||
|
||||
top_window = g_list_last (info->windows)->data;
|
||||
top_window = g_list_last (compositor->windows)->data;
|
||||
|
||||
if (meta_window_actor_should_unredirect (top_window) &&
|
||||
info->disable_unredirect_count == 0)
|
||||
set_unredirected_window (info, meta_window_actor_get_meta_window (top_window));
|
||||
compositor->disable_unredirect_count == 0)
|
||||
set_unredirected_window (compositor, meta_window_actor_get_meta_window (top_window));
|
||||
else
|
||||
set_unredirected_window (info, NULL);
|
||||
set_unredirected_window (compositor, NULL);
|
||||
|
||||
for (l = info->windows; l; l = l->next)
|
||||
for (l = compositor->windows; l; l = l->next)
|
||||
meta_window_actor_pre_paint (l->data);
|
||||
}
|
||||
|
||||
@ -1367,19 +1318,7 @@ static gboolean
|
||||
meta_repaint_func (gpointer data)
|
||||
{
|
||||
MetaCompositor *compositor = data;
|
||||
GSList *screens = meta_display_get_screens (compositor->display);
|
||||
GSList *l;
|
||||
|
||||
for (l = screens; l; l = l->next)
|
||||
{
|
||||
MetaScreen *screen = l->data;
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
if (!info)
|
||||
continue;
|
||||
|
||||
pre_paint_windows (info);
|
||||
}
|
||||
|
||||
pre_paint_windows (compositor);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1387,20 +1326,10 @@ static void
|
||||
on_shadow_factory_changed (MetaShadowFactory *factory,
|
||||
MetaCompositor *compositor)
|
||||
{
|
||||
GSList *screens = meta_display_get_screens (compositor->display);
|
||||
GList *l;
|
||||
GSList *sl;
|
||||
|
||||
for (sl = screens; sl; sl = sl->next)
|
||||
{
|
||||
MetaScreen *screen = sl->data;
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
if (!info)
|
||||
continue;
|
||||
|
||||
for (l = info->windows; l; l = l->next)
|
||||
meta_window_actor_invalidate_shadow (l->data);
|
||||
}
|
||||
for (l = compositor->windows; l; l = l->next)
|
||||
meta_window_actor_invalidate_shadow (l->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1443,9 +1372,8 @@ meta_compositor_new (MetaDisplay *display)
|
||||
Window
|
||||
meta_get_overlay_window (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
return info->output;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
return compositor->output;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1459,9 +1387,8 @@ meta_get_overlay_window (MetaScreen *screen)
|
||||
void
|
||||
meta_disable_unredirect_for_screen (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
if (info != NULL)
|
||||
info->disable_unredirect_count = info->disable_unredirect_count + 1;
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
compositor->disable_unredirect_count++;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1474,11 +1401,11 @@ meta_disable_unredirect_for_screen (MetaScreen *screen)
|
||||
void
|
||||
meta_enable_unredirect_for_screen (MetaScreen *screen)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
if (info != NULL && info->disable_unredirect_count == 0)
|
||||
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
||||
if (compositor->disable_unredirect_count == 0)
|
||||
g_warning ("Called enable_unredirect_for_screen while unredirection is enabled.");
|
||||
if (info != NULL && info->disable_unredirect_count > 0)
|
||||
info->disable_unredirect_count = info->disable_unredirect_count - 1;
|
||||
if (compositor->disable_unredirect_count > 0)
|
||||
compositor->disable_unredirect_count--;
|
||||
}
|
||||
|
||||
#define FLASH_TIME_MS 50
|
||||
@ -1575,20 +1502,16 @@ meta_compositor_monotonic_time_to_server_time (MetaDisplay *display,
|
||||
|
||||
void
|
||||
meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
MetaRectangle *tile_rect,
|
||||
int tile_monitor_number)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
meta_plugin_manager_show_tile_preview (info->plugin_mgr,
|
||||
meta_plugin_manager_show_tile_preview (compositor->plugin_mgr,
|
||||
window, tile_rect, tile_monitor_number);
|
||||
}
|
||||
|
||||
void
|
||||
meta_compositor_hide_tile_preview (MetaCompositor *compositor,
|
||||
MetaScreen *screen)
|
||||
meta_compositor_hide_tile_preview (MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
meta_plugin_manager_hide_tile_preview (info->plugin_mgr);
|
||||
meta_plugin_manager_hide_tile_preview (compositor->plugin_mgr);
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <cogl/cogl-texture-pixmap-x11.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "cogl-utils.h"
|
||||
@ -755,88 +753,6 @@ set_filename (MetaBackground *self,
|
||||
priv->filename = g_strdup (filename);
|
||||
}
|
||||
|
||||
static Pixmap
|
||||
get_still_frame_for_monitor (MetaScreen *screen,
|
||||
int monitor)
|
||||
{
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
Window xroot = meta_screen_get_xroot (screen);
|
||||
Pixmap pixmap;
|
||||
GC gc;
|
||||
XGCValues values;
|
||||
MetaRectangle geometry;
|
||||
int depth;
|
||||
|
||||
meta_screen_get_monitor_geometry (screen, monitor, &geometry);
|
||||
|
||||
depth = DefaultDepth (xdisplay, meta_screen_get_screen_number (screen));
|
||||
|
||||
pixmap = XCreatePixmap (xdisplay,
|
||||
xroot,
|
||||
geometry.width, geometry.height, depth);
|
||||
|
||||
values.function = GXcopy;
|
||||
values.plane_mask = AllPlanes;
|
||||
values.fill_style = FillSolid;
|
||||
values.subwindow_mode = IncludeInferiors;
|
||||
|
||||
gc = XCreateGC (xdisplay,
|
||||
xroot,
|
||||
GCFunction | GCPlaneMask | GCFillStyle | GCSubwindowMode,
|
||||
&values);
|
||||
|
||||
XCopyArea (xdisplay,
|
||||
xroot, pixmap, gc,
|
||||
geometry.x, geometry.y,
|
||||
geometry.width, geometry.height,
|
||||
0, 0);
|
||||
|
||||
XFreeGC (xdisplay, gc);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_background_load_still_frame:
|
||||
* @self: the #MetaBackground
|
||||
*
|
||||
* Takes a screenshot of the desktop and uses it as the background
|
||||
* source.
|
||||
*/
|
||||
void
|
||||
meta_background_load_still_frame (MetaBackground *self)
|
||||
{
|
||||
MetaBackgroundPrivate *priv = self->priv;
|
||||
MetaDisplay *display = meta_screen_get_display (priv->screen);
|
||||
Pixmap still_frame;
|
||||
CoglTexture *texture;
|
||||
CoglContext *context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||
GError *error = NULL;
|
||||
|
||||
ensure_pipeline (self);
|
||||
|
||||
unset_texture (self);
|
||||
set_style (self, G_DESKTOP_BACKGROUND_STYLE_STRETCHED);
|
||||
|
||||
still_frame = get_still_frame_for_monitor (priv->screen, priv->monitor);
|
||||
XSync (meta_display_get_xdisplay (display), False);
|
||||
|
||||
meta_error_trap_push (display);
|
||||
texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (context, still_frame, FALSE, &error));
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
g_warning ("Failed to create background texture from pixmap: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
set_texture (self, texture);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_background_load_gradient:
|
||||
* @self: the #MetaBackground
|
||||
|
@ -37,7 +37,7 @@ static GType plugin_type = G_TYPE_NONE;
|
||||
|
||||
struct MetaPluginManager
|
||||
{
|
||||
MetaScreen *screen;
|
||||
MetaCompositor *compositor;
|
||||
MetaPlugin *plugin;
|
||||
};
|
||||
|
||||
@ -91,7 +91,7 @@ on_confirm_display_change (MetaMonitorManager *monitors,
|
||||
}
|
||||
|
||||
MetaPluginManager *
|
||||
meta_plugin_manager_new (MetaScreen *screen)
|
||||
meta_plugin_manager_new (MetaCompositor *compositor)
|
||||
{
|
||||
MetaPluginManager *plugin_mgr;
|
||||
MetaPluginClass *klass;
|
||||
@ -99,10 +99,10 @@ meta_plugin_manager_new (MetaScreen *screen)
|
||||
MetaMonitorManager *monitors;
|
||||
|
||||
plugin_mgr = g_new0 (MetaPluginManager, 1);
|
||||
plugin_mgr->screen = screen;
|
||||
plugin_mgr->compositor = compositor;
|
||||
plugin_mgr->plugin = plugin = g_object_new (plugin_type, NULL);
|
||||
|
||||
_meta_plugin_set_screen (plugin, screen);
|
||||
_meta_plugin_set_compositor (plugin, compositor);
|
||||
|
||||
klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
|
||||
@ -153,7 +153,7 @@ meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
|
||||
{
|
||||
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||
MetaDisplay *display = plugin_mgr->compositor->display;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (display->display_opening)
|
||||
@ -213,7 +213,7 @@ meta_plugin_manager_event_maximize (MetaPluginManager *plugin_mgr,
|
||||
{
|
||||
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||
MetaDisplay *display = plugin_mgr->compositor->display;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (display->display_opening)
|
||||
@ -266,7 +266,7 @@ meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr,
|
||||
{
|
||||
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||
MetaDisplay *display = plugin_mgr->compositor->display;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (display->display_opening)
|
||||
@ -324,7 +324,7 @@ meta_plugin_manager_show_tile_preview (MetaPluginManager *plugin_mgr,
|
||||
{
|
||||
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||
MetaDisplay *display = plugin_mgr->compositor->display;
|
||||
|
||||
if (display->display_opening)
|
||||
return FALSE;
|
||||
@ -343,7 +343,7 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||
MetaDisplay *display = plugin_mgr->compositor->display;
|
||||
|
||||
if (display->display_opening)
|
||||
return FALSE;
|
||||
|
@ -44,7 +44,7 @@
|
||||
*/
|
||||
typedef struct MetaPluginManager MetaPluginManager;
|
||||
|
||||
MetaPluginManager * meta_plugin_manager_new (MetaScreen *screen);
|
||||
MetaPluginManager * meta_plugin_manager_new (MetaCompositor *compositor);
|
||||
|
||||
void meta_plugin_manager_load (const gchar *plugin_name);
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
#include "compositor-private.h"
|
||||
#include "meta-window-actor-private.h"
|
||||
#include "monitor-private.h"
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (MetaPlugin, meta_plugin, G_TYPE_OBJECT);
|
||||
|
||||
@ -49,7 +49,7 @@ G_DEFINE_ABSTRACT_TYPE (MetaPlugin, meta_plugin, G_TYPE_OBJECT);
|
||||
|
||||
struct _MetaPluginPrivate
|
||||
{
|
||||
MetaScreen *screen;
|
||||
MetaCompositor *compositor;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -101,9 +101,8 @@ void
|
||||
meta_plugin_switch_workspace_completed (MetaPlugin *plugin)
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
|
||||
MetaScreen *screen = priv->screen;
|
||||
|
||||
meta_switch_workspace_completed (screen);
|
||||
meta_switch_workspace_completed (priv->compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -177,7 +176,7 @@ meta_plugin_begin_modal (MetaPlugin *plugin,
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
|
||||
|
||||
return meta_begin_modal_for_plugin (priv->screen, plugin,
|
||||
return meta_begin_modal_for_plugin (priv->compositor, plugin,
|
||||
options, timestamp);
|
||||
}
|
||||
|
||||
@ -198,7 +197,7 @@ meta_plugin_end_modal (MetaPlugin *plugin,
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
|
||||
|
||||
meta_end_modal_for_plugin (priv->screen, plugin, timestamp);
|
||||
meta_end_modal_for_plugin (priv->compositor, plugin, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,16 +213,15 @@ meta_plugin_get_screen (MetaPlugin *plugin)
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
|
||||
|
||||
return priv->screen;
|
||||
return priv->compositor->display->screen;
|
||||
}
|
||||
|
||||
void
|
||||
_meta_plugin_set_screen (MetaPlugin *plugin,
|
||||
MetaScreen *screen)
|
||||
_meta_plugin_set_compositor (MetaPlugin *plugin, MetaCompositor *compositor)
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
|
||||
|
||||
priv->screen = screen;
|
||||
priv->compositor = compositor;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -80,26 +80,6 @@ meta_surface_actor_wayland_pre_paint (MetaSurfaceActor *actor)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_surface_actor_wayland_is_argb32 (MetaSurfaceActor *actor)
|
||||
{
|
||||
MetaShapedTexture *stex = meta_surface_actor_get_texture (actor);
|
||||
CoglTexture *texture = meta_shaped_texture_get_texture (stex);
|
||||
|
||||
switch (cogl_texture_get_components (texture))
|
||||
{
|
||||
case COGL_TEXTURE_COMPONENTS_A:
|
||||
case COGL_TEXTURE_COMPONENTS_RGBA:
|
||||
return TRUE;
|
||||
case COGL_TEXTURE_COMPONENTS_RG:
|
||||
case COGL_TEXTURE_COMPONENTS_RGB:
|
||||
case COGL_TEXTURE_COMPONENTS_DEPTH:
|
||||
return FALSE;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_surface_actor_wayland_is_visible (MetaSurfaceActor *actor)
|
||||
{
|
||||
@ -136,14 +116,24 @@ meta_surface_actor_wayland_get_window (MetaSurfaceActor *actor)
|
||||
return priv->surface->window;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_wayland_dispose (GObject *object)
|
||||
{
|
||||
MetaSurfaceActorWayland *self = META_SURFACE_ACTOR_WAYLAND (object);
|
||||
|
||||
meta_surface_actor_wayland_set_buffer (self, NULL);
|
||||
|
||||
G_OBJECT_CLASS (meta_surface_actor_wayland_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
|
||||
{
|
||||
MetaSurfaceActorClass *surface_actor_class = META_SURFACE_ACTOR_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
surface_actor_class->process_damage = meta_surface_actor_wayland_process_damage;
|
||||
surface_actor_class->pre_paint = meta_surface_actor_wayland_pre_paint;
|
||||
surface_actor_class->is_argb32 = meta_surface_actor_wayland_is_argb32;
|
||||
surface_actor_class->is_visible = meta_surface_actor_wayland_is_visible;
|
||||
|
||||
surface_actor_class->should_unredirect = meta_surface_actor_wayland_should_unredirect;
|
||||
@ -151,6 +141,8 @@ meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
|
||||
surface_actor_class->is_unredirected = meta_surface_actor_wayland_is_unredirected;
|
||||
|
||||
surface_actor_class->get_window = meta_surface_actor_wayland_get_window;
|
||||
|
||||
object_class->dispose = meta_surface_actor_wayland_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "meta-surface-actor-x11.h"
|
||||
|
||||
#include <X11/extensions/Xcomposite.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <cogl/cogl-texture-pixmap-x11.h>
|
||||
|
||||
#include <meta/errors.h>
|
||||
@ -54,7 +53,6 @@ struct _MetaSurfaceActorX11Private
|
||||
guint does_full_damage : 1;
|
||||
|
||||
/* Other state... */
|
||||
guint argb32 : 1;
|
||||
guint received_damage : 1;
|
||||
guint size_changed : 1;
|
||||
|
||||
@ -266,28 +264,6 @@ meta_surface_actor_x11_pre_paint (MetaSurfaceActor *actor)
|
||||
update_pixmap (self);
|
||||
}
|
||||
|
||||
static void
|
||||
update_is_argb32 (MetaSurfaceActorX11 *self)
|
||||
{
|
||||
MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
|
||||
MetaDisplay *display = priv->display;
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
|
||||
XRenderPictFormat *format;
|
||||
format = XRenderFindVisualFormat (xdisplay, priv->window->xvisual);
|
||||
|
||||
priv->argb32 = (format && format->type == PictTypeDirect && format->direct.alphaMask);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_surface_actor_x11_is_argb32 (MetaSurfaceActor *actor)
|
||||
{
|
||||
MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
|
||||
MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
|
||||
|
||||
return priv->argb32;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_surface_actor_x11_is_visible (MetaSurfaceActor *actor)
|
||||
{
|
||||
@ -312,7 +288,7 @@ meta_surface_actor_x11_should_unredirect (MetaSurfaceActor *actor)
|
||||
if (window->shape_region != NULL)
|
||||
return FALSE;
|
||||
|
||||
if (priv->argb32 && !meta_window_requested_bypass_compositor (window))
|
||||
if (meta_surface_actor_is_argb32 (actor) && !meta_window_requested_bypass_compositor (window))
|
||||
return FALSE;
|
||||
|
||||
if (!meta_window_is_monitor_sized (window))
|
||||
@ -405,7 +381,6 @@ meta_surface_actor_x11_class_init (MetaSurfaceActorX11Class *klass)
|
||||
|
||||
surface_actor_class->process_damage = meta_surface_actor_x11_process_damage;
|
||||
surface_actor_class->pre_paint = meta_surface_actor_x11_pre_paint;
|
||||
surface_actor_class->is_argb32 = meta_surface_actor_x11_is_argb32;
|
||||
surface_actor_class->is_visible = meta_surface_actor_x11_is_visible;
|
||||
|
||||
surface_actor_class->should_unredirect = meta_surface_actor_x11_should_unredirect;
|
||||
@ -461,8 +436,6 @@ meta_surface_actor_x11_new (MetaWindow *window)
|
||||
g_signal_connect_object (priv->window, "notify::decorated",
|
||||
G_CALLBACK (window_decorated_notify), self, 0);
|
||||
|
||||
update_is_argb32 (self);
|
||||
|
||||
priv->unredirected = FALSE;
|
||||
sync_unredirected (self);
|
||||
|
||||
|
@ -263,7 +263,26 @@ meta_surface_actor_pre_paint (MetaSurfaceActor *self)
|
||||
gboolean
|
||||
meta_surface_actor_is_argb32 (MetaSurfaceActor *self)
|
||||
{
|
||||
return META_SURFACE_ACTOR_GET_CLASS (self)->is_argb32 (self);
|
||||
MetaShapedTexture *stex = meta_surface_actor_get_texture (self);
|
||||
CoglTexture *texture = meta_shaped_texture_get_texture (stex);
|
||||
|
||||
/* If we don't have a texture, like during initialization, assume
|
||||
* that we're ARGB32. */
|
||||
if (!texture)
|
||||
return TRUE;
|
||||
|
||||
switch (cogl_texture_get_components (texture))
|
||||
{
|
||||
case COGL_TEXTURE_COMPONENTS_A:
|
||||
case COGL_TEXTURE_COMPONENTS_RGBA:
|
||||
return TRUE;
|
||||
case COGL_TEXTURE_COMPONENTS_RG:
|
||||
case COGL_TEXTURE_COMPONENTS_RGB:
|
||||
case COGL_TEXTURE_COMPONENTS_DEPTH:
|
||||
return FALSE;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -29,7 +29,6 @@ struct _MetaSurfaceActorClass
|
||||
void (* process_damage) (MetaSurfaceActor *actor,
|
||||
int x, int y, int width, int height);
|
||||
void (* pre_paint) (MetaSurfaceActor *actor);
|
||||
gboolean (* is_argb32) (MetaSurfaceActor *actor);
|
||||
gboolean (* is_visible) (MetaSurfaceActor *actor);
|
||||
|
||||
gboolean (* should_unredirect) (MetaSurfaceActor *actor);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "meta-window-actor-private.h"
|
||||
#include "meta-texture-rectangle.h"
|
||||
#include "region-utils.h"
|
||||
#include "monitor-private.h"
|
||||
#include "meta-monitor-manager.h"
|
||||
#include "meta-cullable.h"
|
||||
|
||||
#include "meta-surface-actor.h"
|
||||
@ -37,8 +37,8 @@
|
||||
|
||||
struct _MetaWindowActorPrivate
|
||||
{
|
||||
MetaWindow *window;
|
||||
MetaScreen *screen;
|
||||
MetaWindow *window;
|
||||
MetaCompositor *compositor;
|
||||
|
||||
MetaSurfaceActor *surface;
|
||||
|
||||
@ -371,11 +371,11 @@ meta_window_actor_update_surface (MetaWindowActor *self)
|
||||
static void
|
||||
meta_window_actor_constructed (GObject *object)
|
||||
{
|
||||
MetaWindowActor *self = META_WINDOW_ACTOR (object);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaWindow *window = priv->window;
|
||||
MetaWindowActor *self = META_WINDOW_ACTOR (object);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaWindow *window = priv->window;
|
||||
|
||||
priv->screen = window->screen;
|
||||
priv->compositor = window->display->compositor;
|
||||
|
||||
meta_window_actor_update_surface (self);
|
||||
|
||||
@ -389,19 +389,15 @@ meta_window_actor_constructed (GObject *object)
|
||||
static void
|
||||
meta_window_actor_dispose (GObject *object)
|
||||
{
|
||||
MetaWindowActor *self = META_WINDOW_ACTOR (object);
|
||||
MetaWindowActor *self = META_WINDOW_ACTOR (object);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaScreen *screen;
|
||||
MetaCompScreen *info;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
|
||||
if (priv->disposed)
|
||||
return;
|
||||
|
||||
priv->disposed = TRUE;
|
||||
|
||||
screen = priv->screen;
|
||||
info = meta_screen_get_compositor_data (screen);
|
||||
|
||||
if (priv->send_frame_messages_timer != 0)
|
||||
{
|
||||
g_source_remove (priv->send_frame_messages_timer);
|
||||
@ -416,7 +412,7 @@ meta_window_actor_dispose (GObject *object)
|
||||
g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref);
|
||||
g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref);
|
||||
|
||||
info->windows = g_list_remove (info->windows, (gconstpointer) self);
|
||||
compositor->windows = g_list_remove (compositor->windows, (gconstpointer) self);
|
||||
|
||||
g_clear_object (&priv->window);
|
||||
|
||||
@ -706,7 +702,6 @@ static gboolean
|
||||
meta_window_actor_has_shadow (MetaWindowActor *self)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaWindowType window_type = meta_window_get_window_type (priv->window);
|
||||
|
||||
if (priv->no_shadow)
|
||||
return FALSE;
|
||||
@ -745,25 +740,6 @@ meta_window_actor_has_shadow (MetaWindowActor *self)
|
||||
if (priv->window->override_redirect)
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
* Don't put shadow around DND icon windows
|
||||
*/
|
||||
if (window_type == META_WINDOW_DND ||
|
||||
window_type == META_WINDOW_DESKTOP)
|
||||
return FALSE;
|
||||
|
||||
if (window_type == META_WINDOW_MENU
|
||||
#if 0
|
||||
|| window_type == META_WINDOW_DROPDOWN_MENU
|
||||
#endif
|
||||
)
|
||||
return TRUE;
|
||||
|
||||
#if 0
|
||||
if (window_type == META_WINDOW_TOOLTIP)
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -851,8 +827,7 @@ static void
|
||||
queue_send_frame_messages_timeout (MetaWindowActor *self)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaScreen *screen = priv->screen;
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaDisplay *display = meta_window_get_display (priv->window);
|
||||
gint64 current_time = meta_compositor_monotonic_time_to_server_time (display, g_get_monotonic_time ());
|
||||
MetaMonitorManager *monitor_manager = meta_monitor_manager_get ();
|
||||
MetaWindow *window = priv->window;
|
||||
@ -964,7 +939,7 @@ start_simple_effect (MetaWindowActor *self,
|
||||
gulong event)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
gint *counter = NULL;
|
||||
gboolean use_freeze_thaw = FALSE;
|
||||
|
||||
@ -995,9 +970,7 @@ start_simple_effect (MetaWindowActor *self,
|
||||
|
||||
(*counter)++;
|
||||
|
||||
if (!meta_plugin_manager_event_simple (info->plugin_mgr,
|
||||
self,
|
||||
event))
|
||||
if (!meta_plugin_manager_event_simple (compositor->plugin_mgr, self, event))
|
||||
{
|
||||
(*counter)--;
|
||||
if (use_freeze_thaw)
|
||||
@ -1118,15 +1091,11 @@ meta_window_actor_set_unredirected (MetaWindowActor *self,
|
||||
void
|
||||
meta_window_actor_destroy (MetaWindowActor *self)
|
||||
{
|
||||
MetaWindow *window;
|
||||
MetaCompScreen *info;
|
||||
MetaWindowActorPrivate *priv;
|
||||
MetaWindowType window_type;
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaWindow *window = priv->window;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
MetaWindowType window_type = meta_window_get_window_type (window);
|
||||
|
||||
priv = self->priv;
|
||||
|
||||
window = priv->window;
|
||||
window_type = meta_window_get_window_type (window);
|
||||
meta_window_set_compositor_private (window, NULL);
|
||||
|
||||
if (priv->send_frame_messages_timer != 0)
|
||||
@ -1139,8 +1108,7 @@ meta_window_actor_destroy (MetaWindowActor *self)
|
||||
* We remove the window from internal lookup hashes and thus any other
|
||||
* unmap events etc fail
|
||||
*/
|
||||
info = meta_screen_get_compositor_data (priv->screen);
|
||||
info->windows = g_list_remove (info->windows, (gconstpointer) self);
|
||||
compositor->windows = g_list_remove (compositor->windows, (gconstpointer) self);
|
||||
|
||||
if (window_type == META_WINDOW_DROPDOWN_MENU ||
|
||||
window_type == META_WINDOW_POPUP_MENU ||
|
||||
@ -1201,18 +1169,14 @@ void
|
||||
meta_window_actor_show (MetaWindowActor *self,
|
||||
MetaCompEffect effect)
|
||||
{
|
||||
MetaWindowActorPrivate *priv;
|
||||
MetaCompScreen *info;
|
||||
gulong event;
|
||||
|
||||
priv = self->priv;
|
||||
info = meta_screen_get_compositor_data (priv->screen);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
gulong event = 0;
|
||||
|
||||
g_return_if_fail (!priv->visible);
|
||||
|
||||
self->priv->visible = TRUE;
|
||||
|
||||
event = 0;
|
||||
switch (effect)
|
||||
{
|
||||
case META_COMP_EFFECT_CREATE:
|
||||
@ -1229,7 +1193,7 @@ meta_window_actor_show (MetaWindowActor *self,
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (info->switch_workspace_in_progress ||
|
||||
if (compositor->switch_workspace_in_progress ||
|
||||
event == 0 ||
|
||||
!start_simple_effect (self, event))
|
||||
{
|
||||
@ -1241,12 +1205,9 @@ void
|
||||
meta_window_actor_hide (MetaWindowActor *self,
|
||||
MetaCompEffect effect)
|
||||
{
|
||||
MetaWindowActorPrivate *priv;
|
||||
MetaCompScreen *info;
|
||||
gulong event;
|
||||
|
||||
priv = self->priv;
|
||||
info = meta_screen_get_compositor_data (priv->screen);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
gulong event = 0;
|
||||
|
||||
g_return_if_fail (priv->visible);
|
||||
|
||||
@ -1256,10 +1217,9 @@ meta_window_actor_hide (MetaWindowActor *self,
|
||||
* hold off on hiding the window, and do it after the workspace
|
||||
* switch completes
|
||||
*/
|
||||
if (info->switch_workspace_in_progress)
|
||||
if (compositor->switch_workspace_in_progress)
|
||||
return;
|
||||
|
||||
event = 0;
|
||||
switch (effect)
|
||||
{
|
||||
case META_COMP_EFFECT_DESTROY:
|
||||
@ -1285,7 +1245,8 @@ meta_window_actor_maximize (MetaWindowActor *self,
|
||||
MetaRectangle *old_rect,
|
||||
MetaRectangle *new_rect)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (self->priv->screen);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
|
||||
/* The window has already been resized (in order to compute new_rect),
|
||||
* which by side effect caused the actor to be resized. Restore it to the
|
||||
@ -1296,7 +1257,7 @@ meta_window_actor_maximize (MetaWindowActor *self,
|
||||
self->priv->maximize_in_progress++;
|
||||
meta_window_actor_freeze (self);
|
||||
|
||||
if (!meta_plugin_manager_event_maximize (info->plugin_mgr,
|
||||
if (!meta_plugin_manager_event_maximize (compositor->plugin_mgr,
|
||||
self,
|
||||
META_PLUGIN_MAXIMIZE,
|
||||
new_rect->x, new_rect->y,
|
||||
@ -1313,7 +1274,8 @@ meta_window_actor_unmaximize (MetaWindowActor *self,
|
||||
MetaRectangle *old_rect,
|
||||
MetaRectangle *new_rect)
|
||||
{
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (self->priv->screen);
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaCompositor *compositor = priv->compositor;
|
||||
|
||||
/* The window has already been resized (in order to compute new_rect),
|
||||
* which by side effect caused the actor to be resized. Restore it to the
|
||||
@ -1324,7 +1286,7 @@ meta_window_actor_unmaximize (MetaWindowActor *self,
|
||||
self->priv->unmaximize_in_progress++;
|
||||
meta_window_actor_freeze (self);
|
||||
|
||||
if (!meta_plugin_manager_event_maximize (info->plugin_mgr,
|
||||
if (!meta_plugin_manager_event_maximize (compositor->plugin_mgr,
|
||||
self,
|
||||
META_PLUGIN_UNMAXIMIZE,
|
||||
new_rect->x, new_rect->y,
|
||||
@ -1338,8 +1300,8 @@ meta_window_actor_unmaximize (MetaWindowActor *self,
|
||||
MetaWindowActor *
|
||||
meta_window_actor_new (MetaWindow *window)
|
||||
{
|
||||
MetaScreen *screen = meta_window_get_screen (window);
|
||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||
MetaDisplay *display = meta_window_get_display (window);
|
||||
MetaCompositor *compositor = display->compositor;
|
||||
MetaWindowActor *self;
|
||||
MetaWindowActorPrivate *priv;
|
||||
ClutterActor *window_group;
|
||||
@ -1364,9 +1326,9 @@ meta_window_actor_new (MetaWindow *window)
|
||||
meta_window_set_compositor_private (window, G_OBJECT (self));
|
||||
|
||||
if (window->layer == META_LAYER_OVERRIDE_REDIRECT)
|
||||
window_group = info->top_window_group;
|
||||
window_group = compositor->top_window_group;
|
||||
else
|
||||
window_group = info->window_group;
|
||||
window_group = compositor->window_group;
|
||||
|
||||
clutter_actor_add_child (window_group, CLUTTER_ACTOR (self));
|
||||
|
||||
@ -1375,7 +1337,7 @@ meta_window_actor_new (MetaWindow *window)
|
||||
/* Initial position in the stack is arbitrary; stacking will be synced
|
||||
* before we first paint.
|
||||
*/
|
||||
info->windows = g_list_append (info->windows, self);
|
||||
compositor->windows = g_list_append (compositor->windows, self);
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -1756,41 +1718,20 @@ static void
|
||||
meta_window_actor_update_input_region (MetaWindowActor *self)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
cairo_region_t *region = NULL;
|
||||
cairo_rectangle_int_t client_area;
|
||||
MetaWindow *window = priv->window;
|
||||
cairo_region_t *region;
|
||||
|
||||
meta_window_get_client_area_rect (priv->window, &client_area);
|
||||
|
||||
if (priv->window->frame != NULL)
|
||||
if (window->shape_region && window->input_region)
|
||||
{
|
||||
region = meta_frame_get_frame_bounds (priv->window->frame);
|
||||
|
||||
/* input_region is in client window coordinates, so translate the
|
||||
* input region into that coordinate system and back */
|
||||
cairo_region_translate (region, -client_area.x, -client_area.y);
|
||||
cairo_region_union_rectangle (region, &client_area);
|
||||
cairo_region_translate (region, client_area.x, client_area.y);
|
||||
}
|
||||
else if (priv->window->shape_region != NULL ||
|
||||
priv->window->input_region != NULL)
|
||||
{
|
||||
if (priv->window->shape_region != NULL)
|
||||
{
|
||||
region = cairo_region_copy (priv->window->shape_region);
|
||||
|
||||
if (priv->window->input_region != NULL)
|
||||
cairo_region_intersect (region, priv->window->input_region);
|
||||
}
|
||||
else
|
||||
region = cairo_region_reference (priv->window->input_region);
|
||||
region = cairo_region_copy (window->shape_region);
|
||||
cairo_region_intersect (region, window->input_region);
|
||||
}
|
||||
else if (window->shape_region)
|
||||
region = cairo_region_reference (window->shape_region);
|
||||
else if (window->input_region)
|
||||
region = cairo_region_reference (window->input_region);
|
||||
else
|
||||
{
|
||||
/* If we don't have a shape on the server, that means that
|
||||
* we have an implicit shape of one rectangle covering the
|
||||
* entire window. */
|
||||
region = cairo_region_create_rectangle (&client_area);
|
||||
}
|
||||
region = NULL;
|
||||
|
||||
meta_surface_actor_set_input_region (priv->surface, region);
|
||||
cairo_region_destroy (region);
|
||||
@ -1912,8 +1853,7 @@ static void
|
||||
do_send_frame_drawn (MetaWindowActor *self, FrameData *frame)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaScreen *screen = priv->screen;
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaDisplay *display = meta_window_get_display (priv->window);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
|
||||
XClientMessageEvent ev = { 0, };
|
||||
@ -1965,7 +1905,7 @@ do_send_frame_timings (MetaWindowActor *self,
|
||||
gint64 presentation_time)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaDisplay *display = meta_screen_get_display (priv->screen);
|
||||
MetaDisplay *display = meta_window_get_display (priv->window);
|
||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||
|
||||
XClientMessageEvent ev = { 0, };
|
||||
|
@ -74,26 +74,8 @@ static void
|
||||
bell_flash_fullscreen (MetaDisplay *display,
|
||||
XkbAnyEvent *xkb_ev)
|
||||
{
|
||||
XkbBellNotifyEvent *xkb_bell_ev = (XkbBellNotifyEvent *) xkb_ev;
|
||||
MetaScreen *screen;
|
||||
|
||||
g_assert (xkb_ev->xkb_type == XkbBellNotify);
|
||||
if (xkb_bell_ev->window != None)
|
||||
{
|
||||
screen = meta_display_screen_for_xwindow (display, xkb_bell_ev->window);
|
||||
if (screen)
|
||||
meta_compositor_flash_screen (display->compositor, screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSList *screen_list = display->screens;
|
||||
while (screen_list)
|
||||
{
|
||||
screen = (MetaScreen *) screen_list->data;
|
||||
meta_compositor_flash_screen (display->compositor, screen);
|
||||
screen_list = screen_list->next;
|
||||
}
|
||||
}
|
||||
meta_compositor_flash_screen (display->compositor, display->screen);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,7 +274,7 @@ meta_core_lower_beneath_grab_window (Display *xdisplay,
|
||||
MetaStackWindow stack_sibling;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
screen = meta_display_screen_for_xwindow (display, xwindow);
|
||||
screen = display->screen;
|
||||
grab_window = display->grab_window;
|
||||
|
||||
if (grab_window == NULL)
|
||||
@ -603,13 +603,10 @@ meta_core_get_workspace_name_with_index (Display *xdisplay,
|
||||
int index)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaScreen *screen;
|
||||
MetaWorkspace *workspace;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
screen = meta_display_screen_for_root (display, xroot);
|
||||
g_assert (screen != NULL);
|
||||
workspace = meta_screen_get_workspace_by_index (screen, index);
|
||||
workspace = meta_screen_get_workspace_by_index (display->screen, index);
|
||||
return workspace ? meta_workspace_get_name (workspace) : NULL;
|
||||
}
|
||||
|
||||
@ -630,7 +627,7 @@ meta_core_begin_grab_op (Display *xdisplay,
|
||||
MetaScreen *screen;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
screen = meta_display_screen_for_xwindow (display, frame_xwindow);
|
||||
screen = display->screen;
|
||||
|
||||
g_assert (screen != NULL);
|
||||
|
||||
@ -670,10 +667,6 @@ meta_core_get_grab_frame (Display *xdisplay)
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
|
||||
g_assert (display != NULL);
|
||||
g_assert (display->grab_op == META_GRAB_OP_NONE ||
|
||||
display->grab_screen != NULL);
|
||||
g_assert (display->grab_op == META_GRAB_OP_NONE ||
|
||||
display->grab_screen->display->xdisplay == xdisplay);
|
||||
|
||||
if (display->grab_op != META_GRAB_OP_NONE &&
|
||||
display->grab_window &&
|
||||
|
@ -92,6 +92,7 @@ struct _MetaDisplay
|
||||
Display *xdisplay;
|
||||
|
||||
int clutter_event_filter;
|
||||
GSource *x11_event_source;
|
||||
|
||||
Window leader_window;
|
||||
Window timestamp_pinging_window;
|
||||
@ -147,14 +148,10 @@ struct _MetaDisplay
|
||||
guint focused_by_us : 1;
|
||||
|
||||
/*< private-ish >*/
|
||||
guint error_trap_synced_at_last_pop : 1;
|
||||
GSList *screens;
|
||||
MetaScreen *active_screen;
|
||||
MetaScreen *screen;
|
||||
GHashTable *xids;
|
||||
GHashTable *wayland_windows;
|
||||
int error_traps;
|
||||
int (* error_trap_handler) (Display *display,
|
||||
XErrorEvent *error);
|
||||
|
||||
int server_grab_count;
|
||||
|
||||
/* serials of leave/unmap events that may
|
||||
@ -190,7 +187,6 @@ struct _MetaDisplay
|
||||
|
||||
/* current window operation */
|
||||
MetaGrabOp grab_op;
|
||||
MetaScreen *grab_screen;
|
||||
MetaWindow *grab_window;
|
||||
Window grab_xwindow;
|
||||
int grab_button;
|
||||
@ -258,6 +254,8 @@ struct _MetaDisplay
|
||||
/* Closing down the display */
|
||||
int closing;
|
||||
|
||||
GSList *error_traps;
|
||||
|
||||
/* Managed by group.c */
|
||||
GHashTable *groups_by_leader;
|
||||
|
||||
@ -351,10 +349,6 @@ struct _MetaDisplayClass
|
||||
gboolean meta_display_open (void);
|
||||
void meta_display_close (MetaDisplay *display,
|
||||
guint32 timestamp);
|
||||
MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display,
|
||||
Screen *screen);
|
||||
MetaScreen* meta_display_screen_for_xwindow (MetaDisplay *display,
|
||||
Window xindow);
|
||||
void meta_display_grab (MetaDisplay *display);
|
||||
void meta_display_ungrab (MetaDisplay *display);
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include <meta/compositor-mutter.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include "mutter-enum-types.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "meta-idle-monitor-dbus.h"
|
||||
#include "meta-cursor-tracker-private.h"
|
||||
|
||||
#ifdef HAVE_RANDR
|
||||
@ -362,8 +362,6 @@ sn_error_trap_pop (SnDisplay *sn_display,
|
||||
static void
|
||||
enable_compositor (MetaDisplay *display)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
if (!META_DISPLAY_HAS_COMPOSITE (display) ||
|
||||
!META_DISPLAY_HAS_DAMAGE (display) ||
|
||||
!META_DISPLAY_HAS_RENDER (display))
|
||||
@ -379,14 +377,8 @@ enable_compositor (MetaDisplay *display)
|
||||
|
||||
if (!display->compositor)
|
||||
return;
|
||||
|
||||
for (list = display->screens; list != NULL; list = list->next)
|
||||
{
|
||||
MetaScreen *screen = list->data;
|
||||
|
||||
meta_compositor_manage_screen (screen->display->compositor,
|
||||
screen);
|
||||
}
|
||||
|
||||
meta_compositor_manage (display->compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -440,7 +432,6 @@ gboolean
|
||||
meta_display_open (void)
|
||||
{
|
||||
Display *xdisplay;
|
||||
GSList *screens;
|
||||
MetaScreen *screen;
|
||||
int i;
|
||||
guint32 timestamp;
|
||||
@ -455,7 +446,7 @@ meta_display_open (void)
|
||||
|
||||
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
||||
|
||||
xdisplay = meta_ui_get_display ();
|
||||
xdisplay = XOpenDisplay (NULL);
|
||||
|
||||
if (xdisplay == NULL)
|
||||
{
|
||||
@ -481,9 +472,6 @@ meta_display_open (void)
|
||||
*/
|
||||
the_display->name = g_strdup (XDisplayName (NULL));
|
||||
the_display->xdisplay = xdisplay;
|
||||
the_display->error_trap_synced_at_last_pop = TRUE;
|
||||
the_display->error_traps = 0;
|
||||
the_display->error_trap_handler = NULL;
|
||||
the_display->server_grab_count = 0;
|
||||
the_display->display_opening = TRUE;
|
||||
|
||||
@ -536,8 +524,7 @@ meta_display_open (void)
|
||||
the_display->window_with_menu = NULL;
|
||||
the_display->window_menu = NULL;
|
||||
|
||||
the_display->screens = NULL;
|
||||
the_display->active_screen = NULL;
|
||||
the_display->screen = NULL;
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
the_display->sn_display = sn_display_new (the_display->xdisplay,
|
||||
@ -572,7 +559,6 @@ meta_display_open (void)
|
||||
|
||||
the_display->grab_op = META_GRAB_OP_NONE;
|
||||
the_display->grab_window = NULL;
|
||||
the_display->grab_screen = NULL;
|
||||
the_display->grab_resize_popup = NULL;
|
||||
the_display->grab_tile_mode = META_TILE_NONE;
|
||||
the_display->grab_tile_monitor_number = -1;
|
||||
@ -841,15 +827,12 @@ meta_display_open (void)
|
||||
the_display->last_focus_time = timestamp;
|
||||
the_display->last_user_time = timestamp;
|
||||
the_display->compositor = NULL;
|
||||
|
||||
|
||||
/* Mutter used to manage all X screens of the display in a single process, but
|
||||
* now it always manages exactly one screen as specified by the DISPLAY
|
||||
* environment variable. The screens GSList is left for simplicity.
|
||||
* environment variable.
|
||||
*/
|
||||
screens = NULL;
|
||||
|
||||
i = meta_ui_get_screen_number ();
|
||||
|
||||
i = DefaultScreen (the_display->xdisplay);
|
||||
screen = meta_screen_new (the_display, i, timestamp);
|
||||
|
||||
if (!screen)
|
||||
@ -861,9 +844,7 @@ meta_display_open (void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
screens = g_slist_prepend (screens, screen);
|
||||
|
||||
the_display->screens = screens;
|
||||
the_display->screen = screen;
|
||||
|
||||
enable_compositor (the_display);
|
||||
|
||||
@ -895,7 +876,7 @@ meta_display_open (void)
|
||||
if (focus == None || focus == PointerRoot)
|
||||
/* Just focus the no_focus_window on the first screen */
|
||||
meta_display_focus_the_no_focus_window (the_display,
|
||||
the_display->screens->data,
|
||||
the_display->screen,
|
||||
timestamp);
|
||||
else
|
||||
{
|
||||
@ -906,7 +887,7 @@ meta_display_open (void)
|
||||
else
|
||||
/* Just focus the no_focus_window on the first screen */
|
||||
meta_display_focus_the_no_focus_window (the_display,
|
||||
the_display->screens->data,
|
||||
the_display->screen,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
@ -948,8 +929,8 @@ meta_display_list_windows (MetaDisplay *display,
|
||||
MetaListWindowsFlags flags)
|
||||
{
|
||||
GSList *winlist;
|
||||
GSList *tmp;
|
||||
GSList *prev;
|
||||
GSList *tmp;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
@ -1024,8 +1005,6 @@ void
|
||||
meta_display_close (MetaDisplay *display,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
g_assert (display != NULL);
|
||||
|
||||
if (display->closing != 0)
|
||||
@ -1034,9 +1013,6 @@ meta_display_close (MetaDisplay *display,
|
||||
return;
|
||||
}
|
||||
|
||||
if (display->error_traps > 0)
|
||||
meta_bug ("Display closed with error traps pending\n");
|
||||
|
||||
display->closing += 1;
|
||||
|
||||
meta_prefs_remove_listener (prefs_changed_callback, display);
|
||||
@ -1053,17 +1029,7 @@ meta_display_close (MetaDisplay *display,
|
||||
/* Stop caring about events */
|
||||
meta_display_free_events (display);
|
||||
|
||||
/* Free all screens */
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
meta_screen_free (screen, timestamp);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
g_slist_free (display->screens);
|
||||
display->screens = NULL;
|
||||
meta_screen_free (display->screen, timestamp);
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
if (display->sn_display)
|
||||
@ -1099,77 +1065,6 @@ meta_display_close (MetaDisplay *display,
|
||||
meta_quit (META_EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_screen_for_root:
|
||||
* @display: a #MetaDisplay
|
||||
* @xroot: a X window
|
||||
*
|
||||
* Return the #MetaScreen corresponding to a specified X root window ID.
|
||||
*
|
||||
* Return Value: (transfer none): the screen for the specified root window ID, or %NULL
|
||||
*/
|
||||
MetaScreen*
|
||||
meta_display_screen_for_root (MetaDisplay *display,
|
||||
Window xroot)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
if (xroot == screen->xroot)
|
||||
return screen;
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MetaScreen*
|
||||
meta_display_screen_for_xwindow (MetaDisplay *display,
|
||||
Window xwindow)
|
||||
{
|
||||
XWindowAttributes attr;
|
||||
int result;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
attr.screen = NULL;
|
||||
result = XGetWindowAttributes (display->xdisplay, xwindow, &attr);
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
/* Note, XGetWindowAttributes is on all kinds of crack
|
||||
* and returns 1 on success 0 on failure, rather than Success
|
||||
* on success.
|
||||
*/
|
||||
if (result == 0 || attr.screen == NULL)
|
||||
return NULL;
|
||||
|
||||
return meta_display_screen_for_x_screen (display, attr.screen);
|
||||
}
|
||||
|
||||
MetaScreen*
|
||||
meta_display_screen_for_x_screen (MetaDisplay *display,
|
||||
Screen *xscreen)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
if (xscreen == screen->xscreen)
|
||||
return screen;
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Grab/ungrab routines taken from fvwm.
|
||||
* Calling this function will cause X to ignore all other clients until
|
||||
* you ungrab. This may not be quite as bad as it sounds, yet there is
|
||||
@ -1775,7 +1670,6 @@ request_xserver_input_focus_change (MetaDisplay *display,
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
display->last_focus_time = timestamp;
|
||||
display->active_screen = screen;
|
||||
|
||||
if (meta_window == NULL || meta_window != display->autoraise_window)
|
||||
meta_display_remove_autoraise_callback (display);
|
||||
@ -1877,18 +1771,7 @@ gboolean
|
||||
meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
|
||||
Window xwindow)
|
||||
{
|
||||
gboolean is_a_no_focus_window = FALSE;
|
||||
GSList *temp = display->screens;
|
||||
while (temp != NULL) {
|
||||
MetaScreen *screen = temp->data;
|
||||
if (screen->no_focus_window == xwindow) {
|
||||
is_a_no_focus_window = TRUE;
|
||||
break;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
return is_a_no_focus_window;
|
||||
return xwindow == display->screen->no_focus_window;
|
||||
}
|
||||
|
||||
static MetaCursor
|
||||
@ -1950,6 +1833,7 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
|
||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
||||
MetaCursor cursor = meta_cursor_for_grab_op (op);
|
||||
MetaCursorReference *cursor_ref;
|
||||
|
||||
XISetMask (mask.mask, XI_ButtonPress);
|
||||
XISetMask (mask.mask, XI_ButtonRelease);
|
||||
@ -1983,7 +1867,9 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
|
||||
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
meta_cursor_tracker_set_grab_cursor (screen->cursor_tracker, cursor);
|
||||
cursor_ref = meta_cursor_reference_from_theme (screen->cursor_tracker, cursor);
|
||||
meta_cursor_tracker_set_grab_cursor (screen->cursor_tracker, cursor_ref);
|
||||
meta_cursor_reference_unref (cursor_ref);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -2087,7 +1973,6 @@ meta_display_begin_grab_op (MetaDisplay *display,
|
||||
|
||||
display->grab_op = op;
|
||||
display->grab_window = grab_window;
|
||||
display->grab_screen = screen;
|
||||
display->grab_xwindow = grab_xwindow;
|
||||
display->grab_button = button;
|
||||
display->grab_mask = modmask;
|
||||
@ -2140,7 +2025,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
|
||||
"Grab op %u on window %s successful\n",
|
||||
display->grab_op, window ? window->desc : "(null)");
|
||||
|
||||
g_assert (display->grab_window != NULL || display->grab_screen != NULL);
|
||||
g_assert (display->grab_window != NULL);
|
||||
g_assert (display->grab_op != META_GRAB_OP_NONE);
|
||||
|
||||
if (display->grab_window)
|
||||
@ -2168,7 +2053,7 @@ meta_display_end_grab_op (MetaDisplay *display,
|
||||
return;
|
||||
|
||||
g_signal_emit (display, display_signals[GRAB_OP_END], 0,
|
||||
display->grab_screen, display->grab_window, display->grab_op);
|
||||
display->screen, display->grab_window, display->grab_op);
|
||||
|
||||
if (display->grab_window != NULL)
|
||||
display->grab_window->shaken_loose = FALSE;
|
||||
@ -2220,14 +2105,13 @@ meta_display_end_grab_op (MetaDisplay *display,
|
||||
if (display->grab_window)
|
||||
meta_window_ungrab_all_keys (display->grab_window, timestamp);
|
||||
else
|
||||
meta_screen_ungrab_all_keys (display->grab_screen, timestamp);
|
||||
meta_screen_ungrab_all_keys (display->screen, timestamp);
|
||||
}
|
||||
|
||||
meta_cursor_tracker_set_grab_cursor (display->grab_screen->cursor_tracker, META_CURSOR_DEFAULT);
|
||||
meta_cursor_tracker_set_grab_cursor (display->screen->cursor_tracker, NULL);
|
||||
|
||||
display->grab_timestamp = 0;
|
||||
display->grab_window = NULL;
|
||||
display->grab_screen = NULL;
|
||||
display->grab_xwindow = None;
|
||||
display->grab_tile_mode = META_TILE_NONE;
|
||||
display->grab_tile_monitor_number = -1;
|
||||
@ -2322,7 +2206,7 @@ meta_change_button_grab (MetaDisplay *display,
|
||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||
|
||||
if (meta_is_debugging ())
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/* GrabModeSync means freeze until XAllowEvents */
|
||||
|
||||
@ -2517,30 +2401,19 @@ meta_display_increment_event_serial (MetaDisplay *display)
|
||||
void
|
||||
meta_display_update_active_window_hint (MetaDisplay *display)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
gulong data[1];
|
||||
|
||||
if (display->focus_window)
|
||||
data[0] = display->focus_window->xwindow;
|
||||
else
|
||||
data[0] = None;
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
XChangeProperty (display->xdisplay, screen->xroot,
|
||||
display->atom__NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW,
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
meta_error_trap_push (display);
|
||||
XChangeProperty (display->xdisplay, display->screen->xroot,
|
||||
display->atom__NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW,
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
meta_error_trap_pop (display);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2578,22 +2451,12 @@ void
|
||||
meta_display_set_cursor_theme (const char *theme,
|
||||
int size)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
|
||||
XcursorSetTheme (display->xdisplay, theme);
|
||||
XcursorSetDefaultSize (display->xdisplay, size);
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
meta_screen_update_cursor (screen);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
meta_screen_update_cursor (display->screen);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2808,7 +2671,6 @@ get_focused_group (MetaDisplay *display)
|
||||
static MetaWindow*
|
||||
find_tab_forward (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace,
|
||||
GList *start,
|
||||
gboolean skip_first)
|
||||
@ -2826,8 +2688,7 @@ find_tab_forward (MetaDisplay *display,
|
||||
{
|
||||
MetaWindow *window = tmp->data;
|
||||
|
||||
if (window->screen == screen &&
|
||||
IN_TAB_CHAIN (window, type))
|
||||
if (IN_TAB_CHAIN (window, type))
|
||||
return window;
|
||||
|
||||
tmp = tmp->next;
|
||||
@ -2850,7 +2711,6 @@ find_tab_forward (MetaDisplay *display,
|
||||
static MetaWindow*
|
||||
find_tab_backward (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace,
|
||||
GList *start,
|
||||
gboolean skip_last)
|
||||
@ -2867,8 +2727,7 @@ find_tab_backward (MetaDisplay *display,
|
||||
{
|
||||
MetaWindow *window = tmp->data;
|
||||
|
||||
if (window->screen == screen &&
|
||||
IN_TAB_CHAIN (window, type))
|
||||
if (IN_TAB_CHAIN (window, type))
|
||||
return window;
|
||||
|
||||
tmp = tmp->prev;
|
||||
@ -2948,8 +2807,7 @@ meta_display_get_tab_list (MetaDisplay *display,
|
||||
{
|
||||
MetaWindow *window = tmp->data;
|
||||
|
||||
if (window->screen == screen &&
|
||||
IN_TAB_CHAIN (window, type))
|
||||
if (IN_TAB_CHAIN (window, type))
|
||||
tab_list = g_list_prepend (tab_list, window);
|
||||
}
|
||||
|
||||
@ -2979,7 +2837,6 @@ meta_display_get_tab_list (MetaDisplay *display,
|
||||
* meta_display_get_tab_next:
|
||||
* @display: a #MetaDisplay
|
||||
* @type: type of tab list
|
||||
* @screen: a #MetaScreen
|
||||
* @workspace: origin workspace
|
||||
* @window: (allow-none): starting window
|
||||
* @backward: If %TRUE, look for the previous window.
|
||||
@ -2993,7 +2850,6 @@ meta_display_get_tab_list (MetaDisplay *display,
|
||||
MetaWindow*
|
||||
meta_display_get_tab_next (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace,
|
||||
MetaWindow *window,
|
||||
gboolean backward)
|
||||
@ -3001,10 +2857,7 @@ meta_display_get_tab_next (MetaDisplay *display,
|
||||
gboolean skip;
|
||||
GList *tab_list;
|
||||
MetaWindow *ret;
|
||||
tab_list = meta_display_get_tab_list(display,
|
||||
type,
|
||||
screen,
|
||||
workspace);
|
||||
tab_list = meta_display_get_tab_list (display, type, NULL, workspace);
|
||||
|
||||
if (tab_list == NULL)
|
||||
return NULL;
|
||||
@ -3014,26 +2867,18 @@ meta_display_get_tab_next (MetaDisplay *display,
|
||||
g_assert (window->display == display);
|
||||
|
||||
if (backward)
|
||||
ret = find_tab_backward (display, type, screen, workspace,
|
||||
g_list_find (tab_list,
|
||||
window),
|
||||
TRUE);
|
||||
ret = find_tab_backward (display, type, workspace, g_list_find (tab_list, window), TRUE);
|
||||
else
|
||||
ret = find_tab_forward (display, type, screen, workspace,
|
||||
g_list_find (tab_list,
|
||||
window),
|
||||
TRUE);
|
||||
ret = find_tab_forward (display, type, workspace, g_list_find (tab_list, window), TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
skip = display->focus_window != NULL &&
|
||||
tab_list->data == display->focus_window;
|
||||
if (backward)
|
||||
ret = find_tab_backward (display, type, screen, workspace,
|
||||
tab_list, skip);
|
||||
ret = find_tab_backward (display, type, workspace, tab_list, skip);
|
||||
else
|
||||
ret = find_tab_forward (display, type, screen, workspace,
|
||||
tab_list, skip);
|
||||
ret = find_tab_forward (display, type, workspace, tab_list, skip);
|
||||
}
|
||||
|
||||
g_list_free (tab_list);
|
||||
@ -3044,7 +2889,6 @@ meta_display_get_tab_next (MetaDisplay *display,
|
||||
* meta_display_get_tab_current:
|
||||
* @display: a #MetaDisplay
|
||||
* @type: type of tab list
|
||||
* @screen: a #MetaScreen
|
||||
* @workspace: origin workspace
|
||||
*
|
||||
* Determine the active window that should be displayed for Alt-TAB.
|
||||
@ -3055,7 +2899,6 @@ meta_display_get_tab_next (MetaDisplay *display,
|
||||
MetaWindow*
|
||||
meta_display_get_tab_current (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace)
|
||||
{
|
||||
MetaWindow *window;
|
||||
@ -3063,7 +2906,6 @@ meta_display_get_tab_current (MetaDisplay *display,
|
||||
window = display->focus_window;
|
||||
|
||||
if (window != NULL &&
|
||||
window->screen == screen &&
|
||||
IN_TAB_CHAIN (window, type) &&
|
||||
(workspace == NULL ||
|
||||
meta_window_located_on_workspace (window, workspace)))
|
||||
@ -3129,14 +2971,7 @@ meta_display_unmanage_screen (MetaDisplay *display,
|
||||
{
|
||||
meta_verbose ("Unmanaging screen %d on display %s\n",
|
||||
screen->number, display->name);
|
||||
|
||||
g_return_if_fail (g_slist_find (display->screens, screen) != NULL);
|
||||
|
||||
meta_screen_free (screen, timestamp);
|
||||
display->screens = g_slist_remove (display->screens, screen);
|
||||
|
||||
if (display->screens == NULL)
|
||||
meta_display_close (display, timestamp);
|
||||
meta_display_close (display, timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3178,15 +3013,7 @@ meta_display_stack_cmp (const void *a,
|
||||
MetaWindow *aw = (void*) a;
|
||||
MetaWindow *bw = (void*) b;
|
||||
|
||||
if (aw->screen == bw->screen)
|
||||
return meta_stack_windows_cmp (aw->screen->stack, aw, bw);
|
||||
/* Then assume screens are stacked by number */
|
||||
else if (aw->screen->number < bw->screen->number)
|
||||
return -1;
|
||||
else if (aw->screen->number > bw->screen->number)
|
||||
return 1;
|
||||
else
|
||||
return 0; /* not reached in theory, if windows on same display */
|
||||
return meta_stack_windows_cmp (aw->screen->stack, aw, bw);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3322,7 +3149,7 @@ meta_display_increment_focus_sentinel (MetaDisplay *display)
|
||||
data[0] = meta_display_get_current_time (display);
|
||||
|
||||
XChangeProperty (display->xdisplay,
|
||||
((MetaScreen*) display->screens->data)->xroot,
|
||||
display->screen->xroot,
|
||||
display->atom__MUTTER_SENTINEL,
|
||||
XA_CARDINAL,
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
@ -3526,18 +3353,6 @@ meta_display_get_compositor (MetaDisplay *display)
|
||||
return display->compositor;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_screens:
|
||||
* @display: a #MetaDisplay
|
||||
*
|
||||
* Returns: (transfer none) (element-type Meta.Screen): Screens for this display
|
||||
*/
|
||||
GSList *
|
||||
meta_display_get_screens (MetaDisplay *display)
|
||||
{
|
||||
return display->screens;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_display_has_shape (MetaDisplay *display)
|
||||
{
|
||||
|
@ -30,7 +30,6 @@
|
||||
*/
|
||||
#define WINDOW_EDGES_RELEVANT(window, display) \
|
||||
meta_window_should_be_showing (window) && \
|
||||
window->screen == display->grab_screen && \
|
||||
window != display->grab_window && \
|
||||
window->type != META_WINDOW_DESKTOP && \
|
||||
window->type != META_WINDOW_MENU && \
|
||||
@ -963,9 +962,9 @@ compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
/*
|
||||
* 1st: Get the list of relevant windows, from bottom to top
|
||||
*/
|
||||
stacked_windows =
|
||||
meta_stack_list_windows (display->grab_screen->stack,
|
||||
display->grab_screen->active_workspace);
|
||||
stacked_windows =
|
||||
meta_stack_list_windows (display->screen->stack,
|
||||
display->screen->active_workspace);
|
||||
|
||||
/*
|
||||
* 2nd: we need to separate that stacked list into a list of windows that
|
||||
@ -1026,7 +1025,7 @@ compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
* by other windows or DOCKS, but that's handled below).
|
||||
*/
|
||||
meta_rectangle_intersect (&cur_rect,
|
||||
&display->grab_screen->rect,
|
||||
&display->screen->rect,
|
||||
&reduced);
|
||||
|
||||
new_edges = NULL;
|
||||
@ -1123,8 +1122,8 @@ compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
*/
|
||||
cache_edges (display,
|
||||
edges,
|
||||
display->grab_screen->active_workspace->monitor_edges,
|
||||
display->grab_screen->active_workspace->screen_edges);
|
||||
display->screen->active_workspace->monitor_edges,
|
||||
display->screen->active_workspace->screen_edges);
|
||||
g_list_free (edges);
|
||||
|
||||
/*
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington, error trapping inspired by GDK
|
||||
* code copyrighted by the GTK team.
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* 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
|
||||
@ -13,9 +12,11 @@
|
||||
* 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/>.
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -27,42 +28,250 @@
|
||||
#include <config.h>
|
||||
#include <meta/errors.h>
|
||||
#include "display-private.h"
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
/* In GTK+-3.0, the error trapping code was significantly rewritten. The new code
|
||||
* has some neat features (like knowing automatically if a sync is needed or not
|
||||
* and handling errors asynchronously when the error code isn't needed immediately),
|
||||
* but it's basically incompatible with the hacks we played with GTK+-2.0 to
|
||||
* use a custom error handler along with gdk_error_trap_push().
|
||||
*
|
||||
* Since the main point of our custom error trap was to get the error logged
|
||||
* to the right place, with GTK+-3.0 we simply omit our own error handler and
|
||||
* use the GTK+ handling straight-up.
|
||||
* (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.)
|
||||
*/
|
||||
/* This is a copy-paste of the error handling code in GDK, modified
|
||||
* so that it works with mutter's internal structures, since we don't
|
||||
* have a GDK display open. */
|
||||
|
||||
/* compare X sequence numbers handling wraparound */
|
||||
#define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
|
||||
|
||||
typedef struct _GdkErrorTrap GdkErrorTrap;
|
||||
|
||||
struct _GdkErrorTrap
|
||||
{
|
||||
/* Next sequence when trap was pushed, i.e. first sequence to
|
||||
* ignore
|
||||
*/
|
||||
gulong start_sequence;
|
||||
|
||||
/* Next sequence when trap was popped, i.e. first sequence
|
||||
* to not ignore. 0 if trap is still active.
|
||||
*/
|
||||
gulong end_sequence;
|
||||
|
||||
/* Most recent error code within the sequence */
|
||||
int error_code;
|
||||
};
|
||||
|
||||
/* delivers an error event from the error handler in gdkmain-x11.c */
|
||||
static void
|
||||
meta_display_error_event (MetaDisplay *display,
|
||||
XErrorEvent *error)
|
||||
{
|
||||
GSList *tmp_list;
|
||||
gboolean ignore;
|
||||
|
||||
ignore = FALSE;
|
||||
for (tmp_list = display->error_traps;
|
||||
tmp_list != NULL;
|
||||
tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkErrorTrap *trap;
|
||||
|
||||
trap = tmp_list->data;
|
||||
|
||||
if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
|
||||
(trap->end_sequence == 0 ||
|
||||
SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
|
||||
{
|
||||
ignore = TRUE;
|
||||
trap->error_code = error->error_code;
|
||||
break; /* only innermost trap gets the error code */
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore)
|
||||
{
|
||||
gchar buf[64];
|
||||
gchar *msg;
|
||||
|
||||
XGetErrorText (display->xdisplay, error->error_code, buf, 63);
|
||||
|
||||
msg =
|
||||
g_strdup_printf ("mutter received an X Window System error: %s\n"
|
||||
" (Details: serial %ld error_code %d request_code %d minor_code %d)\n",
|
||||
buf,
|
||||
error->serial,
|
||||
error->error_code,
|
||||
error->request_code,
|
||||
error->minor_code);
|
||||
|
||||
g_error ("%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_x_error (Display *xdisplay,
|
||||
XErrorEvent *error)
|
||||
{
|
||||
MetaDisplay *display = meta_display_for_x_display (xdisplay);
|
||||
meta_display_error_event (display, error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* non-GDK previous error handler */
|
||||
typedef int (*GdkXErrorHandler) (Display *, XErrorEvent *);
|
||||
static GdkXErrorHandler _gdk_old_error_handler;
|
||||
/* number of times we've pushed the GDK error handler */
|
||||
static int _gdk_error_handler_push_count = 0;
|
||||
|
||||
static void
|
||||
_gdk_x11_error_handler_push (void)
|
||||
{
|
||||
GdkXErrorHandler previous;
|
||||
|
||||
previous = XSetErrorHandler (gdk_x_error);
|
||||
|
||||
if (_gdk_error_handler_push_count > 0)
|
||||
{
|
||||
if (previous != gdk_x_error)
|
||||
g_warning ("XSetErrorHandler() called with a GDK error trap pushed. Don't do that.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_gdk_old_error_handler = previous;
|
||||
}
|
||||
|
||||
_gdk_error_handler_push_count += 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_x11_error_handler_pop (void)
|
||||
{
|
||||
g_return_if_fail (_gdk_error_handler_push_count > 0);
|
||||
|
||||
_gdk_error_handler_push_count -= 1;
|
||||
|
||||
if (_gdk_error_handler_push_count == 0)
|
||||
{
|
||||
XSetErrorHandler (_gdk_old_error_handler);
|
||||
_gdk_old_error_handler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
delete_outdated_error_traps (MetaDisplay *display)
|
||||
{
|
||||
GSList *tmp_list;
|
||||
gulong processed_sequence;
|
||||
|
||||
processed_sequence = XLastKnownRequestProcessed (display->xdisplay);
|
||||
|
||||
tmp_list = display->error_traps;
|
||||
while (tmp_list != NULL)
|
||||
{
|
||||
GdkErrorTrap *trap = tmp_list->data;
|
||||
|
||||
if (trap->end_sequence != 0 &&
|
||||
SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
|
||||
{
|
||||
GSList *free_me = tmp_list;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
display->error_traps = g_slist_delete_link (display->error_traps, free_me);
|
||||
g_slice_free (GdkErrorTrap, trap);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_error_trap_push (MetaDisplay *display)
|
||||
{
|
||||
gdk_error_trap_push ();
|
||||
GdkErrorTrap *trap;
|
||||
|
||||
delete_outdated_error_traps (display);
|
||||
|
||||
/* set up the Xlib callback to tell us about errors */
|
||||
_gdk_x11_error_handler_push ();
|
||||
|
||||
trap = g_slice_new0 (GdkErrorTrap);
|
||||
|
||||
trap->start_sequence = XNextRequest (display->xdisplay);
|
||||
trap->error_code = Success;
|
||||
|
||||
display->error_traps =
|
||||
g_slist_prepend (display->error_traps, trap);
|
||||
}
|
||||
|
||||
static gint
|
||||
meta_error_trap_pop_internal (MetaDisplay *display,
|
||||
gboolean need_code)
|
||||
{
|
||||
GdkErrorTrap *trap;
|
||||
GSList *tmp_list;
|
||||
int result;
|
||||
|
||||
g_return_val_if_fail (display->error_traps != NULL, Success);
|
||||
|
||||
/* Find the first trap that hasn't been popped already */
|
||||
trap = NULL; /* quiet gcc */
|
||||
for (tmp_list = display->error_traps;
|
||||
tmp_list != NULL;
|
||||
tmp_list = tmp_list->next)
|
||||
{
|
||||
trap = tmp_list->data;
|
||||
|
||||
if (trap->end_sequence == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (trap != NULL, Success);
|
||||
g_assert (trap->end_sequence == 0);
|
||||
|
||||
/* May need to sync to fill in trap->error_code if we care about
|
||||
* getting an error code.
|
||||
*/
|
||||
if (need_code)
|
||||
{
|
||||
gulong processed_sequence;
|
||||
gulong next_sequence;
|
||||
|
||||
next_sequence = XNextRequest (display->xdisplay);
|
||||
processed_sequence = XLastKnownRequestProcessed (display->xdisplay);
|
||||
|
||||
/* If our last request was already processed, there is no point
|
||||
* in syncing. i.e. if last request was a round trip (or even if
|
||||
* we got an event with the serial of a non-round-trip)
|
||||
*/
|
||||
if ((next_sequence - 1) != processed_sequence)
|
||||
{
|
||||
XSync (display->xdisplay, False);
|
||||
}
|
||||
|
||||
result = trap->error_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Success;
|
||||
}
|
||||
|
||||
/* record end of trap, giving us a range of
|
||||
* error sequences we'll ignore.
|
||||
*/
|
||||
trap->end_sequence = XNextRequest (display->xdisplay);
|
||||
|
||||
/* remove the Xlib callback */
|
||||
_gdk_x11_error_handler_pop ();
|
||||
|
||||
/* we may already be outdated */
|
||||
delete_outdated_error_traps (display);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
meta_error_trap_pop (MetaDisplay *display)
|
||||
{
|
||||
gdk_error_trap_pop_ignored ();
|
||||
}
|
||||
|
||||
void
|
||||
meta_error_trap_push_with_return (MetaDisplay *display)
|
||||
{
|
||||
gdk_error_trap_push ();
|
||||
meta_error_trap_pop_internal (display, FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
meta_error_trap_pop_with_return (MetaDisplay *display)
|
||||
{
|
||||
return gdk_error_trap_pop ();
|
||||
return meta_error_trap_pop_internal (display, TRUE);
|
||||
}
|
||||
|
@ -34,10 +34,12 @@
|
||||
#include "window-private.h"
|
||||
#include "bell.h"
|
||||
#include "workspace-private.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "backends/x11/meta-idle-monitor-xsync.h"
|
||||
#include "backends/native/meta-idle-monitor-native.h"
|
||||
|
||||
#include "x11/window-x11.h"
|
||||
#include "x11/xprops.h"
|
||||
#include "wayland/meta-xwayland.h"
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
#include "meta-surface-actor-wayland.h"
|
||||
|
||||
@ -76,9 +78,8 @@ get_input_event (MetaDisplay *display,
|
||||
{
|
||||
XIEvent *input_event;
|
||||
|
||||
/* NB: GDK event filters already have generic events
|
||||
* allocated, so no need to do XGetEventData() on our own
|
||||
*/
|
||||
XGetEventData (display->xdisplay, &event->xcookie);
|
||||
|
||||
input_event = (XIEvent *) event->xcookie.data;
|
||||
|
||||
switch (input_event->evtype)
|
||||
@ -666,10 +667,10 @@ G_GNUC_UNUSED static void
|
||||
meta_spew_event (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
MetaScreen *screen = display->screen;
|
||||
const char *name = NULL;
|
||||
char *extra = NULL;
|
||||
char *winname;
|
||||
MetaScreen *screen;
|
||||
XIEvent *input_event;
|
||||
|
||||
/* filter overnumerous events */
|
||||
@ -693,9 +694,7 @@ meta_spew_event (MetaDisplay *display,
|
||||
else
|
||||
meta_spew_core_event (display, event, &name, &extra);
|
||||
|
||||
screen = meta_display_screen_for_root (display, event->xany.window);
|
||||
|
||||
if (screen)
|
||||
if (event->xany.window == screen->xroot)
|
||||
winname = g_strdup_printf ("root %d", screen->number);
|
||||
else
|
||||
winname = g_strdup_printf ("0x%lx", event->xany.window);
|
||||
@ -735,7 +734,7 @@ handle_window_focus_event (MetaDisplay *display,
|
||||
}
|
||||
else if (meta_display_xwindow_is_a_no_focus_window (display, event->event))
|
||||
window_type = "no_focus_window";
|
||||
else if (meta_display_screen_for_root (display, event->event))
|
||||
else if (event->event == display->screen->xroot)
|
||||
window_type = "root window";
|
||||
else
|
||||
window_type = "unknown window";
|
||||
@ -855,11 +854,22 @@ handle_input_xevent (MetaDisplay *display,
|
||||
XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
|
||||
Window modified;
|
||||
MetaWindow *window;
|
||||
MetaScreen *screen;
|
||||
MetaScreen *screen = display->screen;
|
||||
|
||||
if (input_event == NULL)
|
||||
return FALSE;
|
||||
|
||||
switch (input_event->evtype)
|
||||
{
|
||||
case XI_Enter:
|
||||
case XI_Leave:
|
||||
case XI_FocusIn:
|
||||
case XI_FocusOut:
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
modified = xievent_get_modified_window (display, input_event);
|
||||
window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||
|
||||
@ -869,20 +879,6 @@ handle_input_xevent (MetaDisplay *display,
|
||||
if (display->grab_op == META_GRAB_OP_COMPOSITOR)
|
||||
break;
|
||||
|
||||
/* If the mouse switches screens, active the default window on the new
|
||||
* screen; this will make keybindings and workspace-launched items
|
||||
* actually appear on the right screen.
|
||||
*/
|
||||
{
|
||||
MetaScreen *new_screen =
|
||||
meta_display_screen_for_root (display, enter_event->root);
|
||||
|
||||
if (new_screen != NULL && display->active_screen != new_screen)
|
||||
meta_workspace_focus_default_window (new_screen->active_workspace,
|
||||
NULL,
|
||||
enter_event->time);
|
||||
}
|
||||
|
||||
/* Check if we've entered a window; do this even if window->has_focus to
|
||||
* avoid races.
|
||||
*/
|
||||
@ -923,8 +919,6 @@ handle_input_xevent (MetaDisplay *display,
|
||||
if (enter_event->root != enter_event->event)
|
||||
break;
|
||||
|
||||
screen = meta_display_screen_for_root (display, enter_event->root);
|
||||
|
||||
if (enter_event->evtype == XI_FocusIn &&
|
||||
enter_event->mode == XINotifyDetailNone)
|
||||
{
|
||||
@ -950,12 +944,11 @@ handle_input_xevent (MetaDisplay *display,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Don't send FocusIn / FocusOut to Clutter */
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
/* Don't pass these events through to Clutter / GTK+ */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1013,21 +1006,9 @@ process_request_frame_extents (MetaDisplay *display,
|
||||
if ((hints_set && hints->decorations) || !hints_set)
|
||||
{
|
||||
MetaFrameBorders borders;
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_xwindow (display,
|
||||
event->xclient.window);
|
||||
if (screen == NULL)
|
||||
{
|
||||
meta_warning ("Received request to set _NET_FRAME_EXTENTS "
|
||||
"on 0x%lx which is on a screen we are not managing\n",
|
||||
event->xclient.window);
|
||||
meta_XFree (hints);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Return estimated frame extents for a normal window. */
|
||||
meta_ui_theme_get_frame_borders (screen->ui,
|
||||
meta_ui_theme_get_frame_borders (display->screen->ui,
|
||||
META_FRAME_TYPE_NORMAL,
|
||||
0,
|
||||
&borders);
|
||||
@ -1052,28 +1033,6 @@ process_request_frame_extents (MetaDisplay *display,
|
||||
meta_XFree (hints);
|
||||
}
|
||||
|
||||
static MetaScreen*
|
||||
find_screen_for_selection (MetaDisplay *display,
|
||||
Window owner,
|
||||
Atom selection)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
if (screen->wm_sn_selection_window == owner &&
|
||||
screen->wm_sn_atom == selection)
|
||||
return screen;
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
|
||||
static gboolean
|
||||
convert_property (MetaDisplay *display,
|
||||
@ -1091,7 +1050,7 @@ convert_property (MetaDisplay *display,
|
||||
conversion_targets[2] = display->atom_TIMESTAMP;
|
||||
conversion_targets[3] = display->atom_VERSION;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (target == display->atom_TARGETS)
|
||||
XChangeProperty (display->xdisplay, w, property,
|
||||
XA_ATOM, 32, PropModeReplace,
|
||||
@ -1128,14 +1087,11 @@ static void
|
||||
process_selection_request (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
MetaScreen *screen = display->screen;
|
||||
XSelectionEvent reply;
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = find_screen_for_selection (display,
|
||||
event->xselectionrequest.owner,
|
||||
event->xselectionrequest.selection);
|
||||
|
||||
if (screen == NULL)
|
||||
if (screen->wm_sn_selection_window != event->xselectionrequest.owner ||
|
||||
screen->wm_sn_atom != event->xselectionrequest.selection)
|
||||
{
|
||||
char *str;
|
||||
|
||||
@ -1169,7 +1125,7 @@ process_selection_request (MetaDisplay *display,
|
||||
unsigned long num, rest;
|
||||
unsigned char *data;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (XGetWindowProperty (display->xdisplay,
|
||||
event->xselectionrequest.requestor,
|
||||
event->xselectionrequest.property, 0, 256, False,
|
||||
@ -1231,41 +1187,31 @@ static void
|
||||
process_selection_clear (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
/* We need to unmanage the screen on which we lost the selection */
|
||||
MetaScreen *screen;
|
||||
MetaScreen *screen = display->screen;
|
||||
|
||||
screen = find_screen_for_selection (display,
|
||||
event->xselectionclear.window,
|
||||
event->xselectionclear.selection);
|
||||
|
||||
|
||||
if (screen != NULL)
|
||||
if (screen->wm_sn_selection_window != event->xselectionclear.window ||
|
||||
screen->wm_sn_atom != event->xselectionclear.selection)
|
||||
{
|
||||
meta_verbose ("Got selection clear for screen %d on display %s\n",
|
||||
screen->number, display->name);
|
||||
char *str;
|
||||
|
||||
meta_display_unmanage_screen (display,
|
||||
screen,
|
||||
event->xselectionclear.time);
|
||||
meta_error_trap_push (display);
|
||||
str = XGetAtomName (display->xdisplay,
|
||||
event->xselectionclear.selection);
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
/* display and screen may both be invalid memory... */
|
||||
meta_verbose ("Selection clear with selection %s window 0x%lx not a WM_Sn selection we recognize\n",
|
||||
str ? str : "(bad atom)", event->xselectionclear.window);
|
||||
|
||||
meta_XFree (str);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
char *str;
|
||||
meta_verbose ("Got selection clear for screen %d on display %s\n",
|
||||
screen->number, display->name);
|
||||
|
||||
meta_error_trap_push (display);
|
||||
str = XGetAtomName (display->xdisplay,
|
||||
event->xselectionclear.selection);
|
||||
meta_error_trap_pop (display);
|
||||
|
||||
meta_verbose ("Selection clear with selection %s window 0x%lx not a WM_Sn selection we recognize\n",
|
||||
str ? str : "(bad atom)", event->xselectionclear.window);
|
||||
|
||||
meta_XFree (str);
|
||||
}
|
||||
meta_display_unmanage_screen (display, display->screen,
|
||||
event->xselectionclear.time);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1309,7 +1255,7 @@ handle_other_xevent (MetaDisplay *display,
|
||||
bypass_gtk = TRUE; /* GTK doesn't want to see this really */
|
||||
}
|
||||
else
|
||||
meta_idle_monitor_handle_xevent_all (event);
|
||||
meta_idle_monitor_xsync_handle_xevent_all (event);
|
||||
|
||||
goto out;
|
||||
}
|
||||
@ -1356,24 +1302,16 @@ handle_other_xevent (MetaDisplay *display,
|
||||
break;
|
||||
case CreateNotify:
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xcreatewindow.parent);
|
||||
if (screen)
|
||||
meta_stack_tracker_create_event (screen->stack_tracker,
|
||||
if (event->xcreatewindow.parent == display->screen->xroot)
|
||||
meta_stack_tracker_create_event (display->screen->stack_tracker,
|
||||
&event->xcreatewindow);
|
||||
}
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xdestroywindow.event);
|
||||
if (screen)
|
||||
meta_stack_tracker_destroy_event (screen->stack_tracker,
|
||||
if (event->xdestroywindow.event == display->screen->xroot)
|
||||
meta_stack_tracker_destroy_event (display->screen->stack_tracker,
|
||||
&event->xdestroywindow);
|
||||
}
|
||||
if (window)
|
||||
@ -1447,8 +1385,7 @@ handle_other_xevent (MetaDisplay *display,
|
||||
/* NB: override redirect windows wont cause a map request so we
|
||||
* watch out for map notifies against any root windows too if a
|
||||
* compositor is enabled: */
|
||||
if (window == NULL
|
||||
&& meta_display_screen_for_root (display, event->xmap.event))
|
||||
if (window == NULL && event->xmap.event == display->screen->xroot)
|
||||
{
|
||||
window = meta_window_x11_new (display, event->xmap.window,
|
||||
FALSE, META_COMP_EFFECT_CREATE);
|
||||
@ -1480,24 +1417,16 @@ handle_other_xevent (MetaDisplay *display,
|
||||
break;
|
||||
case ReparentNotify:
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xconfigure.event);
|
||||
if (screen)
|
||||
meta_stack_tracker_reparent_event (screen->stack_tracker,
|
||||
if (event->xreparent.event == display->screen->xroot)
|
||||
meta_stack_tracker_reparent_event (display->screen->stack_tracker,
|
||||
&event->xreparent);
|
||||
}
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (event->xconfigure.event != event->xconfigure.window)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xconfigure.event);
|
||||
if (screen)
|
||||
meta_stack_tracker_configure_event (screen->stack_tracker,
|
||||
if (event->xconfigure.event == display->screen->xroot)
|
||||
meta_stack_tracker_configure_event (display->screen->stack_tracker,
|
||||
&event->xconfigure);
|
||||
}
|
||||
|
||||
@ -1551,7 +1480,6 @@ handle_other_xevent (MetaDisplay *display,
|
||||
case PropertyNotify:
|
||||
{
|
||||
MetaGroup *group;
|
||||
MetaScreen *screen;
|
||||
|
||||
if (window && !frame_was_receiver)
|
||||
meta_window_x11_property_notify (window, event);
|
||||
@ -1563,24 +1491,18 @@ handle_other_xevent (MetaDisplay *display,
|
||||
if (group != NULL)
|
||||
meta_group_property_notify (group, event);
|
||||
|
||||
screen = NULL;
|
||||
if (window == NULL &&
|
||||
group == NULL) /* window/group != NULL means it wasn't a root window */
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xproperty.window);
|
||||
|
||||
if (screen != NULL)
|
||||
if (event->xproperty.window == display->screen->xroot)
|
||||
{
|
||||
if (event->xproperty.atom ==
|
||||
display->atom__NET_DESKTOP_LAYOUT)
|
||||
meta_screen_update_workspace_layout (screen);
|
||||
meta_screen_update_workspace_layout (display->screen);
|
||||
else if (event->xproperty.atom ==
|
||||
display->atom__NET_DESKTOP_NAMES)
|
||||
meta_screen_update_workspace_names (screen);
|
||||
meta_screen_update_workspace_names (display->screen);
|
||||
else if (meta_is_wayland_compositor () &&
|
||||
event->xproperty.atom ==
|
||||
display->atom__XKB_RULES_NAMES)
|
||||
reload_xkb_rules (screen);
|
||||
reload_xkb_rules (display->screen);
|
||||
#if 0
|
||||
else if (event->xproperty.atom ==
|
||||
display->atom__NET_RESTACK_WINDOW)
|
||||
@ -1624,17 +1546,17 @@ handle_other_xevent (MetaDisplay *display,
|
||||
case ClientMessage:
|
||||
if (window)
|
||||
{
|
||||
if (!frame_was_receiver)
|
||||
if (event->xclient.message_type == display->atom_WL_SURFACE_ID)
|
||||
{
|
||||
guint32 surface_id = event->xclient.data.l[0];
|
||||
meta_xwayland_handle_wl_surface_id (window, surface_id);
|
||||
}
|
||||
else if (!frame_was_receiver)
|
||||
meta_window_x11_client_message (window, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xclient.window);
|
||||
|
||||
if (screen)
|
||||
if (event->xclient.window == display->screen->xroot)
|
||||
{
|
||||
if (event->xclient.message_type ==
|
||||
display->atom__NET_CURRENT_DESKTOP)
|
||||
@ -1650,9 +1572,7 @@ handle_other_xevent (MetaDisplay *display,
|
||||
"specified timestamp of %u\n",
|
||||
space, time);
|
||||
|
||||
workspace =
|
||||
meta_screen_get_workspace_by_index (screen,
|
||||
space);
|
||||
workspace = meta_screen_get_workspace_by_index (display->screen, space);
|
||||
|
||||
/* Handle clients using the older version of the spec... */
|
||||
if (time == 0 && workspace)
|
||||
@ -1693,11 +1613,11 @@ handle_other_xevent (MetaDisplay *display,
|
||||
showing_desktop ? "show" : "hide");
|
||||
|
||||
if (showing_desktop)
|
||||
meta_screen_show_desktop (screen, timestamp);
|
||||
meta_screen_show_desktop (display->screen, timestamp);
|
||||
else
|
||||
{
|
||||
meta_screen_unshow_desktop (screen);
|
||||
meta_workspace_focus_default_window (screen->active_workspace, NULL, timestamp);
|
||||
meta_screen_unshow_desktop (display->screen);
|
||||
meta_workspace_focus_default_window (display->screen->active_workspace, NULL, timestamp);
|
||||
}
|
||||
}
|
||||
else if (event->xclient.message_type ==
|
||||
@ -1829,28 +1749,27 @@ window_has_xwindow (MetaWindow *window,
|
||||
* busy around here. Most of this function is a ginormous switch statement
|
||||
* dealing with all the kinds of events that might turn up.
|
||||
*/
|
||||
static gboolean
|
||||
static void
|
||||
meta_display_handle_xevent (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
Window modified;
|
||||
gboolean bypass_compositor = FALSE, bypass_gtk = FALSE;
|
||||
gboolean bypass_compositor = FALSE;
|
||||
XIEvent *input_event;
|
||||
MetaMonitorManager *monitor;
|
||||
MetaScreen *screen;
|
||||
|
||||
#if 0
|
||||
meta_spew_event (display, event);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
sn_display_process_event (display->sn_display, event);
|
||||
if (sn_display_process_event (display->sn_display, event))
|
||||
{
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Intercept XRandR events early and don't attempt any
|
||||
processing for them. We still let them through to Gdk though,
|
||||
so it can update its own internal state.
|
||||
*/
|
||||
monitor = meta_monitor_manager_get ();
|
||||
if (meta_monitor_manager_handle_xevent (monitor, event))
|
||||
{
|
||||
@ -1875,12 +1794,11 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
screen = meta_display_screen_for_root (display, event->xany.window);
|
||||
if (screen)
|
||||
if (event->xany.window == display->screen->xroot)
|
||||
{
|
||||
if (meta_screen_handle_xevent (screen, event))
|
||||
if (meta_screen_handle_xevent (display->screen, event))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -1891,8 +1809,9 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
|
||||
if (event->type == UnmapNotify)
|
||||
{
|
||||
if (meta_ui_window_should_not_cause_focus (display->xdisplay,
|
||||
modified))
|
||||
MetaUI *ui = display->screen->ui;
|
||||
|
||||
if (meta_ui_window_should_not_cause_focus (ui, modified))
|
||||
{
|
||||
meta_display_add_ignored_crossing_serial (display, event->xany.serial);
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
@ -1914,7 +1833,7 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
#ifdef HAVE_XI23
|
||||
if (meta_display_process_barrier_event (display, input_event))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
#endif /* HAVE_XI23 */
|
||||
@ -1925,27 +1844,52 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
*/
|
||||
if (handle_input_xevent (display, input_event, event->xany.serial))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (handle_other_xevent (display, event))
|
||||
{
|
||||
bypass_gtk = TRUE;
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
out:
|
||||
if (!bypass_compositor)
|
||||
{
|
||||
MetaWindow *window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||
|
||||
if (meta_compositor_process_event (display->compositor, event, window))
|
||||
bypass_gtk = TRUE;
|
||||
meta_compositor_process_event (display->compositor, event, window);
|
||||
}
|
||||
}
|
||||
|
||||
display->current_time = CurrentTime;
|
||||
return bypass_gtk;
|
||||
static void
|
||||
handle_idletime_for_event (const ClutterEvent *event)
|
||||
{
|
||||
ClutterInputDevice *device, *source_device;
|
||||
MetaIdleMonitor *core_monitor, *device_monitor;
|
||||
int device_id;
|
||||
|
||||
/* This is handled by XSync under X11. */
|
||||
if (!meta_is_wayland_compositor ())
|
||||
return;
|
||||
|
||||
device = clutter_event_get_device (event);
|
||||
if (device == NULL)
|
||||
return;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
|
||||
core_monitor = meta_idle_monitor_get_core ();
|
||||
device_monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
|
||||
meta_idle_monitor_native_reset_idletime (core_monitor);
|
||||
meta_idle_monitor_native_reset_idletime (device_monitor);
|
||||
|
||||
source_device = clutter_event_get_source_device (event);
|
||||
if (source_device != device)
|
||||
{
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
device_monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
meta_idle_monitor_native_reset_idletime (device_monitor);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1962,6 +1906,8 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
meta_wayland_compositor_update (compositor, event);
|
||||
}
|
||||
|
||||
handle_idletime_for_event (event);
|
||||
|
||||
window = get_window_for_event (display, event);
|
||||
|
||||
display->current_time = event->any.time;
|
||||
@ -2222,15 +2168,6 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
return bypass_clutter;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
xevent_callback (XEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
MetaDisplay *display = data;
|
||||
|
||||
return meta_display_handle_xevent (display, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_callback (const ClutterEvent *event,
|
||||
gpointer data)
|
||||
@ -2240,24 +2177,90 @@ event_callback (const ClutterEvent *event,
|
||||
return meta_display_handle_event (display, event);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GSource source;
|
||||
|
||||
MetaDisplay *display;
|
||||
GPollFD event_poll_fd;
|
||||
} X11EventSource;
|
||||
|
||||
static gboolean
|
||||
x11_event_source_prepare (GSource *source,
|
||||
gint *timeout)
|
||||
{
|
||||
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||
MetaDisplay *display = source_x11->display;
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
return XPending (display->xdisplay);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
x11_event_source_check (GSource *source)
|
||||
{
|
||||
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||
MetaDisplay *display = source_x11->display;
|
||||
|
||||
if (source_x11->event_poll_fd.revents & G_IO_IN)
|
||||
return XPending (display->xdisplay);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
x11_event_source_dispatch (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||
MetaDisplay *display = source_x11->display;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent (display->xdisplay, &event);
|
||||
meta_display_handle_xevent (display, &event);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs x11_event_source_funcs = {
|
||||
x11_event_source_prepare,
|
||||
x11_event_source_check,
|
||||
x11_event_source_dispatch,
|
||||
};
|
||||
|
||||
static GSource *
|
||||
x11_event_source_new (MetaDisplay *display)
|
||||
{
|
||||
GSource *source = g_source_new (&x11_event_source_funcs, sizeof (X11EventSource));
|
||||
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||
|
||||
source_x11->display = display;
|
||||
source_x11->event_poll_fd.fd = ConnectionNumber (display->xdisplay);
|
||||
source_x11->event_poll_fd.events = G_IO_IN;
|
||||
g_source_add_poll (source, &source_x11->event_poll_fd);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_init_events (MetaDisplay *display)
|
||||
{
|
||||
meta_ui_add_event_func (display->xdisplay,
|
||||
xevent_callback,
|
||||
display);
|
||||
display->clutter_event_filter = clutter_event_add_filter (NULL,
|
||||
event_callback,
|
||||
NULL,
|
||||
display);
|
||||
|
||||
display->x11_event_source = x11_event_source_new (display);
|
||||
g_source_attach (display->x11_event_source, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_free_events (MetaDisplay *display)
|
||||
{
|
||||
meta_ui_remove_event_func (display->xdisplay,
|
||||
xevent_callback,
|
||||
display);
|
||||
clutter_event_remove_filter (display->clutter_event_filter);
|
||||
display->clutter_event_filter = 0;
|
||||
|
||||
g_source_unref (display->x11_event_source);
|
||||
display->x11_event_source = NULL;
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ meta_window_ensure_frame (MetaWindow *window)
|
||||
visual = NULL;
|
||||
|
||||
frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
|
||||
window->display->xdisplay,
|
||||
visual,
|
||||
frame->rect.x,
|
||||
frame->rect.y,
|
||||
|
@ -52,6 +52,7 @@
|
||||
#endif
|
||||
|
||||
#include "wayland/meta-wayland.h"
|
||||
#include "meta-backend.h"
|
||||
|
||||
#define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings"
|
||||
#define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings"
|
||||
@ -685,15 +686,7 @@ ungrab_key_bindings (MetaDisplay *display)
|
||||
|
||||
meta_error_trap_push (display); /* for efficiency push outer trap */
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
meta_screen_ungrab_keys (screen);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
meta_screen_ungrab_keys (display->screen);
|
||||
|
||||
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
|
||||
tmp = windows;
|
||||
@ -718,15 +711,7 @@ grab_key_bindings (MetaDisplay *display)
|
||||
|
||||
meta_error_trap_push (display); /* for efficiency push outer trap */
|
||||
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaScreen *screen = tmp->data;
|
||||
|
||||
meta_screen_grab_keys (screen);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
meta_screen_grab_keys (display->screen);
|
||||
|
||||
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
|
||||
tmp = windows;
|
||||
@ -1080,7 +1065,7 @@ meta_change_keygrab (MetaDisplay *display,
|
||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||
|
||||
if (meta_is_debugging ())
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (grab)
|
||||
XIGrabKeycode (display->xdisplay,
|
||||
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||
@ -1298,7 +1283,6 @@ meta_display_grab_accelerator (MetaDisplay *display,
|
||||
guint keycode = 0;
|
||||
guint mask = 0;
|
||||
MetaVirtualModifier modifiers = 0;
|
||||
GSList *l;
|
||||
|
||||
if (!meta_ui_parse_accelerator (accelerator, &keysym, &keycode, &modifiers))
|
||||
{
|
||||
@ -1318,11 +1302,7 @@ meta_display_grab_accelerator (MetaDisplay *display,
|
||||
if (display_get_keybinding (display, keycode, mask))
|
||||
return META_KEYBINDING_ACTION_NONE;
|
||||
|
||||
for (l = display->screens; l; l = l->next)
|
||||
{
|
||||
MetaScreen *screen = l->data;
|
||||
meta_change_keygrab (display, screen->xroot, TRUE, keysym, keycode, mask);
|
||||
}
|
||||
meta_change_keygrab (display, display->screen->xroot, TRUE, keysym, keycode, mask);
|
||||
|
||||
grab = g_new0 (MetaKeyGrab, 1);
|
||||
grab->action = next_dynamic_keybinding_action ();
|
||||
@ -1372,16 +1352,11 @@ meta_display_ungrab_accelerator (MetaDisplay *display,
|
||||
if (binding)
|
||||
{
|
||||
guint32 index_key;
|
||||
GSList *l;
|
||||
|
||||
for (l = display->screens; l; l = l->next)
|
||||
{
|
||||
MetaScreen *screen = l->data;
|
||||
meta_change_keygrab (display, screen->xroot, FALSE,
|
||||
binding->keysym,
|
||||
binding->keycode,
|
||||
binding->mask);
|
||||
}
|
||||
meta_change_keygrab (display, display->screen->xroot, FALSE,
|
||||
binding->keysym,
|
||||
binding->keycode,
|
||||
binding->mask);
|
||||
|
||||
index_key = key_binding_key (binding->keycode, binding->mask);
|
||||
g_hash_table_remove (display->key_bindings_index, GINT_TO_POINTER (index_key));
|
||||
@ -1435,7 +1410,7 @@ grab_keyboard (MetaDisplay *display,
|
||||
/* Grab the keyboard, so we get key releases and all key
|
||||
* presses
|
||||
*/
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/* Strictly, we only need to set grab_mode on the keyboard device
|
||||
* while the pointer should always be XIGrabModeAsync. Unfortunately
|
||||
@ -1686,7 +1661,7 @@ process_event (MetaDisplay *display,
|
||||
/* If the compositor filtered out the keybindings, that
|
||||
* means they don't want the binding to trigger, so we do
|
||||
* the same thing as if the binding didn't exist. */
|
||||
if (meta_compositor_filter_keybinding (display->compositor, screen, binding))
|
||||
if (meta_compositor_filter_keybinding (display->compositor, binding))
|
||||
goto not_found;
|
||||
|
||||
if (binding->handler == NULL)
|
||||
@ -1771,7 +1746,7 @@ process_overlay_key (MetaDisplay *display,
|
||||
display->overlay_key_combo.keycode,
|
||||
display->grab_mask);
|
||||
if (binding &&
|
||||
meta_compositor_filter_keybinding (display->compositor, screen, binding))
|
||||
meta_compositor_filter_keybinding (display->compositor, binding))
|
||||
return TRUE;
|
||||
meta_display_overlay_key_activate (display);
|
||||
}
|
||||
@ -1871,8 +1846,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
|
||||
/* window may be NULL */
|
||||
|
||||
/* XXX */
|
||||
screen = display->active_screen;
|
||||
screen = display->screen;
|
||||
|
||||
all_keys_grabbed = window ? window->all_keys_grabbed : screen->all_keys_grabbed;
|
||||
if (!all_keys_grabbed)
|
||||
@ -1899,8 +1873,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
* we're in some special keyboard mode such as window move
|
||||
* mode.
|
||||
*/
|
||||
if (window ? (window == display->grab_window) :
|
||||
(screen == display->grab_screen))
|
||||
if ((window && window == display->grab_window) || !window)
|
||||
{
|
||||
switch (display->grab_op)
|
||||
{
|
||||
@ -2824,7 +2797,6 @@ do_choose_window (MetaDisplay *display,
|
||||
|
||||
initial_selection = meta_display_get_tab_next (display,
|
||||
type,
|
||||
screen,
|
||||
screen->active_workspace,
|
||||
NULL,
|
||||
backward);
|
||||
@ -3210,10 +3182,9 @@ handle_switch_vt (MetaDisplay *display,
|
||||
gpointer dummy)
|
||||
{
|
||||
gint vt = binding->handler->data;
|
||||
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
||||
GError *error = NULL;
|
||||
|
||||
if (!meta_wayland_compositor_activate_vt (compositor, vt, &error))
|
||||
if (!meta_activate_vt (vt, &error))
|
||||
{
|
||||
g_warning ("Failed to switch VT: %s", error->message);
|
||||
g_error_free (error);
|
||||
|
@ -55,7 +55,6 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
@ -71,7 +70,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include <clutter/x11/clutter-x11.h>
|
||||
|
||||
#ifdef HAVE_INTROSPECTION
|
||||
#include <girepository.h>
|
||||
@ -80,6 +78,7 @@
|
||||
#include "x11/session.h"
|
||||
|
||||
#include "wayland/meta-wayland.h"
|
||||
#include "backends/meta-backend.h"
|
||||
|
||||
/*
|
||||
* The exit code we'll return to our parent process when we eventually die.
|
||||
@ -267,72 +266,6 @@ meta_get_option_context (void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/* Mutter is responsible for pulling events off the X queue, so Clutter
|
||||
* doesn't need (and shouldn't) run its normal event source which polls
|
||||
* the X fd, but we do have to deal with dispatching events that accumulate
|
||||
* in the clutter queue. This happens, for example, when clutter generate
|
||||
* enter/leave events on mouse motion - several events are queued in the
|
||||
* clutter queue but only one dispatched. It could also happen because of
|
||||
* explicit calls to clutter_event_put(). We add a very simple custom
|
||||
* event loop source which is simply responsible for pulling events off
|
||||
* of the queue and dispatching them before we block for new events.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
event_prepare (GSource *source,
|
||||
gint *timeout_)
|
||||
{
|
||||
*timeout_ = -1;
|
||||
|
||||
return clutter_events_pending ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_check (GSource *source)
|
||||
{
|
||||
return clutter_events_pending ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_dispatch (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterEvent *event = clutter_event_get ();
|
||||
|
||||
if (event)
|
||||
{
|
||||
clutter_do_event (event);
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs event_funcs = {
|
||||
event_prepare,
|
||||
event_check,
|
||||
event_dispatch
|
||||
};
|
||||
|
||||
static void
|
||||
meta_clutter_init (void)
|
||||
{
|
||||
clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
|
||||
clutter_x11_disable_event_retrieval ();
|
||||
|
||||
if (CLUTTER_INIT_SUCCESS == clutter_init (NULL, NULL))
|
||||
{
|
||||
GSource *source = g_source_new (&event_funcs, sizeof (GSource));
|
||||
g_source_attach (source, NULL);
|
||||
g_source_unref (source);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_fatal ("Unable to initialize Clutter.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_select_display:
|
||||
*
|
||||
@ -504,32 +437,6 @@ meta_register_with_session (void)
|
||||
g_free (opt_client_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_activate_session:
|
||||
*
|
||||
* Tells mutter to activate the session. When mutter is a
|
||||
* Wayland compositor, this tells logind to switch over to
|
||||
* the new session.
|
||||
*/
|
||||
gboolean
|
||||
meta_activate_session (void)
|
||||
{
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
||||
GError *error = NULL;
|
||||
|
||||
if (!meta_wayland_compositor_activate_session (compositor, &error))
|
||||
{
|
||||
g_warning ("Could not activate session: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_run: (skip)
|
||||
*
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef META_CURSOR_TRACKER_PRIVATE_H
|
||||
#define META_CURSOR_TRACKER_PRIVATE_H
|
||||
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
#include <wayland-server.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
gboolean meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
|
||||
XEvent *xevent);
|
||||
|
||||
void meta_cursor_tracker_set_grab_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor);
|
||||
void meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
|
||||
struct wl_resource *buffer,
|
||||
int hot_x,
|
||||
int hot_y);
|
||||
void meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker);
|
||||
void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursor cursor);
|
||||
|
||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||
int new_x,
|
||||
int new_y);
|
||||
void meta_cursor_tracker_paint (MetaCursorTracker *tracker);
|
||||
|
||||
void meta_cursor_tracker_force_update (MetaCursorTracker *tracker);
|
||||
|
||||
#endif
|
@ -1,996 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Adapted from gnome-session/gnome-session/gs-idle-monitor.c and
|
||||
* from gnome-desktop/libgnome-desktop/gnome-idle-monitor.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:idle-monitor
|
||||
* @title: MetaIdleMonitor
|
||||
* @short_description: Mutter idle counter (similar to X's IDLETIME)
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/sync.h>
|
||||
|
||||
#include <meta/util.h>
|
||||
#include <meta/main.h>
|
||||
#include <meta/meta-idle-monitor.h>
|
||||
#include "display-private.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "meta-dbus-idle-monitor.h"
|
||||
|
||||
G_STATIC_ASSERT(sizeof(unsigned long) == sizeof(gpointer));
|
||||
|
||||
struct _MetaIdleMonitor
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GHashTable *watches;
|
||||
GHashTable *alarms;
|
||||
int device_id;
|
||||
|
||||
/* X11 implementation */
|
||||
Display *display;
|
||||
int sync_event_base;
|
||||
XSyncCounter counter;
|
||||
XSyncAlarm user_active_alarm;
|
||||
|
||||
/* Wayland implementation */
|
||||
guint64 last_event_time;
|
||||
};
|
||||
|
||||
struct _MetaIdleMonitorClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
guint id;
|
||||
MetaIdleMonitorWatchFunc callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify notify;
|
||||
guint64 timeout_msec;
|
||||
|
||||
/* x11 */
|
||||
XSyncAlarm xalarm;
|
||||
int idle_source_id;
|
||||
|
||||
/* wayland */
|
||||
GSource *timeout_source;
|
||||
} MetaIdleMonitorWatch;
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DEVICE_ID,
|
||||
PROP_LAST,
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[PROP_LAST];
|
||||
|
||||
G_DEFINE_TYPE (MetaIdleMonitor, meta_idle_monitor, G_TYPE_OBJECT)
|
||||
|
||||
static MetaIdleMonitor *device_monitors[256];
|
||||
static int device_id_max;
|
||||
|
||||
static gint64
|
||||
_xsyncvalue_to_int64 (XSyncValue value)
|
||||
{
|
||||
return ((guint64) XSyncValueHigh32 (value)) << 32
|
||||
| (guint64) XSyncValueLow32 (value);
|
||||
}
|
||||
|
||||
#define GUINT64_TO_XSYNCVALUE(value, ret) XSyncIntsToValue (ret, (value) & 0xFFFFFFFF, ((guint64)(value)) >> 32)
|
||||
|
||||
static void
|
||||
fire_watch (MetaIdleMonitorWatch *watch)
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
guint id;
|
||||
gboolean is_user_active_watch;
|
||||
|
||||
monitor = watch->monitor;
|
||||
g_object_ref (monitor);
|
||||
|
||||
if (watch->idle_source_id)
|
||||
{
|
||||
g_source_remove (watch->idle_source_id);
|
||||
watch->idle_source_id = 0;
|
||||
}
|
||||
|
||||
id = watch->id;
|
||||
is_user_active_watch = (watch->timeout_msec == 0);
|
||||
|
||||
if (watch->callback)
|
||||
watch->callback (monitor, id, watch->user_data);
|
||||
|
||||
if (is_user_active_watch)
|
||||
meta_idle_monitor_remove_watch (monitor, id);
|
||||
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
static XSyncAlarm
|
||||
_xsync_alarm_set (MetaIdleMonitor *monitor,
|
||||
XSyncTestType test_type,
|
||||
guint64 interval,
|
||||
gboolean want_events)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
XSyncValue delta;
|
||||
guint flags;
|
||||
|
||||
flags = XSyncCACounter | XSyncCAValueType | XSyncCATestType |
|
||||
XSyncCAValue | XSyncCADelta | XSyncCAEvents;
|
||||
|
||||
XSyncIntToValue (&delta, 0);
|
||||
attr.trigger.counter = monitor->counter;
|
||||
attr.trigger.value_type = XSyncAbsolute;
|
||||
attr.delta = delta;
|
||||
attr.events = want_events;
|
||||
|
||||
GUINT64_TO_XSYNCVALUE (interval, &attr.trigger.wait_value);
|
||||
attr.trigger.test_type = test_type;
|
||||
return XSyncCreateAlarm (monitor->display, flags, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_alarm_rescheduled (Display *dpy,
|
||||
XSyncAlarm alarm)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
|
||||
/* Some versions of Xorg have an issue where alarms aren't
|
||||
* always rescheduled. Calling XSyncChangeAlarm, even
|
||||
* without any attributes, will reschedule the alarm. */
|
||||
XSyncChangeAlarm (dpy, alarm, 0, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
set_alarm_enabled (Display *dpy,
|
||||
XSyncAlarm alarm,
|
||||
gboolean enabled)
|
||||
{
|
||||
XSyncAlarmAttributes attr;
|
||||
attr.events = enabled;
|
||||
XSyncChangeAlarm (dpy, alarm, XSyncCAEvents, &attr);
|
||||
}
|
||||
|
||||
static void
|
||||
check_x11_watch (gpointer data,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch = data;
|
||||
XSyncAlarm alarm = (XSyncAlarm) user_data;
|
||||
|
||||
if (watch->xalarm != alarm)
|
||||
return;
|
||||
|
||||
fire_watch (watch);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_handle_xevent (MetaIdleMonitor *monitor,
|
||||
XSyncAlarmNotifyEvent *alarm_event)
|
||||
{
|
||||
XSyncAlarm alarm;
|
||||
GList *watches;
|
||||
gboolean has_alarm;
|
||||
|
||||
if (alarm_event->state != XSyncAlarmActive)
|
||||
return;
|
||||
|
||||
alarm = alarm_event->alarm;
|
||||
|
||||
has_alarm = FALSE;
|
||||
|
||||
if (alarm == monitor->user_active_alarm)
|
||||
{
|
||||
set_alarm_enabled (monitor->display,
|
||||
alarm,
|
||||
FALSE);
|
||||
has_alarm = TRUE;
|
||||
}
|
||||
else if (g_hash_table_contains (monitor->alarms, (gpointer) alarm))
|
||||
{
|
||||
ensure_alarm_rescheduled (monitor->display,
|
||||
alarm);
|
||||
has_alarm = TRUE;
|
||||
}
|
||||
|
||||
if (has_alarm)
|
||||
{
|
||||
watches = g_hash_table_get_values (monitor->watches);
|
||||
|
||||
g_list_foreach (watches, check_x11_watch, (gpointer) alarm);
|
||||
g_list_free (watches);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_handle_xevent_all (XEvent *xevent)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= device_id_max; i++)
|
||||
if (device_monitors[i])
|
||||
meta_idle_monitor_handle_xevent (device_monitors[i], (XSyncAlarmNotifyEvent*)xevent);
|
||||
}
|
||||
|
||||
static char *
|
||||
counter_name_for_device (int device_id)
|
||||
{
|
||||
if (device_id > 0)
|
||||
return g_strdup_printf ("DEVICEIDLETIME %d", device_id);
|
||||
|
||||
return g_strdup ("IDLETIME");
|
||||
}
|
||||
|
||||
static XSyncCounter
|
||||
find_idletime_counter (MetaIdleMonitor *monitor)
|
||||
{
|
||||
int i;
|
||||
int ncounters;
|
||||
XSyncSystemCounter *counters;
|
||||
XSyncCounter counter = None;
|
||||
char *counter_name;
|
||||
|
||||
counter_name = counter_name_for_device (monitor->device_id);
|
||||
counters = XSyncListSystemCounters (monitor->display, &ncounters);
|
||||
for (i = 0; i < ncounters; i++)
|
||||
{
|
||||
if (counters[i].name != NULL && strcmp (counters[i].name, counter_name) == 0)
|
||||
{
|
||||
counter = counters[i].counter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XSyncFreeSystemCounterList (counters);
|
||||
g_free (counter_name);
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_next_watch_serial (void)
|
||||
{
|
||||
static guint32 serial = 0;
|
||||
g_atomic_int_inc (&serial);
|
||||
return serial;
|
||||
}
|
||||
|
||||
static void
|
||||
idle_monitor_watch_free (MetaIdleMonitorWatch *watch)
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
|
||||
if (watch == NULL)
|
||||
return;
|
||||
|
||||
monitor = watch->monitor;
|
||||
g_object_ref (monitor);
|
||||
|
||||
if (watch->idle_source_id)
|
||||
{
|
||||
g_source_remove (watch->idle_source_id);
|
||||
watch->idle_source_id = 0;
|
||||
}
|
||||
|
||||
if (watch->notify != NULL)
|
||||
watch->notify (watch->user_data);
|
||||
|
||||
if (watch->xalarm != monitor->user_active_alarm &&
|
||||
watch->xalarm != None)
|
||||
{
|
||||
XSyncDestroyAlarm (monitor->display, watch->xalarm);
|
||||
g_hash_table_remove (monitor->alarms, (gpointer) watch->xalarm);
|
||||
}
|
||||
|
||||
if (watch->timeout_source != NULL)
|
||||
g_source_destroy (watch->timeout_source);
|
||||
|
||||
g_object_unref (monitor);
|
||||
g_slice_free (MetaIdleMonitorWatch, watch);
|
||||
}
|
||||
|
||||
static void
|
||||
init_xsync (MetaIdleMonitor *monitor)
|
||||
{
|
||||
monitor->counter = find_idletime_counter (monitor);
|
||||
/* IDLETIME counter not found? */
|
||||
if (monitor->counter == None)
|
||||
{
|
||||
meta_warning ("IDLETIME counter not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
monitor->user_active_alarm = _xsync_alarm_set (monitor, XSyncNegativeTransition, 1, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_dispose (GObject *object)
|
||||
{
|
||||
MetaIdleMonitor *monitor;
|
||||
|
||||
monitor = META_IDLE_MONITOR (object);
|
||||
|
||||
g_clear_pointer (&monitor->watches, g_hash_table_destroy);
|
||||
g_clear_pointer (&monitor->alarms, g_hash_table_destroy);
|
||||
|
||||
if (monitor->user_active_alarm != None)
|
||||
{
|
||||
XSyncDestroyAlarm (monitor->display, monitor->user_active_alarm);
|
||||
monitor->user_active_alarm = None;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (meta_idle_monitor_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DEVICE_ID:
|
||||
g_value_set_int (value, monitor->device_id);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DEVICE_ID:
|
||||
monitor->device_id = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_constructed (GObject *object)
|
||||
{
|
||||
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
|
||||
|
||||
if (!meta_is_wayland_compositor ())
|
||||
{
|
||||
monitor->display = meta_get_display ()->xdisplay;
|
||||
init_xsync (monitor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_class_init (MetaIdleMonitorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = meta_idle_monitor_dispose;
|
||||
object_class->constructed = meta_idle_monitor_constructed;
|
||||
object_class->get_property = meta_idle_monitor_get_property;
|
||||
object_class->set_property = meta_idle_monitor_set_property;
|
||||
|
||||
/**
|
||||
* MetaIdleMonitor:device_id:
|
||||
*
|
||||
* The device to listen to idletime on.
|
||||
*/
|
||||
obj_props[PROP_DEVICE_ID] =
|
||||
g_param_spec_int ("device-id",
|
||||
"Device ID",
|
||||
"The device to listen to idletime on",
|
||||
0, 255, 0,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_DEVICE_ID, obj_props[PROP_DEVICE_ID]);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_idle_monitor_init (MetaIdleMonitor *monitor)
|
||||
{
|
||||
monitor->watches = g_hash_table_new_full (NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(GDestroyNotify)idle_monitor_watch_free);
|
||||
|
||||
monitor->alarms = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_device_monitor (int device_id)
|
||||
{
|
||||
if (device_monitors[device_id])
|
||||
return;
|
||||
|
||||
device_monitors[device_id] = g_object_new (META_TYPE_IDLE_MONITOR, "device-id", device_id, NULL);
|
||||
device_id_max = MAX (device_id_max, device_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_core:
|
||||
*
|
||||
* Returns: (transfer none): the #MetaIdleMonitor that tracks the server-global
|
||||
* idletime for all devices. To track device-specific idletime,
|
||||
* use meta_idle_monitor_get_for_device().
|
||||
*/
|
||||
MetaIdleMonitor *
|
||||
meta_idle_monitor_get_core (void)
|
||||
{
|
||||
ensure_device_monitor (0);
|
||||
return device_monitors[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_for_device:
|
||||
* @device_id: the device to get the idle time for.
|
||||
*
|
||||
* Returns: (transfer none): a new #MetaIdleMonitor that tracks the
|
||||
* device-specific idletime for @device. To track server-global idletime
|
||||
* for all devices, use meta_idle_monitor_get_core().
|
||||
*/
|
||||
MetaIdleMonitor *
|
||||
meta_idle_monitor_get_for_device (int device_id)
|
||||
{
|
||||
g_return_val_if_fail (device_id > 0 && device_id < 256, NULL);
|
||||
|
||||
ensure_device_monitor (device_id);
|
||||
return device_monitors[device_id];
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wayland_dispatch_timeout (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch = user_data;
|
||||
|
||||
fire_watch (watch);
|
||||
g_source_set_ready_time (watch->timeout_source, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs wayland_source_funcs = {
|
||||
NULL, /* prepare */
|
||||
NULL, /* check */
|
||||
wayland_dispatch_timeout,
|
||||
NULL, /* finalize */
|
||||
};
|
||||
|
||||
static gboolean
|
||||
fire_watch_idle (gpointer data)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch = data;
|
||||
|
||||
watch->idle_source_id = 0;
|
||||
fire_watch (watch);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static MetaIdleMonitorWatch *
|
||||
make_watch (MetaIdleMonitor *monitor,
|
||||
guint64 timeout_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
watch = g_slice_new0 (MetaIdleMonitorWatch);
|
||||
watch->monitor = monitor;
|
||||
watch->id = get_next_watch_serial ();
|
||||
watch->callback = callback;
|
||||
watch->user_data = user_data;
|
||||
watch->notify = notify;
|
||||
watch->timeout_msec = timeout_msec;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
if (timeout_msec != 0)
|
||||
{
|
||||
GSource *source = g_source_new (&wayland_source_funcs, sizeof (GSource));
|
||||
|
||||
g_source_set_callback (source, NULL, watch, NULL);
|
||||
g_source_set_ready_time (source, monitor->last_event_time + timeout_msec * 1000);
|
||||
g_source_attach (source, NULL);
|
||||
g_source_unref (source);
|
||||
|
||||
watch->timeout_source = source;
|
||||
}
|
||||
}
|
||||
else if (monitor->user_active_alarm != None)
|
||||
{
|
||||
if (timeout_msec != 0)
|
||||
{
|
||||
watch->xalarm = _xsync_alarm_set (monitor, XSyncPositiveTransition, timeout_msec, TRUE);
|
||||
|
||||
g_hash_table_add (monitor->alarms, (gpointer) watch->xalarm);
|
||||
|
||||
if (meta_idle_monitor_get_idletime (monitor) > (gint64)timeout_msec)
|
||||
watch->idle_source_id = g_idle_add (fire_watch_idle, watch);
|
||||
}
|
||||
else
|
||||
{
|
||||
watch->xalarm = monitor->user_active_alarm;
|
||||
|
||||
set_alarm_enabled (monitor->display, monitor->user_active_alarm, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
g_hash_table_insert (monitor->watches,
|
||||
GUINT_TO_POINTER (watch->id),
|
||||
watch);
|
||||
return watch;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_add_idle_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @interval_msec: The idletime interval, in milliseconds
|
||||
* @callback: (allow-none): The callback to call when the user has
|
||||
* accumulated @interval_msec milliseconds of idle time.
|
||||
* @user_data: (allow-none): The user data to pass to the callback
|
||||
* @notify: A #GDestroyNotify
|
||||
*
|
||||
* Returns: a watch id
|
||||
*
|
||||
* Adds a watch for a specific idle time. The callback will be called
|
||||
* when the user has accumulated @interval_msec milliseconds of idle time.
|
||||
* This function will return an ID that can either be passed to
|
||||
* meta_idle_monitor_remove_watch(), or can be used to tell idle time
|
||||
* watches apart if you have more than one.
|
||||
*
|
||||
* Also note that this function will only care about positive transitions
|
||||
* (user's idle time exceeding a certain time). If you want to know about
|
||||
* when the user has become active, use
|
||||
* meta_idle_monitor_add_user_active_watch().
|
||||
*/
|
||||
guint
|
||||
meta_idle_monitor_add_idle_watch (MetaIdleMonitor *monitor,
|
||||
guint64 interval_msec,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
g_return_val_if_fail (META_IS_IDLE_MONITOR (monitor), 0);
|
||||
g_return_val_if_fail (interval_msec > 0, 0);
|
||||
|
||||
watch = make_watch (monitor,
|
||||
interval_msec,
|
||||
callback,
|
||||
user_data,
|
||||
notify);
|
||||
|
||||
return watch->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_add_user_active_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @callback: (allow-none): The callback to call when the user is
|
||||
* active again.
|
||||
* @user_data: (allow-none): The user data to pass to the callback
|
||||
* @notify: A #GDestroyNotify
|
||||
*
|
||||
* Returns: a watch id
|
||||
*
|
||||
* Add a one-time watch to know when the user is active again.
|
||||
* Note that this watch is one-time and will de-activate after the
|
||||
* function is called, for efficiency purposes. It's most convenient
|
||||
* to call this when an idle watch, as added by
|
||||
* meta_idle_monitor_add_idle_watch(), has triggered.
|
||||
*/
|
||||
guint
|
||||
meta_idle_monitor_add_user_active_watch (MetaIdleMonitor *monitor,
|
||||
MetaIdleMonitorWatchFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch;
|
||||
|
||||
g_return_val_if_fail (META_IS_IDLE_MONITOR (monitor), 0);
|
||||
|
||||
watch = make_watch (monitor,
|
||||
0,
|
||||
callback,
|
||||
user_data,
|
||||
notify);
|
||||
|
||||
return watch->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_remove_watch:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
* @id: A watch ID
|
||||
*
|
||||
* Removes an idle time watcher, previously added by
|
||||
* meta_idle_monitor_add_idle_watch() or
|
||||
* meta_idle_monitor_add_user_active_watch().
|
||||
*/
|
||||
void
|
||||
meta_idle_monitor_remove_watch (MetaIdleMonitor *monitor,
|
||||
guint id)
|
||||
{
|
||||
g_return_if_fail (META_IS_IDLE_MONITOR (monitor));
|
||||
|
||||
g_object_ref (monitor);
|
||||
g_hash_table_remove (monitor->watches,
|
||||
GUINT_TO_POINTER (id));
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_idle_monitor_get_idletime:
|
||||
* @monitor: A #MetaIdleMonitor
|
||||
*
|
||||
* Returns: The current idle time, in milliseconds, or -1 for not supported
|
||||
*/
|
||||
gint64
|
||||
meta_idle_monitor_get_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
XSyncValue value;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
return (g_get_monotonic_time () - monitor->last_event_time) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!XSyncQueryCounter (monitor->display, monitor->counter, &value))
|
||||
return -1;
|
||||
|
||||
return _xsyncvalue_to_int64 (value);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
MetaIdleMonitor *monitor;
|
||||
GList *fired_watches;
|
||||
} CheckWaylandClosure;
|
||||
|
||||
static gboolean
|
||||
check_wayland_watch (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaIdleMonitorWatch *watch = value;
|
||||
CheckWaylandClosure *closure = user_data;
|
||||
gboolean steal;
|
||||
|
||||
if (watch->timeout_msec == 0)
|
||||
{
|
||||
closure->fired_watches = g_list_prepend (closure->fired_watches, watch);
|
||||
steal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_source_set_ready_time (watch->timeout_source,
|
||||
closure->monitor->last_event_time +
|
||||
watch->timeout_msec * 1000);
|
||||
steal = FALSE;
|
||||
}
|
||||
|
||||
return steal;
|
||||
}
|
||||
|
||||
static void
|
||||
fire_wayland_watch (gpointer watch,
|
||||
gpointer data)
|
||||
{
|
||||
fire_watch (watch);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor)
|
||||
{
|
||||
CheckWaylandClosure closure;
|
||||
|
||||
monitor->last_event_time = g_get_monotonic_time ();
|
||||
|
||||
closure.monitor = monitor;
|
||||
closure.fired_watches = NULL;
|
||||
g_hash_table_foreach_steal (monitor->watches, check_wayland_watch, &closure);
|
||||
|
||||
g_list_foreach (closure.fired_watches, fire_wayland_watch, NULL);
|
||||
g_list_free (closure.fired_watches);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_get_idletime (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
guint64 idletime;
|
||||
|
||||
idletime = meta_idle_monitor_get_idletime (monitor);
|
||||
meta_dbus_idle_monitor_complete_get_idletime (skeleton, invocation, idletime);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
MetaDBusIdleMonitor *dbus_monitor;
|
||||
MetaIdleMonitor *monitor;
|
||||
char *dbus_name;
|
||||
guint watch_id;
|
||||
guint name_watcher_id;
|
||||
} DBusWatch;
|
||||
|
||||
static void
|
||||
destroy_dbus_watch (gpointer data)
|
||||
{
|
||||
DBusWatch *watch = data;
|
||||
|
||||
g_object_unref (watch->dbus_monitor);
|
||||
g_object_unref (watch->monitor);
|
||||
g_free (watch->dbus_name);
|
||||
g_bus_unwatch_name (watch->name_watcher_id);
|
||||
|
||||
g_slice_free (DBusWatch, watch);
|
||||
}
|
||||
|
||||
static void
|
||||
dbus_idle_callback (MetaIdleMonitor *monitor,
|
||||
guint watch_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
DBusWatch *watch = user_data;
|
||||
GDBusInterfaceSkeleton *skeleton = G_DBUS_INTERFACE_SKELETON (watch->dbus_monitor);
|
||||
|
||||
g_dbus_connection_emit_signal (g_dbus_interface_skeleton_get_connection (skeleton),
|
||||
watch->dbus_name,
|
||||
g_dbus_interface_skeleton_get_object_path (skeleton),
|
||||
"org.gnome.Mutter.IdleMonitor",
|
||||
"WatchFired",
|
||||
g_variant_new ("(u)", watch_id),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
name_vanished_callback (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
DBusWatch *watch = user_data;
|
||||
|
||||
meta_idle_monitor_remove_watch (watch->monitor, watch->watch_id);
|
||||
}
|
||||
|
||||
static DBusWatch *
|
||||
make_dbus_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = g_slice_new (DBusWatch);
|
||||
watch->dbus_monitor = g_object_ref (skeleton);
|
||||
watch->monitor = g_object_ref (monitor);
|
||||
watch->dbus_name = g_strdup (g_dbus_method_invocation_get_sender (invocation));
|
||||
watch->name_watcher_id = g_bus_watch_name_on_connection (g_dbus_method_invocation_get_connection (invocation),
|
||||
watch->dbus_name,
|
||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||
NULL, /* appeared */
|
||||
name_vanished_callback,
|
||||
watch, NULL);
|
||||
|
||||
return watch;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_add_idle_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
guint64 interval,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = make_dbus_watch (skeleton, invocation, monitor);
|
||||
watch->watch_id = meta_idle_monitor_add_idle_watch (monitor, interval,
|
||||
dbus_idle_callback, watch, destroy_dbus_watch);
|
||||
|
||||
meta_dbus_idle_monitor_complete_add_idle_watch (skeleton, invocation, watch->watch_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_add_user_active_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
DBusWatch *watch;
|
||||
|
||||
watch = make_dbus_watch (skeleton, invocation, monitor);
|
||||
watch->watch_id = meta_idle_monitor_add_user_active_watch (monitor,
|
||||
dbus_idle_callback, watch,
|
||||
destroy_dbus_watch);
|
||||
|
||||
meta_dbus_idle_monitor_complete_add_user_active_watch (skeleton, invocation, watch->watch_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_remove_watch (MetaDBusIdleMonitor *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
guint id,
|
||||
MetaIdleMonitor *monitor)
|
||||
{
|
||||
meta_idle_monitor_remove_watch (monitor, id);
|
||||
meta_dbus_idle_monitor_complete_remove_watch (skeleton, invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
create_monitor_skeleton (GDBusObjectManagerServer *manager,
|
||||
MetaIdleMonitor *monitor,
|
||||
const char *path)
|
||||
{
|
||||
MetaDBusIdleMonitor *skeleton;
|
||||
MetaDBusObjectSkeleton *object;
|
||||
|
||||
skeleton = meta_dbus_idle_monitor_skeleton_new ();
|
||||
g_signal_connect_object (skeleton, "handle-add-idle-watch",
|
||||
G_CALLBACK (handle_add_idle_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-add-user-active-watch",
|
||||
G_CALLBACK (handle_add_user_active_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-remove-watch",
|
||||
G_CALLBACK (handle_remove_watch), monitor, 0);
|
||||
g_signal_connect_object (skeleton, "handle-get-idletime",
|
||||
G_CALLBACK (handle_get_idletime), monitor, 0);
|
||||
|
||||
object = meta_dbus_object_skeleton_new (path);
|
||||
meta_dbus_object_skeleton_set_idle_monitor (object, skeleton);
|
||||
|
||||
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_added (ClutterDeviceManager *device_manager,
|
||||
ClutterInputDevice *device,
|
||||
GDBusObjectManagerServer *manager)
|
||||
{
|
||||
|
||||
MetaIdleMonitor *monitor;
|
||||
int device_id;
|
||||
char *path;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
|
||||
|
||||
create_monitor_skeleton (manager, monitor, path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_removed (ClutterDeviceManager *device_manager,
|
||||
ClutterInputDevice *device,
|
||||
GDBusObjectManagerServer *manager)
|
||||
{
|
||||
int device_id;
|
||||
char *path;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
|
||||
g_dbus_object_manager_server_unexport (manager, path);
|
||||
g_free (path);
|
||||
|
||||
g_clear_object (&device_monitors[device_id]);
|
||||
if (device_id == device_id_max)
|
||||
device_id_max--;
|
||||
}
|
||||
|
||||
static void
|
||||
on_bus_acquired (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
GDBusObjectManagerServer *manager;
|
||||
ClutterDeviceManager *device_manager;
|
||||
MetaIdleMonitor *monitor;
|
||||
GSList *devices, *iter;
|
||||
char *path;
|
||||
|
||||
manager = g_dbus_object_manager_server_new ("/org/gnome/Mutter/IdleMonitor");
|
||||
|
||||
/* We never clear the core monitor, as that's supposed to cumulate idle times from
|
||||
all devices */
|
||||
monitor = meta_idle_monitor_get_core ();
|
||||
path = g_strdup ("/org/gnome/Mutter/IdleMonitor/Core");
|
||||
create_monitor_skeleton (manager, monitor, path);
|
||||
g_free (path);
|
||||
|
||||
device_manager = clutter_device_manager_get_default ();
|
||||
devices = clutter_device_manager_list_devices (device_manager);
|
||||
|
||||
for (iter = devices; iter; iter = iter->next)
|
||||
on_device_added (device_manager, iter->data, manager);
|
||||
|
||||
g_slist_free (devices);
|
||||
|
||||
g_signal_connect_object (device_manager, "device-added",
|
||||
G_CALLBACK (on_device_added), manager, 0);
|
||||
g_signal_connect_object (device_manager, "device-removed",
|
||||
G_CALLBACK (on_device_removed), manager, 0);
|
||||
|
||||
g_dbus_object_manager_server_set_connection (manager, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
on_name_acquired (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
meta_verbose ("Acquired name %s\n", name);
|
||||
}
|
||||
|
||||
static void
|
||||
on_name_lost (GDBusConnection *connection,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
meta_verbose ("Lost or failed to acquire name %s\n", name);
|
||||
}
|
||||
|
||||
void
|
||||
meta_idle_monitor_init_dbus (void)
|
||||
{
|
||||
static int dbus_name_id;
|
||||
|
||||
if (dbus_name_id > 0)
|
||||
return;
|
||||
|
||||
dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
||||
"org.gnome.Mutter.IdleMonitor",
|
||||
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
|
||||
(meta_get_replace_current_wm () ?
|
||||
G_BUS_NAME_OWNER_FLAGS_REPLACE : 0),
|
||||
on_bus_acquired,
|
||||
on_name_acquired,
|
||||
on_name_lost,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include "stack-tracker.h"
|
||||
#include "ui.h"
|
||||
#include "monitor-private.h"
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
typedef void (* MetaScreenWindowFunc) (MetaScreen *screen, MetaWindow *window,
|
||||
gpointer user_data);
|
||||
@ -116,9 +116,6 @@ struct _MetaScreen
|
||||
guint all_keys_grabbed : 1;
|
||||
|
||||
int closing;
|
||||
|
||||
/* Managed by compositor.c */
|
||||
gpointer compositor_data;
|
||||
|
||||
/* Instead of unmapping withdrawn windows we can leave them mapped
|
||||
* and restack them below a guard window. When using a compositor
|
||||
|
@ -560,7 +560,7 @@ meta_screen_new (MetaDisplay *display,
|
||||
}
|
||||
|
||||
/* We want to find out when the current selection owner dies */
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
attrs.event_mask = StructureNotifyMask;
|
||||
XChangeWindowAttributes (xdisplay,
|
||||
current_wm_sn_owner, CWEventMask, &attrs);
|
||||
@ -619,7 +619,7 @@ meta_screen_new (MetaDisplay *display,
|
||||
}
|
||||
|
||||
/* select our root window events */
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/* We need to or with the existing event mask since
|
||||
* gtk+ may be interested in other events.
|
||||
@ -707,7 +707,6 @@ meta_screen_new (MetaDisplay *display,
|
||||
screen->columns_of_workspaces = -1;
|
||||
screen->vertical_workspaces = FALSE;
|
||||
screen->starting_corner = META_SCREEN_TOPLEFT;
|
||||
screen->compositor_data = NULL;
|
||||
screen->guard_window = None;
|
||||
|
||||
reload_monitor_infos (screen);
|
||||
@ -758,8 +757,7 @@ meta_screen_new (MetaDisplay *display,
|
||||
screen->keys_grabbed = FALSE;
|
||||
meta_screen_grab_keys (screen);
|
||||
|
||||
screen->ui = meta_ui_new (screen->display->xdisplay,
|
||||
screen->xscreen);
|
||||
screen->ui = meta_ui_new ();
|
||||
|
||||
screen->tile_preview_timeout_id = 0;
|
||||
|
||||
@ -808,8 +806,7 @@ meta_screen_free (MetaScreen *screen,
|
||||
|
||||
meta_display_grab (display);
|
||||
|
||||
meta_compositor_unmanage_screen (screen->display->compositor,
|
||||
screen);
|
||||
meta_compositor_unmanage (screen->display->compositor);
|
||||
|
||||
meta_display_unmanage_windows_for_screen (display, screen, timestamp);
|
||||
|
||||
@ -840,7 +837,7 @@ meta_screen_free (MetaScreen *screen,
|
||||
meta_stack_free (screen->stack);
|
||||
meta_stack_tracker_free (screen->stack_tracker);
|
||||
|
||||
meta_error_trap_push_with_return (screen->display);
|
||||
meta_error_trap_push (screen->display);
|
||||
XSelectInput (screen->display->xdisplay, screen->xroot, 0);
|
||||
if (meta_error_trap_pop_with_return (screen->display) != Success)
|
||||
meta_warning ("Could not release screen %d on display \"%s\"\n",
|
||||
@ -900,28 +897,6 @@ meta_screen_manage_all_windows (MetaScreen *screen)
|
||||
meta_stack_thaw (screen->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_for_x_screen:
|
||||
* @xscreen: an X screen structure.
|
||||
*
|
||||
* Gets the #MetaScreen corresponding to an X screen structure.
|
||||
*
|
||||
* Return value: (transfer none): the #MetaScreen for the X screen
|
||||
* %NULL if Metacity is not managing the screen.
|
||||
*/
|
||||
MetaScreen*
|
||||
meta_screen_for_x_screen (Screen *xscreen)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
|
||||
display = meta_display_for_x_display (DisplayOfScreen (xscreen));
|
||||
|
||||
if (display == NULL)
|
||||
return NULL;
|
||||
|
||||
return meta_display_screen_for_x_screen (display, xscreen);
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_changed_callback (MetaPreference pref,
|
||||
gpointer data)
|
||||
@ -1405,6 +1380,26 @@ update_focus_mode (MetaScreen *screen)
|
||||
/* nothing to do anymore */ ;
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_update_cursor (MetaScreen *screen)
|
||||
{
|
||||
MetaDisplay *display = screen->display;
|
||||
MetaCursor cursor = screen->current_cursor;
|
||||
Cursor xcursor;
|
||||
MetaCursorReference *cursor_ref;
|
||||
|
||||
cursor_ref = meta_cursor_reference_from_theme (screen->cursor_tracker, cursor);
|
||||
meta_cursor_tracker_set_root_cursor (screen->cursor_tracker, cursor_ref);
|
||||
meta_cursor_reference_unref (cursor_ref);
|
||||
|
||||
/* Set a cursor for X11 applications that don't specify their own */
|
||||
xcursor = meta_display_create_x_cursor (display, cursor);
|
||||
|
||||
XDefineCursor (display->xdisplay, screen->xroot, xcursor);
|
||||
XFlush (display->xdisplay);
|
||||
XFreeCursor (display->xdisplay, xcursor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_set_cursor (MetaScreen *screen,
|
||||
MetaCursor cursor)
|
||||
@ -1413,14 +1408,7 @@ meta_screen_set_cursor (MetaScreen *screen,
|
||||
return;
|
||||
|
||||
screen->current_cursor = cursor;
|
||||
meta_cursor_tracker_set_root_cursor (screen->cursor_tracker, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_update_cursor (MetaScreen *screen)
|
||||
{
|
||||
meta_cursor_tracker_set_root_cursor (screen->cursor_tracker,
|
||||
screen->current_cursor);
|
||||
meta_screen_update_cursor (screen);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1461,11 +1449,10 @@ meta_screen_update_tile_preview_timeout (gpointer data)
|
||||
monitor = meta_window_get_current_tile_monitor_number (window);
|
||||
meta_window_get_current_tile_area (window, &tile_rect);
|
||||
meta_compositor_show_tile_preview (screen->display->compositor,
|
||||
screen, window, &tile_rect, monitor);
|
||||
window, &tile_rect, monitor);
|
||||
}
|
||||
else
|
||||
meta_compositor_hide_tile_preview (screen->display->compositor,
|
||||
screen);
|
||||
meta_compositor_hide_tile_preview (screen->display->compositor);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -1501,8 +1488,7 @@ meta_screen_hide_tile_preview (MetaScreen *screen)
|
||||
if (screen->tile_preview_timeout_id > 0)
|
||||
g_source_remove (screen->tile_preview_timeout_id);
|
||||
|
||||
meta_compositor_hide_tile_preview (screen->display->compositor,
|
||||
screen);
|
||||
meta_compositor_hide_tile_preview (screen->display->compositor);
|
||||
}
|
||||
|
||||
MetaWindow*
|
||||
@ -2520,7 +2506,6 @@ on_monitors_changed (MetaMonitorManager *manager,
|
||||
}
|
||||
|
||||
meta_compositor_sync_screen_size (screen->display->compositor,
|
||||
screen,
|
||||
screen->rect.width, screen->rect.height);
|
||||
|
||||
/* Queue a resize on all the windows */
|
||||
@ -3061,24 +3046,6 @@ meta_screen_get_size (MetaScreen *screen,
|
||||
*height = screen->rect.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_compositor_data: (skip)
|
||||
* @screen: A #MetaScreen
|
||||
*
|
||||
*/
|
||||
gpointer
|
||||
meta_screen_get_compositor_data (MetaScreen *screen)
|
||||
{
|
||||
return screen->compositor_data;
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_set_compositor_data (MetaScreen *screen,
|
||||
gpointer compositor)
|
||||
{
|
||||
screen->compositor_data = compositor;
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_set_cm_selection (MetaScreen *screen)
|
||||
{
|
||||
|
@ -1246,7 +1246,6 @@ meta_stack_tracker_sync_stack (MetaStackTracker *tracker)
|
||||
}
|
||||
|
||||
meta_compositor_sync_stack (tracker->screen->display->compositor,
|
||||
tracker->screen,
|
||||
meta_windows);
|
||||
g_list_free (meta_windows);
|
||||
|
||||
|
@ -220,10 +220,18 @@ struct _MetaWindow
|
||||
*/
|
||||
guint hidden : 1;
|
||||
|
||||
/* Whether the compositor thinks the window is visible
|
||||
/* Whether the compositor thinks the window is visible.
|
||||
* This should match up with calls to meta_compositor_show_window /
|
||||
* meta_compositor_hide_window.
|
||||
*/
|
||||
guint visible_to_compositor : 1;
|
||||
|
||||
/* Whether the compositor knows about the window.
|
||||
* This should match up with calls to meta_compositor_add_window /
|
||||
* meta_compositor_remove_window.
|
||||
*/
|
||||
guint known_to_compositor : 1;
|
||||
|
||||
/* When we next show or hide the window, what effect we should
|
||||
* tell the compositor to perform.
|
||||
*/
|
||||
|
@ -867,6 +867,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
window->iconic = FALSE;
|
||||
window->mapped = attrs->map_state != IsUnmapped;
|
||||
window->hidden = FALSE;
|
||||
window->known_to_compositor = FALSE;
|
||||
window->visible_to_compositor = FALSE;
|
||||
window->pending_compositor_effect = effect;
|
||||
/* if already mapped, no need to worry about focus-on-first-time-showing */
|
||||
@ -1195,6 +1196,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
}
|
||||
|
||||
meta_compositor_add_window (screen->display->compositor, window);
|
||||
window->known_to_compositor = TRUE;
|
||||
|
||||
/* Sync stack changes */
|
||||
meta_stack_thaw (window->screen->stack);
|
||||
@ -1248,7 +1250,7 @@ meta_window_wayland_new (MetaDisplay *display,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
XWindowAttributes attrs;
|
||||
MetaScreen *scr = display->screens->data;
|
||||
MetaScreen *scr = display->screen;
|
||||
MetaWindow *window;
|
||||
|
||||
attrs.x = 0;
|
||||
@ -1280,7 +1282,6 @@ meta_window_wayland_new (MetaDisplay *display,
|
||||
* X requests (passing a window xid of None) until we thoroughly audit all
|
||||
* the code to make sure it knows about non X based clients...
|
||||
*/
|
||||
|
||||
meta_error_trap_push (display); /* Push a trap over all of window
|
||||
* creation, to reduce XSync() calls
|
||||
*/
|
||||
@ -1467,13 +1468,17 @@ meta_window_unmanage (MetaWindow *window,
|
||||
/* This needs to happen for both Wayland and XWayland clients,
|
||||
* so it can't be in MetaWindowWayland. */
|
||||
if (window->surface)
|
||||
meta_wayland_surface_window_unmanaged (window->surface);
|
||||
meta_wayland_surface_set_window (window->surface, NULL);
|
||||
|
||||
if (window->visible_to_compositor)
|
||||
meta_compositor_hide_window (window->display->compositor, window,
|
||||
META_COMP_EFFECT_DESTROY);
|
||||
{
|
||||
window->visible_to_compositor = FALSE;
|
||||
meta_compositor_hide_window (window->display->compositor, window,
|
||||
META_COMP_EFFECT_DESTROY);
|
||||
}
|
||||
|
||||
meta_compositor_remove_window (window->display->compositor, window);
|
||||
window->known_to_compositor = FALSE;
|
||||
|
||||
if (window->display->window_with_menu == window)
|
||||
{
|
||||
@ -3948,7 +3953,7 @@ meta_window_create_sync_request_alarm (MetaWindow *window)
|
||||
window->sync_request_alarm != None)
|
||||
return;
|
||||
|
||||
meta_error_trap_push_with_return (window->display);
|
||||
meta_error_trap_push (window->display);
|
||||
|
||||
/* In the new (extended style), the counter value is initialized by
|
||||
* the client before mapping the window. In the old style, we're
|
||||
@ -4329,7 +4334,7 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
newx, newy, window->rect.width, window->rect.height,
|
||||
window->user_rect.x, window->user_rect.y,
|
||||
window->user_rect.width, window->user_rect.height);
|
||||
if (window->visible_to_compositor)
|
||||
if (window->known_to_compositor)
|
||||
meta_compositor_sync_window_geometry (window->display->compositor,
|
||||
window,
|
||||
did_placement);
|
||||
@ -8033,7 +8038,7 @@ warp_grab_pointer (MetaWindow *window,
|
||||
*x = CLAMP (*x, 0, window->screen->rect.width-1);
|
||||
*y = CLAMP (*y, 0, window->screen->rect.height-1);
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Warping pointer to %d,%d with window at %d,%d\n",
|
||||
|
@ -665,7 +665,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
|
||||
meta_screen_free_workspace_layout (&layout1);
|
||||
meta_screen_free_workspace_layout (&layout2);
|
||||
|
||||
meta_compositor_switch_workspace (comp, screen, old, workspace, direction);
|
||||
meta_compositor_switch_workspace (comp, old, workspace, direction);
|
||||
|
||||
/* This needs to be done after telling the compositor we are switching
|
||||
* workspaces since focusing a window will cause it to be immediately
|
||||
|
@ -81,6 +81,7 @@ item(ATOM_PAIR)
|
||||
item(BACKLIGHT)
|
||||
item(_XKB_RULES_NAMES)
|
||||
item(hotplug_mode_update)
|
||||
item(WL_SURFACE_ID)
|
||||
|
||||
/* Oddities: These are used, and we need atoms for them,
|
||||
* but when we need all _NET_WM hints (i.e. when we're making
|
||||
|
@ -57,10 +57,8 @@ typedef enum
|
||||
MetaCompositor *meta_compositor_new (MetaDisplay *display);
|
||||
void meta_compositor_destroy (MetaCompositor *compositor);
|
||||
|
||||
void meta_compositor_manage_screen (MetaCompositor *compositor,
|
||||
MetaScreen *screen);
|
||||
void meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||
MetaScreen *screen);
|
||||
void meta_compositor_manage (MetaCompositor *compositor);
|
||||
void meta_compositor_unmanage (MetaCompositor *compositor);
|
||||
|
||||
void meta_compositor_window_shape_changed (MetaCompositor *compositor,
|
||||
MetaWindow *window);
|
||||
@ -74,7 +72,6 @@ gboolean meta_compositor_process_event (MetaCompositor *compositor,
|
||||
MetaWindow *window);
|
||||
|
||||
gboolean meta_compositor_filter_keybinding (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaKeyBinding *binding);
|
||||
|
||||
void meta_compositor_add_window (MetaCompositor *compositor,
|
||||
@ -88,7 +85,6 @@ void meta_compositor_hide_window (MetaCompositor *compositor,
|
||||
MetaWindow *window,
|
||||
MetaCompEffect effect);
|
||||
void meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction);
|
||||
@ -113,10 +109,8 @@ void meta_compositor_queue_frame_drawn (MetaCompositor *compositor,
|
||||
gboolean no_delay_frame);
|
||||
|
||||
void meta_compositor_sync_stack (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
GList *stack);
|
||||
void meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
guint width,
|
||||
guint height);
|
||||
|
||||
@ -124,11 +118,9 @@ void meta_compositor_flash_screen (MetaCompositor *compositor,
|
||||
MetaScreen *screen);
|
||||
|
||||
void meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
MetaRectangle *tile_rect,
|
||||
int tile_monitor_number);
|
||||
void meta_compositor_hide_tile_preview (MetaCompositor *compositor,
|
||||
MetaScreen *screen);
|
||||
void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
|
||||
|
||||
#endif /* META_COMPOSITOR_H */
|
||||
|
@ -73,12 +73,9 @@ int meta_display_get_xinput_opcode (MetaDisplay *display);
|
||||
gboolean meta_display_supports_extended_barriers (MetaDisplay *display);
|
||||
Display *meta_display_get_xdisplay (MetaDisplay *display);
|
||||
MetaCompositor *meta_display_get_compositor (MetaDisplay *display);
|
||||
GSList *meta_display_get_screens (MetaDisplay *display);
|
||||
|
||||
gboolean meta_display_has_shape (MetaDisplay *display);
|
||||
|
||||
MetaScreen *meta_display_screen_for_root (MetaDisplay *display,
|
||||
Window xroot);
|
||||
MetaWindow *meta_display_get_focus_window (MetaDisplay *display);
|
||||
|
||||
gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
|
||||
@ -104,14 +101,12 @@ GList* meta_display_get_tab_list (MetaDisplay *display,
|
||||
|
||||
MetaWindow* meta_display_get_tab_next (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace,
|
||||
MetaWindow *window,
|
||||
gboolean backward);
|
||||
|
||||
MetaWindow* meta_display_get_tab_current (MetaDisplay *display,
|
||||
MetaTabList type,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *workspace);
|
||||
|
||||
gboolean meta_display_begin_grab_op (MetaDisplay *display,
|
||||
|
@ -30,7 +30,6 @@
|
||||
void meta_error_trap_push (MetaDisplay *display);
|
||||
void meta_error_trap_pop (MetaDisplay *display);
|
||||
|
||||
void meta_error_trap_push_with_return (MetaDisplay *display);
|
||||
/* returns X error code, or 0 for no error */
|
||||
int meta_error_trap_pop_with_return (MetaDisplay *display);
|
||||
|
||||
|
@ -28,7 +28,7 @@ GOptionContext *meta_get_option_context (void);
|
||||
void meta_init (void);
|
||||
int meta_run (void);
|
||||
void meta_register_with_session (void);
|
||||
gboolean meta_activate_session (void);
|
||||
gboolean meta_activate_session (void); /* Actually defined in meta-backend.c */
|
||||
gboolean meta_get_replace_current_wm (void); /* Actually defined in util.c */
|
||||
|
||||
void meta_set_wm_name (const char *wm_name);
|
||||
|
@ -91,7 +91,6 @@ void meta_background_load_gradient (MetaBackground *self,
|
||||
ClutterColor *second_color);
|
||||
void meta_background_load_color (MetaBackground *self,
|
||||
ClutterColor *color);
|
||||
void meta_background_load_still_frame (MetaBackground *self);
|
||||
void meta_background_load_file_async (MetaBackground *self,
|
||||
const char *filename,
|
||||
GDesktopBackgroundStyle style,
|
||||
|
@ -405,7 +405,7 @@ meta_plugin_end_modal (MetaPlugin *plugin,
|
||||
|
||||
MetaScreen *meta_plugin_get_screen (MetaPlugin *plugin);
|
||||
|
||||
void _meta_plugin_set_screen (MetaPlugin *plugin, MetaScreen *screen);
|
||||
void _meta_plugin_set_compositor (MetaPlugin *plugin, MetaCompositor *compositor);
|
||||
|
||||
/* XXX: Putting this in here so it's in the public header. */
|
||||
void meta_plugin_manager_set_plugin_type (GType gtype);
|
||||
|
@ -44,12 +44,6 @@ void meta_screen_get_size (MetaScreen *screen,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
gpointer meta_screen_get_compositor_data (MetaScreen *screen);
|
||||
void meta_screen_set_compositor_data (MetaScreen *screen,
|
||||
gpointer info);
|
||||
|
||||
MetaScreen *meta_screen_for_x_screen (Screen *xscreen);
|
||||
|
||||
void meta_screen_set_cm_selection (MetaScreen *screen);
|
||||
void meta_screen_unset_cm_selection (MetaScreen *screen);
|
||||
|
||||
|
299
src/ui/ui.c
299
src/ui/ui.c
@ -39,8 +39,9 @@ static void meta_ui_accelerator_parse (const char *accel,
|
||||
|
||||
struct _MetaUI
|
||||
{
|
||||
Display *xdisplay;
|
||||
Screen *xscreen;
|
||||
GdkDisplay *display;
|
||||
GdkScreen *screen;
|
||||
|
||||
MetaFrames *frames;
|
||||
|
||||
/* For double-click tracking */
|
||||
@ -60,241 +61,17 @@ meta_ui_init (void)
|
||||
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
||||
}
|
||||
|
||||
Display*
|
||||
meta_ui_get_display (void)
|
||||
{
|
||||
return GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||
}
|
||||
|
||||
gint
|
||||
meta_ui_get_screen_number (void)
|
||||
{
|
||||
return gdk_screen_get_number (gdk_screen_get_default ());
|
||||
}
|
||||
|
||||
/* For XInput2 */
|
||||
#include "display-private.h"
|
||||
|
||||
static gboolean
|
||||
is_input_event (XEvent *event)
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
|
||||
return (event->type == GenericEvent &&
|
||||
event->xcookie.extension == display->xinput_opcode);
|
||||
}
|
||||
|
||||
/* We do some of our event handling in frames.c, which expects
|
||||
* GDK events delivered by GTK+. However, since the transition to
|
||||
* client side windows, we can't let GDK see button events, since the
|
||||
* client-side tracking of implicit and explicit grabs it does will
|
||||
* get confused by our direct use of X grabs in the core code.
|
||||
*
|
||||
* So we do a very minimal GDK => GTK event conversion here and send on the
|
||||
* events we care about, and then filter them out so they don't go
|
||||
* through the normal GDK event handling.
|
||||
*
|
||||
* To reduce the amount of code, the only events fields filled out
|
||||
* below are the ones that frames.c uses. If frames.c is modified to
|
||||
* use more fields, more fields need to be filled out below.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
maybe_redirect_mouse_event (XEvent *xevent)
|
||||
{
|
||||
GdkDisplay *gdisplay;
|
||||
GdkDeviceManager *gmanager;
|
||||
GdkDevice *gdevice;
|
||||
MetaUI *ui;
|
||||
GdkEvent *gevent;
|
||||
GdkWindow *gdk_window;
|
||||
Window window;
|
||||
XIEvent *xev;
|
||||
XIDeviceEvent *xev_d = NULL;
|
||||
XIEnterEvent *xev_e = NULL;
|
||||
|
||||
if (!is_input_event (xevent))
|
||||
return FALSE;
|
||||
|
||||
xev = (XIEvent *) xevent->xcookie.data;
|
||||
|
||||
switch (xev->evtype)
|
||||
{
|
||||
case XI_ButtonPress:
|
||||
case XI_ButtonRelease:
|
||||
case XI_Motion:
|
||||
xev_d = (XIDeviceEvent *) xev;
|
||||
window = xev_d->event;
|
||||
break;
|
||||
case XI_Enter:
|
||||
case XI_Leave:
|
||||
xev_e = (XIEnterEvent *) xev;
|
||||
window = xev_e->event;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdisplay = gdk_x11_lookup_xdisplay (xev->display);
|
||||
ui = g_object_get_data (G_OBJECT (gdisplay), "meta-ui");
|
||||
if (!ui)
|
||||
return FALSE;
|
||||
|
||||
gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
|
||||
if (gdk_window == NULL)
|
||||
return FALSE;
|
||||
|
||||
gmanager = gdk_display_get_device_manager (gdisplay);
|
||||
gdevice = gdk_x11_device_manager_lookup (gmanager, META_VIRTUAL_CORE_POINTER_ID);
|
||||
|
||||
/* If GDK already thinks it has a grab, we better let it see events; this
|
||||
* is the menu-navigation case and events need to get sent to the appropriate
|
||||
* (client-side) subwindow for individual menu items.
|
||||
*/
|
||||
if (gdk_display_device_is_grabbed (gdisplay, gdevice))
|
||||
return FALSE;
|
||||
|
||||
switch (xev->evtype)
|
||||
{
|
||||
case XI_ButtonPress:
|
||||
case XI_ButtonRelease:
|
||||
if (xev_d->evtype == XI_ButtonPress)
|
||||
{
|
||||
GtkSettings *settings = gtk_settings_get_default ();
|
||||
int double_click_time;
|
||||
int double_click_distance;
|
||||
|
||||
g_object_get (settings,
|
||||
"gtk-double-click-time", &double_click_time,
|
||||
"gtk-double-click-distance", &double_click_distance,
|
||||
NULL);
|
||||
|
||||
if (xev_d->detail == ui->button_click_number &&
|
||||
xev_d->event == ui->button_click_window &&
|
||||
xev_d->time < ui->button_click_time + double_click_time &&
|
||||
ABS (xev_d->event_x - ui->button_click_x) <= double_click_distance &&
|
||||
ABS (xev_d->event_y - ui->button_click_y) <= double_click_distance)
|
||||
{
|
||||
gevent = gdk_event_new (GDK_2BUTTON_PRESS);
|
||||
|
||||
ui->button_click_number = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
gevent = gdk_event_new (GDK_BUTTON_PRESS);
|
||||
ui->button_click_number = xev_d->detail;
|
||||
ui->button_click_window = xev_d->event;
|
||||
ui->button_click_time = xev_d->time;
|
||||
ui->button_click_x = xev_d->event_x;
|
||||
ui->button_click_y = xev_d->event_y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gevent = gdk_event_new (GDK_BUTTON_RELEASE);
|
||||
}
|
||||
|
||||
gevent->button.window = g_object_ref (gdk_window);
|
||||
gevent->button.button = xev_d->detail;
|
||||
gevent->button.time = xev_d->time;
|
||||
gevent->button.x = xev_d->event_x;
|
||||
gevent->button.y = xev_d->event_y;
|
||||
gevent->button.x_root = xev_d->root_x;
|
||||
gevent->button.y_root = xev_d->root_y;
|
||||
|
||||
break;
|
||||
case XI_Motion:
|
||||
gevent = gdk_event_new (GDK_MOTION_NOTIFY);
|
||||
gevent->motion.type = GDK_MOTION_NOTIFY;
|
||||
gevent->motion.window = g_object_ref (gdk_window);
|
||||
break;
|
||||
case XI_Enter:
|
||||
case XI_Leave:
|
||||
gevent = gdk_event_new (xev_e->evtype == XI_Enter ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
|
||||
gevent->crossing.window = g_object_ref (gdk_window);
|
||||
gevent->crossing.x = xev_e->event_x;
|
||||
gevent->crossing.y = xev_e->event_y;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we've gotten here, we've created the gdk_event and should send it on */
|
||||
gdk_event_set_device (gevent, gdevice);
|
||||
gtk_main_do_event (gevent);
|
||||
gdk_event_free (gevent);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct _EventFunc EventFunc;
|
||||
|
||||
struct _EventFunc
|
||||
{
|
||||
MetaEventFunc func;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static EventFunc *ef = NULL;
|
||||
|
||||
static GdkFilterReturn
|
||||
filter_func (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (ef != NULL, GDK_FILTER_CONTINUE);
|
||||
|
||||
if ((* ef->func) (xevent, ef->data) ||
|
||||
maybe_redirect_mouse_event (xevent))
|
||||
return GDK_FILTER_REMOVE;
|
||||
else
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_add_event_func (Display *xdisplay,
|
||||
MetaEventFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (ef == NULL);
|
||||
|
||||
ef = g_new (EventFunc, 1);
|
||||
ef->func = func;
|
||||
ef->data = data;
|
||||
|
||||
gdk_window_add_filter (NULL, filter_func, ef);
|
||||
}
|
||||
|
||||
/* removal is by data due to proxy function */
|
||||
void
|
||||
meta_ui_remove_event_func (Display *xdisplay,
|
||||
MetaEventFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (ef != NULL);
|
||||
|
||||
gdk_window_remove_filter (NULL, filter_func, ef);
|
||||
|
||||
g_free (ef);
|
||||
ef = NULL;
|
||||
}
|
||||
|
||||
MetaUI*
|
||||
meta_ui_new (Display *xdisplay,
|
||||
Screen *screen)
|
||||
meta_ui_new (void)
|
||||
{
|
||||
GdkDisplay *gdisplay;
|
||||
MetaUI *ui;
|
||||
|
||||
ui = g_new0 (MetaUI, 1);
|
||||
ui->xdisplay = xdisplay;
|
||||
ui->xscreen = screen;
|
||||
ui->display = gdk_display_get_default ();
|
||||
ui->screen = gdk_screen_get_default ();
|
||||
|
||||
gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
g_assert (gdisplay == gdk_display_get_default ());
|
||||
ui->frames = meta_frames_new (gdk_screen_get_number (ui->screen));
|
||||
|
||||
ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
|
||||
/* GTK+ needs the frame-sync protocol to work in order to properly
|
||||
* handle style changes. This means that the dummy widget we create
|
||||
* to get the style for title bars actually needs to be mapped
|
||||
@ -303,21 +80,14 @@ meta_ui_new (Display *xdisplay,
|
||||
*/
|
||||
gtk_widget_show (GTK_WIDGET (ui->frames));
|
||||
|
||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_free (MetaUI *ui)
|
||||
{
|
||||
GdkDisplay *gdisplay;
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
||||
|
||||
gdisplay = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", NULL);
|
||||
|
||||
g_free (ui);
|
||||
}
|
||||
|
||||
@ -342,7 +112,6 @@ meta_ui_get_frame_borders (MetaUI *ui,
|
||||
|
||||
Window
|
||||
meta_ui_create_frame_window (MetaUI *ui,
|
||||
Display *xdisplay,
|
||||
Visual *xvisual,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -351,7 +120,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
||||
gint screen_no,
|
||||
gulong *create_serial)
|
||||
{
|
||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkScreen *screen = gdk_display_get_screen (display, screen_no);
|
||||
GdkWindowAttr attrs;
|
||||
gint attributes_mask;
|
||||
@ -400,7 +169,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
||||
* as long as you pass in a colormap.
|
||||
*/
|
||||
if (create_serial)
|
||||
*create_serial = XNextRequest (xdisplay);
|
||||
*create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (display));
|
||||
window =
|
||||
gdk_window_new (gdk_screen_get_root_window(screen),
|
||||
&attrs, attributes_mask);
|
||||
@ -434,10 +203,9 @@ void
|
||||
meta_ui_map_frame (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
@ -448,10 +216,9 @@ void
|
||||
meta_ui_unmap_frame (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
@ -669,13 +436,13 @@ meta_ui_get_default_mini_icon (MetaUI *ui)
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
Window xwindow)
|
||||
meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
display = ui->display;
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
/* we shouldn't cause focus if we're an override redirect
|
||||
@ -687,38 +454,6 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char*
|
||||
meta_text_property_to_utf8 (Display *xdisplay,
|
||||
const XTextProperty *prop)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
char **list;
|
||||
int count;
|
||||
char *retval;
|
||||
|
||||
list = NULL;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
count = gdk_text_property_to_utf8_list_for_display (display,
|
||||
gdk_x11_xatom_to_atom_for_display (display, prop->encoding),
|
||||
prop->format,
|
||||
prop->value,
|
||||
prop->nitems,
|
||||
&list);
|
||||
|
||||
if (count == 0)
|
||||
retval = NULL;
|
||||
else
|
||||
{
|
||||
retval = list[0];
|
||||
list[0] = g_strdup (""); /* something to free */
|
||||
}
|
||||
|
||||
g_strfreev (list);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
MetaFrameType type,
|
||||
@ -738,8 +473,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
|
||||
if (!font_desc)
|
||||
{
|
||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
|
||||
GdkScreen *screen = ui->screen;
|
||||
GtkWidgetPath *widget_path;
|
||||
|
||||
style = gtk_style_context_new ();
|
||||
@ -978,10 +712,9 @@ gboolean
|
||||
meta_ui_window_is_widget (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
|
22
src/ui/ui.h
22
src/ui/ui.h
@ -42,19 +42,7 @@ typedef enum
|
||||
|
||||
void meta_ui_init (void);
|
||||
|
||||
Display* meta_ui_get_display (void);
|
||||
|
||||
gint meta_ui_get_screen_number (void);
|
||||
|
||||
void meta_ui_add_event_func (Display *xdisplay,
|
||||
MetaEventFunc func,
|
||||
gpointer data);
|
||||
void meta_ui_remove_event_func (Display *xdisplay,
|
||||
MetaEventFunc func,
|
||||
gpointer data);
|
||||
|
||||
MetaUI* meta_ui_new (Display *xdisplay,
|
||||
Screen *screen);
|
||||
MetaUI* meta_ui_new (void);
|
||||
void meta_ui_free (MetaUI *ui);
|
||||
|
||||
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
@ -72,7 +60,6 @@ void meta_ui_get_frame_mask (MetaUI *ui,
|
||||
cairo_t *cr);
|
||||
|
||||
Window meta_ui_create_frame_window (MetaUI *ui,
|
||||
Display *xdisplay,
|
||||
Visual *xvisual,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -146,11 +133,8 @@ GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
|
||||
GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui);
|
||||
GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
|
||||
|
||||
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
Window xwindow);
|
||||
|
||||
char* meta_text_property_to_utf8 (Display *xdisplay,
|
||||
const XTextProperty *prop);
|
||||
gboolean meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||
Window xwindow);
|
||||
|
||||
void meta_ui_set_current_theme (const char *name);
|
||||
gboolean meta_ui_have_a_theme (void);
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <cairo.h>
|
||||
|
||||
#include "window-private.h"
|
||||
#include "meta-weston-launch.h"
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
|
||||
#include "meta-wayland.h"
|
||||
@ -85,8 +84,6 @@ struct _MetaWaylandCompositor
|
||||
|
||||
MetaXWaylandManager xwayland_manager;
|
||||
|
||||
MetaLauncher *launcher;
|
||||
|
||||
MetaWaylandSeat *seat;
|
||||
};
|
||||
|
||||
|
@ -68,20 +68,26 @@ set_cursor_surface (MetaWaylandSeat *seat,
|
||||
void
|
||||
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
||||
{
|
||||
struct wl_resource *buffer;
|
||||
MetaCursorReference *cursor;
|
||||
|
||||
if (seat->cursor_tracker == NULL)
|
||||
return;
|
||||
|
||||
if (seat->cursor_surface && seat->cursor_surface->buffer)
|
||||
buffer = seat->cursor_surface->buffer->resource;
|
||||
{
|
||||
struct wl_resource *buffer = seat->cursor_surface->buffer->resource;
|
||||
cursor = meta_cursor_reference_from_buffer (seat->cursor_tracker,
|
||||
buffer,
|
||||
seat->hotspot_x,
|
||||
seat->hotspot_y);
|
||||
}
|
||||
else
|
||||
buffer = NULL;
|
||||
cursor = NULL;
|
||||
|
||||
meta_cursor_tracker_set_window_cursor (seat->cursor_tracker,
|
||||
buffer,
|
||||
seat->hotspot_x,
|
||||
seat->hotspot_y);
|
||||
meta_cursor_tracker_set_window_cursor (seat->cursor_tracker, cursor);
|
||||
|
||||
if (cursor)
|
||||
meta_cursor_reference_unref (cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -109,8 +115,16 @@ pointer_set_cursor (struct wl_client *client,
|
||||
meta_wayland_seat_update_cursor_surface (seat);
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_release (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static const struct wl_pointer_interface pointer_interface = {
|
||||
pointer_set_cursor
|
||||
pointer_set_cursor,
|
||||
pointer_release,
|
||||
};
|
||||
|
||||
static void
|
||||
@ -131,6 +145,17 @@ seat_get_pointer (struct wl_client *client,
|
||||
meta_wayland_pointer_set_focus (&seat->pointer, seat->pointer.focus_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_release (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_interface keyboard_interface = {
|
||||
keyboard_release,
|
||||
};
|
||||
|
||||
static void
|
||||
seat_get_keyboard (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
|
@ -62,7 +62,7 @@ meta_wayland_stage_init (MetaWaylandStage *self)
|
||||
ClutterActor *
|
||||
meta_wayland_stage_new (void)
|
||||
{
|
||||
return g_object_new (META_WAYLAND_TYPE_STAGE,
|
||||
return g_object_new (META_TYPE_WAYLAND_STAGE,
|
||||
"cursor-visible", FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
@ -27,26 +27,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define META_WAYLAND_TYPE_STAGE \
|
||||
(meta_wayland_stage_get_type())
|
||||
#define META_WAYLAND_STAGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
META_WAYLAND_TYPE_STAGE, \
|
||||
MetaWaylandStage))
|
||||
#define META_WAYLAND_STAGE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
META_WAYLAND_TYPE_STAGE, \
|
||||
MetaWaylandStageClass))
|
||||
#define META_WAYLAND_IS_STAGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
META_WAYLAND_TYPE_STAGE))
|
||||
#define META_WAYLAND_IS_STAGE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
META_WAYLAND_TYPE_STAGE))
|
||||
#define META_WAYLAND_STAGE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
META_WAYLAND_STAGE, \
|
||||
MetaWaylandStageClass))
|
||||
#define META_TYPE_WAYLAND_STAGE (meta_wayland_stage_get_type ())
|
||||
#define META_WAYLAND_STAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WAYLAND_STAGE, MetaWaylandStage))
|
||||
#define META_WAYLAND_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_WAYLAND_STAGE, MetaWaylandStageClass))
|
||||
#define META_IS_WAYLAND_STAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_WAYLAND_STAGE))
|
||||
#define META_IS_WAYLAND_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_WAYLAND_STAGE))
|
||||
#define META_WAYLAND_STAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_WAYLAND_STAGE, MetaWaylandStageClass))
|
||||
|
||||
typedef struct _MetaWaylandStage MetaWaylandStage;
|
||||
typedef struct _MetaWaylandStageClass MetaWaylandStageClass;
|
||||
|
32
src/wayland/meta-wayland-surface-private.h
Normal file
32
src/wayland/meta-wayland-surface-private.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#ifndef META_WAYLAND_SURFACE_PRIVATE_H
|
||||
#define META_WAYLAND_SURFACE_PRIVATE_H
|
||||
|
||||
#include "meta-wayland-types.h"
|
||||
|
||||
void meta_wayland_surface_commit (MetaWaylandSurface *surface);
|
||||
|
||||
#endif /* META_WAYLAND_SURFACE_PRIVATE_H */
|
@ -48,6 +48,7 @@
|
||||
#include "meta-wayland-keyboard.h"
|
||||
#include "meta-wayland-pointer.h"
|
||||
#include "meta-wayland-data-device.h"
|
||||
#include "meta-wayland-surface-private.h"
|
||||
|
||||
#include "meta-cursor-tracker-private.h"
|
||||
#include "display-private.h"
|
||||
@ -55,8 +56,6 @@
|
||||
#include <meta/types.h>
|
||||
#include <meta/main.h>
|
||||
#include "frame.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "monitor-private.h"
|
||||
|
||||
#include "meta-surface-actor.h"
|
||||
#include "meta-surface-actor-wayland.h"
|
||||
@ -83,8 +82,8 @@ surface_set_buffer (MetaWaylandSurface *surface,
|
||||
|
||||
if (surface->buffer)
|
||||
{
|
||||
meta_wayland_buffer_unref (surface->buffer);
|
||||
wl_list_remove (&surface->buffer_destroy_listener.link);
|
||||
meta_wayland_buffer_unref (surface->buffer);
|
||||
}
|
||||
|
||||
surface->buffer = buffer;
|
||||
@ -119,132 +118,6 @@ surface_process_damage (MetaWaylandSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_destroy (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_attach (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *buffer_resource,
|
||||
gint32 dx, gint32 dy)
|
||||
{
|
||||
MetaWaylandSurface *surface =
|
||||
wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandBuffer *buffer;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
if (buffer_resource)
|
||||
buffer = meta_wayland_buffer_from_resource (buffer_resource);
|
||||
else
|
||||
buffer = NULL;
|
||||
|
||||
/* Attach without commit in between does not send wl_buffer.release */
|
||||
if (surface->pending.buffer)
|
||||
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
|
||||
|
||||
surface->pending.dx = dx;
|
||||
surface->pending.dy = dy;
|
||||
surface->pending.buffer = buffer;
|
||||
surface->pending.newly_attached = TRUE;
|
||||
|
||||
if (buffer)
|
||||
wl_signal_add (&buffer->destroy_signal,
|
||||
&surface->pending.buffer_destroy_listener);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_damage (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
gint32 x,
|
||||
gint32 y,
|
||||
gint32 width,
|
||||
gint32 height)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
cairo_rectangle_int_t rectangle = { x, y, width, height };
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
cairo_region_union_rectangle (surface->pending.damage, &rectangle);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_frame_callback (struct wl_resource *callback_resource)
|
||||
{
|
||||
MetaWaylandFrameCallback *callback =
|
||||
wl_resource_get_user_data (callback_resource);
|
||||
|
||||
wl_list_remove (&callback->link);
|
||||
g_slice_free (MetaWaylandFrameCallback, callback);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_frame (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
guint32 callback_id)
|
||||
{
|
||||
MetaWaylandFrameCallback *callback;
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
callback = g_slice_new0 (MetaWaylandFrameCallback);
|
||||
callback->compositor = surface->compositor;
|
||||
callback->resource = wl_resource_create (client, &wl_callback_interface, META_WL_CALLBACK_VERSION, callback_id);
|
||||
wl_resource_set_implementation (callback->resource, NULL, callback, destroy_frame_callback);
|
||||
|
||||
wl_list_insert (surface->pending.frame_callback_list.prev, &callback->link);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_set_opaque_region (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
surface->pending.opaque_region = cairo_region_copy (region->region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_set_input_region (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
surface->pending.input_region = cairo_region_copy (region->region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
empty_region (cairo_region_t *region)
|
||||
{
|
||||
@ -272,22 +145,37 @@ ensure_buffer_texture (MetaWaylandBuffer *buffer)
|
||||
buffer->texture = texture;
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_surface_commit (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending,
|
||||
gboolean buffer_changed)
|
||||
static gboolean
|
||||
commit_attached_surface (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
if (buffer_changed)
|
||||
meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
|
||||
/* wl_surface.attach */
|
||||
if (pending->newly_attached && surface->buffer != pending->buffer)
|
||||
{
|
||||
surface_set_buffer (surface, pending->buffer);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_surface_commit (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
if (commit_attached_surface (surface, pending))
|
||||
meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
actor_surface_commit (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending,
|
||||
gboolean buffer_changed)
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
||||
MetaWaylandBuffer *buffer = pending->buffer;
|
||||
gboolean buffer_changed;
|
||||
|
||||
buffer_changed = commit_attached_surface (surface, pending);
|
||||
|
||||
if (buffer_changed && buffer)
|
||||
{
|
||||
@ -301,16 +189,15 @@ actor_surface_commit (MetaWaylandSurface *surface,
|
||||
meta_surface_actor_set_opaque_region (surface_actor, pending->opaque_region);
|
||||
if (pending->input_region)
|
||||
meta_surface_actor_set_input_region (surface_actor, pending->input_region);
|
||||
|
||||
return buffer_changed;
|
||||
}
|
||||
|
||||
static void
|
||||
toplevel_surface_commit (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending,
|
||||
gboolean buffer_changed)
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
actor_surface_commit (surface, pending, buffer_changed);
|
||||
|
||||
if (buffer_changed)
|
||||
if (actor_surface_commit (surface, pending))
|
||||
{
|
||||
MetaWindow *window = surface->window;
|
||||
MetaWaylandBuffer *buffer = pending->buffer;
|
||||
@ -419,8 +306,7 @@ move_double_buffered_state (MetaWaylandDoubleBufferedState *from,
|
||||
|
||||
static void
|
||||
subsurface_surface_commit (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending,
|
||||
gboolean buffer_changed)
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
/*
|
||||
* If the sub-surface is in synchronous mode, post-pone the commit of its
|
||||
@ -440,9 +326,7 @@ subsurface_surface_commit (MetaWaylandSurface *surface,
|
||||
}
|
||||
else
|
||||
{
|
||||
actor_surface_commit (surface, pending, buffer_changed);
|
||||
|
||||
if (buffer_changed)
|
||||
if (actor_surface_commit (surface, pending))
|
||||
{
|
||||
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
||||
MetaWaylandBuffer *buffer = pending->buffer;
|
||||
@ -475,21 +359,21 @@ commit_double_buffered_state (MetaWaylandSurface *surface,
|
||||
MetaWaylandDoubleBufferedState *pending)
|
||||
{
|
||||
MetaWaylandCompositor *compositor = surface->compositor;
|
||||
gboolean buffer_changed = FALSE;
|
||||
|
||||
/* wl_surface.attach */
|
||||
if (pending->newly_attached && surface->buffer != pending->buffer)
|
||||
{
|
||||
surface_set_buffer (surface, pending->buffer);
|
||||
buffer_changed = TRUE;
|
||||
}
|
||||
|
||||
if (surface == compositor->seat->cursor_surface)
|
||||
cursor_surface_commit (surface, pending, buffer_changed);
|
||||
cursor_surface_commit (surface, pending);
|
||||
else if (surface->window)
|
||||
toplevel_surface_commit (surface, pending, buffer_changed);
|
||||
toplevel_surface_commit (surface, pending);
|
||||
else if (surface->subsurface.resource)
|
||||
subsurface_surface_commit (surface, pending, buffer_changed);
|
||||
subsurface_surface_commit (surface, pending);
|
||||
else
|
||||
{
|
||||
/* Unknown surface type. In this case, it's most likely a XWayland
|
||||
* surface that we haven't gotten the ClientMessage for yet. Make
|
||||
* sure *not* to reset the double-buffered state or do anything too
|
||||
* fancy. */
|
||||
return;
|
||||
}
|
||||
|
||||
g_list_foreach (surface->subsurfaces,
|
||||
parent_surface_committed,
|
||||
@ -508,9 +392,141 @@ commit_double_buffered_state (MetaWaylandSurface *surface,
|
||||
double_buffered_state_reset (pending);
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_surface_commit (MetaWaylandSurface *surface)
|
||||
{
|
||||
commit_double_buffered_state (surface, &surface->pending);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_commit (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
wl_surface_destroy (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_attach (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *buffer_resource,
|
||||
gint32 dx, gint32 dy)
|
||||
{
|
||||
MetaWaylandSurface *surface =
|
||||
wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandBuffer *buffer;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
if (buffer_resource)
|
||||
buffer = meta_wayland_buffer_from_resource (buffer_resource);
|
||||
else
|
||||
buffer = NULL;
|
||||
|
||||
/* Attach without commit in between does not send wl_buffer.release */
|
||||
if (surface->pending.buffer)
|
||||
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
|
||||
|
||||
surface->pending.dx = dx;
|
||||
surface->pending.dy = dy;
|
||||
surface->pending.buffer = buffer;
|
||||
surface->pending.newly_attached = TRUE;
|
||||
|
||||
if (buffer)
|
||||
wl_signal_add (&buffer->destroy_signal,
|
||||
&surface->pending.buffer_destroy_listener);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_damage (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
gint32 x,
|
||||
gint32 y,
|
||||
gint32 width,
|
||||
gint32 height)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
cairo_rectangle_int_t rectangle = { x, y, width, height };
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
cairo_region_union_rectangle (surface->pending.damage, &rectangle);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_frame_callback (struct wl_resource *callback_resource)
|
||||
{
|
||||
MetaWaylandFrameCallback *callback =
|
||||
wl_resource_get_user_data (callback_resource);
|
||||
|
||||
wl_list_remove (&callback->link);
|
||||
g_slice_free (MetaWaylandFrameCallback, callback);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_frame (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
guint32 callback_id)
|
||||
{
|
||||
MetaWaylandFrameCallback *callback;
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
callback = g_slice_new0 (MetaWaylandFrameCallback);
|
||||
callback->compositor = surface->compositor;
|
||||
callback->resource = wl_resource_create (client, &wl_callback_interface, META_WL_CALLBACK_VERSION, callback_id);
|
||||
wl_resource_set_implementation (callback->resource, NULL, callback, destroy_frame_callback);
|
||||
|
||||
wl_list_insert (surface->pending.frame_callback_list.prev, &callback->link);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_set_opaque_region (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
surface->pending.opaque_region = cairo_region_copy (region->region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_set_input_region (struct wl_client *client,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
surface->pending.input_region = cairo_region_copy (region->region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wl_surface_commit (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
||||
|
||||
@ -518,49 +534,46 @@ meta_wayland_surface_commit (struct wl_client *client,
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
commit_double_buffered_state (surface, &surface->pending);
|
||||
meta_wayland_surface_commit (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_set_buffer_transform (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t transform)
|
||||
wl_surface_set_buffer_transform (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t transform)
|
||||
{
|
||||
g_warning ("TODO: support set_buffer_transform request");
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_set_buffer_scale (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int scale)
|
||||
wl_surface_set_buffer_scale (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int scale)
|
||||
{
|
||||
if (scale != 1)
|
||||
g_warning ("TODO: support set_buffer_scale request");
|
||||
}
|
||||
|
||||
const struct wl_surface_interface meta_wayland_surface_interface = {
|
||||
meta_wayland_surface_destroy,
|
||||
meta_wayland_surface_attach,
|
||||
meta_wayland_surface_damage,
|
||||
meta_wayland_surface_frame,
|
||||
meta_wayland_surface_set_opaque_region,
|
||||
meta_wayland_surface_set_input_region,
|
||||
meta_wayland_surface_commit,
|
||||
meta_wayland_surface_set_buffer_transform,
|
||||
meta_wayland_surface_set_buffer_scale
|
||||
const struct wl_surface_interface meta_wayland_wl_surface_interface = {
|
||||
wl_surface_destroy,
|
||||
wl_surface_attach,
|
||||
wl_surface_damage,
|
||||
wl_surface_frame,
|
||||
wl_surface_set_opaque_region,
|
||||
wl_surface_set_input_region,
|
||||
wl_surface_commit,
|
||||
wl_surface_set_buffer_transform,
|
||||
wl_surface_set_buffer_scale
|
||||
};
|
||||
|
||||
void
|
||||
meta_wayland_surface_make_toplevel (MetaWaylandSurface *surface)
|
||||
meta_wayland_surface_set_window (MetaWaylandSurface *surface,
|
||||
MetaWindow *window)
|
||||
{
|
||||
clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), TRUE);
|
||||
}
|
||||
gboolean has_window = (window != NULL);
|
||||
|
||||
void
|
||||
meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface)
|
||||
{
|
||||
clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), FALSE);
|
||||
surface->window = NULL;
|
||||
clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), has_window);
|
||||
surface->window = window;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -614,7 +627,7 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
||||
surface->compositor = compositor;
|
||||
|
||||
surface->resource = wl_resource_create (client, &wl_surface_interface, version, id);
|
||||
wl_resource_set_implementation (surface->resource, &meta_wayland_surface_interface, surface, wl_surface_destructor);
|
||||
wl_resource_set_implementation (surface->resource, &meta_wayland_wl_surface_interface, surface, wl_surface_destructor);
|
||||
|
||||
surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
|
||||
surface->surface_actor = g_object_ref_sink (meta_surface_actor_wayland_new (surface));
|
||||
@ -911,6 +924,7 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
|
||||
struct wl_resource *surface_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWindow *window;
|
||||
|
||||
if (!create_surface_extension (&surface->xdg_surface,
|
||||
META_XDG_SURFACE_VERSION,
|
||||
@ -925,8 +939,8 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
meta_wayland_surface_make_toplevel (surface);
|
||||
surface->window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
meta_wayland_surface_set_window (surface, window);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -964,6 +978,7 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
|
||||
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
||||
MetaWindow *window;
|
||||
|
||||
if (parent_surf == NULL || parent_surf->window == NULL)
|
||||
return;
|
||||
@ -981,15 +996,15 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
meta_wayland_surface_make_toplevel (surface);
|
||||
surface->window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
surface->window->rect.x = parent_surf->window->rect.x + x;
|
||||
surface->window->rect.y = parent_surf->window->rect.y + y;
|
||||
surface->window->showing_for_first_time = FALSE;
|
||||
surface->window->placed = TRUE;
|
||||
meta_window_set_transient_for (surface->window, parent_surf->window);
|
||||
window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
window->rect.x = parent_surf->window->rect.x + x;
|
||||
window->rect.y = parent_surf->window->rect.y + y;
|
||||
window->showing_for_first_time = FALSE;
|
||||
window->placed = TRUE;
|
||||
meta_window_set_transient_for (window, parent_surf->window);
|
||||
meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
|
||||
|
||||
meta_window_set_type (surface->window, META_WINDOW_DROPDOWN_MENU);
|
||||
meta_wayland_surface_set_window (surface, window);
|
||||
|
||||
meta_wayland_pointer_start_popup_grab (&seat->pointer, surface);
|
||||
}
|
||||
@ -1272,6 +1287,7 @@ wl_shell_get_shell_surface (struct wl_client *client,
|
||||
struct wl_resource *surface_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWindow *window;
|
||||
|
||||
if (!create_surface_extension (&surface->wl_shell_surface,
|
||||
META_WL_SHELL_SURFACE_VERSION,
|
||||
@ -1286,8 +1302,8 @@ wl_shell_get_shell_surface (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
meta_wayland_surface_make_toplevel (surface);
|
||||
surface->window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
window = meta_window_wayland_new (meta_get_display (), surface);
|
||||
meta_wayland_surface_set_window (surface, window);
|
||||
}
|
||||
|
||||
static const struct wl_shell_interface meta_wayland_wl_shell_interface = {
|
||||
|
@ -111,8 +111,8 @@ MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *composit
|
||||
guint32 id,
|
||||
guint32 version);
|
||||
|
||||
void meta_wayland_surface_make_toplevel (MetaWaylandSurface *surface);
|
||||
void meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface);
|
||||
void meta_wayland_surface_set_window (MetaWaylandSurface *surface,
|
||||
MetaWindow *window);
|
||||
|
||||
void meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
|
||||
int width,
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define META_WL_COMPOSITOR_VERSION 3
|
||||
#define META_WL_DATA_DEVICE_MANAGER_VERSION 1
|
||||
#define META_WL_SHELL_VERSION 1
|
||||
#define META_WL_SEAT_VERSION 2 /* 3 not implemented yet */
|
||||
#define META_WL_SEAT_VERSION 3
|
||||
#define META_WL_OUTPUT_VERSION 2
|
||||
#define META_XSERVER_VERSION 1
|
||||
#define META_GTK_SHELL_VERSION 1
|
||||
@ -49,8 +49,8 @@
|
||||
#define META_WL_DATA_SOURCE_VERSION 1 /* from wl_data_device */
|
||||
#define META_WL_DATA_DEVICE_VERSION 1 /* from wl_data_device_manager */
|
||||
#define META_WL_SURFACE_VERSION 3 /* from wl_compositor */
|
||||
#define META_WL_POINTER_VERSION 2 /* from wl_seat; 3 not implemented yet */
|
||||
#define META_WL_KEYBOARD_VERSION 2 /* from wl_seat; 3 not implemented yet */
|
||||
#define META_WL_POINTER_VERSION 3 /* from wl_seat */
|
||||
#define META_WL_KEYBOARD_VERSION 3 /* from wl_seat */
|
||||
#define META_WL_TOUCH_VERSION 0 /* from wl_seat; wl_touch not supported */
|
||||
#define META_WL_REGION_VERSION 1 /* from wl_compositor */
|
||||
#define META_XDG_SURFACE_VERSION 1 /* from xdg_shell */
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "backends/meta-backend.h"
|
||||
|
||||
#include "meta-wayland-private.h"
|
||||
#include "meta-xwayland-private.h"
|
||||
#include "meta-wayland-stage.h"
|
||||
@ -51,9 +53,7 @@
|
||||
#include <meta/types.h>
|
||||
#include <meta/main.h>
|
||||
#include "frame.h"
|
||||
#include "meta-idle-monitor-private.h"
|
||||
#include "meta-weston-launch.h"
|
||||
#include "monitor-private.h"
|
||||
#include "meta-monitor-manager.h"
|
||||
|
||||
static MetaWaylandCompositor _meta_wayland_compositor;
|
||||
|
||||
@ -520,30 +520,6 @@ void
|
||||
meta_wayland_compositor_update (MetaWaylandCompositor *compositor,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
ClutterInputDevice *device, *source_device;
|
||||
MetaIdleMonitor *core_monitor, *device_monitor;
|
||||
int device_id;
|
||||
|
||||
device = clutter_event_get_device (event);
|
||||
if (device == NULL)
|
||||
return;
|
||||
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
|
||||
core_monitor = meta_idle_monitor_get_core ();
|
||||
device_monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
|
||||
meta_idle_monitor_reset_idletime (core_monitor);
|
||||
meta_idle_monitor_reset_idletime (device_monitor);
|
||||
|
||||
source_device = clutter_event_get_source_device (event);
|
||||
if (source_device != device)
|
||||
{
|
||||
device_id = clutter_input_device_get_device_id (device);
|
||||
device_monitor = meta_idle_monitor_get_for_device (device_id);
|
||||
meta_idle_monitor_reset_idletime (device_monitor);
|
||||
}
|
||||
|
||||
meta_wayland_seat_update (compositor->seat, event);
|
||||
}
|
||||
|
||||
@ -575,14 +551,13 @@ set_gnome_env (const char *name,
|
||||
const char *value)
|
||||
{
|
||||
GDBusConnection *session_bus;
|
||||
GError *error;
|
||||
GError *error = NULL;
|
||||
|
||||
setenv (name, value, TRUE);
|
||||
|
||||
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
||||
g_assert (session_bus);
|
||||
|
||||
error = NULL;
|
||||
g_dbus_connection_call_sync (session_bus,
|
||||
"org.gnome.SessionManager",
|
||||
"/org/gnome/SessionManager",
|
||||
@ -594,8 +569,10 @@ set_gnome_env (const char *name,
|
||||
-1, NULL, &error);
|
||||
if (error)
|
||||
{
|
||||
meta_warning ("Failed to set environment variable %s for gnome-session: %s\n", name, error->message);
|
||||
g_clear_error (&error);
|
||||
if (g_strcmp0 (g_dbus_error_get_remote_error (error), "org.gnome.SessionManager.NotInInitialization") != 0)
|
||||
meta_warning ("Failed to set environment variable %s for gnome-session: %s\n", name, error->message);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -651,15 +628,7 @@ meta_wayland_init (void)
|
||||
|
||||
clutter_wayland_set_compositor_display (compositor->wayland_display);
|
||||
|
||||
/* If we're running on bare metal, we're a display server,
|
||||
* so start talking to weston-launch. */
|
||||
#if defined(CLUTTER_WINDOWING_EGL)
|
||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL))
|
||||
compositor->launcher = meta_launcher_new ();
|
||||
#endif
|
||||
|
||||
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
|
||||
g_error ("Failed to initialize Clutter");
|
||||
meta_clutter_init ();
|
||||
|
||||
meta_monitor_manager_initialize ();
|
||||
monitors = meta_monitor_manager_get ();
|
||||
@ -711,38 +680,4 @@ meta_wayland_finalize (void)
|
||||
compositor = meta_wayland_compositor_get_default ();
|
||||
|
||||
meta_xwayland_stop (&compositor->xwayland_manager);
|
||||
|
||||
if (compositor->launcher)
|
||||
meta_launcher_free (compositor->launcher);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
|
||||
int vt,
|
||||
GError **error)
|
||||
{
|
||||
if (compositor->launcher)
|
||||
{
|
||||
return meta_launcher_activate_vt (compositor->launcher, vt, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Ignoring VT switch keybinding, not running as display server");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor,
|
||||
GError **error)
|
||||
{
|
||||
if (compositor->launcher)
|
||||
{
|
||||
return meta_launcher_activate_vt (compositor->launcher, -1, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Ignoring activate_session, not running as display server");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,5 @@ void meta_wayland_compositor_update (MetaWaylandComp
|
||||
const ClutterEvent *event);
|
||||
void meta_wayland_compositor_paint_finished (MetaWaylandCompositor *compositor);
|
||||
|
||||
gboolean meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
|
||||
int vt,
|
||||
GError **error);
|
||||
gboolean meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor,
|
||||
GError **error);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* X Wayland Support
|
||||
*
|
||||
@ -19,33 +21,29 @@
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-xwayland.h"
|
||||
#include "meta-xwayland-private.h"
|
||||
|
||||
#include "meta-wayland-surface-private.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-unix.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "meta-xwayland-private.h"
|
||||
#include "meta-window-actor-private.h"
|
||||
#include "xserver-server-protocol.h"
|
||||
|
||||
static void
|
||||
xserver_set_window_id (struct wl_client *client,
|
||||
struct wl_resource *compositor_resource,
|
||||
struct wl_resource *surface_resource,
|
||||
guint32 xid)
|
||||
associate_window_with_surface (MetaWindow *window,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWindow *window;
|
||||
|
||||
window = meta_display_lookup_x_window (display, xid);
|
||||
if (!window)
|
||||
return;
|
||||
MetaDisplay *display = window->display;
|
||||
|
||||
/* If the window has an existing surface, like if we're
|
||||
* undecorating or decorating the window, then we need
|
||||
@ -54,51 +52,75 @@ xserver_set_window_id (struct wl_client *client,
|
||||
if (window->surface)
|
||||
window->surface->window = NULL;
|
||||
|
||||
meta_wayland_surface_make_toplevel (surface);
|
||||
|
||||
surface->window = window;
|
||||
meta_wayland_surface_set_window (surface, window);
|
||||
window->surface = surface;
|
||||
|
||||
meta_compositor_window_surface_changed (display->compositor, window);
|
||||
|
||||
/* Since the association comes in the form of a ClientMessage,
|
||||
* we have no way to know when the surface was set up. Since
|
||||
* commit just breaks if we don't have a window associated with
|
||||
* it, we need to do a commit *again* here. */
|
||||
meta_wayland_surface_commit (surface);
|
||||
}
|
||||
|
||||
static const struct xserver_interface xserver_implementation = {
|
||||
xserver_set_window_id
|
||||
};
|
||||
|
||||
static void
|
||||
bind_xserver (struct wl_client *client,
|
||||
void *data,
|
||||
guint32 version,
|
||||
guint32 id)
|
||||
static gboolean
|
||||
associate_window_with_surface_id (MetaXWaylandManager *manager,
|
||||
MetaWindow *window,
|
||||
guint32 surface_id)
|
||||
{
|
||||
MetaXWaylandManager *manager = data;
|
||||
struct wl_resource *resource;
|
||||
|
||||
/* If it's a different client than the xserver we launched,
|
||||
* just freeze up... */
|
||||
if (client != manager->client)
|
||||
return;
|
||||
resource = wl_client_get_object (manager->client, surface_id);
|
||||
if (resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
||||
associate_window_with_surface (window, surface);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
manager->xserver_resource = wl_resource_create (client, &xserver_interface,
|
||||
MIN (META_XSERVER_VERSION, version), id);
|
||||
wl_resource_set_implementation (manager->xserver_resource,
|
||||
&xserver_implementation, manager, NULL);
|
||||
typedef struct {
|
||||
MetaXWaylandManager *manager;
|
||||
MetaWindow *window;
|
||||
guint32 surface_id;
|
||||
} AssociateWindowWithSurfaceOp;
|
||||
|
||||
xserver_send_listen_socket (manager->xserver_resource, manager->abstract_fd);
|
||||
xserver_send_listen_socket (manager->xserver_resource, manager->unix_fd);
|
||||
static gboolean
|
||||
associate_window_with_surface_idle (gpointer user_data)
|
||||
{
|
||||
AssociateWindowWithSurfaceOp *op = user_data;
|
||||
if (!associate_window_with_surface_id (op->manager, op->window, op->surface_id))
|
||||
{
|
||||
/* Not here? Oh well... nothing we can do */
|
||||
g_warning ("Unknown surface ID %d (from window %s)", op->surface_id, op->window->desc);
|
||||
}
|
||||
g_free (op);
|
||||
|
||||
/* Make sure xwayland will recieve the above sockets in a finite
|
||||
* time before unblocking the initialization mainloop since we are
|
||||
* then going to immediately try and connect to those as the window
|
||||
* manager. */
|
||||
wl_client_flush (client);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
/* At this point xwayland is all setup to start accepting
|
||||
* connections so we can quit the transient initialization mainloop
|
||||
* and unblock meta_wayland_init() to continue initializing mutter.
|
||||
* */
|
||||
g_main_loop_quit (manager->init_loop);
|
||||
g_clear_pointer (&manager->init_loop, g_main_loop_unref);
|
||||
void
|
||||
meta_xwayland_handle_wl_surface_id (MetaWindow *window,
|
||||
guint32 surface_id)
|
||||
{
|
||||
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
||||
MetaXWaylandManager *manager = &compositor->xwayland_manager;
|
||||
|
||||
if (!associate_window_with_surface_id (manager, window, surface_id))
|
||||
{
|
||||
/* No surface ID yet... it should arrive after the next
|
||||
* iteration through the loop, so queue an idle and see
|
||||
* what happens.
|
||||
*/
|
||||
AssociateWindowWithSurfaceOp *op = g_new0 (AssociateWindowWithSurfaceOp, 1);
|
||||
op->manager = manager;
|
||||
op->window = window;
|
||||
op->surface_id = surface_id;
|
||||
g_idle_add (associate_window_with_surface_idle, op);
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -145,7 +167,6 @@ create_lockfile (int display, int *display_out)
|
||||
|
||||
if (kill (other, 0) < 0 && errno == ESRCH)
|
||||
{
|
||||
g_warning ("unlinking stale lock file %s", filename);
|
||||
if (unlink (filename) < 0)
|
||||
{
|
||||
const char *msg = strerror (errno);
|
||||
@ -207,8 +228,7 @@ bind_to_abstract_socket (int display)
|
||||
size = offsetof (struct sockaddr_un, sun_path) + name_size;
|
||||
if (bind (fd, (struct sockaddr *) &addr, size) < 0)
|
||||
{
|
||||
g_warning ("failed to bind to @%s: %s\n",
|
||||
addr.sun_path + 1, strerror (errno));
|
||||
g_warning ("failed to bind to @%s: %m", addr.sun_path + 1);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
@ -240,8 +260,7 @@ bind_to_unix_socket (int display)
|
||||
unlink (addr.sun_path);
|
||||
if (bind (fd, (struct sockaddr *) &addr, size) < 0)
|
||||
{
|
||||
char *msg = strerror (errno);
|
||||
g_warning ("failed to bind to %s (%s)\n", addr.sun_path, msg);
|
||||
g_warning ("failed to bind to %s: %m\n", addr.sun_path);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
@ -256,18 +275,6 @@ bind_to_unix_socket (int display)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void
|
||||
uncloexec (gpointer user_data)
|
||||
{
|
||||
int fd = GPOINTER_TO_INT (user_data);
|
||||
|
||||
/* Make sure the client end of the socket pair doesn't get closed
|
||||
* when we exec xwayland. */
|
||||
int flags = fcntl (fd, F_GETFD);
|
||||
if (flags != -1)
|
||||
fcntl (fd, F_SETFD, flags & ~FD_CLOEXEC);
|
||||
}
|
||||
|
||||
static void
|
||||
xserver_died (GPid pid,
|
||||
gint status,
|
||||
@ -293,20 +300,11 @@ x_io_error (Display *display)
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_xwayland_start (MetaXWaylandManager *manager,
|
||||
struct wl_display *wl_display)
|
||||
static gboolean
|
||||
choose_xdisplay (MetaXWaylandManager *manager)
|
||||
{
|
||||
int display = 0;
|
||||
char *lockfile = NULL;
|
||||
int sp[2];
|
||||
pid_t pid;
|
||||
char **env;
|
||||
char *fd_string;
|
||||
|
||||
wl_global_create (wl_display, &xserver_interface,
|
||||
META_XSERVER_VERSION,
|
||||
manager, bind_xserver);
|
||||
|
||||
do
|
||||
{
|
||||
@ -344,60 +342,102 @@ meta_xwayland_start (MetaXWaylandManager *manager,
|
||||
while (1);
|
||||
|
||||
manager->display_index = display;
|
||||
manager->display_name = g_strdup_printf (":%d", manager->display_index);
|
||||
manager->lockfile = lockfile;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xserver_finished_init (MetaXWaylandManager *manager)
|
||||
{
|
||||
/* At this point xwayland is all setup to start accepting
|
||||
* connections so we can quit the transient initialization mainloop
|
||||
* and unblock meta_wayland_init() to continue initializing mutter.
|
||||
* */
|
||||
g_main_loop_quit (manager->init_loop);
|
||||
g_clear_pointer (&manager->init_loop, g_main_loop_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
got_sigusr1 (gpointer user_data)
|
||||
{
|
||||
MetaXWaylandManager *manager = user_data;
|
||||
|
||||
xserver_finished_init (manager);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_xwayland_start (MetaXWaylandManager *manager,
|
||||
struct wl_display *wl_display)
|
||||
{
|
||||
int sp[2];
|
||||
int fd;
|
||||
|
||||
if (!choose_xdisplay (manager))
|
||||
return FALSE;
|
||||
|
||||
/* We want xwayland to be a wayland client so we make a socketpair to setup a
|
||||
* wayland protocol connection. */
|
||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sp) < 0)
|
||||
{
|
||||
g_warning ("socketpair failed\n");
|
||||
unlink (lockfile);
|
||||
unlink (manager->lockfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
env = g_get_environ ();
|
||||
fd_string = g_strdup_printf ("%d", sp[1]);
|
||||
env = g_environ_setenv (env, "WAYLAND_SOCKET", fd_string, TRUE);
|
||||
g_free (fd_string);
|
||||
manager->pid = fork ();
|
||||
if (manager->pid == 0)
|
||||
{
|
||||
char socket_fd[8], unix_fd[8], abstract_fd[8];
|
||||
|
||||
manager->display_name = g_strdup_printf (":%d", manager->display_index);
|
||||
/* We passed SOCK_CLOEXEC, so dup the FD so it isn't
|
||||
* closed on exec.. */
|
||||
fd = dup (sp[1]);
|
||||
snprintf (socket_fd, sizeof (socket_fd), "%d", fd);
|
||||
setenv ("WAYLAND_SOCKET", socket_fd, TRUE);
|
||||
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *args[] = { XWAYLAND_PATH,
|
||||
manager->display_name,
|
||||
"-wayland",
|
||||
"-rootless",
|
||||
"-noreset",
|
||||
"-nolisten",
|
||||
"all",
|
||||
NULL };
|
||||
fd = dup (manager->abstract_fd);
|
||||
snprintf (abstract_fd, sizeof (abstract_fd), "%d", fd);
|
||||
|
||||
if (g_spawn_async (NULL, /* cwd */
|
||||
args,
|
||||
env,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
uncloexec,
|
||||
GINT_TO_POINTER (sp[1]),
|
||||
&pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("forked X server, pid %d\n", pid);
|
||||
fd = dup (manager->unix_fd);
|
||||
snprintf (unix_fd, sizeof (unix_fd), "%d", fd);
|
||||
|
||||
close (sp[1]);
|
||||
manager->client = wl_client_create (wl_display, sp[0]);
|
||||
/* xwayland, please. */
|
||||
if (getenv ("XWAYLAND_STFU"))
|
||||
{
|
||||
int dev_null;
|
||||
dev_null = open ("/dev/null", O_WRONLY);
|
||||
|
||||
manager->pid = pid;
|
||||
g_child_watch_add (pid, xserver_died, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_error ("Failed to fork for xwayland server: %s", error->message);
|
||||
}
|
||||
}
|
||||
dup2 (dev_null, STDOUT_FILENO);
|
||||
dup2 (dev_null, STDERR_FILENO);
|
||||
}
|
||||
|
||||
g_strfreev (env);
|
||||
/* We have to ignore SIGUSR1 in the child to make sure
|
||||
* that the server will send it to mutter-wayland. */
|
||||
signal(SIGUSR1, SIG_IGN);
|
||||
|
||||
if (execl (XWAYLAND_PATH, XWAYLAND_PATH,
|
||||
manager->display_name,
|
||||
"-rootless",
|
||||
"-noreset",
|
||||
"-listen", abstract_fd,
|
||||
"-listen", unix_fd,
|
||||
NULL) < 0)
|
||||
{
|
||||
g_error ("Failed to spawn XWayland: %m");
|
||||
}
|
||||
}
|
||||
else if (manager->pid == -1)
|
||||
{
|
||||
g_error ("Failed to fork: %m");
|
||||
}
|
||||
|
||||
g_child_watch_add (manager->pid, xserver_died, NULL);
|
||||
g_unix_signal_add (SIGUSR1, got_sigusr1, manager);
|
||||
manager->client = wl_client_create (wl_display, sp[0]);
|
||||
|
||||
/* We need to run a mainloop until we know xwayland has a binding
|
||||
* for our xserver interface at which point we can assume it's
|
||||
|
35
src/wayland/meta-xwayland.h
Normal file
35
src/wayland/meta-xwayland.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#ifndef META_XWAYLAND_H
|
||||
#define META_XWAYLAND_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <meta/types.h>
|
||||
|
||||
void
|
||||
meta_xwayland_handle_wl_surface_id (MetaWindow *window,
|
||||
guint32 surface_id);
|
||||
|
||||
#endif /* META_XWAYLAND_H */
|
@ -1,18 +0,0 @@
|
||||
<protocol name="xserver">
|
||||
|
||||
<interface name="xserver" version="1">
|
||||
<request name="set_window_id">
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
<arg name="id" type="uint"/>
|
||||
</request>
|
||||
|
||||
<event name="client">
|
||||
<arg name="fd" type="fd"/>
|
||||
</event>
|
||||
|
||||
<event name="listen_socket">
|
||||
<arg name="fd" type="fd"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
@ -92,7 +92,13 @@ meta_window_wayland_delete (MetaWindow *window,
|
||||
static void
|
||||
meta_window_wayland_kill (MetaWindow *window)
|
||||
{
|
||||
/* TODO */
|
||||
MetaWaylandSurface *surface = window->surface;
|
||||
struct wl_resource *resource = surface->resource;
|
||||
|
||||
/* Send the client an unrecoverable error to kill the client. */
|
||||
wl_resource_post_error (resource,
|
||||
WL_DISPLAY_ERROR_NO_MEMORY,
|
||||
"User requested that we kill you. Sorry. Don't take it too personally.");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -230,7 +230,7 @@ read_rgb_icon (MetaDisplay *display,
|
||||
int mini_w, mini_h;
|
||||
gulong *data_as_long;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
type = None;
|
||||
data = NULL;
|
||||
result = XGetWindowProperty (display->xdisplay,
|
||||
@ -504,7 +504,7 @@ get_kwm_win_icon (MetaDisplay *display,
|
||||
*pixmap = None;
|
||||
*mask = None;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
icons = NULL;
|
||||
result = XGetWindowProperty (display->xdisplay, xwindow,
|
||||
display->atom__KWM_WIN_ICON,
|
||||
|
@ -1816,7 +1816,7 @@ warn_about_lame_clients_and_finish_interact (gboolean shutdown)
|
||||
"and will have to be restarted manually next time "
|
||||
"you log in."),
|
||||
"240",
|
||||
meta_get_display()->active_screen->screen_name,
|
||||
meta_get_display()->screen->screen_name,
|
||||
NULL, NULL, NULL,
|
||||
None,
|
||||
columns,
|
||||
|
@ -1665,12 +1665,12 @@ meta_window_x11_client_message (MetaWindow *window,
|
||||
char *str1;
|
||||
char *str2;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
str1 = XGetAtomName (display->xdisplay, first);
|
||||
if (meta_error_trap_pop_with_return (display) != Success)
|
||||
str1 = NULL;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
str2 = XGetAtomName (display->xdisplay, second);
|
||||
if (meta_error_trap_pop_with_return (display) != Success)
|
||||
str2 = NULL;
|
||||
@ -2227,9 +2227,8 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
gboolean must_be_viewable,
|
||||
MetaCompEffect effect)
|
||||
{
|
||||
MetaScreen *screen = display->screen;
|
||||
XWindowAttributes attrs;
|
||||
MetaScreen *screen = NULL;
|
||||
GSList *tmp;
|
||||
gulong existing_wm_state;
|
||||
MetaWindow *window = NULL;
|
||||
gulong event_mask;
|
||||
@ -2259,19 +2258,12 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
|
||||
if (attrs.root != screen->xroot)
|
||||
{
|
||||
MetaScreen *scr = tmp->data;
|
||||
|
||||
if (scr->xroot == attrs.root)
|
||||
{
|
||||
screen = tmp->data;
|
||||
break;
|
||||
}
|
||||
meta_verbose ("Not on our screen\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_assert (screen);
|
||||
|
||||
if (is_our_xwindow (display, screen, xwindow, &attrs))
|
||||
{
|
||||
meta_verbose ("Not managing our own windows\n");
|
||||
@ -2306,7 +2298,7 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
wm_state_to_string (existing_wm_state));
|
||||
}
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/*
|
||||
* XAddToSaveSet can only be called on windows created by a different
|
||||
@ -2317,7 +2309,7 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
*/
|
||||
XAddToSaveSet (display->xdisplay, xwindow);
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
event_mask = PropertyChangeMask;
|
||||
if (attrs.override_redirect)
|
||||
|
@ -191,7 +191,7 @@ get_property (MetaDisplay *display,
|
||||
results->bytes_after = 0;
|
||||
results->format = 0;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (XGetWindowProperty (display->xdisplay, xwindow, xatom,
|
||||
0, G_MAXLONG,
|
||||
False, req_type, &results->type, &results->format,
|
||||
@ -736,6 +736,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay *display,
|
||||
return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
|
||||
}
|
||||
|
||||
static char *
|
||||
text_property_to_utf8 (Display *xdisplay,
|
||||
const XTextProperty *prop)
|
||||
{
|
||||
char *ret = NULL;
|
||||
char **local_list = NULL;
|
||||
int count = 0;
|
||||
int res;
|
||||
|
||||
res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
|
||||
if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
|
||||
goto out;
|
||||
|
||||
if (count == 0)
|
||||
goto out;
|
||||
|
||||
ret = g_strdup (local_list[0]);
|
||||
|
||||
out:
|
||||
meta_XFree (local_list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
text_property_from_results (GetPropertyResults *results,
|
||||
char **utf8_str_p)
|
||||
@ -743,15 +766,14 @@ text_property_from_results (GetPropertyResults *results,
|
||||
XTextProperty tp;
|
||||
|
||||
*utf8_str_p = NULL;
|
||||
|
||||
|
||||
tp.value = results->prop;
|
||||
results->prop = NULL;
|
||||
tp.encoding = results->type;
|
||||
tp.format = results->format;
|
||||
tp.nitems = results->n_items;
|
||||
|
||||
*utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
|
||||
&tp);
|
||||
*utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
|
||||
|
||||
if (tp.value != NULL)
|
||||
XFree (tp.value);
|
||||
|
Reference in New Issue
Block a user