summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-09-09 20:02:02 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-09-09 20:02:02 +0000
commitf4cd637056333396347f290a250f8727f2f1854c (patch)
treea1302b2894f3d37010edf59a5fa8eb3bba7bccc8
parent6e1e1991d5a376202bf4fca8a6f93d88e17f3131 (diff)
parent31a57fe389b82ba708cedf00848740e4df55d5d0 (diff)
downloadgtk+-f4cd637056333396347f290a250f8727f2f1854c.tar.gz
Merge branch 'drop-mir' into 'gtk-3-24'
Drop the mir backend See merge request GNOME/gtk!1062
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac37
-rw-r--r--docs/reference/gtk/Makefile.am1
-rw-r--r--docs/reference/gtk/building.sgml9
-rw-r--r--docs/reference/gtk/gtk-docs.sgml1
-rw-r--r--docs/reference/gtk/meson.build1
-rw-r--r--docs/reference/gtk/mir.xml35
-rw-r--r--docs/reference/gtk/running.sgml5
-rw-r--r--gdk/Makefile.am6
-rw-r--r--gdk/gdkdisplaymanager.c7
-rw-r--r--gdk/meson.build2
-rw-r--r--gdk/mir/Makefile.am45
-rw-r--r--gdk/mir/gdkmir-debug.c548
-rw-r--r--gdk/mir/gdkmir-private.h141
-rw-r--r--gdk/mir/gdkmir.h52
-rw-r--r--gdk/mir/gdkmircursor.c176
-rw-r--r--gdk/mir/gdkmirdevicemanager.c125
-rw-r--r--gdk/mir/gdkmirdisplay.c1182
-rw-r--r--gdk/mir/gdkmireventsource.c838
-rw-r--r--gdk/mir/gdkmirglcontext.c178
-rw-r--r--gdk/mir/gdkmirkeyboard.c164
-rw-r--r--gdk/mir/gdkmirkeymap.c476
-rw-r--r--gdk/mir/gdkmirpointer.c247
-rw-r--r--gdk/mir/gdkmirscreen.c1141
-rw-r--r--gdk/mir/gdkmirwindow.c52
-rw-r--r--gdk/mir/gdkmirwindowimpl.c2499
-rw-r--r--gdk/mir/meson.build1
-rw-r--r--gtk/gtktooltip.c3
-rw-r--r--gtk/gtkwindow.c9
-rw-r--r--meson.build3
-rw-r--r--meson_options.txt2
-rw-r--r--po-properties/POTFILES.in2
-rw-r--r--po/POTFILES.in2
33 files changed, 8 insertions, 7988 deletions
diff --git a/Makefile.am b/Makefile.am
index 0c9d59108d..622c290fe3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,11 +42,11 @@ MAINTAINERCLEANFILES = \
## Copy .pc files to target-specific names
-gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-broadway-3.0.pc gtk+-wayland-3.0.pc gtk+-mir-3.0.pc: gtk+-3.0.pc
+gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-broadway-3.0.pc gtk+-wayland-3.0.pc: gtk+-3.0.pc
rm -f $@ && \
cp gtk+-3.0.pc $@
-gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc gdk-wayland-3.0.pc gdk-mir-3.0.pc: gdk-3.0.pc
+gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc gdk-wayland-3.0.pc: gdk-3.0.pc
rm -f $@ && \
cp gdk-3.0.pc $@
@@ -67,14 +67,12 @@ DISTCLEANFILES = \
gtk+-quartz-3.0.pc \
gtk+-broadway-3.0.pc \
gtk+-wayland-3.0.pc \
- gtk+-mir-3.0.pc \
gdk-3.0.pc \
gdk-x11-3.0.pc \
gdk-win32-3.0.pc \
gdk-quartz-3.0.pc \
gdk-broadway-3.0.pc \
gdk-wayland-3.0.pc \
- gdk-mir-3.0.pc \
gail-3.0.pc \
config.lt
diff --git a/configure.ac b/configure.ac
index 5a34049698..230df57c6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,8 +62,6 @@ m4_define([gdk_pixbuf_required_version], [2.30.0])
m4_define([introspection_required_version], [1.39.0])
m4_define([wayland_required_version], [1.9.91])
m4_define([wayland_protocols_required_version], [1.14])
-m4_define([mirclient_required_version], [0.22.0])
-m4_define([mircookie_required_version], [0.17.0])
m4_define([epoxy_required_version], [1.4])
m4_define([cloudproviders_required_version], [0.2.5])
m4_define([sysprof_required_version], [3.33.2])
@@ -344,11 +342,6 @@ AC_ARG_ENABLE(wayland-backend,
[AS_HELP_STRING([--enable-wayland-backend],
[enable the wayland gdk backend])],
[backend_set=yes])
-AC_ARG_ENABLE(mir-backend,
- [AS_HELP_STRING([--enable-mir-backend],
- [enable the Mir gdk backend])],
- [backend_set=yes])
-
AC_ARG_ENABLE(cloudproviders,
[AS_HELP_STRING([--enable-cloudproviders],
[enable libcloudproviders integration])],
@@ -366,7 +359,6 @@ if test -z "$backend_set"; then
else
enable_x11_backend=yes
enable_wayland_backend=maybe
- enable_mir_backend=no
fi
fi
@@ -479,30 +471,6 @@ else
AM_CONDITIONAL(USE_WAYLAND, false)
fi
-MIR_DEPENDENCIES="mirclient >= mirclient_required_version mircookie >= mircookie_required_version libcontent-hub-glib"
-if test "$enable_mir_backend" = "maybe" ; then
- PKG_CHECK_EXISTS($MIR_DEPENDENCIES, [have_mir_deps=yes], [have_mir_deps=no])
- AC_MSG_CHECKING([for MIR_DEPENDENCIES])
- if test "$have_mir_deps" = "no" ; then
- enable_mir_backend=no
- else
- enable_mir_backend=yes
- fi
- AC_MSG_RESULT($enable_mir_backend)
-fi
-
-if test "$enable_mir_backend" = "yes"; then
- cairo_backends="$cairo_backends cairo"
- GDK_BACKENDS="$GDK_BACKENDS mir"
- GDK_WINDOWING="$GDK_WINDOWING
-#define GDK_WINDOWING_MIR"
- MIR_PACKAGES="$MIR_DEPENDENCIES"
-
- AM_CONDITIONAL(USE_MIR, true)
-else
- AM_CONDITIONAL(USE_MIR, false)
-fi
-
# strip leading space
GDK_BACKENDS=${GDK_BACKENDS#* }
@@ -1345,7 +1313,7 @@ CFLAGS="$saved_cflags"
LDFLAGS="$saved_ldflags"
GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version"
-GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version"
+GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version"
PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES)
GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB"
@@ -1379,7 +1347,7 @@ fi
PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
GTK_PACKAGES="atk >= atk_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version gdk-pixbuf-2.0 >= gdk_pixbuf_required_version gio-2.0 >= glib_required_version"
-GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version"
+GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version"
if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then
GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
fi
@@ -1966,7 +1934,6 @@ gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/quartz/Makefile
gdk/wayland/Makefile
-gdk/mir/Makefile
gdk/gdkversionmacros.h
gtk/Makefile
gtk/makefile.msc
diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am
index 4e20337d7d..fabfbcd931 100644
--- a/docs/reference/gtk/Makefile.am
+++ b/docs/reference/gtk/Makefile.am
@@ -307,7 +307,6 @@ content_files = \
migrating-GtkStyleContext.xml \
migrating-smclient-GtkApplication.xml \
migrating-unique-GtkApplication.xml \
- mir.xml \
osx.sgml \
overview.xml \
question_index.sgml \
diff --git a/docs/reference/gtk/building.sgml b/docs/reference/gtk/building.sgml
index eb4232bbba..02e3347c1d 100644
--- a/docs/reference/gtk/building.sgml
+++ b/docs/reference/gtk/building.sgml
@@ -408,11 +408,6 @@ How to compile GTK+ itself
</group>
<sbr/>
<group>
- <arg choice="plain">--enable-mir-backend</arg>
- <arg choice="plain">--disable-mir-backend</arg>
- </group>
- <sbr/>
- <group>
<arg choice="plain">--enable-introspection=[no/auto/yes]</arg>
</group>
<sbr/>
@@ -609,9 +604,7 @@ How to compile GTK+ itself
<systemitem>--enable-broadway-backend</systemitem>,
<systemitem>--disable-broadway-backend</systemitem>,
<systemitem>--enable-wayland-backend</systemitem>,
- <systemitem>--disable-wayland-backend</systemitem>
- <systemitem>--enable-mir-backend</systemitem>, and
- <systemitem>--disable-mir-backend</systemitem></title>
+ <systemitem>--disable-wayland-backend</systemitem></title>
<para>
Enables specific backends for GDK. If none of these options
diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml
index eba4cc1bb7..e4f4952353 100644
--- a/docs/reference/gtk/gtk-docs.sgml
+++ b/docs/reference/gtk/gtk-docs.sgml
@@ -437,7 +437,6 @@
<xi:include href="osx.sgml" />
<xi:include href="broadway.xml" />
<xi:include href="wayland.xml" />
- <xi:include href="mir.xml" />
</part>
<xi:include href="glossary.xml" />
diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build
index a49235cb1e..d3f55b442c 100644
--- a/docs/reference/gtk/meson.build
+++ b/docs/reference/gtk/meson.build
@@ -395,7 +395,6 @@ content_files = [
'gtk-query-immodules-3.0.xml',
'gtk-query-settings.xml',
'gtk-update-icon-cache.xml',
- 'mir.xml',
'osx.sgml',
'overview.xml',
'resources.sgml',
diff --git a/docs/reference/gtk/mir.xml b/docs/reference/gtk/mir.xml
deleted file mode 100644
index 3a0a52e082..0000000000
--- a/docs/reference/gtk/mir.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
-]>
-<refentry id="gtk-mir">
-<refmeta>
-<refentrytitle>Using GTK+ with Mir</refentrytitle>
-<manvolnum>3</manvolnum>
-<refmiscinfo>GTK Library</refmiscinfo>
-</refmeta>
-
-<refnamediv>
-<refname>Using GTK+ with Mir</refname>
-<refpurpose>
-Mir-specific aspects of using GTK+
-</refpurpose>
-</refnamediv>
-
-<refsect1>
-<title>Using GTK+ with Mir</title>
-
-<para>
-The GDK Mir backend provides support for running GTK+ applications
-under Mir based display servers. To run your application in this way,
-select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
-</para>
-
-<para>
-Currently, the Mir backend does not use any additional commandline
-options or environment variables.
-</para>
-
-</refsect1>
-
-</refentry>
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index 5e04460ae8..520a12d42d 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -508,11 +508,6 @@ nevertheless.
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
</varlistentry>
- <varlistentry>
- <term>mir</term>
- <listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
- </varlistentry>
-
</variablelist>
Since 3.10, this environment variable can contain a comma-separated list
of backend names, which are tried in order. The list may also contain
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 6373e26a26..a53391c5d1 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -13,7 +13,7 @@ INTROSPECTION_COMPILER_ARGS = \
SUBDIRS = $(GDK_BACKENDS) .
-DIST_SUBDIRS = win32 x11 quartz broadway wayland mir
+DIST_SUBDIRS = win32 x11 quartz broadway wayland
CLEANFILES =
@@ -240,10 +240,6 @@ if USE_WAYLAND
libgdk_3_la_LIBADD += wayland/libgdk-wayland.la
endif
-if USE_MIR
-libgdk_3_la_LIBADD += mir/libgdk-mir.la
-endif
-
if HAVE_INTROSPECTION
introspection_files = \
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index d87ed133ae..24f8ea09f6 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -60,10 +60,6 @@
#include "wayland/gdkprivate-wayland.h"
#endif
-#ifdef GDK_WINDOWING_MIR
-#include "mir/gdkmir-private.h"
-#endif
-
/**
* SECTION:gdkdisplaymanager
* @Short_description: Maintains a list of all open GdkDisplays
@@ -276,9 +272,6 @@ static GdkBackend gdk_backends[] = {
#ifdef GDK_WINDOWING_WAYLAND
{ "wayland", _gdk_wayland_display_open },
#endif
-#ifdef GDK_WINDOWING_MIR
- { "mir", _gdk_mir_display_open },
-#endif
#ifdef GDK_WINDOWING_X11
{ "x11", _gdk_x11_display_open },
#endif
diff --git a/gdk/meson.build b/gdk/meson.build
index d56803486d..fd234917cc 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -258,7 +258,7 @@ endif
gdk_backends = []
gdk_backends_gen_headers = [] # non-public generated headers
-foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11', 'mir']
+foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11']
if get_variable('@0@_enabled'.format(backend))
subdir(backend)
gdk_deps += get_variable('gdk_@0@_deps'.format(backend))
diff --git a/gdk/mir/Makefile.am b/gdk/mir/Makefile.am
deleted file mode 100644
index 0f0174cefc..0000000000
--- a/gdk/mir/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-## Process this file with automake to produce Makefile.in
-include $(top_srcdir)/Makefile.decl
-
-libgdkincludedir = $(includedir)/gtk-3.0/gdk
-libgdkmirincludedir = $(includedir)/gtk-3.0/gdk/mir
-
-AM_CPPFLAGS = \
- -DG_LOG_DOMAIN=\"Gdk\" \
- -DG_LOG_USE_STRUCTURED=1 \
- -DGDK_COMPILATION \
- -I$(top_srcdir) \
- -I$(top_srcdir)/gdk \
- -I$(top_builddir)/gdk \
- $(GDK_HIDDEN_VISIBILITY_CFLAGS) \
- $(GTK_DEBUG_FLAGS) \
- $(GDK_DEP_CFLAGS)
-
-LDADDS = $(GDK_DEP_LIBS)
-
-noinst_LTLIBRARIES = \
- libgdk-mir.la
-
-libgdk_mir_la_SOURCES = \
- gdkmircursor.c \
- gdkmirdevicemanager.c \
- gdkmirdisplay.c \
- gdkmireventsource.c \
- gdkmirglcontext.c \
- gdkmirkeyboard.c \
- gdkmirkeymap.c \
- gdkmirpointer.c \
- gdkmirscreen.c \
- gdkmirwindow.c \
- gdkmirwindowimpl.c \
- gdkmir-debug.c \
- gdkmir-private.h \
- gdkmir.h
-
-libgdkinclude_HEADERS = \
- gdkmir.h
-
-EXTRA_DIST += \
- meson.build
-
--include $(top_srcdir)/git.mk
diff --git a/gdk/mir/gdkmir-debug.c b/gdk/mir/gdkmir-debug.c
deleted file mode 100644
index 73dcd805c5..0000000000
--- a/gdk/mir/gdkmir-debug.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gdkmir-private.h"
-
-#include <mir_toolkit/events/window_placement.h>
-
-static void
-_gdk_mir_print_modifiers (unsigned int modifiers)
-{
- g_printerr (" Modifiers");
- if ((modifiers & mir_input_event_modifier_alt) != 0)
- g_printerr (" alt");
- if ((modifiers & mir_input_event_modifier_alt_left) != 0)
- g_printerr (" alt-left");
- if ((modifiers & mir_input_event_modifier_alt_right) != 0)
- g_printerr (" alt-right");
- if ((modifiers & mir_input_event_modifier_shift) != 0)
- g_printerr (" shift");
- if ((modifiers & mir_input_event_modifier_shift_left) != 0)
- g_printerr (" shift-left");
- if ((modifiers & mir_input_event_modifier_shift_right) != 0)
- g_printerr (" shift-right");
- if ((modifiers & mir_input_event_modifier_sym) != 0)
- g_printerr (" sym");
- if ((modifiers & mir_input_event_modifier_function) != 0)
- g_printerr (" function");
- if ((modifiers & mir_input_event_modifier_ctrl) != 0)
- g_printerr (" ctrl");
- if ((modifiers & mir_input_event_modifier_ctrl_left) != 0)
- g_printerr (" ctrl-left");
- if ((modifiers & mir_input_event_modifier_ctrl_right) != 0)
- g_printerr (" ctrl-right");
- if ((modifiers & mir_input_event_modifier_meta) != 0)
- g_printerr (" meta");
- if ((modifiers & mir_input_event_modifier_meta_left) != 0)
- g_printerr (" meta-left");
- if ((modifiers & mir_input_event_modifier_meta_right) != 0)
- g_printerr (" meta-right");
- if ((modifiers & mir_input_event_modifier_caps_lock) != 0)
- g_printerr (" caps-lock");
- if ((modifiers & mir_input_event_modifier_num_lock) != 0)
- g_printerr (" num-lock");
- if ((modifiers & mir_input_event_modifier_scroll_lock) != 0)
- g_printerr (" scroll-lock");
- g_printerr ("\n");
-}
-
-static void
-_gdk_mir_print_key_event (const MirInputEvent *event)
-{
- const MirKeyboardEvent *keyboard_event = mir_input_event_get_keyboard_event (event);
-
- if (!keyboard_event)
- return;
-
- g_printerr ("KEY\n");
- g_printerr (" Device %lld\n", (long long int) mir_input_event_get_device_id (event));
- g_printerr (" Action ");
- switch (mir_keyboard_event_action (keyboard_event))
- {
- case mir_keyboard_action_down:
- g_printerr ("down");
- break;
- case mir_keyboard_action_up:
- g_printerr ("up");
- break;
- case mir_keyboard_action_repeat:
- g_printerr ("repeat");
- break;
- default:
- g_printerr ("%u", mir_keyboard_event_action (keyboard_event));
- break;
- }
- g_printerr ("\n");
- _gdk_mir_print_modifiers (mir_keyboard_event_modifiers (keyboard_event));
- g_printerr (" Key Code %i\n", mir_keyboard_event_key_code (keyboard_event));
- g_printerr (" Scan Code %i\n", mir_keyboard_event_scan_code (keyboard_event));
- g_printerr (" Event Time %lli\n", (long long int) mir_input_event_get_event_time (event));
-}
-
-static void
-_gdk_mir_print_touch_event (const MirInputEvent *event)
-{
- const MirTouchEvent *touch_event = mir_input_event_get_touch_event (event);
- guint i;
- guint n;
-
- if (!touch_event)
- return;
-
- g_printerr ("TOUCH\n");
- g_printerr (" Device %lld\n", (long long int) mir_input_event_get_device_id (event));
- g_printerr (" Event Time %lld\n", (long long int) mir_input_event_get_event_time (event));
- _gdk_mir_print_modifiers (mir_touch_event_modifiers (touch_event));
- n = mir_touch_event_point_count (touch_event);
-
- for (i = 0; i < n; i++)
- {
- g_printerr (" [%u] (%u/%u) ", mir_touch_event_id (touch_event, i), i + 1, n);
- switch (mir_touch_event_action (touch_event, i))
- {
- case mir_touch_action_down:
- g_printerr ("Down");
- break;
- case mir_touch_action_up:
- g_printerr ("Up");
- break;
- case mir_touch_action_change:
- g_printerr ("Change");
- break;
- default:
- g_printerr ("%u", mir_touch_event_action (touch_event, i));
- break;
- }
- switch (mir_touch_event_tooltype (touch_event, i))
- {
- default:
- case mir_touch_tooltype_unknown:
- g_printerr (" ? ");
- break;
- case mir_touch_tooltype_finger:
- g_printerr (" finger ");
- break;
- case mir_touch_tooltype_stylus:
- g_printerr (" stylus ");
- break;
- }
- g_printerr ("\n x: %f y: %f P: %f A: %f B: %f d: %f\n",
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_x),
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_y),
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_pressure),
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_touch_major),
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_touch_minor),
- mir_touch_event_axis_value (touch_event, i, mir_touch_axis_size));
- }
-}
-
-static void
-_gdk_mir_print_motion_event (const MirInputEvent *event)
-{
- const MirPointerEvent *pointer_event = mir_input_event_get_pointer_event (event);
-
- if (!pointer_event)
- return;
-
- g_printerr ("MOTION\n");
- g_printerr (" Device %lld\n", (long long int) mir_input_event_get_device_id (event));
- g_printerr (" Action ");
- switch (mir_pointer_event_action (pointer_event))
- {
- case mir_pointer_action_button_down:
- g_printerr ("down");
- break;
- case mir_pointer_action_button_up:
- g_printerr ("up");
- break;
- case mir_pointer_action_enter:
- g_printerr ("enter");
- break;
- case mir_pointer_action_leave:
- g_printerr ("leave");
- break;
- case mir_pointer_action_motion:
- g_printerr ("motion");
- break;
- default:
- g_printerr ("%u", mir_pointer_event_action (pointer_event));
- }
- g_printerr ("\n");
- _gdk_mir_print_modifiers (mir_pointer_event_modifiers (pointer_event));
- g_printerr (" Button State");
- if (mir_pointer_event_button_state (pointer_event, mir_pointer_button_primary))
- g_printerr (" primary");
- if (mir_pointer_event_button_state (pointer_event, mir_pointer_button_secondary))
- g_printerr (" secondary");
- if (mir_pointer_event_button_state (pointer_event, mir_pointer_button_tertiary))
- g_printerr (" tertiary");
- if (mir_pointer_event_button_state (pointer_event, mir_pointer_button_back))
- g_printerr (" back");
- if (mir_pointer_event_button_state (pointer_event, mir_pointer_button_forward))
- g_printerr (" forward");
- g_printerr ("\n");
- g_printerr (" Offset (%f, %f)\n", mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_x),
- mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_y));
- g_printerr (" Scroll (%f, %f)\n", mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_hscroll),
- mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_vscroll));
- g_printerr (" Event Time %lli\n", (long long int) mir_input_event_get_event_time (event));
-}
-
-static void
-_gdk_mir_print_input_event (const MirInputEvent *event)
-{
- g_printerr ("INPUT\n");
-}
-
-static void
-_gdk_mir_print_window_event (const MirWindowEvent *event)
-{
- g_printerr ("WINDOW\n");
- g_printerr (" Attribute ");
- switch (mir_window_event_get_attribute (event))
- {
- case mir_window_attrib_type:
- g_printerr ("type");
- break;
- case mir_window_attrib_state:
- g_printerr ("state");
- break;
- case mir_window_attrib_swapinterval:
- g_printerr ("swapinterval");
- break;
- case mir_window_attrib_focus:
- g_printerr ("focus");
- break;
- case mir_window_attrib_dpi:
- g_printerr ("dpi");
- break;
- case mir_window_attrib_visibility:
- g_printerr ("visibility");
- break;
- case mir_window_attrib_preferred_orientation:
- g_printerr ("preferred_orientation");
- break;
- default:
- g_printerr ("%u", mir_window_event_get_attribute (event));
- break;
- }
- g_printerr ("\n");
- g_printerr (" Value %i\n", mir_window_event_get_attribute_value (event));
-}
-
-static void
-_gdk_mir_print_resize_event (const MirResizeEvent *event)
-{
- g_printerr ("RESIZE\n");
- g_printerr (" Size (%i, %i)\n", mir_resize_event_get_width (event), mir_resize_event_get_height (event));
-}
-
-static void
-_gdk_mir_print_prompt_session_state_change_event (const MirPromptSessionEvent *event)
-{
- g_printerr ("PROMPT_SESSION_STATE_CHANGE\n");
- g_printerr (" State ");
-
- switch (mir_prompt_session_event_get_state (event))
- {
- case mir_prompt_session_state_stopped:
- g_printerr ("stopped");
- break;
- case mir_prompt_session_state_started:
- g_printerr ("started");
- break;
- case mir_prompt_session_state_suspended:
- g_printerr ("suspended");
- break;
- default:
- g_printerr ("%u", mir_prompt_session_event_get_state (event));
- break;
- }
-
- g_printerr ("\n");
-}
-
-static void
-_gdk_mir_print_orientation_event (const MirOrientationEvent *event)
-{
- g_printerr ("ORIENTATION\n");
- g_printerr (" Direction ");
-
- switch (mir_orientation_event_get_direction (event))
- {
- case mir_orientation_normal:
- g_printerr ("normal");
- break;
- case mir_orientation_left:
- g_printerr ("left");
- break;
- case mir_orientation_inverted:
- g_printerr ("inverted");
- break;
- case mir_orientation_right:
- g_printerr ("right");
- break;
- default:
- g_printerr ("%u", mir_orientation_event_get_direction (event));
- break;
- }
-
- g_printerr ("\n");
-}
-
-static void
-_gdk_mir_print_close_event (void)
-{
- g_printerr ("CLOSED\n");
-}
-
-static void
-_gdk_mir_print_keymap_event (const MirKeymapEvent *event)
-{
- g_printerr ("KEYMAP\n");
-}
-
-static void
-_gdk_mir_print_window_output_event (const MirWindowOutputEvent *event)
-{
- g_printerr ("WINDOW_OUTPUT\n");
- g_printerr (" DPI %d\n", mir_window_output_event_get_dpi (event));
- g_printerr (" Form Factor ");
-
- switch (mir_window_output_event_get_form_factor (event))
- {
- case mir_form_factor_unknown:
- g_printerr ("unknown");
- break;
- case mir_form_factor_phone:
- g_printerr ("phone");
- break;
- case mir_form_factor_tablet:
- g_printerr ("tablet");
- break;
- case mir_form_factor_monitor:
- g_printerr ("monitor");
- break;
- case mir_form_factor_tv:
- g_printerr ("tv");
- break;
- case mir_form_factor_projector:
- g_printerr ("projector");
- break;
- default:
- g_printerr ("%u", mir_window_output_event_get_form_factor (event));
- break;
- }
-
- g_printerr ("\n");
- g_printerr (" Scale %f\n", mir_window_output_event_get_scale (event));
- g_printerr (" Refresh Rate %lf\n", mir_window_output_event_get_refresh_rate (event));
- g_printerr (" Output ID %u\n", mir_window_output_event_get_output_id (event));
-}
-
-static void
-_gdk_mir_print_input_device_state_event (const MirInputDeviceStateEvent *event)
-{
- MirPointerButtons buttons;
- MirInputEventModifiers modifiers;
- gint i;
- gint j;
-
- g_printerr ("INPUT_DEVICE_STATE\n");
- g_printerr (" Pointer Buttons\n");
- buttons = mir_input_device_state_event_pointer_buttons (event);
-
- if (buttons == 0)
- g_printerr (" none\n");
- else
- {
- if (buttons & mir_pointer_button_primary)
- g_printerr (" primary\n");
- if (buttons & mir_pointer_button_secondary)
- g_printerr (" secondary\n");
- if (buttons & mir_pointer_button_tertiary)
- g_printerr (" tertiary\n");
- if (buttons & mir_pointer_button_back)
- g_printerr (" back\n");
- if (buttons & mir_pointer_button_forward)
- g_printerr (" forward\n");
- if (buttons & mir_pointer_button_side)
- g_printerr (" side\n");
- if (buttons & mir_pointer_button_extra)
- g_printerr (" extra\n");
- if (buttons & mir_pointer_button_task)
- g_printerr (" task\n");
- }
-
- g_printerr (" Pointer Axis\n");
- g_printerr (" X %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_x));
- g_printerr (" Y %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_y));
- g_printerr (" V Scroll %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_vscroll));
- g_printerr (" H Scroll %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_hscroll));
- g_printerr (" Relative X %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_relative_x));
- g_printerr (" Relative Y %f\n", mir_input_device_state_event_pointer_axis (event, mir_pointer_axis_relative_y));
- g_printerr (" Time %ld\n", mir_input_device_state_event_time (event));
- g_printerr (" Event Modifiers\n");
- modifiers = mir_input_device_state_event_modifiers (event);
-
- if (modifiers & mir_input_event_modifier_none)
- g_printerr (" none\n");
- if (modifiers & mir_input_event_modifier_alt)
- g_printerr (" alt\n");
- if (modifiers & mir_input_event_modifier_alt_left)
- g_printerr (" alt_left\n");
- if (modifiers & mir_input_event_modifier_alt_right)
- g_printerr (" alt_right\n");
- if (modifiers & mir_input_event_modifier_shift)
- g_printerr (" shift\n");
- if (modifiers & mir_input_event_modifier_shift_left)
- g_printerr (" shift_left\n");
- if (modifiers & mir_input_event_modifier_shift_right)
- g_printerr (" shift_right\n");
- if (modifiers & mir_input_event_modifier_sym)
- g_printerr (" sym\n");
- if (modifiers & mir_input_event_modifier_function)
- g_printerr (" function\n");
- if (modifiers & mir_input_event_modifier_ctrl)
- g_printerr (" ctrl\n");
- if (modifiers & mir_input_event_modifier_ctrl_left)
- g_printerr (" ctrl_left\n");
- if (modifiers & mir_input_event_modifier_ctrl_right)
- g_printerr (" ctrl_right\n");
- if (modifiers & mir_input_event_modifier_meta)
- g_printerr (" meta\n");
- if (modifiers & mir_input_event_modifier_meta_left)
- g_printerr (" meta_left\n");
- if (modifiers & mir_input_event_modifier_meta_right)
- g_printerr (" meta_right\n");
- if (modifiers & mir_input_event_modifier_caps_lock)
- g_printerr (" caps_lock\n");
- if (modifiers & mir_input_event_modifier_num_lock)
- g_printerr (" num_lock\n");
- if (modifiers & mir_input_event_modifier_scroll_lock)
- g_printerr (" scroll_lock\n");
-
- for (i = 0; i < mir_input_device_state_event_device_count (event); i++)
- {
- g_printerr (" Device %ld\n", mir_input_device_state_event_device_id (event, i));
-
- for (j = 0; j < mir_input_device_state_event_device_pressed_keys_count (event, i); j++)
- g_printerr (" Pressed %u\n", mir_input_device_state_event_device_pressed_keys_for_index (event, i, j));
-
- g_printerr (" Pointer Buttons\n");
- buttons = mir_input_device_state_event_device_pointer_buttons (event, i);
-
- if (buttons == 0)
- g_printerr (" none\n");
- else
- {
- if (buttons & mir_pointer_button_primary)
- g_printerr (" primary\n");
- if (buttons & mir_pointer_button_secondary)
- g_printerr (" secondary\n");
- if (buttons & mir_pointer_button_tertiary)
- g_printerr (" tertiary\n");
- if (buttons & mir_pointer_button_back)
- g_printerr (" back\n");
- if (buttons & mir_pointer_button_forward)
- g_printerr (" forward\n");
- if (buttons & mir_pointer_button_side)
- g_printerr (" side\n");
- if (buttons & mir_pointer_button_extra)
- g_printerr (" extra\n");
- if (buttons & mir_pointer_button_task)
- g_printerr (" task\n");
- }
- }
-}
-
-static void
-_gdk_mir_print_window_placement_event (const MirWindowPlacementEvent *event)
-{
- MirRectangle rect = mir_window_placement_get_relative_position (event);
-
- g_printerr ("WINDOW_PLACEMENT\n");
- g_printerr (" X %d\n", rect.left);
- g_printerr (" Y %d\n", rect.top);
- g_printerr (" Width %u\n", rect.width);
- g_printerr (" Height %u\n", rect.height);
-}
-
-void
-_gdk_mir_print_event (const MirEvent *event)
-{
- const MirInputEvent *input_event;
-
- switch (mir_event_get_type (event))
- {
- case mir_event_type_input:
- input_event = mir_event_get_input_event (event);
-
- switch (mir_input_event_get_type (input_event))
- {
- case mir_input_event_type_key:
- _gdk_mir_print_key_event (mir_event_get_input_event (event));
- break;
- case mir_input_event_type_touch:
- _gdk_mir_print_touch_event (mir_event_get_input_event (event));
- break;
- case mir_input_event_type_pointer:
- _gdk_mir_print_motion_event (mir_event_get_input_event (event));
- break;
- default:
- _gdk_mir_print_input_event (mir_event_get_input_event (event));
- break;
- }
- break;
- case mir_event_type_key:
- _gdk_mir_print_key_event (mir_event_get_input_event (event));
- break;
- case mir_event_type_motion:
- _gdk_mir_print_motion_event (mir_event_get_input_event (event));
- break;
- case mir_event_type_window:
- _gdk_mir_print_window_event (mir_event_get_window_event (event));
- break;
- case mir_event_type_resize:
- _gdk_mir_print_resize_event (mir_event_get_resize_event (event));
- break;
- case mir_event_type_prompt_session_state_change:
- _gdk_mir_print_prompt_session_state_change_event (mir_event_get_prompt_session_event (event));
- break;
- case mir_event_type_orientation:
- _gdk_mir_print_orientation_event (mir_event_get_orientation_event (event));
- break;
- case mir_event_type_close_window:
- _gdk_mir_print_close_event ();
- break;
- case mir_event_type_keymap:
- _gdk_mir_print_keymap_event (mir_event_get_keymap_event (event));
- break;
- case mir_event_type_window_output:
- _gdk_mir_print_window_output_event (mir_event_get_window_output_event (event));
- break;
- case mir_event_type_input_device_state:
- _gdk_mir_print_input_device_state_event (mir_event_get_input_device_state_event (event));
- break;
- case mir_event_type_window_placement:
- _gdk_mir_print_window_placement_event (mir_event_get_window_placement_event (event));
- break;
- default:
- g_printerr ("EVENT %u\n", mir_event_get_type (event));
- break;
- }
-}
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
deleted file mode 100644
index e726703b21..0000000000
--- a/gdk/mir/gdkmir-private.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GDK_PRIVATE_MIR_H__
-#define __GDK_PRIVATE_MIR_H__
-
-#include <epoxy/egl.h>
-
-#include "gdkmir.h"
-#include "gdkdisplay.h"
-#include "gdkscreen.h"
-#include "gdkdevicemanager.h"
-#include "gdkglcontextprivate.h"
-#include "gdkkeys.h"
-#include "gdkwindowimpl.h"
-
-typedef struct _GdkMirWindowImpl GdkMirWindowImpl;
-typedef struct _GdkMirWindowReference GdkMirWindowReference;
-typedef struct _GdkMirEventSource GdkMirEventSource;
-
-#define GDK_TYPE_MIR_WINDOW_IMPL (gdk_mir_window_impl_get_type ())
-#define GDK_MIR_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_WINDOW_IMPL, GdkMirWindowImpl))
-#define GDK_IS_WINDOW_IMPL_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW_IMPL))
-
-GType gdk_mir_window_impl_get_type (void);
-
-
-struct _GdkMirGLContext
-{
- GdkGLContext parent_instance;
-
- EGLContext egl_context;
- EGLConfig egl_config;
- gboolean is_attached;
-};
-
-struct _GdkMirGLContextClass
-{
- GdkGLContextClass parent_class;
-};
-
-typedef struct _GdkMirGLContext GdkMirGLContext;
-typedef struct _GdkMirGLContextClass GdkMirGLContextClass;
-
-#define GDK_MIR_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_MIR_GL_CONTEXT, GdkMirGLContext))
-
-
-GdkDisplay *_gdk_mir_display_open (const gchar *display_name);
-
-GdkScreen *_gdk_mir_screen_new (GdkDisplay *display);
-
-GdkDeviceManager *_gdk_mir_device_manager_new (GdkDisplay *display);
-
-GdkDevice *_gdk_mir_device_manager_get_keyboard (GdkDeviceManager *device_manager);
-
-GdkKeymap *_gdk_mir_keymap_new (void);
-
-gboolean _gdk_mir_keymap_key_is_modifier (GdkKeymap *keymap, guint keycode);
-
-GdkDevice *_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name);
-
-GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name);
-
-void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, GdkModifierType mask);
-
-GdkCursor *_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type);
-
-GdkCursor *_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name);
-
-const gchar *_gdk_mir_cursor_get_name (GdkCursor *cursor);
-
-MirWindow *_gdk_mir_window_get_mir_window (GdkWindow *window);
-
-GdkWindowImpl *_gdk_mir_window_impl_new (GdkDisplay *display, GdkWindow *window, GdkWindowAttr *attributes, gint attributes_mask);
-
-void _gdk_mir_window_impl_set_window_state (GdkMirWindowImpl *impl, MirWindowState state);
-
-void _gdk_mir_window_impl_set_window_type (GdkMirWindowImpl *impl, MirWindowType type);
-
-void _gdk_mir_window_set_scale (GdkWindow *window, gdouble scale);
-
-void _gdk_mir_window_set_final_rect (GdkWindow *window, MirRectangle rect);
-
-void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean cursor_inside, guint button_state);
-
-void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean *cursor_inside, guint *button_state);
-
-GdkMirEventSource *_gdk_mir_display_get_event_source (GdkDisplay *display);
-
-GdkMirEventSource *_gdk_mir_event_source_new (GdkDisplay *display);
-
-GdkMirWindowReference *_gdk_mir_event_source_get_window_reference (GdkWindow *window);
-
-void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref);
-
-void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
-
-MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage);
-
-void _gdk_mir_display_focus_window (GdkDisplay *display, GdkWindow *window);
-
-void _gdk_mir_display_unfocus_window (GdkDisplay *display, GdkWindow *window);
-
-void _gdk_mir_display_create_paste (GdkDisplay *display,
- const gchar * const *paste_formats,
- gconstpointer paste_data,
- gsize paste_size);
-
-gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display);
-
-EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display);
-
-gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display);
-
-gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display);
-
-gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display);
-
-gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display);
-
-EGLSurface _gdk_mir_window_get_egl_surface (GdkWindow *window, EGLConfig config);
-
-EGLSurface _gdk_mir_window_get_dummy_egl_surface (GdkWindow *window, EGLConfig config);
-
-void _gdk_mir_print_event (const MirEvent *event);
-
-#endif /* __GDK_PRIVATE_MIR_H__ */
diff --git a/gdk/mir/gdkmir.h b/gdk/mir/gdkmir.h
deleted file mode 100644
index 811a8dfe86..0000000000
--- a/gdk/mir/gdkmir.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GDK_MIR_H__
-#define __GDK_MIR_H__
-
-#include <gdk/gdk.h>
-#include <mir_toolkit/mir_client_library.h>
-
-G_BEGIN_DECLS
-
-#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
-#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
-
-#define GDK_TYPE_MIR_GL_CONTEXT (gdk_mir_gl_context_get_type ())
-#define GDK_MIR_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_MIR_GL_CONTEXT))
-
-#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
-#define GDK_IS_MIR_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW))
-
-GDK_AVAILABLE_IN_3_16
-GType gdk_mir_display_get_type (void);
-
-GDK_AVAILABLE_IN_3_16
-MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
-
-GDK_AVAILABLE_IN_3_16
-GType gdk_mir_window_get_type (void);
-
-GDK_DEPRECATED_IN_3_22
-MirSurface *gdk_mir_window_get_mir_surface (GdkWindow *window);
-
-GDK_AVAILABLE_IN_3_16
-GType gdk_mir_gl_context_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* __GDK_MIR_H__ */
diff --git a/gdk/mir/gdkmircursor.c b/gdk/mir/gdkmircursor.c
deleted file mode 100644
index 92fe452da8..0000000000
--- a/gdk/mir/gdkmircursor.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkcursorprivate.h"
-
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-typedef struct GdkMirCursor GdkMirCursor;
-typedef struct GdkMirCursorClass GdkMirCursorClass;
-
-#define GDK_TYPE_MIR_CURSOR (gdk_mir_cursor_get_type ())
-#define GDK_MIR_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_CURSOR, GdkMirCursor))
-#define GDK_MIR_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_CURSOR, GdkMirCursorClass))
-#define GDK_IS_MIR_CURSOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_CURSOR))
-#define GDK_IS_MIR_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_CURSOR))
-#define GDK_MIR_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_CURSOR, GdkMirCursorClass))
-
-struct GdkMirCursor
-{
- GdkCursor parent_instance;
-
- gchar *name;
-};
-
-struct GdkMirCursorClass
-{
- GdkCursorClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirCursor, gdk_mir_cursor, GDK_TYPE_CURSOR)
-
-static const gchar *
-get_cursor_name_for_cursor_type (GdkCursorType cursor_type)
-{
- switch (cursor_type)
- {
- case GDK_BLANK_CURSOR:
- return mir_disabled_cursor_name;
- case GDK_X_CURSOR:
- case GDK_ARROW:
- case GDK_CENTER_PTR:
- case GDK_DRAFT_LARGE:
- case GDK_DRAFT_SMALL:
- case GDK_LEFT_PTR:
- case GDK_RIGHT_PTR:
- case GDK_TOP_LEFT_ARROW:
- return mir_arrow_cursor_name;
- case GDK_CLOCK:
- case GDK_WATCH:
- return mir_busy_cursor_name;
- case GDK_XTERM:
- return mir_caret_cursor_name;
- case GDK_HAND1:
- case GDK_HAND2:
- return mir_pointing_hand_cursor_name;
- return mir_open_hand_cursor_name;
- case GDK_FLEUR:
- return mir_closed_hand_cursor_name;
- case GDK_LEFT_SIDE:
- case GDK_LEFT_TEE:
- case GDK_RIGHT_SIDE:
- case GDK_RIGHT_TEE:
- case GDK_SB_LEFT_ARROW:
- case GDK_SB_RIGHT_ARROW:
- return mir_horizontal_resize_cursor_name;
- case GDK_BASED_ARROW_DOWN:
- case GDK_BASED_ARROW_UP:
- case GDK_BOTTOM_SIDE:
- case GDK_BOTTOM_TEE:
- case GDK_DOUBLE_ARROW:
- case GDK_SB_DOWN_ARROW:
- case GDK_SB_UP_ARROW:
- case GDK_TOP_SIDE:
- case GDK_TOP_TEE:
- return mir_vertical_resize_cursor_name;
- case GDK_BOTTOM_LEFT_CORNER:
- case GDK_LL_ANGLE:
- case GDK_TOP_RIGHT_CORNER:
- case GDK_UR_ANGLE:
- return mir_diagonal_resize_bottom_to_top_cursor_name;
- case GDK_BOTTOM_RIGHT_CORNER:
- case GDK_LR_ANGLE:
- case GDK_SIZING:
- case GDK_TOP_LEFT_CORNER:
- case GDK_UL_ANGLE:
- return mir_diagonal_resize_top_to_bottom_cursor_name;
- return mir_omnidirectional_resize_cursor_name;
- case GDK_SB_V_DOUBLE_ARROW:
- return mir_vsplit_resize_cursor_name;
- case GDK_SB_H_DOUBLE_ARROW:
- return mir_hsplit_resize_cursor_name;
- default:
- return mir_default_cursor_name;
- }
-}
-
-
-GdkCursor *
-_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name)
-{
- GdkMirCursor *cursor;
-
- cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", GDK_CURSOR_IS_PIXMAP, NULL);
- cursor->name = g_strdup (name);
-
- return GDK_CURSOR (cursor);
-}
-
-GdkCursor *
-_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type)
-{
- GdkMirCursor *cursor;
-
- cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
- cursor->name = g_strdup (get_cursor_name_for_cursor_type (type));
-
- return GDK_CURSOR (cursor);
-}
-
-const gchar *
-_gdk_mir_cursor_get_name (GdkCursor *cursor)
-{
- GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (cursor);
-
- return mir_cursor->name;
-}
-
-cairo_surface_t *
-gdk_mir_cursor_get_surface (GdkCursor *cursor,
- gdouble *x_hot,
- gdouble *y_hot)
-{
- return NULL;
-}
-
-static void
-gdk_mir_cursor_init (GdkMirCursor *cursor)
-{
-}
-
-static void
-gdk_mir_cursor_finalize (GObject *object)
-{
- GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (object);
-
- g_free (mir_cursor->name);
-
- G_OBJECT_CLASS (gdk_mir_cursor_parent_class)->finalize (object);
-}
-
-static void
-gdk_mir_cursor_class_init (GdkMirCursorClass *klass)
-{
- GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- cursor_class->get_surface = gdk_mir_cursor_get_surface;
- object_class->finalize = gdk_mir_cursor_finalize;
-}
diff --git a/gdk/mir/gdkmirdevicemanager.c b/gdk/mir/gdkmirdevicemanager.c
deleted file mode 100644
index 68f40719cb..0000000000
--- a/gdk/mir/gdkmirdevicemanager.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkdevicemanagerprivate.h"
-#include "gdkdisplayprivate.h"
-#include "gdkdeviceprivate.h"
-#include "gdkseatdefaultprivate.h"
-
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-typedef struct GdkMirDeviceManager GdkMirDeviceManager;
-typedef struct GdkMirDeviceManagerClass GdkMirDeviceManagerClass;
-
-#define GDK_TYPE_MIR_DEVICE_MANAGER (gdk_mir_device_manager_get_type ())
-#define GDK_MIR_DEVICE_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManager))
-#define GDK_MIR_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManagerClass))
-#define GDK_IS_MIR_DEVICE_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DEVICE_MANAGER))
-#define GDK_IS_MIR_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_DEVICE_MANAGER))
-#define GDK_MIR_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManagerClass))
-
-struct GdkMirDeviceManager
-{
- GdkDeviceManager parent_instance;
-
- GdkDevice *pointer;
- GdkDevice *keyboard;
-};
-
-struct GdkMirDeviceManagerClass
-{
- GdkDeviceManagerClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirDeviceManager, gdk_mir_device_manager, GDK_TYPE_DEVICE_MANAGER)
-
-GdkDeviceManager *
-_gdk_mir_device_manager_new (GdkDisplay *display)
-{
- return g_object_new (GDK_TYPE_MIR_DEVICE_MANAGER, "display", display, NULL);
-}
-
-static GList *
-gdk_mir_device_manager_list_devices (GdkDeviceManager *device_manager,
- GdkDeviceType type)
-{
- GdkMirDeviceManager *dm = GDK_MIR_DEVICE_MANAGER (device_manager);
-
- if (type == GDK_DEVICE_TYPE_MASTER)
- {
- GList *devices;
-
- devices = g_list_append (NULL, dm->keyboard);
- devices = g_list_append (devices, dm->pointer);
-
- return devices;
- }
-
- return NULL;
-}
-
-static GdkDevice *
-gdk_mir_device_manager_get_client_pointer (GdkDeviceManager *device_manager)
-{
- return GDK_MIR_DEVICE_MANAGER (device_manager)->pointer;
-}
-
-GdkDevice *
-_gdk_mir_device_manager_get_keyboard (GdkDeviceManager *device_manager)
-{
- return GDK_MIR_DEVICE_MANAGER (device_manager)->keyboard;
-}
-
-static void
-gdk_mir_device_manager_init (GdkMirDeviceManager *device_manager)
-{
-}
-
-static void
-gdk_mir_device_manager_constructed (GObject *object)
-{
- GdkMirDeviceManager *device_manager = GDK_MIR_DEVICE_MANAGER (object);
- GdkDisplay *display;
- GdkSeat *seat;
-
- device_manager->keyboard = _gdk_mir_keyboard_new (GDK_DEVICE_MANAGER (device_manager), "Mir Keyboard");
- device_manager->pointer = _gdk_mir_pointer_new (GDK_DEVICE_MANAGER (device_manager), "Mir Pointer");
- _gdk_device_set_associated_device (device_manager->keyboard, device_manager->pointer);
- _gdk_device_set_associated_device (device_manager->pointer, device_manager->keyboard);
-
- display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
-
- seat = gdk_seat_default_new_for_master_pair (device_manager->pointer, device_manager->keyboard);
- gdk_display_add_seat (display, seat);
- g_object_unref (seat);
-
- G_OBJECT_CLASS (gdk_mir_device_manager_parent_class)->constructed (object);
-}
-
-static void
-gdk_mir_device_manager_class_init (GdkMirDeviceManagerClass *klass)
-{
- GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- device_manager_class->list_devices = gdk_mir_device_manager_list_devices;
- device_manager_class->get_client_pointer = gdk_mir_device_manager_get_client_pointer;
- object_class->constructed = gdk_mir_device_manager_constructed;
-}
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
deleted file mode 100644
index 8b39e82e3e..0000000000
--- a/gdk/mir/gdkmirdisplay.c
+++ /dev/null
@@ -1,1182 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkdisplayprivate.h"
-#include "gdkinternals.h"
-
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-#include <string.h>
-
-#include <com/ubuntu/content/glib/content-hub-glib.h>
-
-#define GDK_TYPE_DISPLAY_MIR (gdk_mir_display_get_type ())
-#define GDK_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MIR, GdkMirDisplay))
-#define GDK_MIR_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_MIR, GdkMirDisplayClass))
-#define GDK_IS_MIR_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_DISPLAY))
-#define GDK_MIR_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_DISPLAY, GdkMirDisplayImplClass))
-
-typedef struct GdkMirDisplay
-{
- GdkDisplay parent_instance;
-
- /* Connection to Mir server */
- MirConnection *connection;
-
- /* Event source */
- GdkMirEventSource *event_source;
-
- /* Serial number? */
- gulong serial;
-
- /* Screen information */
- GdkScreen *screen;
-
- GdkKeymap *keymap;
-
- GdkWindow *focused_window;
-
- MirPixelFormat sw_pixel_format;
- MirPixelFormat hw_pixel_format;
-
- EGLDisplay egl_display;
- guint have_egl_khr_create_context : 1;
- guint have_egl_buffer_age : 1;
- guint have_egl_swap_buffers_with_damage : 1;
- guint have_egl_surfaceless_context : 1;
-
- ContentHubService *content_service;
- ContentHubHandler *content_handler;
- GVariant *paste_data;
-} GdkMirDisplay;
-
-typedef struct GdkMirDisplayClass
-{
- GdkDisplayClass parent_class;
-} GdkMirDisplayClass;
-
-static void get_pixel_formats (MirConnection *, MirPixelFormat *sw, MirPixelFormat *hw);
-
-/**
- * SECTION:mir_interaction
- * @Short_description: Mir backend-specific functions
- * @Title: Mir Interaction
- *
- * The functions in this section are specific to the GDK Mir backend.
- * To use them, you need to include the <literal>&lt;gdk/gdkmir.h&gt;</literal>
- * header and use the Mir-specific pkg-config files to build your
- * application (either <literal>gdk-mir-3.0</literal> or
- * <literal>gtk+-mir-3.0</literal>).
- *
- * To make your code compile with other GDK backends, guard backend-specific
- * calls by an ifdef as follows. Since GDK may be built with multiple
- * backends, you should also check for the backend that is in use (e.g. by
- * using the GDK_IS_MIR_DISPLAY() macro).
- * |[
- * #ifdef GDK_WINDOWING_MIR
- * if (GDK_IS_MIR_DISPLAY (display))
- * {
- * /&ast; make Mir-specific calls here &ast;/
- * }
- * else
- * #endif
- * #ifdef GDK_WINDOWING_X11
- * if (GDK_IS_X11_DISPLAY (display))
- * {
- * /&ast; make X11-specific calls here &ast;/
- * }
- * else
- * #endif
- * g_error ("Unsupported GDK backend");
- * ]|
- */
-
-G_DEFINE_TYPE (GdkMirDisplay, gdk_mir_display, GDK_TYPE_DISPLAY)
-
-static void
-pasteboard_changed_cb (GdkMirDisplay *display,
- gpointer user_data)
-{
- g_clear_pointer (&display->paste_data, g_variant_unref);
-}
-
-GdkDisplay *
-_gdk_mir_display_open (const gchar *display_name)
-{
- MirConnection *connection;
- MirPixelFormat sw_pixel_format, hw_pixel_format;
- GdkMirDisplay *display;
- GDBusConnection *session;
-
- connection = mir_connect_sync (NULL, g_get_prgname ());
- if (!connection)
- return NULL;
-
- if (!mir_connection_is_valid (connection))
- {
- mir_connection_release (connection);
- return NULL;
- }
-
- get_pixel_formats (connection, &sw_pixel_format, &hw_pixel_format);
-
- if (sw_pixel_format == mir_pixel_format_invalid ||
- hw_pixel_format == mir_pixel_format_invalid)
- {
- g_printerr ("Mir display does not support required pixel formats\n");
- mir_connection_release (connection);
- return NULL;
- }
-
- display = g_object_new (GDK_TYPE_MIR_DISPLAY, NULL);
-
- display->connection = connection;
- GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
- display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
- display->sw_pixel_format = sw_pixel_format;
- display->hw_pixel_format = hw_pixel_format;
-
- session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-
- display->content_service = content_hub_service_proxy_new_sync (
- session,
- G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
- "com.ubuntu.content.dbus.Service",
- "/",
- NULL,
- NULL);
-
- g_signal_connect_swapped (
- display->content_service,
- "pasteboard-changed",
- G_CALLBACK (pasteboard_changed_cb),
- display);
-
- display->content_handler = content_hub_handler_skeleton_new ();
-
- g_dbus_interface_skeleton_export (
- G_DBUS_INTERFACE_SKELETON (display->content_handler),
- session,
- "/org/gnome/gtk/content/handler",
- NULL);
-
- g_object_unref (session);
-
- content_hub_service_call_register_import_export_handler_sync (
- display->content_service,
- g_application_get_application_id (g_application_get_default ()),
- "/org/gnome/gtk/content/handler",
- NULL,
- NULL);
-
- content_hub_service_call_handler_active_sync (
- display->content_service,
- g_application_get_application_id (g_application_get_default ()),
- NULL,
- NULL);
-
- g_signal_emit_by_name (display, "opened");
-
- return GDK_DISPLAY (display);
-}
-
-/**
- * gdk_mir_display_get_mir_connection
- * @display: (type GdkMirDisplay): a #GdkDisplay
- *
- * Returns the #MirConnection for a #GdkDisplay
- *
- * Returns: (transfer none): a #MirConnection
- *
- * Since: 3.14
- */
-struct MirConnection *
-gdk_mir_display_get_mir_connection (GdkDisplay *display)
-{
- g_return_val_if_fail (GDK_IS_MIR_DISPLAY (display), NULL);
- return GDK_MIR_DISPLAY (display)->connection;
-}
-
-GdkMirEventSource *
-_gdk_mir_display_get_event_source (GdkDisplay *display)
-{
- g_return_val_if_fail (GDK_IS_MIR_DISPLAY (display), NULL);
-
- return GDK_MIR_DISPLAY (display)->event_source;
-}
-
-static void
-gdk_mir_display_dispose (GObject *object)
-{
- GdkMirDisplay *display = GDK_MIR_DISPLAY (object);
-
- g_clear_pointer (&display->paste_data, g_variant_unref);
- g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (display->content_handler));
- g_clear_object (&display->content_handler);
- g_clear_object (&display->content_service);
- g_clear_object (&display->screen);
- g_clear_object (&display->keymap);
- g_clear_pointer (&display->event_source, g_source_unref);
-
- G_OBJECT_CLASS (gdk_mir_display_parent_class)->dispose (object);
-}
-
-static void
-gdk_mir_display_finalize (GObject *object)
-{
- GdkMirDisplay *display = GDK_MIR_DISPLAY (object);
-
- mir_connection_release (display->connection);
-
- G_OBJECT_CLASS (gdk_mir_display_parent_class)->finalize (object);
-}
-
-static const gchar *
-gdk_mir_display_get_name (GdkDisplay *display)
-{
- return "Mir";
-}
-
-static GdkScreen *
-gdk_mir_display_get_default_screen (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->screen;
-}
-
-static void
-gdk_mir_display_beep (GdkDisplay *display)
-{
- /* No system level beep... */
-}
-
-static void
-gdk_mir_display_sync (GdkDisplay *display)
-{
-}
-
-static void
-gdk_mir_display_flush (GdkDisplay *display)
-{
-}
-
-static gboolean
-gdk_mir_display_has_pending (GdkDisplay *display)
-{
- /* We don't need to poll for events - so nothing pending */
- return FALSE;
-}
-
-static void
-gdk_mir_display_queue_events (GdkDisplay *display)
-{
- /* We don't need to poll for events - so don't do anything*/
-}
-
-static void
-gdk_mir_display_make_default (GdkDisplay *display)
-{
-}
-
-static GdkWindow *
-gdk_mir_display_get_default_group (GdkDisplay *display)
-{
- return NULL;
-}
-
-static gboolean
-gdk_mir_display_supports_shapes (GdkDisplay *display)
-{
- /* Mir doesn't support shaped windows */
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_input_shapes (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_composite (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_clipboard_persistence (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_cursor_alpha (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_cursor_color (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_supports_selection_notification (GdkDisplay *display)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_display_request_selection_notification (GdkDisplay *display,
- GdkAtom selection)
-{
- return FALSE;
-}
-
-static void
-gdk_mir_display_store_clipboard (GdkDisplay *display,
- GdkWindow *clipboard_window,
- guint32 time_,
- const GdkAtom *targets,
- gint n_targets)
-{
-}
-
-static void
-gdk_mir_display_get_default_cursor_size (GdkDisplay *display,
- guint *width,
- guint *height)
-{
- *width = *height = 32; // FIXME: Random value
-}
-
-static void
-gdk_mir_display_get_maximal_cursor_size (GdkDisplay *display,
- guint *width,
- guint *height)
-{
- *width = *height = 32; // FIXME: Random value
-}
-
-static GdkCursor *
-gdk_mir_display_get_cursor_for_type (GdkDisplay *display,
- GdkCursorType cursor_type)
-{
- return _gdk_mir_cursor_new_for_type (display, cursor_type);
-}
-
-static GdkCursor *
-gdk_mir_display_get_cursor_for_name (GdkDisplay *display,
- const gchar *name)
-{
- return _gdk_mir_cursor_new_for_name (display, name);
-}
-
-static GdkCursor *
-gdk_mir_display_get_cursor_for_surface (GdkDisplay *display,
- cairo_surface_t *surface,
- gdouble x,
- gdouble y)
-{
- return NULL;
-}
-
-static GdkAppLaunchContext *
-gdk_mir_display_get_app_launch_context (GdkDisplay *display)
-{
- return NULL;
-}
-
-static void
-gdk_mir_display_before_process_all_updates (GdkDisplay *display)
-{
-}
-
-static void
-gdk_mir_display_after_process_all_updates (GdkDisplay *display)
-{
-}
-
-static gulong
-gdk_mir_display_get_next_serial (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->serial++;
-}
-
-static void
-gdk_mir_display_notify_startup_complete (GdkDisplay *display,
- const gchar *startup_id)
-{
-}
-
-static void
-gdk_mir_display_create_window_impl (GdkDisplay *display,
- GdkWindow *window,
- GdkWindow *real_parent,
- GdkScreen *screen,
- GdkEventMask event_mask,
- GdkWindowAttr *attributes,
- gint attributes_mask)
-{
- if (attributes->wclass == GDK_INPUT_OUTPUT)
- {
- window->impl = _gdk_mir_window_impl_new (display, window, attributes, attributes_mask);
- window->impl_window = window;
- }
- else /* attributes->wclass == GDK_INPUT_ONLY */
- {
- window->impl = g_object_ref (real_parent->impl);
- window->impl_window = real_parent;
-
- /* FIXME: this is called in gdk_window_new, which sets window->impl_window
- * back to window after this function returns. */
- }
-}
-
-static GdkKeymap *
-gdk_mir_display_get_keymap (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->keymap;
-}
-
-static void
-gdk_mir_display_push_error_trap (GdkDisplay *display)
-{
-}
-
-static gint
-gdk_mir_display_pop_error_trap (GdkDisplay *display,
- gboolean ignored)
-{
- return 0;
-}
-
-static GdkWindow *
-gdk_mir_display_get_selection_owner (GdkDisplay *display,
- GdkAtom selection)
-{
- return NULL;
-}
-
-static gboolean
-gdk_mir_display_set_selection_owner (GdkDisplay *display,
- GdkWindow *owner,
- GdkAtom selection,
- guint32 time,
- gboolean send_event)
-{
- GdkEvent *event;
-
- if (selection == GDK_SELECTION_CLIPBOARD)
- {
- if (owner)
- {
- event = gdk_event_new (GDK_SELECTION_REQUEST);
- event->selection.window = g_object_ref (owner);
- event->selection.send_event = FALSE;
- event->selection.selection = selection;
- event->selection.target = gdk_atom_intern_static_string ("TARGETS");
- event->selection.property = gdk_atom_intern_static_string ("AVAILABLE_TARGETS");
- event->selection.time = GDK_CURRENT_TIME;
- event->selection.requestor = g_object_ref (owner);
-
- gdk_event_put (event);
- gdk_event_free (event);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-gdk_mir_display_send_selection_notify (GdkDisplay *display,
- GdkWindow *requestor,
- GdkAtom selection,
- GdkAtom target,
- GdkAtom property,
- guint32 time)
-{
-}
-
-static gint
-gdk_mir_display_get_selection_property (GdkDisplay *display,
- GdkWindow *requestor,
- guchar **data,
- GdkAtom *ret_type,
- gint *ret_format)
-{
- gint length;
-
- gdk_property_get (requestor,
- gdk_atom_intern_static_string ("GDK_SELECTION"),
- GDK_NONE,
- 0,
- G_MAXULONG,
- FALSE,
- ret_type,
- ret_format,
- &length,
- data);
-
- return length;
-}
-
-static gint
-get_format_score (const gchar *format,
- GdkAtom target,
- GdkAtom *out_type,
- gint *out_size)
-{
- const gchar *target_string;
- GdkAtom dummy_type;
- gint dummy_size;
-
- target_string = _gdk_atom_name_const (target);
-
- if (!out_type)
- out_type = &dummy_type;
-
- if (!out_size)
- out_size = &dummy_size;
-
- if (!g_ascii_strcasecmp (format, target_string))
- {
- *out_type = GDK_SELECTION_TYPE_STRING;
- *out_size = sizeof (guchar);
-
- return G_MAXINT;
- }
-
- if (target == gdk_atom_intern_static_string ("UTF8_STRING"))
- return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
-
- /* TODO: use best media type for COMPOUND_TEXT target */
- if (target == gdk_atom_intern_static_string ("COMPOUND_TEXT"))
- return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
-
- if (target == GDK_TARGET_STRING)
- return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=iso-8859-1"), out_type, out_size);
-
- if (target == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
- return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
-
- if (g_content_type_is_a (format, target_string))
- {
- *out_type = GDK_SELECTION_TYPE_STRING;
- *out_size = sizeof (guchar);
-
- return 2;
- }
-
- if (g_content_type_is_a (target_string, format))
- {
- *out_type = GDK_SELECTION_TYPE_STRING;
- *out_size = sizeof (guchar);
-
- return 1;
- }
-
- return 0;
-}
-
-static gint
-get_best_format_index (const gchar * const *formats,
- guint n_formats,
- GdkAtom target,
- GdkAtom *out_type,
- gint *out_size)
-{
- gint best_i = -1;
- gint best_score = 0;
- GdkAtom best_type;
- gint best_size;
- gint score;
- GdkAtom type;
- gint size;
- gint i;
-
- if (!out_type)
- out_type = &best_type;
-
- if (!out_size)
- out_size = &best_size;
-
- *out_type = GDK_NONE;
- *out_size = 0;
-
- for (i = 0; i < n_formats; i++)
- {
- score = get_format_score (formats[i], target, &type, &size);
-
- if (score > best_score)
- {
- best_i = i;
- best_score = score;
- *out_type = type;
- *out_size = size;
- }
- }
-
- return best_i;
-}
-
-static void
-gdk_mir_display_real_convert_selection (GdkDisplay *display,
- GdkWindow *requestor,
- GdkAtom selection,
- GdkAtom target,
- guint32 time)
-{
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
- const gchar *paste_data;
- gsize paste_size;
- const gint *paste_header;
- GPtrArray *paste_formats;
- GArray *paste_targets;
- GdkAtom paste_target;
- GdkEvent *event;
- gint best_i;
- GdkAtom best_type;
- gint best_size;
- gint i;
-
- g_return_if_fail (mir_display->paste_data);
-
- paste_data = g_variant_get_fixed_array (mir_display->paste_data, &paste_size, sizeof (guchar));
- paste_header = (const gint *) paste_data;
-
- if (paste_data)
- {
- paste_formats = g_ptr_array_new_full (paste_header[0], g_free);
-
- for (i = 0; i < paste_header[0]; i++)
- g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * i]));
- }
- else
- paste_formats = g_ptr_array_new_with_free_func (g_free);
-
- if (target == gdk_atom_intern_static_string ("TARGETS"))
- {
- paste_targets = g_array_sized_new (TRUE, FALSE, sizeof (GdkAtom), paste_formats->len);
-
- for (i = 0; i < paste_formats->len; i++)
- {
- paste_target = gdk_atom_intern (g_ptr_array_index (paste_formats, i), FALSE);
- g_array_append_val (paste_targets, paste_target);
- }
-
- gdk_property_change (requestor,
- gdk_atom_intern_static_string ("GDK_SELECTION"),
- GDK_SELECTION_TYPE_ATOM,
- 8 * sizeof (GdkAtom),
- GDK_PROP_MODE_REPLACE,
- (const guchar *) paste_targets->data,
- paste_targets->len);
-
- g_array_unref (paste_targets);
-
- event = gdk_event_new (GDK_SELECTION_NOTIFY);
- event->selection.window = g_object_ref (requestor);
- event->selection.send_event = FALSE;
- event->selection.selection = selection;
- event->selection.target = target;
- event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION");
- event->selection.time = time;
- event->selection.requestor = g_object_ref (requestor);
-
- gdk_event_put (event);
- gdk_event_free (event);
- }
- else
- {
- best_i = get_best_format_index ((const gchar * const *) paste_formats->pdata,
- paste_formats->len,
- target,
- &best_type,
- &best_size);
-
- if (best_i >= 0)
- {
- gdk_property_change (requestor,
- gdk_atom_intern_static_string ("GDK_SELECTION"),
- best_type,
- 8 * best_size,
- GDK_PROP_MODE_REPLACE,
- (const guchar *) paste_data + paste_header[3 + 4 * best_i],
- paste_header[4 + 4 * best_i] / best_size);
-
- event = gdk_event_new (GDK_SELECTION_NOTIFY);
- event->selection.window = g_object_ref (requestor);
- event->selection.send_event = FALSE;
- event->selection.selection = selection;
- event->selection.target = target;
- event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION");
- event->selection.time = time;
- event->selection.requestor = g_object_ref (requestor);
-
- gdk_event_put (event);
- gdk_event_free (event);
- }
- }
-
- g_ptr_array_unref (paste_formats);
-}
-
-typedef struct
-{
- GdkDisplay *display;
- GdkWindow *requestor;
- GdkAtom selection;
- GdkAtom target;
- guint32 time;
-} ConvertInfo;
-
-static void
-paste_data_ready_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- ContentHubService *content_service = CONTENT_HUB_SERVICE (source_object);
- ConvertInfo *info = user_data;
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (info->display);
- gboolean result;
-
- g_clear_pointer (&mir_display->paste_data, g_variant_unref);
-
- result = content_hub_service_call_get_latest_paste_data_finish (content_service,
- &mir_display->paste_data,
- res,
- NULL);
-
- if (result)
- gdk_mir_display_real_convert_selection (info->display,
- info->requestor,
- info->selection,
- info->target,
- info->time);
-
- g_object_unref (info->requestor);
- g_object_unref (info->display);
- g_free (info);
-}
-
-static void
-gdk_mir_display_convert_selection (GdkDisplay *display,
- GdkWindow *requestor,
- GdkAtom selection,
- GdkAtom target,
- guint32 time)
-{
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
- MirWindow *mir_window;
- MirWindowId *mir_window_id;
- ConvertInfo *info;
-
- if (selection != GDK_SELECTION_CLIPBOARD)
- return;
- else if (mir_display->paste_data)
- gdk_mir_display_real_convert_selection (display, requestor, selection, target, time);
- else if (mir_display->focused_window)
- {
- mir_window = _gdk_mir_window_get_mir_window (mir_display->focused_window);
-
- if (!mir_window)
- return;
-
- mir_window_id = mir_window_request_window_id_sync (mir_window);
-
- if (!mir_window_id)
- return;
-
- if (mir_window_id_is_valid (mir_window_id))
- {
- info = g_new (ConvertInfo, 1);
- info->display = g_object_ref (display);
- info->requestor = g_object_ref (requestor);
- info->selection = selection;
- info->target = target;
- info->time = time;
-
- content_hub_service_call_get_latest_paste_data (
- mir_display->content_service,
- mir_window_id_as_string (mir_window_id),
- NULL,
- paste_data_ready_cb,
- info);
- }
-
- mir_window_id_release (mir_window_id);
- }
-}
-
-static gint
-gdk_mir_display_text_property_to_utf8_list (GdkDisplay *display,
- GdkAtom encoding,
- gint format,
- const guchar *text,
- gint length,
- gchar ***list)
-{
- GPtrArray *array;
- const gchar *ptr;
- gsize chunk_len;
- gchar *copy;
- guint nitems;
-
- ptr = (const gchar *) text;
- array = g_ptr_array_new ();
-
- /* split text into utf-8 strings */
- while (ptr < (const gchar *) &text[length])
- {
- chunk_len = strlen (ptr);
-
- if (g_utf8_validate (ptr, chunk_len, NULL))
- {
- copy = g_strndup (ptr, chunk_len);
- g_ptr_array_add (array, copy);
- }
-
- ptr = &ptr[chunk_len + 1];
- }
-
- nitems = array->len;
- g_ptr_array_add (array, NULL);
-
- if (list)
- *list = (gchar **) g_ptr_array_free (array, FALSE);
- else
- g_ptr_array_free (array, TRUE);
-
- return nitems;
-}
-
-static gchar *
-gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
- const gchar *str)
-{
- return NULL;
-}
-
-static void
-get_pixel_formats (MirConnection *connection,
- MirPixelFormat *sw_pixel_format,
- MirPixelFormat *hw_pixel_format)
-{
- MirPixelFormat formats[mir_pixel_formats];
- unsigned int n_formats, i;
-
- mir_connection_get_available_surface_formats (connection, formats,
- mir_pixel_formats, &n_formats);
-
- if (sw_pixel_format)
- {
- *sw_pixel_format = mir_pixel_format_invalid;
-
- for (i = 0; i < n_formats && *sw_pixel_format == mir_pixel_format_invalid; i++)
- {
- switch (formats[i])
- {
- case mir_pixel_format_abgr_8888:
- case mir_pixel_format_xbgr_8888:
- case mir_pixel_format_argb_8888:
- case mir_pixel_format_xrgb_8888:
- case mir_pixel_format_rgb_565:
- *sw_pixel_format = formats[i];
- break;
- default:
- break;
- }
- }
- }
-
- if (hw_pixel_format)
- {
- *hw_pixel_format = mir_pixel_format_invalid;
-
- for (i = 0; i < n_formats && *hw_pixel_format == mir_pixel_format_invalid; i++)
- {
- switch (formats[i])
- {
- case mir_pixel_format_abgr_8888:
- case mir_pixel_format_xbgr_8888:
- case mir_pixel_format_argb_8888:
- case mir_pixel_format_xrgb_8888:
- case mir_pixel_format_rgb_565:
- *hw_pixel_format = formats[i];
- break;
- default:
- break;
- }
- }
- }
-}
-
-MirPixelFormat
-_gdk_mir_display_get_pixel_format (GdkDisplay *display,
- MirBufferUsage usage)
-{
- GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
-
- if (usage == mir_buffer_usage_hardware)
- return mir_dpy->hw_pixel_format;
-
- return mir_dpy->sw_pixel_format;
-}
-
-void
-_gdk_mir_display_focus_window (GdkDisplay *display,
- GdkWindow *window)
-{
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
-
- g_set_object (&mir_display->focused_window, window);
-}
-
-void
-_gdk_mir_display_unfocus_window (GdkDisplay *display,
- GdkWindow *window)
-{
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
-
- if (window == mir_display->focused_window)
- g_clear_object (&mir_display->focused_window);
-}
-
-void
-_gdk_mir_display_create_paste (GdkDisplay *display,
- const gchar * const *paste_formats,
- gconstpointer paste_data,
- gsize paste_size)
-{
- GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
- MirWindow *mir_window;
- MirWindowId *mir_window_id;
-
- if (!mir_display->focused_window)
- return;
-
- mir_window = _gdk_mir_window_get_mir_window (mir_display->focused_window);
-
- if (!mir_window)
- return;
-
- mir_window_id = mir_window_request_window_id_sync (mir_window);
-
- if (!mir_window_id)
- return;
-
- if (mir_window_id_is_valid (mir_window_id))
- content_hub_service_call_create_paste_sync (
- mir_display->content_service,
- g_application_get_application_id (g_application_get_default ()),
- mir_window_id_as_string (mir_window_id),
- g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, paste_data, paste_size, sizeof (guchar)),
- paste_formats,
- NULL,
- NULL,
- NULL);
-
- mir_window_id_release (mir_window_id);
-}
-
-gboolean
-_gdk_mir_display_init_egl_display (GdkDisplay *display)
-{
- GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
- EGLint major_version, minor_version;
- EGLDisplay *dpy;
-
- if (mir_dpy->egl_display)
- return TRUE;
-
- dpy = eglGetDisplay (mir_connection_get_egl_native_display (mir_dpy->connection));
- if (dpy == NULL)
- return FALSE;
-
- if (!eglInitialize (dpy, &major_version, &minor_version))
- return FALSE;
-
- if (!eglBindAPI (EGL_OPENGL_API))
- return FALSE;
-
- mir_dpy->egl_display = dpy;
-
- mir_dpy->have_egl_khr_create_context =
- epoxy_has_egl_extension (dpy, "EGL_KHR_create_context");
-
- mir_dpy->have_egl_buffer_age =
- epoxy_has_egl_extension (dpy, "EGL_EXT_buffer_age");
-
- mir_dpy->have_egl_swap_buffers_with_damage =
- epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage");
-
- mir_dpy->have_egl_surfaceless_context =
- epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context");
-
- GDK_NOTE (OPENGL,
- g_print ("EGL API version %d.%d found\n"
- " - Vendor: %s\n"
- " - Version: %s\n"
- " - Client APIs: %s\n"
- " - Extensions:\n"
- "\t%s\n",
- major_version,
- minor_version,
- eglQueryString (dpy, EGL_VENDOR),
- eglQueryString (dpy, EGL_VERSION),
- eglQueryString (dpy, EGL_CLIENT_APIS),
- eglQueryString (dpy, EGL_EXTENSIONS)));
-
- return TRUE;
-}
-
-static gboolean
-gdk_mir_display_make_gl_context_current (GdkDisplay *display,
- GdkGLContext *context)
-{
- EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
- GdkMirGLContext *mir_context;
- GdkWindow *window;
- EGLSurface egl_surface;
-
- if (context == NULL)
- {
- eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- return TRUE;
- }
-
- mir_context = GDK_MIR_GL_CONTEXT (context);
- window = gdk_gl_context_get_window (context);
-
- if (mir_context->is_attached)
- {
- egl_surface = _gdk_mir_window_get_egl_surface (window,
- mir_context->egl_config);
- }
- else
- {
- if (_gdk_mir_display_have_egl_surfaceless_context (display))
- egl_surface = EGL_NO_SURFACE;
- else
- egl_surface = _gdk_mir_window_get_dummy_egl_surface (window,
- mir_context->egl_config);
- }
-
- if (!eglMakeCurrent (egl_display, egl_surface, egl_surface, mir_context->egl_context))
- {
- g_warning ("eglMakeCurrent failed");
- return FALSE;
- }
-
- return TRUE;
-}
-
-EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->egl_display;
-}
-
-gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->have_egl_khr_create_context;
-}
-
-gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display)
-{
- /* FIXME: this is not really supported by mir yet (despite is advertised) */
- // return GDK_MIR_DISPLAY (display)->have_egl_buffer_age;
- return FALSE;
-}
-
-gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display)
-{
- /* FIXME: this is not really supported by mir yet (despite is advertised) */
- // return GDK_MIR_DISPLAY (display)->have_egl_swap_buffers_with_damage;
- return FALSE;
-}
-
-gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display)
-{
- return GDK_MIR_DISPLAY (display)->have_egl_surfaceless_context;
-}
-
-
-static void
-gdk_mir_display_init (GdkMirDisplay *display)
-{
- display->event_source = _gdk_mir_event_source_new (GDK_DISPLAY (display));
- display->keymap = _gdk_mir_keymap_new ();
-}
-
-static void
-gdk_mir_display_class_init (GdkMirDisplayClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (klass);
-
- object_class->dispose = gdk_mir_display_dispose;
- object_class->finalize = gdk_mir_display_finalize;
-
- display_class->window_type = gdk_mir_window_get_type ();
-
- display_class->get_name = gdk_mir_display_get_name;
- display_class->get_default_screen = gdk_mir_display_get_default_screen;
- display_class->beep = gdk_mir_display_beep;
- display_class->sync = gdk_mir_display_sync;
- display_class->flush = gdk_mir_display_flush;
- display_class->has_pending = gdk_mir_display_has_pending;
- display_class->queue_events = gdk_mir_display_queue_events;
- display_class->make_default = gdk_mir_display_make_default;
- display_class->get_default_group = gdk_mir_display_get_default_group;
- display_class->supports_shapes = gdk_mir_display_supports_shapes;
- display_class->supports_input_shapes = gdk_mir_display_supports_input_shapes;
- display_class->supports_composite = gdk_mir_display_supports_composite;
- display_class->supports_clipboard_persistence = gdk_mir_display_supports_clipboard_persistence;
- display_class->supports_cursor_alpha = gdk_mir_display_supports_cursor_alpha;
- display_class->supports_cursor_color = gdk_mir_display_supports_cursor_color;
- display_class->supports_selection_notification = gdk_mir_display_supports_selection_notification;
- display_class->request_selection_notification = gdk_mir_display_request_selection_notification;
- display_class->store_clipboard = gdk_mir_display_store_clipboard;
- display_class->get_default_cursor_size = gdk_mir_display_get_default_cursor_size;
- display_class->get_maximal_cursor_size = gdk_mir_display_get_maximal_cursor_size;
- display_class->get_cursor_for_type = gdk_mir_display_get_cursor_for_type;
- display_class->get_cursor_for_name = gdk_mir_display_get_cursor_for_name;
- display_class->get_cursor_for_surface = gdk_mir_display_get_cursor_for_surface;
- display_class->get_app_launch_context = gdk_mir_display_get_app_launch_context;
- display_class->before_process_all_updates = gdk_mir_display_before_process_all_updates;
- display_class->after_process_all_updates = gdk_mir_display_after_process_all_updates;
- display_class->get_next_serial = gdk_mir_display_get_next_serial;
- display_class->notify_startup_complete = gdk_mir_display_notify_startup_complete;
- display_class->create_window_impl = gdk_mir_display_create_window_impl;
- display_class->get_keymap = gdk_mir_display_get_keymap;
- display_class->push_error_trap = gdk_mir_display_push_error_trap;
- display_class->pop_error_trap = gdk_mir_display_pop_error_trap;
- display_class->get_selection_owner = gdk_mir_display_get_selection_owner;
- display_class->set_selection_owner = gdk_mir_display_set_selection_owner;
- display_class->send_selection_notify = gdk_mir_display_send_selection_notify;
- display_class->get_selection_property = gdk_mir_display_get_selection_property;
- display_class->convert_selection = gdk_mir_display_convert_selection;
- display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
- display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
- display_class->make_gl_context_current = gdk_mir_display_make_gl_context_current;
-}
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c
deleted file mode 100644
index ea0cc52819..0000000000
--- a/gdk/mir/gdkmireventsource.c
+++ /dev/null
@@ -1,838 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkinternals.h"
-#include "gdkdisplayprivate.h"
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-#include <mir_toolkit/events/window_placement.h>
-
-#define NANO_TO_MILLI(x) ((x) / 1000000)
-
-struct _GdkMirWindowReference {
- GdkMirEventSource *source;
- GdkWindow *window;
- gint ref_count;
-};
-
-typedef struct {
- GdkMirWindowReference *window_ref;
- const MirEvent *event;
-} GdkMirQueuedEvent;
-
-struct _GdkMirEventSource
-{
- GSource parent_instance;
-
- GMutex mir_event_lock;
- GQueue mir_events;
- gboolean log_events;
-
- GdkDisplay *display;
-};
-
-static void
-send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
-{
- GdkDisplay *display;
- GList *node;
-
- gdk_event_set_device (event, device);
- gdk_event_set_source_device (event, device);
- gdk_event_set_screen (event, gdk_display_get_default_screen (gdk_window_get_display (window)));
- event->any.window = g_object_ref (window);
-
- display = gdk_window_get_display (window);
- node = _gdk_event_queue_append (display, event);
- _gdk_windowing_got_event (display, node, event, _gdk_display_get_next_serial (display));
-}
-
-static void
-set_key_event_string (GdkEventKey *event)
-{
- gunichar c = 0;
-
- if (event->keyval != GDK_KEY_VoidSymbol)
- c = gdk_keyval_to_unicode (event->keyval);
-
- if (c)
- {
- gchar buf[7];
- gint len;
- gsize bytes_written;
-
- /* Apply the control key - Taken from Xlib
- */
- if (event->state & GDK_CONTROL_MASK)
- {
- if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
- else if (c == '2')
- {
- event->string = g_memdup ("\0\0", 2);
- event->length = 1;
- buf[0] = '\0';
- return;
- }
- else if (c >= '3' && c <= '7') c -= ('3' - '\033');
- else if (c == '8') c = '\177';
- else if (c == '/') c = '_' & 0x1F;
- }
-
- len = g_unichar_to_utf8 (c, buf);
- buf[len] = '\0';
-
- event->string = g_locale_from_utf8 (buf, len,
- NULL, &bytes_written,
- NULL);
- if (event->string)
- event->length = bytes_written;
- }
- else if (event->keyval == GDK_KEY_Escape)
- {
- event->length = 1;
- event->string = g_strdup ("\033");
- }
- else if (event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter)
- {
- event->length = 1;
- event->string = g_strdup ("\r");
- }
-
- if (!event->string)
- {
- event->length = 0;
- event->string = g_strdup ("");
- }
-}
-
-static void
-generate_key_event (GdkWindow *window, GdkEventType type, guint state, guint keyval, guint16 keycode, gboolean is_modifier, guint32 event_time)
-{
- GdkEvent *event;
- GdkDisplay *display;
- GdkSeat *seat;
- GdkDevice *keyboard;
-
- event = gdk_event_new (type);
- event->key.state = state;
- event->key.keyval = keyval;
- event->key.hardware_keycode = keycode + 8;
- gdk_event_set_scancode (event, keycode + 8);
- event->key.is_modifier = is_modifier;
- event->key.time = event_time;
- set_key_event_string (&event->key);
-
- display = gdk_window_get_display (window);
- seat = gdk_display_get_default_seat (display);
- keyboard = gdk_seat_get_keyboard (seat);
-
- send_event (window, keyboard, event);
-}
-
-static GdkDevice *
-get_pointer (GdkWindow *window)
-{
- GdkDisplay *display;
- GdkSeat *seat;
- GdkDevice *pointer;
-
- display = gdk_window_get_display (window);
- seat = gdk_display_get_default_seat (display);
- pointer = gdk_seat_get_pointer (seat);
-
- return pointer;
-}
-
-static void
-generate_button_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble y, guint button, guint state, guint32 event_time)
-{
- GdkEvent *event;
-
- event = gdk_event_new (type);
- event->button.x = x;
- event->button.y = y;
- event->button.state = state;
- event->button.button = button;
- event->button.time = event_time;
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-generate_scroll_event (GdkWindow *window, gdouble x, gdouble y, gdouble delta_x, gdouble delta_y, guint state, guint32 event_time)
-{
- GdkEvent *event;
-
- event = gdk_event_new (GDK_SCROLL);
- event->scroll.x = x;
- event->scroll.y = y;
- event->scroll.state = state;
- event->scroll.time = event_time;
-
- if (ABS (delta_x) == 1 && delta_y == 0)
- {
- event->scroll.direction = (delta_x < 0) ? GDK_SCROLL_LEFT : GDK_SCROLL_RIGHT;
- }
- else if (ABS (delta_y) == 1 && delta_x == 0)
- {
- event->scroll.direction = (delta_y < 0) ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;
- }
- else
- {
- event->scroll.direction = GDK_SCROLL_SMOOTH;
- event->scroll.delta_x = delta_x;
- event->scroll.delta_y = -delta_y;
- }
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-generate_motion_event (GdkWindow *window, gdouble x, gdouble y, guint state, guint32 event_time)
-{
- GdkEvent *event;
-
- event = gdk_event_new (GDK_MOTION_NOTIFY);
- event->motion.x = x;
- event->motion.y = y;
- event->motion.state = state;
- event->motion.is_hint = FALSE;
- event->motion.time = event_time;
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-generate_crossing_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble y, guint32 event_time)
-{
- GdkEvent *event;
-
- event = gdk_event_new (type);
- event->crossing.x = x;
- event->crossing.y = y;
- event->crossing.mode = GDK_CROSSING_NORMAL;
- event->crossing.detail = GDK_NOTIFY_ANCESTOR;
- event->crossing.focus = TRUE;
- event->crossing.time = event_time;
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-generate_focus_event (GdkWindow *window, gboolean focused)
-{
- GdkEvent *event;
-
- if (focused)
- {
- gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
- _gdk_mir_display_focus_window (gdk_window_get_display (window), window);
- }
- else
- {
- gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
- _gdk_mir_display_unfocus_window (gdk_window_get_display (window), window);
- }
-
- event = gdk_event_new (GDK_FOCUS_CHANGE);
- event->focus_change.send_event = FALSE;
- event->focus_change.in = focused;
-
- send_event (window, get_pointer (window), event);
-}
-
-static guint
-get_modifier_state (unsigned int modifiers, guint button_state)
-{
- guint modifier_state = button_state;
-
- if ((modifiers & (mir_input_event_modifier_alt |
- mir_input_event_modifier_alt_left |
- mir_input_event_modifier_alt_right)) != 0)
- modifier_state |= GDK_MOD1_MASK;
- if ((modifiers & (mir_input_event_modifier_shift |
- mir_input_event_modifier_shift_left |
- mir_input_event_modifier_shift_right)) != 0)
- modifier_state |= GDK_SHIFT_MASK;
- if ((modifiers & (mir_input_event_modifier_ctrl |
- mir_input_event_modifier_ctrl_left |
- mir_input_event_modifier_ctrl_right)) != 0)
- modifier_state |= GDK_CONTROL_MASK;
- if ((modifiers & (mir_input_event_modifier_meta |
- mir_input_event_modifier_meta_left |
- mir_input_event_modifier_meta_right)) != 0)
- modifier_state |= GDK_META_MASK;
- if ((modifiers & mir_input_event_modifier_caps_lock) != 0)
- modifier_state |= GDK_LOCK_MASK;
-
- return modifier_state;
-}
-
-static void
-handle_key_event (GdkWindow *window, const MirInputEvent *event)
-{
- const MirKeyboardEvent *keyboard_event = mir_input_event_get_keyboard_event (event);
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkKeymap *keymap;
- guint modifier_state;
- guint button_state;
-
- if (!keyboard_event)
- return;
-
- _gdk_mir_window_impl_get_cursor_state (impl, NULL, NULL, NULL, &button_state);
- modifier_state = get_modifier_state (mir_keyboard_event_modifiers (keyboard_event), button_state);
- keymap = gdk_keymap_get_for_display (gdk_window_get_display (window));
-
- generate_key_event (window,
- mir_keyboard_event_action (keyboard_event) == mir_keyboard_action_up ? GDK_KEY_RELEASE : GDK_KEY_PRESS,
- modifier_state,
- mir_keyboard_event_key_code (keyboard_event),
- mir_keyboard_event_scan_code (keyboard_event),
- _gdk_mir_keymap_key_is_modifier (keymap, mir_keyboard_event_key_code (keyboard_event)),
- NANO_TO_MILLI (mir_input_event_get_event_time (event)));
-}
-
-static void
-handle_touch_event (GdkWindow *window,
- const MirTouchEvent *mir_touch_event)
-{
- const MirInputEvent *mir_input_event = mir_touch_event_input_event (mir_touch_event);
- guint n = mir_touch_event_point_count (mir_touch_event);
- GdkEvent *gdk_event;
- guint i;
-
- for (i = 0; i < n; i++)
- {
- MirTouchAction action = mir_touch_event_action (mir_touch_event, i);
- if (action == mir_touch_action_up)
- gdk_event = gdk_event_new (GDK_TOUCH_END);
- else if (action == mir_touch_action_down)
- gdk_event = gdk_event_new (GDK_TOUCH_BEGIN);
- else
- gdk_event = gdk_event_new (GDK_TOUCH_UPDATE);
-
- gdk_event->touch.window = window;
- gdk_event->touch.sequence = GINT_TO_POINTER (mir_touch_event_id (mir_touch_event, i));
- gdk_event->touch.time = mir_input_event_get_event_time (mir_input_event);
- gdk_event->touch.state = get_modifier_state (mir_touch_event_modifiers (mir_touch_event), 0);
- gdk_event->touch.x = mir_touch_event_axis_value (mir_touch_event, i, mir_touch_axis_x);
- gdk_event->touch.y = mir_touch_event_axis_value (mir_touch_event, i, mir_touch_axis_y);
- gdk_event->touch.x_root = mir_touch_event_axis_value (mir_touch_event, i, mir_touch_axis_x);
- gdk_event->touch.y_root = mir_touch_event_axis_value (mir_touch_event, i, mir_touch_axis_y);
- gdk_event->touch.emulating_pointer = TRUE;
- gdk_event_set_pointer_emulated (gdk_event, TRUE);
-
- send_event (window, get_pointer (window), gdk_event);
- }
-}
-
-static guint
-get_button_state (const MirPointerEvent *event)
-{
- guint state = 0;
-
- if (mir_pointer_event_button_state (event, mir_pointer_button_primary)) /* left */
- state |= GDK_BUTTON1_MASK;
- if (mir_pointer_event_button_state (event, mir_pointer_button_secondary)) /* right */
- state |= GDK_BUTTON3_MASK;
- if (mir_pointer_event_button_state (event, mir_pointer_button_tertiary)) /* middle */
- state |= GDK_BUTTON2_MASK;
-
- return state;
-}
-
-static void
-handle_motion_event (GdkWindow *window, const MirInputEvent *event)
-{
- const MirPointerEvent *pointer_event = mir_input_event_get_pointer_event (event);
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- gdouble x, y;
- gboolean cursor_inside;
- guint button_state;
- guint new_button_state;
- guint modifier_state;
- guint32 event_time;
- GdkEventType event_type;
- guint changed_button_state;
-
- if (!pointer_event)
- return;
-
- _gdk_mir_window_impl_get_cursor_state (impl, &x, &y, &cursor_inside, &button_state);
- new_button_state = get_button_state (pointer_event);
- modifier_state = get_modifier_state (mir_pointer_event_modifiers (pointer_event), new_button_state);
- event_time = NANO_TO_MILLI (mir_input_event_get_event_time (event));
-
- if (window)
- {
- gdouble new_x;
- gdouble new_y;
- gdouble hscroll;
- gdouble vscroll;
-
- /* Update which window has focus */
- _gdk_mir_pointer_set_location (get_pointer (window), x, y, window, modifier_state);
- switch (mir_pointer_event_action (pointer_event))
- {
- case mir_pointer_action_button_up:
- case mir_pointer_action_button_down:
- event_type = mir_pointer_event_action (pointer_event) == mir_pointer_action_button_down ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
- changed_button_state = button_state ^ new_button_state;
- if (changed_button_state == 0 || (changed_button_state & GDK_BUTTON1_MASK) != 0)
- generate_button_event (window, event_type, x, y, GDK_BUTTON_PRIMARY, modifier_state, event_time);
- if ((changed_button_state & GDK_BUTTON2_MASK) != 0)
- generate_button_event (window, event_type, x, y, GDK_BUTTON_MIDDLE, modifier_state, event_time);
- if ((changed_button_state & GDK_BUTTON3_MASK) != 0)
- generate_button_event (window, event_type, x, y, GDK_BUTTON_SECONDARY, modifier_state, event_time);
- button_state = new_button_state;
- break;
- case mir_pointer_action_motion:
- new_x = mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_x);
- new_y = mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_y);
- hscroll = mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_hscroll);
- vscroll = mir_pointer_event_axis_value (pointer_event, mir_pointer_axis_vscroll);
-
- if (hscroll != 0.0 || vscroll != 0.0)
- generate_scroll_event (window, x, y, hscroll, vscroll, modifier_state, event_time);
- if (ABS (new_x - x) > 0.5 || ABS (new_y - y) > 0.5)
- {
- generate_motion_event (window, new_x, new_y, modifier_state, event_time);
- x = new_x;
- y = new_y;
- }
-
- break;
- case mir_pointer_action_enter:
- if (!cursor_inside)
- {
- cursor_inside = TRUE;
- generate_crossing_event (window, GDK_ENTER_NOTIFY, x, y, event_time);
- }
- break;
- case mir_pointer_action_leave:
- if (cursor_inside)
- {
- cursor_inside = FALSE;
- generate_crossing_event (window, GDK_LEAVE_NOTIFY, x, y, event_time);
- }
- break;
- default:
- break;
- }
-
- _gdk_mir_window_impl_set_cursor_state (impl, x, y, cursor_inside, button_state);
- }
-}
-
-static void
-handle_window_event (GdkWindow *window,
- const MirWindowEvent *event)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirWindowState state;
-
- switch (mir_window_event_get_attribute (event))
- {
- case mir_window_attrib_type:
- _gdk_mir_window_impl_set_window_type (impl, mir_window_event_get_attribute_value (event));
- break;
- case mir_window_attrib_state:
- state = mir_window_event_get_attribute_value (event);
- _gdk_mir_window_impl_set_window_state (impl, state);
-
- switch (state)
- {
- case mir_window_state_restored:
- case mir_window_state_hidden:
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_ICONIFIED |
- GDK_WINDOW_STATE_MAXIMIZED |
- GDK_WINDOW_STATE_FULLSCREEN,
- 0);
- break;
- case mir_window_state_minimized:
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_MAXIMIZED |
- GDK_WINDOW_STATE_FULLSCREEN,
- GDK_WINDOW_STATE_ICONIFIED);
- break;
- case mir_window_state_maximized:
- case mir_window_state_vertmaximized:
- case mir_window_state_horizmaximized:
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_ICONIFIED |
- GDK_WINDOW_STATE_FULLSCREEN,
- GDK_WINDOW_STATE_MAXIMIZED);
- break;
- case mir_window_state_fullscreen:
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_ICONIFIED |
- GDK_WINDOW_STATE_MAXIMIZED,
- GDK_WINDOW_STATE_FULLSCREEN);
- break;
- default:
- break;
- }
-
- break;
- case mir_window_attrib_swapinterval:
- break;
- case mir_window_attrib_focus:
- generate_focus_event (window, mir_window_event_get_attribute_value (event) != 0);
- break;
- default:
- break;
- }
-}
-
-static void
-generate_configure_event (GdkWindow *window,
- gint width,
- gint height)
-{
- GdkEvent *event;
-
- event = gdk_event_new (GDK_CONFIGURE);
- event->configure.send_event = FALSE;
- event->configure.width = width;
- event->configure.height = height;
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-handle_resize_event (GdkWindow *window,
- const MirResizeEvent *event)
-{
- window->width = mir_resize_event_get_width (event);
- window->height = mir_resize_event_get_height (event);
- _gdk_window_update_size (window);
-
- generate_configure_event (window, mir_resize_event_get_width (event), mir_resize_event_get_height (event));
-}
-
-static void
-handle_close_event (GdkWindow *window)
-{
- send_event (window, get_pointer (window), gdk_event_new (GDK_DESTROY));
- gdk_window_destroy_notify (window);
-}
-
-static void
-handle_window_output_event (GdkWindow *window,
- const MirWindowOutputEvent *event)
-{
- _gdk_mir_window_set_scale (window, mir_window_output_event_get_scale (event));
-}
-
-static void
-handle_window_placement_event (GdkWindow *window,
- const MirWindowPlacementEvent *event)
-{
- _gdk_mir_window_set_final_rect (window, mir_window_placement_get_relative_position (event));
-}
-
-typedef struct
-{
- GdkWindow *window;
- MirEvent *event;
-} EventData;
-
-static void
-gdk_mir_event_source_queue_event (GdkDisplay *display,
- GdkWindow *window,
- const MirEvent *event)
-{
- const MirInputEvent *input_event;
-
- // FIXME: Only generate events if the window wanted them?
- switch (mir_event_get_type (event))
- {
- case mir_event_type_input:
- input_event = mir_event_get_input_event (event);
-
- switch (mir_input_event_get_type (input_event))
- {
- case mir_input_event_type_key:
- handle_key_event (window, input_event);
- break;
- case mir_input_event_type_touch:
- handle_touch_event (window, mir_input_event_get_touch_event (input_event));
- break;
- case mir_input_event_type_pointer:
- handle_motion_event (window, input_event);
- break;
- default:
- break;
- }
-
- break;
- case mir_event_type_key:
- handle_key_event (window, mir_event_get_input_event (event));
- break;
- case mir_event_type_motion:
- handle_motion_event (window, mir_event_get_input_event (event));
- break;
- case mir_event_type_window:
- handle_window_event (window, mir_event_get_window_event (event));
- break;
- case mir_event_type_resize:
- handle_resize_event (window, mir_event_get_resize_event (event));
- break;
- case mir_event_type_prompt_session_state_change:
- break;
- case mir_event_type_orientation:
- break;
- case mir_event_type_close_window:
- handle_close_event (window);
- break;
- case mir_event_type_keymap:
- break;
- case mir_event_type_window_output:
- handle_window_output_event (window, mir_event_get_window_output_event (event));
- break;
- case mir_event_type_input_device_state:
- break;
- case mir_event_type_window_placement:
- handle_window_placement_event (window, mir_event_get_window_placement_event (event));
- break;
- default:
- g_warning ("Ignoring unknown Mir event %d", mir_event_get_type (event));
- break;
- }
-}
-
-static GdkMirQueuedEvent *
-gdk_mir_event_source_take_queued_event (GdkMirEventSource *source)
-{
- GdkMirQueuedEvent *queued_event;
-
- g_mutex_lock (&source->mir_event_lock);
- queued_event = g_queue_pop_head (&source->mir_events);
- g_mutex_unlock (&source->mir_event_lock);
-
- return queued_event;
-}
-
-static void
-gdk_mir_queued_event_free (GdkMirQueuedEvent *event)
-{
- _gdk_mir_window_reference_unref (event->window_ref);
- mir_event_unref (event->event);
- g_slice_free (GdkMirQueuedEvent, event);
-}
-
-static void
-gdk_mir_event_source_convert_events (GdkMirEventSource *source)
-{
- GdkMirQueuedEvent *event;
-
- while ((event = gdk_mir_event_source_take_queued_event (source)))
- {
- GdkWindow *window = event->window_ref->window;
-
- /* The window may have been destroyed in the main thread while the
- * event was being dispatched...
- */
- if (window != NULL)
- {
- if (source->log_events)
- _gdk_mir_print_event (event->event);
-
- gdk_mir_event_source_queue_event (source->display, window, event->event);
- }
- else
- g_warning ("window was destroyed before event arrived...");
-
- gdk_mir_queued_event_free (event);
- }
-}
-
-static gboolean
-gdk_mir_event_source_prepare (GSource *g_source,
- gint *timeout)
-{
- GdkMirEventSource *source = (GdkMirEventSource *) g_source;
- gboolean mir_events_in_queue;
-
- if (_gdk_event_queue_find_first (source->display))
- return TRUE;
-
- g_mutex_lock (&source->mir_event_lock);
- mir_events_in_queue = g_queue_get_length (&source->mir_events) > 0;
- g_mutex_unlock (&source->mir_event_lock);
-
- return mir_events_in_queue;
-}
-
-static gboolean
-gdk_mir_event_source_check (GSource *g_source)
-{
- return gdk_mir_event_source_prepare (g_source, NULL);
-}
-
-static gboolean
-gdk_mir_event_source_dispatch (GSource *g_source,
- GSourceFunc callback,
- gpointer user_data)
-{
- GdkMirEventSource *source = (GdkMirEventSource *) g_source;
- GdkEvent *event;
-
- /* First, run the queue of events from the thread */
- gdk_mir_event_source_convert_events (source);
-
- /* Next, dispatch one single event from the display's queue.
- *
- * If there is more than one event then we will soon find ourselves
- * back here again.
- */
-
- gdk_threads_enter ();
-
- event = gdk_display_get_event (source->display);
-
- if (event)
- {
- _gdk_event_emit (event);
-
- gdk_event_free (event);
- }
-
- gdk_threads_leave ();
-
- return TRUE;
-}
-
-static void
-gdk_mir_event_source_finalize (GSource *g_source)
-{
- GdkMirEventSource *source = (GdkMirEventSource *) g_source;
- GdkMirQueuedEvent *event;
-
- while ((event = gdk_mir_event_source_take_queued_event (source)))
- gdk_mir_queued_event_free (event);
-
- g_mutex_clear (&source->mir_event_lock);
-}
-
-static GSourceFuncs gdk_mir_event_source_funcs = {
- gdk_mir_event_source_prepare,
- gdk_mir_event_source_check,
- gdk_mir_event_source_dispatch,
- gdk_mir_event_source_finalize
-};
-
-GdkMirEventSource *
-_gdk_mir_event_source_new (GdkDisplay *display)
-{
- GdkMirEventSource *source;
- GSource *g_source;
- char *name;
-
- g_source = g_source_new (&gdk_mir_event_source_funcs, sizeof (GdkMirEventSource));
- name = g_strdup_printf ("GDK Mir Event source (%s)", gdk_display_get_name (display));
- g_source_set_name (g_source, name);
- g_free (name);
- g_source_set_priority (g_source, GDK_PRIORITY_EVENTS);
- g_source_set_can_recurse (g_source, TRUE);
- g_source_attach (g_source, NULL);
-
- source = (GdkMirEventSource *) g_source;
- g_mutex_init (&source->mir_event_lock);
- source->display = display;
- source->log_events = (g_getenv ("GDK_MIR_LOG_EVENTS") != NULL);
-
- return source;
-}
-
-GdkMirWindowReference *
-_gdk_mir_event_source_get_window_reference (GdkWindow *window)
-{
- static GQuark win_ref_quark;
- GdkMirWindowReference *ref;
-
- if G_UNLIKELY (!win_ref_quark)
- win_ref_quark = g_quark_from_string ("GdkMirEventSource window reference");
-
- ref = g_object_get_qdata (G_OBJECT (window), win_ref_quark);
-
- if (!ref)
- {
- GdkMirEventSource *source;
-
- source = _gdk_mir_display_get_event_source (gdk_window_get_display (window));
- g_source_ref ((GSource *) source);
-
- ref = g_slice_new (GdkMirWindowReference);
- ref->window = window;
- ref->source = source;
- ref->ref_count = 0;
- g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &ref->window);
-
- g_object_set_qdata_full (G_OBJECT (window), win_ref_quark,
- ref, (GDestroyNotify) _gdk_mir_window_reference_unref);
- }
-
- g_atomic_int_inc (&ref->ref_count);
-
- return ref;
-}
-
-void
-_gdk_mir_window_reference_unref (GdkMirWindowReference *ref)
-{
- if (g_atomic_int_dec_and_test (&ref->ref_count))
- {
- if (ref->window)
- g_object_remove_weak_pointer (G_OBJECT (ref->window), (gpointer *) &ref->window);
-
- g_source_unref ((GSource *) ref->source);
-
- g_slice_free (GdkMirWindowReference, ref);
- }
-}
-
-void
-_gdk_mir_event_source_queue (GdkMirWindowReference *window_ref,
- const MirEvent *event)
-{
- GdkMirEventSource *source = window_ref->source;
- GdkMirQueuedEvent *queued_event;
-
- /* We are in the wrong thread right now. We absolutely cannot touch
- * the window.
- *
- * We can do pretty much anything we want with the source, though...
- */
-
- queued_event = g_slice_new (GdkMirQueuedEvent);
- g_atomic_int_inc (&window_ref->ref_count);
- queued_event->window_ref = window_ref;
- queued_event->event = mir_event_ref (event);
-
- g_mutex_lock (&source->mir_event_lock);
- g_queue_push_tail (&source->mir_events, queued_event);
- g_mutex_unlock (&source->mir_event_lock);
-
- g_main_context_wakeup (NULL);
-}
diff --git a/gdk/mir/gdkmirglcontext.c b/gdk/mir/gdkmirglcontext.c
deleted file mode 100644
index 9506461f1c..0000000000
--- a/gdk/mir/gdkmirglcontext.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- *
- * gdkmirglcontext.c: Mir specific OpenGL wrappers
- *
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkmir-private.h"
-#include "gdkinternals.h"
-#include "gdkintl.h"
-
-G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
-
-#define N_EGL_ATTRS 16
-
-static gboolean
-gdk_mir_gl_context_realize (GdkGLContext *context,
- GError **error)
-{
- GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
- GdkDisplay *display = gdk_gl_context_get_display (context);
- GdkGLContext *share = gdk_gl_context_get_shared_context (context);
- EGLContext ctx;
- EGLint context_attribs[N_EGL_ATTRS];
- int major, minor, flags;
- gboolean debug_bit, forward_bit;
- int i = 0;
-
- if (!_gdk_mir_display_init_egl_display (display))
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_NOT_AVAILABLE,
- _("No GL implementation is available"));
- return FALSE;
- }
-
- gdk_gl_context_get_required_version (context, &major, &minor);
- debug_bit = gdk_gl_context_get_debug_enabled (context);
- forward_bit = gdk_gl_context_get_forward_compatible (context);
-
- flags = 0;
-
- if (debug_bit)
- flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
- if (forward_bit)
- flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
-
- /* We want a core profile */
- context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
-
- /* Specify the version */
- context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
- context_attribs[i++] = major;
- context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
- context_attribs[i++] = minor;
-
- /* Specify the flags */
- context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
- context_attribs[i++] = flags;
-
- context_attribs[i++] = EGL_NONE;
- g_assert (i < N_EGL_ATTRS);
-
- ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
- context_mir->egl_config,
- share != NULL ? GDK_MIR_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
- context_attribs);
- if (ctx == NULL)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_NOT_AVAILABLE,
- _("Unable to create a GL context"));
- return FALSE;
- }
-
- GDK_NOTE (OPENGL, g_print ("Created EGL context[%p]\n", ctx));
-
- context_mir->egl_context = ctx;
-
- return TRUE;
-}
-
-static void
-gdk_mir_gl_context_end_frame (GdkGLContext *context,
- cairo_region_t *painted,
- cairo_region_t *damage)
-{
- GdkWindow *window = gdk_gl_context_get_window (context);
- GdkDisplay *display = gdk_window_get_display (window);
- GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
- EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
- EGLSurface egl_surface;
-
- gdk_gl_context_make_current (context);
-
- egl_surface = _gdk_mir_window_get_egl_surface (window,
- context_mir->egl_config);
-
- if (_gdk_mir_display_have_egl_swap_buffers_with_damage (display))
- {
- int i, j, n_rects = cairo_region_num_rectangles (damage);
- EGLint *rects = g_new (EGLint, n_rects * 4);
- cairo_rectangle_int_t rect;
- int window_height = gdk_window_get_height (window);
-
- for (i = 0, j = 0; i < n_rects; i++)
- {
- cairo_region_get_rectangle (damage, i, &rect);
- rects[j++] = rect.x;
- rects[j++] = window_height - rect.height - rect.y;
- rects[j++] = rect.width;
- rects[j++] = rect.height;
- }
- eglSwapBuffersWithDamageEXT (egl_display, egl_surface, rects, n_rects);
- g_free (rects);
- }
- else
- {
- eglSwapBuffers (egl_display, egl_surface);
- }
-}
-
-static void
-gdk_mir_gl_context_dispose (GObject *gobject)
-{
- GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (gobject);
-
- if (context_mir->egl_context != NULL)
- {
- GdkGLContext *context = GDK_GL_CONTEXT (gobject);
- GdkWindow *window = gdk_gl_context_get_window (context);
- GdkDisplay *display = gdk_window_get_display (window);
- EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
-
- if (eglGetCurrentContext () == context_mir->egl_context)
- eglMakeCurrent (egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-
- GDK_NOTE (OPENGL, g_print ("Destroying EGL context\n"));
-
- eglDestroyContext (egl_display, context_mir->egl_context);
- context_mir->egl_context = NULL;
- }
-
- G_OBJECT_CLASS (gdk_mir_gl_context_parent_class)->dispose (gobject);
-}
-
-static void
-gdk_mir_gl_context_class_init (GdkMirGLContextClass *klass)
-{
- GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- context_class->realize = gdk_mir_gl_context_realize;
- context_class->end_frame = gdk_mir_gl_context_end_frame;
- gobject_class->dispose = gdk_mir_gl_context_dispose;
-}
-
-static void
-gdk_mir_gl_context_init (GdkMirGLContext *self)
-{
-}
diff --git a/gdk/mir/gdkmirkeyboard.c b/gdk/mir/gdkmirkeyboard.c
deleted file mode 100644
index 289473a89a..0000000000
--- a/gdk/mir/gdkmirkeyboard.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkdeviceprivate.h"
-
-typedef struct GdkMirKeyboard GdkMirKeyboard;
-typedef struct GdkMirKeyboardClass GdkMirKeyboardClass;
-
-#define GDK_TYPE_MIR_KEYBOARD (gdk_mir_keyboard_get_type ())
-#define GDK_MIR_KEYBOARD(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboard))
-#define GDK_MIR_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboardClass))
-#define GDK_IS_MIR_KEYBOARD(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_KEYBOARD))
-#define GDK_IS_MIR_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_KEYBOARD))
-#define GDK_MIR_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboardClass))
-
-struct GdkMirKeyboard
-{
- GdkDevice parent_instance;
-};
-
-struct GdkMirKeyboardClass
-{
- GdkDeviceClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirKeyboard, gdk_mir_keyboard, GDK_TYPE_DEVICE)
-
-GdkDevice *
-_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name)
-{
- return g_object_new (GDK_TYPE_MIR_KEYBOARD,
- "display", gdk_device_manager_get_display (device_manager),
- "device-manager", device_manager,
- "name", name,
- "type", GDK_DEVICE_TYPE_MASTER,
- "input-source", GDK_SOURCE_KEYBOARD,
- "input-mode", GDK_MODE_SCREEN,
- "has-cursor", FALSE,
- NULL);
-}
-
-static gboolean
-gdk_mir_keyboard_get_history (GdkDevice *device,
- GdkWindow *window,
- guint32 start,
- guint32 stop,
- GdkTimeCoord ***events,
- gint *n_events)
-{
- return FALSE;
-}
-
-static void
-gdk_mir_keyboard_get_state (GdkDevice *device,
- GdkWindow *window,
- gdouble *axes,
- GdkModifierType *mask)
-{
-}
-
-static void
-gdk_mir_keyboard_set_window_cursor (GdkDevice *device,
- GdkWindow *window,
- GdkCursor *cursor)
-{
- /* Keyboards don't have cursors... */
-}
-
-static void
-gdk_mir_keyboard_warp (GdkDevice *device,
- GdkScreen *screen,
- gdouble x,
- gdouble y)
-{
- /* Can't warp a keyboard... */
-}
-
-static void
-gdk_mir_keyboard_query_state (GdkDevice *device,
- GdkWindow *window,
- GdkWindow **root_window,
- GdkWindow **child_window,
- gdouble *root_x,
- gdouble *root_y,
- gdouble *win_x,
- gdouble *win_y,
- GdkModifierType *mask)
-{
-}
-
-static GdkGrabStatus
-gdk_mir_keyboard_grab (GdkDevice *device,
- GdkWindow *window,
- gboolean owner_events,
- GdkEventMask event_mask,
- GdkWindow *confine_to,
- GdkCursor *cursor,
- guint32 time_)
-{
- /* Mir doesn't do grabs, so sure, you have the grab */
- return GDK_GRAB_SUCCESS;
-}
-
-static void
-gdk_mir_keyboard_ungrab (GdkDevice *device,
- guint32 time_)
-{
- /* Mir doesn't do grabs */
-}
-
-static GdkWindow *
-gdk_mir_keyboard_window_at_position (GdkDevice *device,
- gdouble *win_x,
- gdouble *win_y,
- GdkModifierType *mask,
- gboolean get_toplevel)
-{
- /* Keyboard don't have locations... */
- return NULL; // FIXME: Or the window with the keyboard focus?
-}
-
-static void
-gdk_mir_keyboard_select_window_events (GdkDevice *device,
- GdkWindow *window,
- GdkEventMask event_mask)
-{
-}
-
-static void
-gdk_mir_keyboard_init (GdkMirKeyboard *device)
-{
-}
-
-static void
-gdk_mir_keyboard_class_init (GdkMirKeyboardClass *klass)
-{
- GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
-
- device_class->get_history = gdk_mir_keyboard_get_history;
- device_class->get_state = gdk_mir_keyboard_get_state;
- device_class->set_window_cursor = gdk_mir_keyboard_set_window_cursor;
- device_class->warp = gdk_mir_keyboard_warp;
- device_class->query_state = gdk_mir_keyboard_query_state;
- device_class->grab = gdk_mir_keyboard_grab;
- device_class->ungrab = gdk_mir_keyboard_ungrab;
- device_class->window_at_position = gdk_mir_keyboard_window_at_position;
- device_class->select_window_events = gdk_mir_keyboard_select_window_events;
-}
diff --git a/gdk/mir/gdkmirkeymap.c b/gdk/mir/gdkmirkeymap.c
deleted file mode 100644
index 40a2343836..0000000000
--- a/gdk/mir/gdkmirkeymap.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <xkbcommon/xkbcommon.h>
-
-#include "gdkkeysprivate.h"
-
-typedef struct GdkMirKeymap GdkMirKeymap;
-typedef struct GdkMirKeymapClass GdkMirKeymapClass;
-
-#define GDK_TYPE_MIR_KEYMAP (gdk_mir_keymap_get_type ())
-#define GDK_MIR_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_KEYMAP, GdkMirKeymap))
-#define GDK_MIR_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_KEYMAP, GdkMirKeymapClass))
-#define GDK_IS_MIR_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_KEYMAP))
-#define GDK_IS_MIR_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_KEYMAP))
-#define GDK_MIR_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_KEYMAP, GdkMirKeymapClass))
-
-#define IsModifierKey(keysym) \
- (((keysym) >= XKB_KEY_Shift_L && (keysym) <= XKB_KEY_Hyper_R) || \
- ((keysym) >= XKB_KEY_ISO_Lock && (keysym) <= XKB_KEY_ISO_Last_Group_Lock) || \
- ((keysym) == XKB_KEY_Mode_switch) || \
- ((keysym) == XKB_KEY_Num_Lock))
-
-struct GdkMirKeymap
-{
- GdkKeymap parent_instance;
-
- struct xkb_keymap *xkb_keymap;
- struct xkb_state *xkb_state;
-
- PangoDirection *direction;
- gboolean bidi;
-};
-
-struct GdkMirKeymapClass
-{
- GdkKeymapClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirKeymap, gdk_mir_keymap, GDK_TYPE_KEYMAP)
-
-GdkKeymap *
-_gdk_mir_keymap_new (void)
-{
- return g_object_new (GDK_TYPE_MIR_KEYMAP, NULL);
-}
-
-static PangoDirection
-gdk_mir_keymap_get_direction (GdkKeymap *keymap)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- gint i;
-
- for (i = 0; i < xkb_keymap_num_layouts (mir_keymap->xkb_keymap); i++)
- {
- if (xkb_state_layout_index_is_active (mir_keymap->xkb_state, i, XKB_STATE_LAYOUT_EFFECTIVE))
- return mir_keymap->direction[i];
- }
-
- return PANGO_DIRECTION_NEUTRAL;
-}
-
-static gboolean
-gdk_mir_keymap_have_bidi_layouts (GdkKeymap *keymap)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_keymap_get_caps_lock_state (GdkKeymap *keymap)
-{
- return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_CAPS);
-}
-
-static gboolean
-gdk_mir_keymap_get_num_lock_state (GdkKeymap *keymap)
-{
- return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_NUM);
-}
-
-static gboolean
-gdk_mir_keymap_get_scroll_lock_state (GdkKeymap *keymap)
-{
- return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_SCROLL);
-}
-
-static gboolean
-gdk_mir_keymap_get_entries_for_keyval (GdkKeymap *keymap,
- guint keyval,
- GdkKeymapKey **keys,
- gint *n_keys)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- GArray *key_array;
- guint keycode;
-
- key_array = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
-
- for (keycode = 8; keycode < 255; keycode++) /* FIXME: min/max keycode */
- {
- gint num_layouts, layout;
-
- num_layouts = xkb_keymap_num_layouts_for_key (mir_keymap->xkb_keymap, keycode);
- for (layout = 0; layout < num_layouts; layout++)
- {
- gint num_levels, level;
-
- num_levels = xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, keycode, layout);
- for (level = 0; level < num_levels; level++)
- {
- const xkb_keysym_t *syms;
- gint num_syms, sym;
-
- num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap, keycode, layout, level, &syms);
- for (sym = 0; sym < num_syms; sym++)
- {
- if (syms[sym] == keyval)
- {
- GdkKeymapKey key;
-
- key.keycode = keycode;
- key.group = layout;
- key.level = level;
-
- g_array_append_val (key_array, key);
- }
- }
- }
- }
- }
-
- *n_keys = key_array->len;
- *keys = (GdkKeymapKey*) g_array_free (key_array, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-gdk_mir_keymap_get_entries_for_keycode (GdkKeymap *keymap,
- guint hardware_keycode,
- GdkKeymapKey **keys,
- guint **keyvals,
- gint *n_entries)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- gint num_layouts, layout;
- gint num_entries;
- gint i;
-
- num_layouts = xkb_keymap_num_layouts_for_key (mir_keymap->xkb_keymap, hardware_keycode);
-
- num_entries = 0;
- for (layout = 0; layout < num_layouts; layout++)
- num_entries += xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, hardware_keycode, layout);
-
- if (n_entries)
- *n_entries = num_entries;
- if (keys)
- *keys = g_new0 (GdkKeymapKey, num_entries);
- if (keyvals)
- *keyvals = g_new0 (guint, num_entries);
-
- i = 0;
- for (layout = 0; layout < num_layouts; layout++)
- {
- gint num_levels, level;
- num_levels = xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, hardware_keycode, layout);
- for (level = 0; level < num_levels; level++)
- {
- const xkb_keysym_t *syms;
- int num_syms;
-
- num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap, hardware_keycode, layout, 0, &syms);
- if (keys)
- {
- (*keys)[i].keycode = hardware_keycode;
- (*keys)[i].group = layout;
- (*keys)[i].level = level;
- }
- if (keyvals && num_syms > 0)
- (*keyvals)[i] = syms[0];
-
- i++;
- }
- }
-
- return num_entries > 0;
-}
-
-static guint
-gdk_mir_keymap_lookup_key (GdkKeymap *keymap,
- const GdkKeymapKey *key)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- const xkb_keysym_t *syms;
- int num_syms;
-
- num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap,
- key->keycode,
- key->group,
- key->level,
- &syms);
- if (num_syms > 0)
- return syms[0];
- else
- return XKB_KEY_NoSymbol;
-}
-
-static guint32
-get_xkb_modifiers (struct xkb_keymap *xkb_keymap,
- GdkModifierType state)
-{
- guint32 mods = 0;
-
- if (state & GDK_SHIFT_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_SHIFT);
- if (state & GDK_LOCK_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS);
- if (state & GDK_CONTROL_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CTRL);
- if (state & GDK_MOD1_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT);
- if (state & GDK_MOD2_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod2");
- if (state & GDK_MOD3_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod3");
- if (state & GDK_MOD4_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO);
- if (state & GDK_MOD5_MASK)
- mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod5");
-
- return mods;
-}
-
-static GdkModifierType
-get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
- guint32 mods)
-{
- GdkModifierType state = 0;
-
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_SHIFT)))
- state |= GDK_SHIFT_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS)))
- state |= GDK_LOCK_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CTRL)))
- state |= GDK_CONTROL_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT)))
- state |= GDK_MOD1_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod2")))
- state |= GDK_MOD2_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod3")))
- state |= GDK_MOD3_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO)))
- state |= GDK_MOD4_MASK;
- if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod5")))
- state |= GDK_MOD5_MASK;
-
- return state;
-}
-
-static gboolean
-gdk_mir_keymap_translate_keyboard_state (GdkKeymap *keymap,
- guint hardware_keycode,
- GdkModifierType state,
- gint group,
- guint *keyval,
- gint *effective_group,
- gint *effective_level,
- GdkModifierType *consumed_modifiers)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- struct xkb_state *xkb_state;
- guint32 modifiers;
- guint32 consumed;
- xkb_layout_index_t layout;
- xkb_level_index_t level;
- xkb_keysym_t sym;
-
- modifiers = get_xkb_modifiers (mir_keymap->xkb_keymap, state);
-
- xkb_state = xkb_state_new (mir_keymap->xkb_keymap);
-
- xkb_state_update_mask (xkb_state, modifiers, 0, 0, group, 0, 0);
-
- layout = xkb_state_key_get_layout (xkb_state, hardware_keycode);
- level = xkb_state_key_get_level (xkb_state, hardware_keycode, layout);
- sym = xkb_state_key_get_one_sym (xkb_state, hardware_keycode);
- consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (xkb_state, hardware_keycode, modifiers);
-
- xkb_state_unref (xkb_state);
-
- if (keyval)
- *keyval = sym;
- if (effective_group)
- *effective_group = layout;
- if (effective_level)
- *effective_level = level;
- if (consumed_modifiers)
- *consumed_modifiers = get_gdk_modifiers (mir_keymap->xkb_keymap, consumed);
-
- return TRUE;
-}
-
-static void
-gdk_mir_keymap_add_virtual_modifiers (GdkKeymap *keymap,
- GdkModifierType *state)
-{
- // FIXME: What is this?
-}
-
-static gboolean
-gdk_mir_keymap_map_virtual_modifiers (GdkKeymap *keymap,
- GdkModifierType *state)
-{
- // FIXME: What is this?
- return TRUE;
-}
-
-static guint
-gdk_mir_keymap_get_modifier_state (GdkKeymap *keymap)
-{
- GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
- xkb_mod_mask_t mods;
-
- mods = xkb_state_serialize_mods (mir_keymap->xkb_state, XKB_STATE_MODS_EFFECTIVE);
-
- return get_gdk_modifiers (mir_keymap->xkb_keymap, mods);
-}
-
-gboolean
-_gdk_mir_keymap_key_is_modifier (GdkKeymap *keymap,
- guint keycode)
-{
- // FIXME: use xkb_state
- return IsModifierKey (keycode);
-}
-
-static void
-update_direction (GdkMirKeymap *keymap)
-{
- gint num_layouts;
- gint *rtl;
- guint key;
- gboolean have_rtl, have_ltr;
- gint i;
-
- num_layouts = xkb_keymap_num_layouts (keymap->xkb_keymap);
-
- g_free (keymap->direction);
- keymap->direction = g_new0 (PangoDirection, num_layouts);
-
- rtl = g_new0 (gint, num_layouts);
-
- for (key = 8; key < 255; key++) /* FIXME: min/max keycode */
- {
- gint layouts;
- gint layout;
-
- layouts = xkb_keymap_num_layouts_for_key (keymap->xkb_keymap, key);
- for (layout = 0; layout < layouts; layout++)
- {
- const xkb_keysym_t *syms;
- gint num_syms;
- gint sym;
-
- num_syms = xkb_keymap_key_get_syms_by_level (keymap->xkb_keymap, key, layout, 0, &syms);
- for (sym = 0; sym < num_syms; sym++)
- {
- PangoDirection dir;
- dir = pango_unichar_direction (xkb_keysym_to_utf32 (syms[sym]));
- switch (dir)
- {
- case PANGO_DIRECTION_RTL:
- rtl[layout]++;
- break;
- case PANGO_DIRECTION_LTR:
- rtl[layout]--;
- break;
- default:
- break;
- }
- }
- }
- }
-
- have_rtl = have_ltr = FALSE;
- for (i = 0; i < num_layouts; i++)
- {
- if (rtl[i] > 0)
- {
- keymap->direction[i] = PANGO_DIRECTION_RTL;
- have_rtl = TRUE;
- }
- else
- {
- keymap->direction[i] = PANGO_DIRECTION_LTR;
- have_ltr = TRUE;
- }
- }
-
- if (have_rtl && have_ltr)
- keymap->bidi = TRUE;
-
- g_free (rtl);
-}
-
-static void
-gdk_mir_keymap_init (GdkMirKeymap *keymap)
-{
- struct xkb_context *context;
- struct xkb_rule_names names;
-
- context = xkb_context_new (0);
-
- names.rules = "evdev";
- names.model = "pc105";
- names.layout = "us";
- names.variant = "";
- names.options = "";
- keymap->xkb_keymap = xkb_keymap_new_from_names (context, &names, 0);
- keymap->xkb_state = xkb_state_new (keymap->xkb_keymap);
-
- xkb_context_unref (context);
-
- update_direction (keymap);
-}
-
-static void
-gdk_mir_keymap_finalize (GObject *object)
-{
- GdkMirKeymap *keymap = GDK_MIR_KEYMAP (object);
-
- xkb_keymap_unref (keymap->xkb_keymap);
- xkb_state_unref (keymap->xkb_state);
- g_free (keymap->direction);
-
- G_OBJECT_CLASS (gdk_mir_keymap_parent_class)->finalize (object);
-}
-
-static void
-gdk_mir_keymap_class_init (GdkMirKeymapClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkKeymapClass *keymap_class = GDK_KEYMAP_CLASS (klass);
-
- object_class->finalize = gdk_mir_keymap_finalize;
-
- keymap_class->get_direction = gdk_mir_keymap_get_direction;
- keymap_class->have_bidi_layouts = gdk_mir_keymap_have_bidi_layouts;
- keymap_class->get_caps_lock_state = gdk_mir_keymap_get_caps_lock_state;
- keymap_class->get_num_lock_state = gdk_mir_keymap_get_num_lock_state;
- keymap_class->get_scroll_lock_state = gdk_mir_keymap_get_scroll_lock_state;
- keymap_class->get_entries_for_keyval = gdk_mir_keymap_get_entries_for_keyval;
- keymap_class->get_entries_for_keycode = gdk_mir_keymap_get_entries_for_keycode;
- keymap_class->lookup_key = gdk_mir_keymap_lookup_key;
- keymap_class->translate_keyboard_state = gdk_mir_keymap_translate_keyboard_state;
- keymap_class->add_virtual_modifiers = gdk_mir_keymap_add_virtual_modifiers;
- keymap_class->map_virtual_modifiers = gdk_mir_keymap_map_virtual_modifiers;
- keymap_class->get_modifier_state = gdk_mir_keymap_get_modifier_state;
-}
diff --git a/gdk/mir/gdkmirpointer.c b/gdk/mir/gdkmirpointer.c
deleted file mode 100644
index b5504245a8..0000000000
--- a/gdk/mir/gdkmirpointer.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkdisplayprivate.h"
-#include "gdkdeviceprivate.h"
-#include "gdkscreen.h"
-#include "gdkwindow.h"
-
-typedef struct GdkMirPointer GdkMirPointer;
-typedef struct GdkMirPointerClass GdkMirPointerClass;
-
-#define GDK_TYPE_MIR_POINTER (gdk_mir_pointer_get_type ())
-#define GDK_MIR_POINTER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_POINTER, GdkMirPointer))
-#define GDK_MIR_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_POINTER, GdkMirPointerClass))
-#define GDK_IS_MIR_POINTER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_POINTER))
-#define GDK_IS_MIR_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_POINTER))
-#define GDK_MIR_POINTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_POINTER, GdkMirPointerClass))
-
-struct GdkMirPointer
-{
- GdkDevice parent_instance;
-
- /* Location of pointer */
- gdouble x;
- gdouble y;
-
- /* Window this pointer is over */
- GdkWindow *over_window;
-
- /* Current modifier mask */
- GdkModifierType modifier_mask;
-};
-
-struct GdkMirPointerClass
-{
- GdkDeviceClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirPointer, gdk_mir_pointer, GDK_TYPE_DEVICE)
-
-GdkDevice *
-_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name)
-{
- return g_object_new (GDK_TYPE_MIR_POINTER,
- "display", gdk_device_manager_get_display (device_manager),
- "device-manager", device_manager,
- "name", name,
- "type", GDK_DEVICE_TYPE_MASTER,
- "input-source", GDK_SOURCE_MOUSE,
- "input-mode", GDK_MODE_SCREEN,
- "has-cursor", TRUE,
- NULL);
-}
-
-void
-_gdk_mir_pointer_set_location (GdkDevice *pointer,
- gdouble x,
- gdouble y,
- GdkWindow *window,
- GdkModifierType mask)
-{
- GdkMirPointer *p = GDK_MIR_POINTER (pointer);
-
- p->x = x;
- p->y = y;
- if (p->over_window)
- g_object_unref (p->over_window);
- p->over_window = g_object_ref (window);
- p->modifier_mask = mask;
-}
-
-static gboolean
-gdk_mir_pointer_get_history (GdkDevice *device,
- GdkWindow *window,
- guint32 start,
- guint32 stop,
- GdkTimeCoord ***events,
- gint *n_events)
-{
- return FALSE;
-}
-
-static void
-gdk_mir_pointer_get_state (GdkDevice *device,
- GdkWindow *window,
- gdouble *axes,
- GdkModifierType *mask)
-{
- GdkMirPointer *p = GDK_MIR_POINTER (device);
- gdouble x, y;
-
- gdk_window_get_device_position_double (window, device, &x, &y, mask);
- if (axes)
- {
- axes[0] = p->x;
- axes[1] = p->y;
- }
-}
-
-static void
-gdk_mir_pointer_set_window_cursor (GdkDevice *device,
- GdkWindow *window,
- GdkCursor *cursor)
-{
- /* Mir doesn't support cursors */
-}
-
-static void
-gdk_mir_pointer_warp (GdkDevice *device,
- GdkScreen *screen,
- gdouble x,
- gdouble y)
-{
- /* Mir doesn't support warping */
-}
-
-static void
-gdk_mir_pointer_query_state (GdkDevice *device,
- GdkWindow *window,
- GdkWindow **root_window,
- GdkWindow **child_window,
- gdouble *root_x,
- gdouble *root_y,
- gdouble *win_x,
- gdouble *win_y,
- GdkModifierType *mask)
-{
- GdkMirPointer *p = GDK_MIR_POINTER (device);
-
- if (root_window)
- *root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (gdk_device_get_display (device)));
- if (child_window)
- *child_window = p->over_window;
- if (root_x)
- *root_x = p->x;
- if (root_y)
- *root_y = p->y;
- if (win_x)
- *win_x = p->x; // FIXME
- if (win_y)
- *win_y = p->y;
- if (mask)
- *mask = p->modifier_mask;
-}
-
-static GdkGrabStatus
-gdk_mir_pointer_grab (GdkDevice *device,
- GdkWindow *window,
- gboolean owner_events,
- GdkEventMask event_mask,
- GdkWindow *confine_to,
- GdkCursor *cursor,
- guint32 time_)
-{
- /* Mir doesn't do grabs, so sure, you have the grab */
- return GDK_GRAB_SUCCESS;
-}
-
-static void
-gdk_mir_pointer_ungrab (GdkDevice *device,
- guint32 time_)
-{
- /* Mir doesn't do grabs */
-
- GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (gdk_device_get_display (device), device);
-
- if (grab)
- grab->serial_end = grab->serial_start;
-}
-
-static GdkWindow *
-gdk_mir_pointer_window_at_position (GdkDevice *device,
- gdouble *win_x,
- gdouble *win_y,
- GdkModifierType *mask,
- gboolean get_toplevel)
-{
- GdkMirPointer *p = GDK_MIR_POINTER (device);
-
- if (win_x)
- *win_x = p->x;
- if (win_y)
- *win_y = p->y;
- if (mask)
- *mask = p->modifier_mask;
-
- return p->over_window;
-}
-
-static void
-gdk_mir_pointer_select_window_events (GdkDevice *device,
- GdkWindow *window,
- GdkEventMask event_mask)
-{
- // FIXME?
-}
-
-static void
-gdk_mir_pointer_init (GdkMirPointer *device)
-{
-}
-
-static void
-gdk_mir_pointer_finalize (GObject *object)
-{
- GdkMirPointer *p = GDK_MIR_POINTER (object);
-
- if (p->over_window)
- g_object_unref (p->over_window);
-
- G_OBJECT_CLASS (gdk_mir_pointer_parent_class)->finalize (object);
-}
-
-static void
-gdk_mir_pointer_class_init (GdkMirPointerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
-
- object_class->finalize = gdk_mir_pointer_finalize;
-
- device_class->get_history = gdk_mir_pointer_get_history;
- device_class->get_state = gdk_mir_pointer_get_state;
- device_class->set_window_cursor = gdk_mir_pointer_set_window_cursor;
- device_class->warp = gdk_mir_pointer_warp;
- device_class->query_state = gdk_mir_pointer_query_state;
- device_class->grab = gdk_mir_pointer_grab;
- device_class->ungrab = gdk_mir_pointer_ungrab;
- device_class->window_at_position = gdk_mir_pointer_window_at_position;
- device_class->select_window_events = gdk_mir_pointer_select_window_events;
-}
diff --git a/gdk/mir/gdkmirscreen.c b/gdk/mir/gdkmirscreen.c
deleted file mode 100644
index 0ddcb8787a..0000000000
--- a/gdk/mir/gdkmirscreen.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <string.h>
-
-#include "gdkscreenprivate.h"
-#include "gdkdisplayprivate.h"
-#include "gdkvisualprivate.h"
-#include "gdkinternals.h"
-
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-#define VISUAL_TYPE GDK_VISUAL_TRUE_COLOR
-#define VISUAL_DEPTH 32
-
-typedef struct GdkMirScreen GdkMirScreen;
-typedef struct GdkMirScreenClass GdkMirScreenClass;
-
-#define GDK_TYPE_MIR_SCREEN (gdk_mir_screen_get_type ())
-#define GDK_MIR_SCREEN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_SCREEN, GdkMirScreen))
-#define GDK_MIR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_SCREEN, GdkMirScreenClass))
-#define GDK_IS_MIR_SCREEN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_SCREEN))
-#define GDK_IS_MIR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_SCREEN))
-#define GDK_MIR_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_SCREEN, GdkMirScreenClass))
-
-struct GdkMirScreen
-{
- GdkScreen parent_instance;
-
- /* Display this screen is running on */
- GdkDisplay *display;
-
- /* Current monitor configuration */
- MirDisplayConfig *display_config;
-
- /* Display format */
- GdkVisual *visual;
-
- /* Root window */
- GdkWindow *root_window;
-
- /* Settings */
- GHashTable *settings_objects;
- GHashTable *current_settings;
-};
-
-struct GdkMirScreenClass
-{
- GdkScreenClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirScreen, gdk_mir_screen, GDK_TYPE_SCREEN)
-
-static MirConnection *
-get_connection (GdkMirScreen *screen)
-{
- return gdk_mir_display_get_mir_connection (GDK_DISPLAY (screen->display));
-}
-
-static void
-get_screen_size (MirDisplayConfig *config,
- gint *width,
- gint *height)
-{
- const MirOutput *output;
- const MirOutputMode *mode;
- gint right;
- gint bottom;
- gint i;
-
- *width = 0;
- *height = 0;
-
- if (!config)
- return;
-
- for (i = 0; i < mir_display_config_get_num_outputs (config); i++)
- {
- output = mir_display_config_get_output (config, i);
-
- if (!mir_output_is_enabled (output))
- continue;
-
- mode = mir_output_get_current_mode (output);
-
- right = mir_output_get_position_x (output) + mir_output_mode_get_width (mode);
- bottom = mir_output_get_position_y (output) + mir_output_mode_get_height (mode);
-
- if (right > *width)
- *width = right;
-
- if (bottom > *height)
- *height = bottom;
- }
-}
-
-static void
-get_screen_size_mm (MirDisplayConfig *config,
- gint *width,
- gint *height)
-{
- const MirOutput *output;
- gint i;
-
- *width = 0;
- *height = 0;
-
- if (!config)
- return;
-
- for (i = 0; i < mir_display_config_get_num_outputs (config); i++)
- {
- output = mir_display_config_get_output (config, i);
-
- if (!mir_output_is_enabled (output))
- continue;
-
- *width += mir_output_get_physical_width_mm (output);
- *height += mir_output_get_physical_height_mm (output);
- }
-}
-
-static void
-update_display_config (GdkMirScreen *screen)
-{
- gdk_mir_display_get_mir_connection (GDK_DISPLAY (screen->display));
- mir_display_config_release (screen->display_config);
- screen->display_config = mir_connection_create_display_configuration (get_connection (screen));
-}
-
-static void
-config_changed_cb (MirConnection *connection, void *data)
-{
- GdkMirScreen *screen = data;
- gint old_width, old_height, new_width, new_height;
-
- get_screen_size (screen->display_config, &old_width, &old_height);
- update_display_config (screen);
- get_screen_size (screen->display_config, &new_width, &new_height);
-
- g_signal_emit_by_name (screen, "monitors-changed");
- if (old_width > 0 && (old_width != new_width || old_height != new_height))
- g_signal_emit_by_name (screen, "size-changed");
-}
-
-GdkScreen *
-_gdk_mir_screen_new (GdkDisplay *display)
-{
- GdkMirScreen *screen;
-
- screen = g_object_new (GDK_TYPE_MIR_SCREEN, NULL);
- screen->display = display;
- mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, screen);
- update_display_config (screen);
-
- return GDK_SCREEN (screen);
-}
-
-static void
-gdk_mir_screen_dispose (GObject *object)
-{
- GdkMirScreen *screen = GDK_MIR_SCREEN (object);
-
- g_clear_pointer (&screen->current_settings, g_hash_table_unref);
- g_clear_pointer (&screen->settings_objects, g_hash_table_unref);
-
- G_OBJECT_CLASS (gdk_mir_screen_parent_class)->dispose (object);
-}
-
-static void
-gdk_mir_screen_finalize (GObject *object)
-{
- GdkMirScreen *screen = GDK_MIR_SCREEN (object);
-
- mir_connection_set_display_config_change_callback (get_connection (screen), NULL, NULL);
- mir_display_config_release (screen->display_config);
- g_clear_object (&screen->visual);
- g_clear_object (&screen->root_window);
-
- G_OBJECT_CLASS (gdk_mir_screen_parent_class)->finalize (object);
-}
-
-static GdkDisplay *
-gdk_mir_screen_get_display (GdkScreen *screen)
-{
- return GDK_DISPLAY (GDK_MIR_SCREEN (screen)->display);
-}
-
-static const MirOutput *
-get_output (GdkScreen *screen,
- gint monitor_num)
-{
- MirDisplayConfig *config;
- const MirOutput *output;
- gint i;
- gint j;
-
- config = GDK_MIR_SCREEN (screen)->display_config;
-
- for (i = 0, j = 0; i < mir_display_config_get_num_outputs (config); i++)
- {
- output = mir_display_config_get_output (config, i);
-
- if (!mir_output_is_enabled (output))
- continue;
-
- if (j == monitor_num)
- return output;
-
- j++;
- }
-
- return NULL;
-}
-
-static gint
-gdk_mir_screen_get_width (GdkScreen *screen)
-{
- gint width, height;
- get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
- return width;
-}
-
-static gint
-gdk_mir_screen_get_height (GdkScreen *screen)
-{
- gint width, height;
- get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
- return height;
-}
-
-static gint
-gdk_mir_screen_get_width_mm (GdkScreen *screen)
-{
- gint width, height;
- get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
- return width;
-}
-
-static gint
-gdk_mir_screen_get_height_mm (GdkScreen *screen)
-{
- gint width, height;
- get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
- return height;
-}
-
-static gint
-gdk_mir_screen_get_number (GdkScreen *screen)
-{
- /* There is only one screen... */
- return 0;
-}
-
-static GdkWindow *
-gdk_mir_screen_get_root_window (GdkScreen *screen)
-{
- GdkMirScreen *s = GDK_MIR_SCREEN (screen);
- gint width, height;
-
- if (s->root_window)
- return s->root_window;
-
- get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
-
- s->root_window = _gdk_display_create_window (s->display);
- s->root_window->impl_window = s->root_window;
- s->root_window->visual = s->visual;
- s->root_window->window_type = GDK_WINDOW_ROOT;
- s->root_window->depth = VISUAL_DEPTH;
- s->root_window->x = 0;
- s->root_window->y = 0;
- s->root_window->abs_x = 0;
- s->root_window->abs_y = 0;
- s->root_window->width = width;
- s->root_window->height = height;
- s->root_window->viewable = TRUE;
- s->root_window->impl = _gdk_mir_window_impl_new (s->display, s->root_window, NULL, 0);
-
- return s->root_window;
-}
-
-static gint
-gdk_mir_screen_get_n_monitors (GdkScreen *screen)
-{
- MirDisplayConfig *config;
- gint count = 0;
- gint i;
-
- config = GDK_MIR_SCREEN (screen)->display_config;
-
- for (i = 0; i < mir_display_config_get_num_outputs (config); i++)
- if (mir_output_is_enabled (mir_display_config_get_output (config, i)))
- count++;
-
- return count;
-}
-
-static gint
-gdk_mir_screen_get_primary_monitor (GdkScreen *screen)
-{
- return 0; //?
-}
-
-static gint
-gdk_mir_screen_get_monitor_width_mm (GdkScreen *screen,
- gint monitor_num)
-{
- const MirOutput *output = get_output (screen, monitor_num);
-
- return output ? mir_output_get_physical_width_mm (output) : 0;
-}
-
-static gint
-gdk_mir_screen_get_monitor_height_mm (GdkScreen *screen,
- gint monitor_num)
-{
- const MirOutput *output = get_output (screen, monitor_num);
-
- return output ? mir_output_get_physical_height_mm (output) : 0;
-}
-
-static gchar *
-gdk_mir_screen_get_monitor_plug_name (GdkScreen *screen,
- gint monitor_num)
-{
- const MirOutput *output = get_output (screen, monitor_num);
-
- if (output)
- {
- switch (mir_output_get_type (output))
- {
- case mir_output_type_unknown:
- return g_strdup_printf ("None-%u", mir_output_get_id (output));
- case mir_output_type_vga:
- return g_strdup_printf ("VGA-%u", mir_output_get_id (output));
- case mir_output_type_dvii:
- case mir_output_type_dvid:
- case mir_output_type_dvia:
- return g_strdup_printf ("DVI-%u", mir_output_get_id (output));
- case mir_output_type_composite:
- return g_strdup_printf ("Composite-%u", mir_output_get_id (output));
- case mir_output_type_lvds:
- return g_strdup_printf ("LVDS-%u", mir_output_get_id (output));
- case mir_output_type_component:
- return g_strdup_printf ("CTV-%u", mir_output_get_id (output));
- case mir_output_type_ninepindin:
- return g_strdup_printf ("DIN-%u", mir_output_get_id (output));
- case mir_output_type_displayport:
- return g_strdup_printf ("DP-%u", mir_output_get_id (output));
- case mir_output_type_hdmia:
- case mir_output_type_hdmib:
- return g_strdup_printf ("HDMI-%u", mir_output_get_id (output));
- case mir_output_type_svideo:
- case mir_output_type_tv:
- return g_strdup_printf ("TV-%u", mir_output_get_id (output));
- case mir_output_type_edp:
- return g_strdup_printf ("eDP-%u", mir_output_get_id (output));
- case mir_output_type_virtual:
- return g_strdup_printf ("Virtual-%u", mir_output_get_id (output));
- case mir_output_type_dsi:
- return g_strdup_printf ("DSI-%u", mir_output_get_id (output));
- case mir_output_type_dpi:
- return g_strdup_printf ("DPI-%u", mir_output_get_id (output));
- }
- }
-
- return NULL;
-}
-
-static void
-gdk_mir_screen_get_monitor_geometry (GdkScreen *screen,
- gint monitor_num,
- GdkRectangle *dest)
-{
- const MirOutput *output;
- const MirOutputMode *mode;
-
- output = get_output (screen, monitor_num);
-
- if (output)
- {
- mode = mir_output_get_current_mode (output);
-
- dest->x = mir_output_get_position_x (output);
- dest->y = mir_output_get_position_y (output);
- dest->width = mir_output_mode_get_width (mode);
- dest->height = mir_output_mode_get_height (mode);
- }
- else
- {
- dest->x = 0;
- dest->y = 0;
- dest->width = 0;
- dest->height = 0;
- }
-}
-
-static void
-gdk_mir_screen_get_monitor_workarea (GdkScreen *screen,
- gint monitor_num,
- GdkRectangle *dest)
-{
- // FIXME: Don't know what this is
- gdk_mir_screen_get_monitor_geometry (screen, monitor_num, dest);
-}
-
-static GList *
-gdk_mir_screen_list_visuals (GdkScreen *screen)
-{
- return g_list_append (NULL, GDK_MIR_SCREEN (screen)->visual);
-}
-
-static GdkVisual *
-gdk_mir_screen_get_system_visual (GdkScreen *screen)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static GdkVisual *
-gdk_mir_screen_get_rgba_visual (GdkScreen *screen)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static gboolean
-gdk_mir_screen_is_composited (GdkScreen *screen)
-{
- /* We're always composited */
- return TRUE;
-}
-
-static gchar *
-gdk_mir_screen_make_display_name (GdkScreen *screen)
-{
- return NULL; // FIXME
-}
-
-static GdkWindow *
-gdk_mir_screen_get_active_window (GdkScreen *screen)
-{
- return NULL; // FIXME
-}
-
-static GList *
-gdk_mir_screen_get_window_stack (GdkScreen *screen)
-{
- return NULL; // FIXME
-}
-
-static void
-gdk_mir_screen_broadcast_client_message (GdkScreen *screen,
- GdkEvent *event)
-{
- // FIXME
-}
-
-static void setting_changed (GSettings *settings,
- const gchar *key,
- GdkMirScreen *screen);
-
-static GSettings *
-get_settings (GdkMirScreen *screen,
- const gchar *schema_id)
-{
- GSettings *settings;
- GSettingsSchemaSource *source;
- GSettingsSchema *schema;
-
- settings = g_hash_table_lookup (screen->settings_objects, schema_id);
-
- if (settings)
- return g_object_ref (settings);
-
- source = g_settings_schema_source_get_default ();
-
- if (!source)
- {
- g_warning ("no schemas installed");
- return NULL;
- }
-
- schema = g_settings_schema_source_lookup (source, schema_id, TRUE);
-
- if (!schema)
- {
- g_warning ("schema not found: %s", schema_id);
- return NULL;
- }
-
- settings = g_settings_new_full (schema, NULL, NULL);
- g_signal_connect (settings, "changed", G_CALLBACK (setting_changed), screen);
- g_hash_table_insert (screen->settings_objects, g_strdup (schema_id), g_object_ref (settings));
- g_settings_schema_unref (schema);
- return settings;
-}
-
-static GVariant *
-read_setting (GdkMirScreen *screen,
- const gchar *schema_id,
- const gchar *key)
-{
- GSettings *settings;
- GVariant *variant;
-
- settings = get_settings (screen, schema_id);
-
- if (!settings)
- return NULL;
-
- variant = g_settings_get_value (settings, key);
- g_object_unref (settings);
- return variant;
-}
-
-static void
-change_setting (GdkMirScreen *screen,
- const gchar *name,
- GVariant *variant)
-{
- GVariant *old_variant;
- GdkEventSetting event;
-
- old_variant = g_hash_table_lookup (screen->current_settings, name);
-
- if (variant == old_variant)
- return;
-
- if (variant && old_variant && g_variant_equal (variant, old_variant))
- return;
-
- event.type = GDK_SETTING;
- event.window = gdk_screen_get_root_window (GDK_SCREEN (screen));
- event.send_event = FALSE;
- event.name = g_strdup (name);
-
- if (variant)
- {
- event.action = old_variant ? GDK_SETTING_ACTION_CHANGED : GDK_SETTING_ACTION_NEW;
- g_hash_table_insert (screen->current_settings, g_strdup (name), g_variant_ref_sink (variant));
- }
- else
- {
- event.action = GDK_SETTING_ACTION_DELETED;
- g_hash_table_remove (screen->current_settings, name);
- }
-
- gdk_event_put ((const GdkEvent *) &event);
- g_free (event.name);
-}
-
-static const struct
-{
- const gchar *name;
- const gchar *schema_id;
- const gchar *key;
-} SETTINGS_MAP[] = {
- {
- "gtk-double-click-time",
- "org.gnome.settings-daemon.peripherals.mouse",
- "double-click"
- },
- {
- "gtk-cursor-blink",
- "org.gnome.desktop.interface",
- "cursor-blink"
- },
- {
- "gtk-cursor-blink-time",
- "org.gnome.desktop.interface",
- "cursor-blink-time"
- },
- {
- "gtk-cursor-blink-timeout",
- "org.gnome.desktop.interface",
- "cursor-blink-timeout"
- },
- {
- "gtk-theme-name",
- "org.gnome.desktop.interface",
- "gtk-theme"
- },
- {
- "gtk-icon-theme-name",
- "org.gnome.desktop.interface",
- "icon-theme"
- },
- {
- "gtk-key-theme-name",
- "org.gnome.desktop.interface",
- "gtk-key-theme"
- },
- {
- "gtk-dnd-drag-threshold",
- "org.gnome.settings-daemon.peripherals.mouse",
- "drag-threshold"
- },
- {
- "gtk-font-name",
- "org.gnome.desktop.interface",
- "font-name"
- },
- {
- "gtk-xft-antialias",
- "org.gnome.settings-daemon.plugins.xsettings",
- "antialiasing"
- },
- {
- "gtk-xft-hinting",
- "org.gnome.settings-daemon.plugins.xsettings",
- "hinting"
- },
- {
- "gtk-xft-hintstyle",
- "org.gnome.settings-daemon.plugins.xsettings",
- "hinting"
- },
- {
- "gtk-xft-rgba",
- "org.gnome.settings-daemon.plugins.xsettings",
- "rgba-order"
- },
- {
- "gtk-xft-dpi",
- "org.gnome.desktop.interface",
- "text-scaling-factor"
- },
- {
- "gtk-cursor-theme-name",
- "org.gnome.desktop.interface",
- "cursor-theme"
- },
- {
- "gtk-cursor-theme-size",
- "org.gnome.desktop.interface",
- "cursor-size"
- },
- {
- "gtk-enable-animations",
- "org.gnome.desktop.interface",
- "enable-animations"
- },
- {
- "gtk-im-module",
- "org.gnome.desktop.interface",
- "gtk-im-module"
- },
- {
- "gtk-recent-files-max-age",
- "org.gnome.desktop.privacy",
- "recent-files-max-age"
- },
- {
- "gtk-sound-theme-name",
- "org.gnome.desktop.sound",
- "theme-name"
- },
- {
- "gtk-enable-input-feedback-sounds",
- "org.gnome.desktop.sound",
- "input-feedback-sounds"
- },
- {
- "gtk-enable-event-sounds",
- "org.gnome.desktop.sound",
- "event-sounds"
- },
- {
- "gtk-shell-shows-desktop",
- "org.gnome.desktop.background",
- "show-desktop-icons"
- },
- {
- "gtk-decoration-layout",
- "org.gnome.desktop.wm.preferences",
- "button-layout"
- },
- {
- "gtk-titlebar-double-click",
- "org.gnome.desktop.wm.preferences",
- "action-double-click-titlebar"
- },
- {
- "gtk-titlebar-middle-click",
- "org.gnome.desktop.wm.preferences",
- "action-middle-click-titlebar"
- },
- {
- "gtk-titlebar-right-click",
- "org.gnome.desktop.wm.preferences",
- "action-right-click-titlebar"
- },
- {
- "gtk-enable-primary-paste",
- "org.gnome.desktop.interface",
- "gtk-enable-primary-paste"
- },
- {
- "gtk-recent-files-enabled",
- "org.gnome.desktop.privacy",
- "remember-recent-files"
- },
- {
- "gtk-keynav-use-caret",
- "org.gnome.desktop.a11y",
- "always-show-text-caret"
- },
- { NULL }
-};
-
-static guint
-get_scaling_factor (GdkMirScreen *screen)
-{
- GVariant *variant;
- guint scaling_factor;
-
- variant = read_setting (screen, "org.gnome.desktop.interface", "scaling-factor");
-
- if (!variant)
- {
- g_warning ("no scaling factor: org.gnome.desktop.interface.scaling-factor");
- variant = g_variant_ref_sink (g_variant_new_uint32 (0));
- }
-
- scaling_factor = g_variant_get_uint32 (variant);
- g_variant_unref (variant);
-
- if (scaling_factor)
- return scaling_factor;
-
- scaling_factor = 1;
-
- /* TODO: scaling_factor = 2 if HiDPI >= 2 * 96 */
-
- return scaling_factor;
-}
-
-static void
-update_setting (GdkMirScreen *screen,
- const gchar *name)
-{
- GVariant *variant;
- GVariant *antialiasing_variant;
- gboolean gtk_xft_antialias;
- gboolean gtk_xft_hinting;
- gdouble text_scaling_factor;
- gint cursor_size;
- gint i;
-
- if (!g_strcmp0 (name, "gtk-modules"))
- {
- /* TODO: X-GTK-Module-Enabled-Schema, X-GTK-Module-Enabled-Key */
- /* TODO: org.gnome.settings-daemon.plugins.xsettings.enabled-gtk-modules */
- /* TODO: org.gnome.settings-daemon.plugins.xsettings.disabled-gtk-modules */
- return;
- }
- else
- {
- for (i = 0; SETTINGS_MAP[i].name; i++)
- if (!g_strcmp0 (name, SETTINGS_MAP[i].name))
- break;
-
- if (!SETTINGS_MAP[i].name)
- return;
-
- variant = read_setting (screen, SETTINGS_MAP[i].schema_id, SETTINGS_MAP[i].key);
-
- if (!variant)
- {
- g_warning ("no setting for %s: %s.%s", SETTINGS_MAP[i].name, SETTINGS_MAP[i].schema_id, SETTINGS_MAP[i].key);
- return;
- }
- }
-
- if (!g_strcmp0 (name, "gtk-xft-antialias"))
- {
- gtk_xft_antialias = g_strcmp0 (g_variant_get_string (variant, NULL), "none");
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_int32 (gtk_xft_antialias ? 1 : 0));
- }
- else if (!g_strcmp0 (name, "gtk-xft-hinting"))
- {
- gtk_xft_hinting = g_strcmp0 (g_variant_get_string (variant, NULL), "none");
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_int32 (gtk_xft_hinting ? 1 : 0));
- }
- else if (!g_strcmp0 (name, "gtk-xft-hintstyle"))
- {
- if (!g_strcmp0 (g_variant_get_string (variant, NULL), "none"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("hintnone"));
- }
- else if (!g_strcmp0 (g_variant_get_string (variant, NULL), "slight"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("hintslight"));
- }
- else if (!g_strcmp0 (g_variant_get_string (variant, NULL), "medium"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("hintmedium"));
- }
- else if (!g_strcmp0 (g_variant_get_string (variant, NULL), "full"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("hintfull"));
- }
- else
- {
- g_warning ("unknown org.gnome.settings-daemon.plugins.xsettings.hinting value: %s", g_variant_get_string (variant, NULL));
- g_variant_unref (variant);
- return;
- }
- }
- else if (!g_strcmp0 (name, "gtk-xft-rgba"))
- {
- antialiasing_variant = read_setting (screen, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing");
-
- if (g_strcmp0 (g_variant_get_string (antialiasing_variant, NULL), "rgba"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("none"));
- }
- else if (g_strcmp0 (g_variant_get_string (variant, NULL), "rgba"))
- {
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_string ("rgb"));
- }
-
- g_variant_unref (antialiasing_variant);
- }
- else if (!g_strcmp0 (name, "gtk-xft-dpi"))
- {
- text_scaling_factor = g_variant_get_double (variant);
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_int32 (1024 * get_scaling_factor (screen) * text_scaling_factor + 0.5));
- }
- else if (!g_strcmp0 (name, "gtk-cursor-theme-size"))
- {
- cursor_size = g_variant_get_int32 (variant);
- g_variant_unref (variant);
- variant = g_variant_ref_sink (g_variant_new_int32 (get_scaling_factor (screen) * cursor_size));
- }
- else if (!g_strcmp0 (name, "gtk-enable-animations"))
- {
- /* TODO: disable under vnc/vino/llvmpipe */
- }
-
- change_setting (screen, name, variant);
- g_variant_unref (variant);
-}
-
-static void
-setting_changed (GSettings *settings,
- const gchar *key,
- GdkMirScreen *screen)
-{
- gchar *schema_id;
- gint i;
-
- g_object_get (settings, "schema-id", &schema_id, NULL);
-
- for (i = 0; SETTINGS_MAP[i].name; i++)
- if (!g_strcmp0 (schema_id, SETTINGS_MAP[i].schema_id) && !g_strcmp0 (key, SETTINGS_MAP[i].key))
- update_setting (screen, SETTINGS_MAP[i].name);
-
- if (!g_strcmp0 (schema_id, "org.gnome.settings-daemon.plugins.xsettings"))
- {
- if (!g_strcmp0 (key, "enabled-gtk-modules"))
- update_setting (screen, "gtk-modules");
- else if (!g_strcmp0 (key, "disabled-gtk-modules"))
- update_setting (screen, "gtk-modules");
- else if (!g_strcmp0 (key, "antialiasing"))
- update_setting (screen, "rgba-order");
- }
- else if (!g_strcmp0 (schema_id, "org.gnome.desktop.interface"))
- {
- if (!g_strcmp0 (key, "scaling-factor"))
- {
- update_setting (screen, "gtk-xft-dpi");
- update_setting (screen, "gtk-cursor-theme-size");
- }
- }
-
- g_free (schema_id);
-}
-
-static const gchar * const KNOWN_SETTINGS[] =
-{
- "gtk-double-click-time",
- "gtk-double-click-distance",
- "gtk-cursor-blink",
- "gtk-cursor-blink-time",
- "gtk-cursor-blink-timeout",
- "gtk-split-cursor",
- "gtk-theme-name",
- "gtk-icon-theme-name",
- "gtk-fallback-icon-theme",
- "gtk-key-theme-name",
- "gtk-menu-bar-accel",
- "gtk-dnd-drag-threshold",
- "gtk-font-name",
- "gtk-icon-sizes",
- "gtk-modules",
- "gtk-xft-antialias",
- "gtk-xft-hinting",
- "gtk-xft-hintstyle",
- "gtk-xft-rgba",
- "gtk-xft-dpi",
- "gtk-cursor-theme-name",
- "gtk-cursor-theme-size",
- "gtk-alternative-button-order",
- "gtk-alternative-sort-arrows",
- "gtk-show-input-method-menu",
- "gtk-show-unicode-menu",
- "gtk-timeout-initial",
- "gtk-timeout-repeat",
- "gtk-timeout-expand",
- "gtk-color-scheme",
- "gtk-enable-animations",
- "gtk-touchscreen-mode",
- "gtk-tooltip-timeout",
- "gtk-tooltip-browse-timeout",
- "gtk-tooltip-browse-mode-timeout",
- "gtk-keynav-cursor-only",
- "gtk-keynav-wrap-around",
- "gtk-error-bell",
- "color-hash",
- "gtk-file-chooser-backend",
- "gtk-print-backends",
- "gtk-print-preview-command",
- "gtk-enable-mnemonics",
- "gtk-enable-accels",
- "gtk-recent-files-limit",
- "gtk-im-module",
- "gtk-recent-files-max-age",
- "gtk-fontconfig-timestamp",
- "gtk-sound-theme-name",
- "gtk-enable-input-feedback-sounds",
- "gtk-enable-event-sounds",
- "gtk-enable-tooltips",
- "gtk-toolbar-style",
- "gtk-toolbar-icon-size",
- "gtk-auto-mnemonics",
- "gtk-primary-button-warps-slider",
- "gtk-visible-focus",
- "gtk-application-prefer-dark-theme",
- "gtk-button-images",
- "gtk-entry-select-on-focus",
- "gtk-entry-password-hint-timeout",
- "gtk-menu-images",
- "gtk-menu-bar-popup-delay",
- "gtk-scrolled-window-placement",
- "gtk-can-change-accels",
- "gtk-menu-popup-delay",
- "gtk-menu-popdown-delay",
- "gtk-label-select-on-focus",
- "gtk-color-palette",
- "gtk-im-preedit-style",
- "gtk-im-status-style",
- "gtk-shell-shows-app-menu",
- "gtk-shell-shows-menubar",
- "gtk-shell-shows-desktop",
- "gtk-decoration-layout",
- "gtk-titlebar-double-click",
- "gtk-titlebar-middle-click",
- "gtk-titlebar-right-click",
- "gtk-dialogs-use-header",
- "gtk-enable-primary-paste",
- "gtk-recent-files-enabled",
- "gtk-long-press-time",
- "gtk-keynav-use-caret",
- NULL
-};
-
-static gboolean
-gdk_mir_screen_get_setting (GdkScreen *screen,
- const gchar *name,
- GValue *value)
-{
- GdkMirScreen *mir_screen;
- GVariant *variant;
-
- mir_screen = GDK_MIR_SCREEN (screen);
- variant = g_hash_table_lookup (mir_screen->current_settings, name);
-
- if (!variant)
- update_setting (mir_screen, name);
-
- variant = g_hash_table_lookup (mir_screen->current_settings, name);
-
- if (!variant)
- {
- if (!g_strv_contains (KNOWN_SETTINGS, name))
- g_warning ("unknown setting: %s", name);
-
- return FALSE;
- }
-
- g_dbus_gvariant_to_gvalue (variant, value);
- return TRUE;
-}
-
-static gint
-gdk_mir_screen_visual_get_best_depth (GdkScreen *screen)
-{
- return VISUAL_DEPTH;
-}
-
-static GdkVisualType
-gdk_mir_screen_visual_get_best_type (GdkScreen *screen)
-{
- return VISUAL_TYPE;
-}
-
-static GdkVisual*
-gdk_mir_screen_visual_get_best (GdkScreen *screen)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static GdkVisual*
-gdk_mir_screen_visual_get_best_with_depth (GdkScreen *screen,
- gint depth)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static GdkVisual*
-gdk_mir_screen_visual_get_best_with_type (GdkScreen *screen,
- GdkVisualType visual_type)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static GdkVisual*
-gdk_mir_screen_visual_get_best_with_both (GdkScreen *screen,
- gint depth,
- GdkVisualType visual_type)
-{
- return GDK_MIR_SCREEN (screen)->visual;
-}
-
-static void
-gdk_mir_screen_query_depths (GdkScreen *screen,
- gint **depths,
- gint *count)
-{
- static gint supported_depths[] = { VISUAL_DEPTH };
- *depths = supported_depths;
- *count = 1;
-}
-
-static void
-gdk_mir_screen_query_visual_types (GdkScreen *screen,
- GdkVisualType **visual_types,
- gint *count)
-{
- static GdkVisualType supported_visual_types[] = { VISUAL_TYPE };
- *visual_types = supported_visual_types;
- *count = 1;
-}
-
-static gint
-gdk_mir_screen_get_monitor_scale_factor (GdkScreen *screen,
- gint monitor_num)
-{
- /* Don't support monitor scaling */
- return 1;
-}
-
-static void
-gdk_mir_screen_init (GdkMirScreen *screen)
-{
- screen->visual = g_object_new (GDK_TYPE_VISUAL, NULL);
- screen->visual->screen = GDK_SCREEN (screen);
- screen->visual->type = VISUAL_TYPE;
- screen->visual->depth = VISUAL_DEPTH;
-
- screen->settings_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- screen->current_settings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
-}
-
-static void
-gdk_mir_screen_class_init (GdkMirScreenClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
-
- object_class->dispose = gdk_mir_screen_dispose;
- object_class->finalize = gdk_mir_screen_finalize;
-
- screen_class->get_display = gdk_mir_screen_get_display;
- screen_class->get_width = gdk_mir_screen_get_width;
- screen_class->get_height = gdk_mir_screen_get_height;
- screen_class->get_width_mm = gdk_mir_screen_get_width_mm;
- screen_class->get_height_mm = gdk_mir_screen_get_height_mm;
- screen_class->get_number = gdk_mir_screen_get_number;
- screen_class->get_root_window = gdk_mir_screen_get_root_window;
- screen_class->get_n_monitors = gdk_mir_screen_get_n_monitors;
- screen_class->get_primary_monitor = gdk_mir_screen_get_primary_monitor;
- screen_class->get_monitor_width_mm = gdk_mir_screen_get_monitor_width_mm;
- screen_class->get_monitor_height_mm = gdk_mir_screen_get_monitor_height_mm;
- screen_class->get_monitor_plug_name = gdk_mir_screen_get_monitor_plug_name;
- screen_class->get_monitor_geometry = gdk_mir_screen_get_monitor_geometry;
- screen_class->get_monitor_workarea = gdk_mir_screen_get_monitor_workarea;
- screen_class->list_visuals = gdk_mir_screen_list_visuals;
- screen_class->get_system_visual = gdk_mir_screen_get_system_visual;
- screen_class->get_rgba_visual = gdk_mir_screen_get_rgba_visual;
- screen_class->is_composited = gdk_mir_screen_is_composited;
- screen_class->make_display_name = gdk_mir_screen_make_display_name;
- screen_class->get_active_window = gdk_mir_screen_get_active_window;
- screen_class->get_window_stack = gdk_mir_screen_get_window_stack;
- screen_class->broadcast_client_message = gdk_mir_screen_broadcast_client_message;
- screen_class->get_setting = gdk_mir_screen_get_setting;
- screen_class->visual_get_best_depth = gdk_mir_screen_visual_get_best_depth;
- screen_class->visual_get_best_type = gdk_mir_screen_visual_get_best_type;
- screen_class->visual_get_best = gdk_mir_screen_visual_get_best;
- screen_class->visual_get_best_with_depth = gdk_mir_screen_visual_get_best_with_depth;
- screen_class->visual_get_best_with_type = gdk_mir_screen_visual_get_best_with_type;
- screen_class->visual_get_best_with_both = gdk_mir_screen_visual_get_best_with_both;
- screen_class->query_depths = gdk_mir_screen_query_depths;
- screen_class->query_visual_types = gdk_mir_screen_query_visual_types;
- screen_class->get_monitor_scale_factor = gdk_mir_screen_get_monitor_scale_factor;
-}
diff --git a/gdk/mir/gdkmirwindow.c b/gdk/mir/gdkmirwindow.c
deleted file mode 100644
index 03da7e0013..0000000000
--- a/gdk/mir/gdkmirwindow.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gdkinternals.h"
-
-#include "gdkmir.h"
-
-#define GDK_MIR_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_MIR, GdkMirWindow))
-#define GDK_MIR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_MIR, GdkMirWindowClass))
-#define GDK_IS_WINDOW_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_MIR))
-#define GDK_MIR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_MIR, GdkMirWindowClass))
-
-typedef struct _GdkMirWindow GdkMirWindow;
-typedef struct _GdkMirWindowClass GdkMirWindowClass;
-
-struct _GdkMirWindow
-{
- GdkWindow parent_instance;
-};
-
-struct _GdkMirWindowClass
-{
- GdkWindowClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirWindow, gdk_mir_window, GDK_TYPE_WINDOW)
-
-static void
-gdk_mir_window_init (GdkMirWindow *impl)
-{
-}
-
-static void
-gdk_mir_window_class_init (GdkMirWindowClass *klass)
-{
-}
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
deleted file mode 100644
index 9f9107611e..0000000000
--- a/gdk/mir/gdkmirwindowimpl.c
+++ /dev/null
@@ -1,2499 +0,0 @@
-/*
- * Copyright © 2014 Canonical Ltd
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <inttypes.h>
-#include <math.h>
-
-#include "config.h"
-
-#include "gdk.h"
-#include "gdkmir.h"
-#include "gdkmir-private.h"
-
-#include "gdkwindowimpl.h"
-#include "gdkinternals.h"
-#include "gdkintl.h"
-#include "gdkdisplayprivate.h"
-#include "gdkdeviceprivate.h"
-
-#define GDK_MIR_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImplClass))
-#define GDK_IS_WINDOW_IMPL_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_MIR))
-#define GDK_MIR_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImplClass))
-
-#define MAX_EGL_ATTRS 30
-
-typedef struct
-{
- GdkAtom type;
- GArray *array;
-} GdkMirProperty;
-
-static GdkMirProperty *
-gdk_mir_property_new (GdkAtom type,
- guint format,
- guint capacity)
-{
- GdkMirProperty *property = g_slice_new (GdkMirProperty);
-
- property->type = type;
- property->array = g_array_sized_new (TRUE, FALSE, format, capacity);
-
- return property;
-}
-
-static void
-gdk_mir_property_free (gpointer data)
-{
- GdkMirProperty *property = data;
-
- if (!property)
- return;
-
- g_array_unref (property->array);
- g_slice_free (GdkMirProperty, property);
-}
-
-typedef struct _GdkMirWindowImplClass GdkMirWindowImplClass;
-
-struct _GdkMirWindowImpl
-{
- GdkWindowImpl parent_instance;
-
- GHashTable *properties;
-
- /* Window we are temporary for */
- GdkWindow *transient_for;
- gint transient_x;
- gint transient_y;
-
- /* gdk_window_move_to_rect */
- gboolean has_rect;
- GdkRectangle rect;
- MirRectangle mir_rect;
- MirPlacementGravity rect_anchor;
- MirPlacementGravity window_anchor;
- MirPlacementHints anchor_hints;
- gint rect_anchor_dx;
- gint rect_anchor_dy;
-
- /* Desired window attributes */
- GdkWindowTypeHint type_hint;
- MirWindowState window_state;
- gboolean modal;
-
- /* Pattern for background */
- cairo_pattern_t *background;
-
- /* Current button state for checking which buttons are being pressed / released */
- gdouble x;
- gdouble y;
- guint button_state;
-
- GdkDisplay *display;
-
- /* Window being rendered to (only exists when visible) */
- MirWindow *mir_window;
- MirBufferStream *buffer_stream;
- MirBufferUsage buffer_usage;
-
- /* Cairo context for current frame */
- cairo_surface_t *cairo_surface;
-
- gchar *title;
-
- GdkGeometry geometry_hints;
- GdkWindowHints geometry_mask;
-
- /* Egl surface for the current mir window */
- EGLSurface egl_surface;
-
- /* Dummy MIR and EGL surfaces */
- EGLSurface dummy_egl_surface;
-
- /* TRUE if the window can be seen */
- gboolean visible;
-
- /* TRUE if cursor is inside this window */
- gboolean cursor_inside;
-
- gboolean pending_spec_update;
- gint output_scale;
-};
-
-struct _GdkMirWindowImplClass
-{
- GdkWindowImplClass parent_class;
-};
-
-G_DEFINE_TYPE (GdkMirWindowImpl, gdk_mir_window_impl, GDK_TYPE_WINDOW_IMPL)
-
-static cairo_surface_t *gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window);
-static void ensure_mir_window (GdkWindow *window);
-
-static gboolean
-type_hint_differs (GdkWindowTypeHint lhs, GdkWindowTypeHint rhs)
-{
- if (lhs == rhs)
- return FALSE;
-
- switch (lhs)
- {
- case GDK_WINDOW_TYPE_HINT_DIALOG:
- case GDK_WINDOW_TYPE_HINT_DOCK:
- return rhs != GDK_WINDOW_TYPE_HINT_DIALOG &&
- rhs != GDK_WINDOW_TYPE_HINT_DOCK;
- case GDK_WINDOW_TYPE_HINT_MENU:
- case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
- case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
- case GDK_WINDOW_TYPE_HINT_TOOLBAR:
- case GDK_WINDOW_TYPE_HINT_COMBO:
- case GDK_WINDOW_TYPE_HINT_DND:
- case GDK_WINDOW_TYPE_HINT_TOOLTIP:
- case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
- return rhs != GDK_WINDOW_TYPE_HINT_MENU &&
- rhs != GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU &&
- rhs != GDK_WINDOW_TYPE_HINT_POPUP_MENU &&
- rhs != GDK_WINDOW_TYPE_HINT_TOOLBAR &&
- rhs != GDK_WINDOW_TYPE_HINT_COMBO &&
- rhs != GDK_WINDOW_TYPE_HINT_DND &&
- rhs != GDK_WINDOW_TYPE_HINT_TOOLTIP &&
- rhs != GDK_WINDOW_TYPE_HINT_NOTIFICATION;
- case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
- case GDK_WINDOW_TYPE_HINT_UTILITY:
- return rhs != GDK_WINDOW_TYPE_HINT_SPLASHSCREEN &&
- rhs != GDK_WINDOW_TYPE_HINT_UTILITY;
- case GDK_WINDOW_TYPE_HINT_NORMAL:
- case GDK_WINDOW_TYPE_HINT_DESKTOP:
- default:
- return rhs != GDK_WINDOW_TYPE_HINT_NORMAL &&
- rhs != GDK_WINDOW_TYPE_HINT_DESKTOP;
- }
-}
-
-static void
-drop_cairo_surface (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
-}
-
-static const gchar *
-get_default_title (void)
-{
- const char *title;
-
- title = g_get_application_name ();
- if (!title)
- title = g_get_prgname ();
- if (!title)
- title = "";
-
- return title;
-}
-
-GdkWindowImpl *
-_gdk_mir_window_impl_new (GdkDisplay *display, GdkWindow *window, GdkWindowAttr *attributes, gint attributes_mask)
-{
- GdkMirWindowImpl *impl = g_object_new (GDK_TYPE_MIR_WINDOW_IMPL, NULL);
-
- impl->display = display;
-
- if (attributes && attributes_mask & GDK_WA_TITLE)
- impl->title = g_strdup (attributes->title);
- else
- impl->title = g_strdup (get_default_title ());
-
- if (attributes && attributes_mask & GDK_WA_TYPE_HINT)
- impl->type_hint = attributes->type_hint;
-
- impl->pending_spec_update = TRUE;
-
- return (GdkWindowImpl *) impl;
-}
-
-void
-_gdk_mir_window_impl_set_window_state (GdkMirWindowImpl *impl,
- MirWindowState state)
-{
- impl->window_state = state;
-}
-
-void
-_gdk_mir_window_impl_set_window_type (GdkMirWindowImpl *impl,
- MirWindowType type)
-{
-}
-
-void
-_gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl,
- gdouble x,
- gdouble y,
- gboolean cursor_inside,
- guint button_state)
-{
- impl->x = x;
- impl->y = y;
- impl->cursor_inside = cursor_inside;
- impl->button_state = button_state;
-}
-
-void
-_gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl,
- gdouble *x,
- gdouble *y,
- gboolean *cursor_inside,
- guint *button_state)
-{
- if (x)
- *x = impl->x;
- if (y)
- *y = impl->y;
- if (cursor_inside)
- *cursor_inside = impl->cursor_inside;
- if (button_state)
- *button_state = impl->button_state;
-}
-
-static void
-gdk_mir_window_impl_init (GdkMirWindowImpl *impl)
-{
- impl->properties = g_hash_table_new_full (NULL, NULL, NULL, gdk_mir_property_free);
- impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
- impl->window_state = mir_window_state_unknown;
- impl->output_scale = 1;
-}
-
-static void
-set_window_state (GdkMirWindowImpl *impl,
- MirWindowState state)
-{
- MirConnection *connection = gdk_mir_display_get_mir_connection (impl->display);
- MirWindowSpec *spec;
-
- if (state == impl->window_state)
- return;
-
- impl->window_state = state;
-
- if (impl->mir_window && !impl->pending_spec_update)
- {
- spec = mir_create_window_spec (connection);
- mir_window_spec_set_state (spec, state);
- mir_window_apply_spec (impl->mir_window, spec);
- mir_window_spec_release (spec);
- }
-}
-
-static void
-event_cb (MirWindow *mir_window,
- const MirEvent *event,
- void *context)
-{
- _gdk_mir_event_source_queue (context, event);
-}
-
-static MirWindowSpec *
-create_window_type_spec (GdkDisplay *display,
- GdkWindow *parent,
- gint x,
- gint y,
- gint width,
- gint height,
- gboolean modal,
- GdkWindowTypeHint type,
- MirBufferUsage buffer_usage)
-{
- MirConnection *connection = gdk_mir_display_get_mir_connection (display);
- MirWindow *parent_mir_window = NULL;
- MirPixelFormat format;
- MirRectangle rect;
- MirWindowSpec *spec;
-
- if (parent && parent->impl)
- {
- ensure_mir_window (parent);
- parent_mir_window = GDK_MIR_WINDOW_IMPL (parent->impl)->mir_window;
- }
-
- if (!parent_mir_window)
- {
- switch (type)
- {
- case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
- case GDK_WINDOW_TYPE_HINT_UTILITY:
- type = GDK_WINDOW_TYPE_HINT_DIALOG;
- break;
- default:
- break;
- }
- }
-
- format = _gdk_mir_display_get_pixel_format (display, buffer_usage);
-
- rect.left = x;
- rect.top = y;
- rect.width = 1;
- rect.height = 1;
-
- switch (type)
- {
- case GDK_WINDOW_TYPE_HINT_DIALOG:
- if (modal)
- spec = mir_create_modal_dialog_window_spec (connection,
- width,
- height,
- parent_mir_window);
- else
- spec = mir_create_dialog_window_spec (connection,
- width,
- height);
- break;
- case GDK_WINDOW_TYPE_HINT_DOCK:
- spec = mir_create_dialog_window_spec (connection,
- width,
- height);
- break;
- case GDK_WINDOW_TYPE_HINT_MENU:
- case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
- case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
- case GDK_WINDOW_TYPE_HINT_TOOLBAR:
- case GDK_WINDOW_TYPE_HINT_COMBO:
- case GDK_WINDOW_TYPE_HINT_DND:
- case GDK_WINDOW_TYPE_HINT_TOOLTIP:
- case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
- spec = mir_create_menu_window_spec (connection,
- width,
- height,
- parent_mir_window,
- &rect,
- 0);
- break;
- case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
- case GDK_WINDOW_TYPE_HINT_UTILITY:
- spec = mir_create_modal_dialog_window_spec (connection,
- width,
- height,
- parent_mir_window);
- break;
- case GDK_WINDOW_TYPE_HINT_NORMAL:
- case GDK_WINDOW_TYPE_HINT_DESKTOP:
- default:
- spec = mir_create_normal_window_spec (connection,
- width,
- height);
- break;
- }
-
- mir_window_spec_set_pixel_format (spec, format);
-
- return spec;
-}
-
-static void
-apply_geometry_hints (MirWindowSpec *spec,
- GdkMirWindowImpl *impl)
-{
- if (impl->geometry_mask & GDK_HINT_RESIZE_INC)
- {
- mir_window_spec_set_width_increment (spec, impl->geometry_hints.width_inc);
- mir_window_spec_set_height_increment (spec, impl->geometry_hints.height_inc);
- }
- if (impl->geometry_mask & GDK_HINT_MIN_SIZE)
- {
- mir_window_spec_set_min_width (spec, impl->geometry_hints.min_width);
- mir_window_spec_set_min_height (spec, impl->geometry_hints.min_height);
- }
- if (impl->geometry_mask & GDK_HINT_MAX_SIZE)
- {
- mir_window_spec_set_max_width (spec, impl->geometry_hints.max_width);
- mir_window_spec_set_max_height (spec, impl->geometry_hints.max_height);
- }
- if (impl->geometry_mask & GDK_HINT_ASPECT)
- {
- mir_window_spec_set_min_aspect_ratio (spec, (guint) 1000 * impl->geometry_hints.min_aspect, 1000);
- mir_window_spec_set_max_aspect_ratio (spec, (guint) 1000 * impl->geometry_hints.max_aspect, 1000);
- }
-}
-
-static MirWindowSpec *
-create_spec (GdkWindow *window,
- GdkMirWindowImpl *impl)
-{
- MirWindowSpec *spec = NULL;
- GdkWindow *parent;
- MirRectangle rect;
-
- spec = create_window_type_spec (impl->display,
- impl->transient_for,
- impl->transient_x,
- impl->transient_y,
- window->width,
- window->height,
- impl->modal,
- impl->type_hint,
- impl->buffer_usage);
-
- mir_window_spec_set_name (spec, impl->title);
- mir_window_spec_set_buffer_usage (spec, impl->buffer_usage);
-
- apply_geometry_hints (spec, impl);
-
- if (impl->has_rect)
- {
- impl->mir_rect.left = impl->rect.x;
- impl->mir_rect.top = impl->rect.y;
- impl->mir_rect.width = impl->rect.width;
- impl->mir_rect.height = impl->rect.height;
-
- parent = impl->transient_for;
-
- while (parent && !gdk_window_has_native (parent))
- {
- impl->mir_rect.left += parent->x;
- impl->mir_rect.top += parent->y;
-
- parent = gdk_window_get_parent (parent);
- }
-
- mir_window_spec_set_placement (spec,
- &impl->mir_rect,
- impl->rect_anchor,
- impl->window_anchor,
- impl->anchor_hints,
- impl->rect_anchor_dx,
- impl->rect_anchor_dy);
- }
- else
- {
- switch (impl->type_hint)
- {
- case GDK_WINDOW_TYPE_HINT_MENU:
- case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
- case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
- case GDK_WINDOW_TYPE_HINT_TOOLBAR:
- case GDK_WINDOW_TYPE_HINT_COMBO:
- case GDK_WINDOW_TYPE_HINT_DND:
- case GDK_WINDOW_TYPE_HINT_TOOLTIP:
- case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
- rect.left = impl->transient_x;
- rect.top = impl->transient_y;
- rect.width = 1;
- rect.height = 1;
-
- mir_window_spec_set_placement (spec,
- &rect,
- mir_placement_gravity_southeast,
- mir_placement_gravity_northwest,
- (mir_placement_hints_flip_x |
- mir_placement_hints_flip_y |
- mir_placement_hints_slide_x |
- mir_placement_hints_slide_y |
- mir_placement_hints_resize_x |
- mir_placement_hints_resize_y),
- -window->shadow_left,
- -window->shadow_top);
-
- break;
- default:
- break;
- }
- }
-
- return spec;
-}
-
-static void
-update_window_spec (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirWindowSpec *spec;
-
- if (!impl->mir_window)
- return;
-
- spec = create_spec (window, impl);
-
- mir_window_apply_spec (impl->mir_window, spec);
- mir_window_spec_release (spec);
-
- impl->pending_spec_update = FALSE;
- impl->buffer_stream = mir_window_get_buffer_stream (impl->mir_window);
-}
-
-static GdkDevice *
-get_pointer (GdkWindow *window)
-{
- GdkDisplay *display;
- GdkSeat *seat;
- GdkDevice *pointer;
-
- display = gdk_window_get_display (window);
- seat = gdk_display_get_default_seat (display);
- pointer = gdk_seat_get_pointer (seat);
-
- return pointer;
-}
-
-static void
-send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
-{
- GdkDisplay *display;
- GList *node;
-
- display = gdk_window_get_display (window);
- gdk_event_set_device (event, device);
- gdk_event_set_source_device (event, device);
- gdk_event_set_screen (event, gdk_display_get_default_screen (display));
- event->any.window = g_object_ref (window);
-
- node = _gdk_event_queue_append (display, event);
- _gdk_windowing_got_event (display, node, event, _gdk_display_get_next_serial (display));
-}
-
-static void
-generate_configure_event (GdkWindow *window,
- gint width,
- gint height)
-{
- GdkEvent *event;
-
- event = gdk_event_new (GDK_CONFIGURE);
- event->configure.send_event = FALSE;
- event->configure.width = width;
- event->configure.height = height;
-
- send_event (window, get_pointer (window), event);
-}
-
-static void
-synthesize_resize (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirWindowParameters params;
-
- if (!impl->mir_window)
- return;
-
- mir_window_get_parameters (impl->mir_window, &params);
-
- window->width = params.width;
- window->height = params.height;
-
- _gdk_window_update_size (window);
-
- generate_configure_event (window, window->width, window->height);
-}
-
-static void
-maybe_synthesize_resize (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirWindowParameters params;
-
- if (!impl->mir_window)
- return;
-
- mir_window_get_parameters (impl->mir_window, &params);
-
- if (params.width != window->width || params.height != window->height)
- {
- window->width = params.width;
- window->height = params.height;
-
- _gdk_window_update_size (window);
-
- generate_configure_event (window, window->width, window->height);
- }
-}
-
-static void
-ensure_mir_window_full (GdkWindow *window,
- MirBufferUsage buffer_usage)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkMirWindowReference *window_ref;
- MirWindowSpec *spec;
-
- if (window->input_only)
- return;
-
- if (impl->mir_window)
- {
- if (impl->pending_spec_update)
- update_window_spec (window);
- return;
- }
-
- /* no destroy notify -- we must leak for now
- * https://bugs.launchpad.net/mir/+bug/1324100
- */
- window_ref = _gdk_mir_event_source_get_window_reference (window);
- impl->buffer_usage = buffer_usage;
-
- spec = create_spec (window, impl);
-
- impl->mir_window = mir_create_window_sync (spec);
-
- mir_window_spec_release (spec);
-
- impl->pending_spec_update = FALSE;
- impl->buffer_stream = mir_window_get_buffer_stream (impl->mir_window);
-
- synthesize_resize (window);
-
- /* FIXME: Ignore some events until shown */
- mir_window_set_event_handler (impl->mir_window, event_cb, window_ref);
-}
-
-static void
-ensure_mir_window (GdkWindow *window)
-{
- ensure_mir_window_full (window,
- window->gl_paint_context ?
- mir_buffer_usage_hardware :
- mir_buffer_usage_software);
-}
-
-static void
-ensure_no_mir_window (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (impl->cairo_surface)
- {
- cairo_surface_finish (impl->cairo_surface);
- g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
- }
-
- if (window->gl_paint_context)
- {
- GdkDisplay *display = gdk_window_get_display (window);
- EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
-
- if (impl->egl_surface)
- {
- eglDestroySurface (egl_display, impl->egl_surface);
- impl->egl_surface = NULL;
- }
-
- if (impl->dummy_egl_surface)
- {
- eglDestroySurface (egl_display, impl->dummy_egl_surface);
- impl->dummy_egl_surface = NULL;
- }
- }
-
- g_clear_pointer (&impl->mir_window, mir_window_release_sync);
-}
-
-static void
-send_buffer (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- /* Send the completed buffer to Mir */
- if (impl->mir_window)
- mir_buffer_stream_swap_buffers_sync (mir_window_get_buffer_stream (impl->mir_window));
-
- /* The Cairo context is no longer valid */
- g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
- if (impl->pending_spec_update)
- update_window_spec (window);
-
- impl->pending_spec_update = FALSE;
-
- maybe_synthesize_resize (window);
-}
-
-static cairo_surface_t *
-gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirGraphicsRegion region;
- cairo_format_t pixel_format = CAIRO_FORMAT_ARGB32;
- cairo_surface_t *cairo_surface;
- cairo_t *c;
-
- if (impl->cairo_surface)
- {
- cairo_surface_reference (impl->cairo_surface);
- return impl->cairo_surface;
- }
-
- ensure_mir_window (window);
-
- if (!impl->mir_window)
- return NULL;
-
- if (window->gl_paint_context)
- {
- cairo_surface = cairo_image_surface_create (pixel_format, window->width, window->height);
- cairo_surface_set_device_scale (cairo_surface, (double) impl->output_scale, (double) impl->output_scale);
- }
- else if (impl->visible)
- {
- mir_buffer_stream_get_graphics_region (mir_window_get_buffer_stream (impl->mir_window), &region);
-
- switch (region.pixel_format)
- {
- case mir_pixel_format_abgr_8888:
- g_warning ("pixel format ABGR 8888 not supported, using ARGB 8888");
- pixel_format = CAIRO_FORMAT_ARGB32;
- break;
- case mir_pixel_format_xbgr_8888:
- g_warning ("pixel format XBGR 8888 not supported, using XRGB 8888");
- pixel_format = CAIRO_FORMAT_RGB24;
- break;
- case mir_pixel_format_argb_8888:
- pixel_format = CAIRO_FORMAT_ARGB32;
- break;
- case mir_pixel_format_xrgb_8888:
- pixel_format = CAIRO_FORMAT_RGB24;
- break;
- case mir_pixel_format_bgr_888:
- g_error ("pixel format BGR 888 not supported");
- break;
- case mir_pixel_format_rgb_888:
- g_error ("pixel format RGB 888 not supported");
- break;
- case mir_pixel_format_rgb_565:
- pixel_format = CAIRO_FORMAT_RGB16_565;
- break;
- case mir_pixel_format_rgba_5551:
- g_error ("pixel format RGBA 5551 not supported");
- break;
- case mir_pixel_format_rgba_4444:
- g_error ("pixel format RGBA 4444 not supported");
- break;
- default:
- g_error ("unknown pixel format");
- break;
- }
-
- cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
- pixel_format,
- region.width,
- region.height,
- region.stride);
- cairo_surface_set_device_scale (cairo_surface, (double) impl->output_scale, (double) impl->output_scale);
- }
- else
- cairo_surface = cairo_image_surface_create (pixel_format, 0, 0);
-
- impl->cairo_surface = cairo_surface_reference (cairo_surface);
-
- /* Draw background */
- if (impl->background)
- {
- c = cairo_create (impl->cairo_surface);
- cairo_set_source (c, impl->background);
- cairo_paint (c);
- cairo_destroy (c);
- }
-
- return cairo_surface;
-}
-
-static cairo_surface_t *
-gdk_mir_window_impl_create_similar_image_surface (GdkWindow *window,
- cairo_format_t format,
- int width,
- int height)
-{
- return cairo_image_surface_create (format, width, height);
-}
-
-static void
-gdk_mir_window_impl_finalize (GObject *object)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (object);
-
- g_free (impl->title);
-
- g_clear_pointer (&impl->background, cairo_pattern_destroy);
- g_clear_pointer (&impl->mir_window, mir_window_release_sync);
- g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
- g_clear_pointer (&impl->properties, g_hash_table_unref);
-
- G_OBJECT_CLASS (gdk_mir_window_impl_parent_class)->finalize (object);
-}
-
-static void
-gdk_mir_window_impl_show (GdkWindow *window,
- gboolean already_mapped)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- cairo_surface_t *s;
-
- impl->visible = TRUE;
- set_window_state (impl, mir_window_state_restored);
-
- /* Make sure there's a window to see */
- ensure_mir_window (window);
-
- if (!window->gl_paint_context)
- {
- /* Make sure something is rendered and then show first frame */
- s = gdk_mir_window_impl_ref_cairo_surface (window);
- send_buffer (window);
- cairo_surface_destroy (s);
- }
-}
-
-static void
-gdk_mir_window_impl_hide (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- impl->cursor_inside = FALSE;
- impl->visible = FALSE;
-
- set_window_state (impl, mir_window_state_hidden);
-}
-
-static void
-gdk_mir_window_impl_withdraw (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- impl->cursor_inside = FALSE;
- impl->visible = FALSE;
-
- set_window_state (impl, mir_window_state_hidden);
-}
-
-static void
-gdk_mir_window_impl_raise (GdkWindow *window)
-{
- /* We don't support client window stacking */
-}
-
-static void
-gdk_mir_window_impl_lower (GdkWindow *window)
-{
- /* We don't support client window stacking */
-}
-
-static void
-gdk_mir_window_impl_restack_under (GdkWindow *window,
- GList *native_siblings)
-{
- /* We don't support client window stacking */
-}
-
-static void
-gdk_mir_window_impl_restack_toplevel (GdkWindow *window,
- GdkWindow *sibling,
- gboolean above)
-{
- /* We don't support client window stacking */
-}
-
-static void
-gdk_mir_window_impl_move_resize (GdkWindow *window,
- gboolean with_move,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- /* If resize requested then rebuild window */
- if (width >= 0 && (window->width != width || window->height != height))
- {
- /* We accept any resize */
- window->width = width;
- window->height = height;
- impl->pending_spec_update = TRUE;
- }
-
- /* Transient windows can move wherever they want */
- if (with_move)
- {
- if (impl->has_rect || x != impl->transient_x || y != impl->transient_y)
- {
- impl->has_rect = FALSE;
- impl->transient_x = x;
- impl->transient_y = y;
- if (!impl->pending_spec_update && impl->mir_window)
- update_window_spec (window);
- }
- }
-}
-
-static MirPlacementGravity
-get_mir_placement_gravity (GdkGravity gravity)
-{
- switch (gravity)
- {
- case GDK_GRAVITY_STATIC:
- case GDK_GRAVITY_NORTH_WEST:
- return mir_placement_gravity_northwest;
- case GDK_GRAVITY_NORTH:
- return mir_placement_gravity_north;
- case GDK_GRAVITY_NORTH_EAST:
- return mir_placement_gravity_northeast;
- case GDK_GRAVITY_WEST:
- return mir_placement_gravity_west;
- case GDK_GRAVITY_CENTER:
- return mir_placement_gravity_center;
- case GDK_GRAVITY_EAST:
- return mir_placement_gravity_east;
- case GDK_GRAVITY_SOUTH_WEST:
- return mir_placement_gravity_southwest;
- case GDK_GRAVITY_SOUTH:
- return mir_placement_gravity_south;
- case GDK_GRAVITY_SOUTH_EAST:
- return mir_placement_gravity_southeast;
- }
-
- g_warn_if_reached ();
-
- return mir_placement_gravity_center;
-}
-
-static MirPlacementHints
-get_mir_placement_hints (GdkAnchorHints hints)
-{
- MirPlacementHints mir_hints = 0;
-
- if (hints & GDK_ANCHOR_FLIP_X)
- mir_hints |= mir_placement_hints_flip_x;
-
- if (hints & GDK_ANCHOR_FLIP_Y)
- mir_hints |= mir_placement_hints_flip_y;
-
- if (hints & GDK_ANCHOR_SLIDE_X)
- mir_hints |= mir_placement_hints_slide_x;
-
- if (hints & GDK_ANCHOR_SLIDE_Y)
- mir_hints |= mir_placement_hints_slide_y;
-
- if (hints & GDK_ANCHOR_RESIZE_X)
- mir_hints |= mir_placement_hints_resize_x;
-
- if (hints & GDK_ANCHOR_RESIZE_Y)
- mir_hints |= mir_placement_hints_resize_y;
-
- return mir_hints;
-}
-
-static gint
-get_window_shadow_dx (GdkWindow *window,
- GdkGravity window_anchor)
-{
- switch (window_anchor)
- {
- case GDK_GRAVITY_STATIC:
- case GDK_GRAVITY_NORTH_WEST:
- case GDK_GRAVITY_WEST:
- case GDK_GRAVITY_SOUTH_WEST:
- return -window->shadow_left;
-
- case GDK_GRAVITY_NORTH:
- case GDK_GRAVITY_CENTER:
- case GDK_GRAVITY_SOUTH:
- return (window->shadow_right - window->shadow_left) / 2;
-
- case GDK_GRAVITY_NORTH_EAST:
- case GDK_GRAVITY_EAST:
- case GDK_GRAVITY_SOUTH_EAST:
- return window->shadow_right;
- }
-
- g_warn_if_reached ();
-
- return 0;
-}
-
-static gint
-get_window_shadow_dy (GdkWindow *window,
- GdkGravity window_anchor)
-{
- switch (window_anchor)
- {
- case GDK_GRAVITY_STATIC:
- case GDK_GRAVITY_NORTH_WEST:
- case GDK_GRAVITY_NORTH:
- case GDK_GRAVITY_NORTH_EAST:
- return -window->shadow_top;
-
- case GDK_GRAVITY_WEST:
- case GDK_GRAVITY_CENTER:
- case GDK_GRAVITY_EAST:
- return (window->shadow_bottom - window->shadow_top) / 2;
-
- case GDK_GRAVITY_SOUTH_WEST:
- case GDK_GRAVITY_SOUTH:
- case GDK_GRAVITY_SOUTH_EAST:
- return window->shadow_bottom;
- }
-
- g_warn_if_reached ();
-
- return 0;
-}
-
-static void
-gdk_mir_window_impl_move_to_rect (GdkWindow *window,
- const GdkRectangle *rect,
- GdkGravity rect_anchor,
- GdkGravity window_anchor,
- GdkAnchorHints anchor_hints,
- gint rect_anchor_dx,
- gint rect_anchor_dy)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- impl->has_rect = TRUE;
- impl->rect = *rect;
- impl->rect_anchor = get_mir_placement_gravity (rect_anchor);
- impl->window_anchor = get_mir_placement_gravity (window_anchor);
- impl->anchor_hints = get_mir_placement_hints (anchor_hints);
- impl->rect_anchor_dx = rect_anchor_dx + get_window_shadow_dx (window, window_anchor);
- impl->rect_anchor_dy = rect_anchor_dy + get_window_shadow_dy (window, window_anchor);
-
- if (impl->mir_window && !impl->pending_spec_update)
- update_window_spec (window);
-}
-
-static gint
-get_mir_placement_gravity_x (MirPlacementGravity gravity)
-{
- switch (gravity)
- {
- case mir_placement_gravity_west:
- case mir_placement_gravity_northwest:
- case mir_placement_gravity_southwest:
- return 0;
-
- case mir_placement_gravity_center:
- case mir_placement_gravity_north:
- case mir_placement_gravity_south:
- return 1;
-
- case mir_placement_gravity_east:
- case mir_placement_gravity_northeast:
- case mir_placement_gravity_southeast:
- return 2;
- }
-
- g_warn_if_reached ();
-
- return 1;
-}
-
-static gint
-get_mir_placement_gravity_y (MirPlacementGravity gravity)
-{
- switch (gravity)
- {
- case mir_placement_gravity_north:
- case mir_placement_gravity_northwest:
- case mir_placement_gravity_northeast:
- return 0;
-
- case mir_placement_gravity_center:
- case mir_placement_gravity_west:
- case mir_placement_gravity_east:
- return 1;
-
- case mir_placement_gravity_south:
- case mir_placement_gravity_southwest:
- case mir_placement_gravity_southeast:
- return 2;
- }
-
- g_warn_if_reached ();
-
- return 1;
-}
-
-static GdkRectangle
-get_unflipped_rect (const GdkRectangle *rect,
- gint width,
- gint height,
- MirPlacementGravity rect_anchor,
- MirPlacementGravity window_anchor,
- gint rect_anchor_dx,
- gint rect_anchor_dy)
-{
- GdkRectangle unflipped_rect;
-
- unflipped_rect.x = rect->x;
- unflipped_rect.x += rect->width * get_mir_placement_gravity_x (rect_anchor) / 2;
- unflipped_rect.x -= width * get_mir_placement_gravity_x (window_anchor) / 2;
- unflipped_rect.x += rect_anchor_dx;
- unflipped_rect.y = rect->y;
- unflipped_rect.y += rect->height * get_mir_placement_gravity_y (rect_anchor) / 2;
- unflipped_rect.y -= height * get_mir_placement_gravity_y (window_anchor) / 2;
- unflipped_rect.y += rect_anchor_dy;
- unflipped_rect.width = width;
- unflipped_rect.height = height;
-
- return unflipped_rect;
-}
-
-static MirPlacementGravity
-get_opposite_mir_placement_gravity (MirPlacementGravity gravity)
-{
- switch (gravity)
- {
- case mir_placement_gravity_center:
- return mir_placement_gravity_center;
- case mir_placement_gravity_west:
- return mir_placement_gravity_east;
- case mir_placement_gravity_east:
- return mir_placement_gravity_west;
- case mir_placement_gravity_north:
- return mir_placement_gravity_south;
- case mir_placement_gravity_south:
- return mir_placement_gravity_north;
- case mir_placement_gravity_northwest:
- return mir_placement_gravity_southeast;
- case mir_placement_gravity_northeast:
- return mir_placement_gravity_southwest;
- case mir_placement_gravity_southwest:
- return mir_placement_gravity_northeast;
- case mir_placement_gravity_southeast:
- return mir_placement_gravity_northwest;
- }
-
- g_warn_if_reached ();
-
- return gravity;
-}
-
-static gint
-get_anchor_x (const GdkRectangle *rect,
- MirPlacementGravity anchor)
-{
- return rect->x + rect->width * get_mir_placement_gravity_x (anchor) / 2;
-}
-
-static gint
-get_anchor_y (const GdkRectangle *rect,
- MirPlacementGravity anchor)
-{
- return rect->y + rect->height * get_mir_placement_gravity_y (anchor) / 2;
-}
-
-void
-_gdk_mir_window_set_final_rect (GdkWindow *window,
- MirRectangle rect)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkRectangle best_rect;
- GdkRectangle worst_rect;
- GdkRectangle flipped_rect;
- GdkRectangle final_rect;
- gboolean flipped_x = FALSE;
- gboolean flipped_y = FALSE;
- gint test_position;
- gint final_position;
- gint unflipped_offset;
- gint flipped_offset;
-
- if (!impl->has_rect)
- return;
-
- best_rect = get_unflipped_rect (&impl->rect,
- window->width,
- window->height,
- impl->rect_anchor,
- impl->window_anchor,
- impl->rect_anchor_dx,
- impl->rect_anchor_dy);
-
- worst_rect = get_unflipped_rect (&impl->rect,
- window->width,
- window->height,
- get_opposite_mir_placement_gravity (impl->rect_anchor),
- get_opposite_mir_placement_gravity (impl->window_anchor),
- -impl->rect_anchor_dx,
- -impl->rect_anchor_dy);
-
- flipped_rect.x = best_rect.x;
- flipped_rect.y = best_rect.y;
- flipped_rect.width = window->width;
- flipped_rect.height = window->height;
-
- final_rect.x = rect.left - (impl->mir_rect.left - impl->rect.x);
- final_rect.y = rect.top - (impl->mir_rect.top - impl->rect.y);
- final_rect.width = rect.width;
- final_rect.height = rect.height;
-
- if (impl->anchor_hints & mir_placement_hints_flip_x)
- {
- test_position = get_anchor_x (&best_rect, impl->window_anchor);
- final_position = get_anchor_x (&final_rect, impl->window_anchor);
- unflipped_offset = final_position - test_position;
-
- test_position = get_anchor_x (&worst_rect, get_opposite_mir_placement_gravity (impl->window_anchor));
- final_position = get_anchor_x (&final_rect, get_opposite_mir_placement_gravity (impl->window_anchor));
- flipped_offset = final_position - test_position;
-
- if (ABS (flipped_offset) < ABS (unflipped_offset))
- {
- flipped_rect.x = worst_rect.x;
- flipped_x = TRUE;
- }
- }
-
- if (impl->anchor_hints & mir_placement_hints_flip_y)
- {
- test_position = get_anchor_y (&best_rect, impl->window_anchor);
- final_position = get_anchor_y (&final_rect, impl->window_anchor);
- unflipped_offset = final_position - test_position;
-
- test_position = get_anchor_y (&worst_rect, get_opposite_mir_placement_gravity (impl->window_anchor));
- final_position = get_anchor_y (&final_rect, get_opposite_mir_placement_gravity (impl->window_anchor));
- flipped_offset = final_position - test_position;
-
- if (ABS (flipped_offset) < ABS (unflipped_offset))
- {
- flipped_rect.y = worst_rect.y;
- flipped_y = TRUE;
- }
- }
-
- g_signal_emit_by_name (window,
- "moved-to-rect",
- &flipped_rect,
- &final_rect,
- flipped_x,
- flipped_y);
-}
-
-static void
-gdk_mir_window_impl_set_background (GdkWindow *window,
- cairo_pattern_t *pattern)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (impl->background)
- cairo_pattern_destroy (impl->background);
- impl->background = cairo_pattern_reference (pattern);
-}
-
-static GdkEventMask
-gdk_mir_window_impl_get_events (GdkWindow *window)
-{
- return window->event_mask;
-}
-
-static void
-gdk_mir_window_impl_set_events (GdkWindow *window,
- GdkEventMask event_mask)
-{
- /* We send all events and let GDK decide */
-}
-
-static gboolean
-gdk_mir_window_impl_reparent (GdkWindow *window,
- GdkWindow *new_parent,
- gint x,
- gint y)
-{
- return FALSE;
-}
-
-static void
-gdk_mir_window_impl_set_device_cursor (GdkWindow *window,
- GdkDevice *device,
- GdkCursor *cursor)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirConnection *connection = gdk_mir_display_get_mir_connection (impl->display);
- MirWindowSpec *spec;
- const gchar *cursor_name;
-
- if (cursor)
- cursor_name = _gdk_mir_cursor_get_name (cursor);
- else
- cursor_name = mir_default_cursor_name;
-
- spec = mir_create_window_spec (connection);
- mir_window_spec_set_cursor_name (spec, cursor_name);
- mir_window_apply_spec (impl->mir_window, spec);
- mir_window_spec_release (spec);
-}
-
-static void
-gdk_mir_window_impl_get_geometry (GdkWindow *window,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
-{
- if (x)
- *x = 0; // FIXME
- if (y)
- *y = 0; // FIXME
- if (width)
- *width = window->width;
- if (height)
- *height = window->height;
-}
-
-static void
-gdk_mir_window_impl_get_root_coords (GdkWindow *window,
- gint x,
- gint y,
- gint *root_x,
- gint *root_y)
-{
- if (root_x)
- *root_x = x; // FIXME
- if (root_y)
- *root_y = y; // FIXME
-}
-
-static gboolean
-gdk_mir_window_impl_get_device_state (GdkWindow *window,
- GdkDevice *device,
- gdouble *x,
- gdouble *y,
- GdkModifierType *mask)
-{
- GdkWindow *child;
-
- _gdk_device_query_state (device, window, NULL, &child, NULL, NULL, x, y, mask);
-
- return child != NULL;
-}
-
-static gboolean
-gdk_mir_window_impl_begin_paint (GdkWindow *window)
-{
- /* Indicate we are ready to be drawn onto directly? */
- return FALSE;
-}
-
-static void
-gdk_mir_window_impl_end_paint (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (impl->visible && !window->current_paint.use_gl)
- send_buffer (window);
-}
-
-static cairo_region_t *
-gdk_mir_window_impl_get_shape (GdkWindow *window)
-{
- return NULL;
-}
-
-static cairo_region_t *
-gdk_mir_window_impl_get_input_shape (GdkWindow *window)
-{
- return NULL;
-}
-
-static void
-gdk_mir_window_impl_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
-{
-}
-
-static void
-gdk_mir_window_impl_input_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
-{
-}
-
-static void
-gdk_mir_window_impl_destroy (GdkWindow *window,
- gboolean recursing,
- gboolean foreign_destroy)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- impl->visible = FALSE;
- ensure_no_mir_window (window);
-}
-
-static void
-gdk_mir_window_impl_destroy_foreign (GdkWindow *window)
-{
-}
-
-static void
-gdk_mir_window_impl_focus (GdkWindow *window,
- guint32 timestamp)
-{
-}
-
-static void
-gdk_mir_window_impl_set_type_hint (GdkWindow *window,
- GdkWindowTypeHint hint)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (type_hint_differs (hint, impl->type_hint))
- {
- impl->type_hint = hint;
-
- if (impl->mir_window && !impl->pending_spec_update)
- update_window_spec (window);
- }
-}
-
-static GdkWindowTypeHint
-gdk_mir_window_impl_get_type_hint (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- return impl->type_hint;
-}
-
-void
-gdk_mir_window_impl_set_modal_hint (GdkWindow *window,
- gboolean modal)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (modal != impl->modal)
- {
- impl->modal = modal;
-
- if (impl->mir_window && !impl->pending_spec_update)
- update_window_spec (window);
- }
-}
-
-static void
-gdk_mir_window_impl_set_skip_taskbar_hint (GdkWindow *window,
- gboolean skips_taskbar)
-{
-}
-
-static void
-gdk_mir_window_impl_set_skip_pager_hint (GdkWindow *window,
- gboolean skips_pager)
-{
-}
-
-static void
-gdk_mir_window_impl_set_urgency_hint (GdkWindow *window,
- gboolean urgent)
-{
-}
-
-static void
-gdk_mir_window_impl_set_geometry_hints (GdkWindow *window,
- const GdkGeometry *geometry,
- GdkWindowHints geom_mask)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirConnection *connection = gdk_mir_display_get_mir_connection (impl->display);
- MirWindowSpec *spec;
-
- impl->geometry_hints = *geometry;
- impl->geometry_mask = geom_mask;
-
- if (impl->mir_window && !impl->pending_spec_update)
- {
- spec = mir_create_window_spec (connection);
- apply_geometry_hints (spec, impl);
- mir_window_apply_spec (impl->mir_window, spec);
- mir_window_spec_release (spec);
- }
-}
-
-static void
-gdk_mir_window_impl_set_title (GdkWindow *window,
- const gchar *title)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- MirConnection *connection = gdk_mir_display_get_mir_connection (impl->display);
- MirWindowSpec *spec;
-
- g_free (impl->title);
- impl->title = g_strdup (title);
-
- if (impl->mir_window && !impl->pending_spec_update)
- {
- spec = mir_create_window_spec (connection);
- mir_window_spec_set_name (spec, impl->title);
- mir_window_apply_spec (impl->mir_window, spec);
- mir_window_spec_release (spec);
- }
-}
-
-static void
-gdk_mir_window_impl_set_role (GdkWindow *window,
- const gchar *role)
-{
-}
-
-static void
-gdk_mir_window_impl_set_startup_id (GdkWindow *window,
- const gchar *startup_id)
-{
-}
-
-static void
-gdk_mir_window_impl_set_transient_for (GdkWindow *window,
- GdkWindow *parent)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (impl->transient_for == parent)
- return;
-
- /* Link this window to the parent */
- impl->transient_for = parent;
-
- if (impl->mir_window && !impl->pending_spec_update)
- update_window_spec (window);
-}
-
-static void
-gdk_mir_window_impl_get_frame_extents (GdkWindow *window,
- GdkRectangle *rect)
-{
-}
-
-static void
-gdk_mir_window_impl_set_override_redirect (GdkWindow *window,
- gboolean override_redirect)
-{
-}
-
-static void
-gdk_mir_window_impl_set_accept_focus (GdkWindow *window,
- gboolean accept_focus)
-{
- /* Mir clients cannot control focus */
-}
-
-static void
-gdk_mir_window_impl_set_focus_on_map (GdkWindow *window,
- gboolean focus_on_map)
-{
- /* Mir clients cannot control focus */
-}
-
-static void
-gdk_mir_window_impl_set_icon_list (GdkWindow *window,
- GList *pixbufs)
-{
- // ??
-}
-
-static void
-gdk_mir_window_impl_set_icon_name (GdkWindow *window,
- const gchar *name)
-{
-}
-
-static void
-gdk_mir_window_impl_iconify (GdkWindow *window)
-{
- /* We don't support iconification */
-}
-
-static void
-gdk_mir_window_impl_deiconify (GdkWindow *window)
-{
- /* We don't support iconification */
-}
-
-static void
-gdk_mir_window_impl_stick (GdkWindow *window)
-{
- /* We do not support stick/unstick in Mir */
-}
-
-static void
-gdk_mir_window_impl_unstick (GdkWindow *window)
-{
- /* We do not support stick/unstick in Mir */
-}
-
-static void
-gdk_mir_window_impl_maximize (GdkWindow *window)
-{
- set_window_state (GDK_MIR_WINDOW_IMPL (window->impl), mir_window_state_maximized);
-}
-
-static void
-gdk_mir_window_impl_unmaximize (GdkWindow *window)
-{
- set_window_state (GDK_MIR_WINDOW_IMPL (window->impl), mir_window_state_restored);
-}
-
-static void
-gdk_mir_window_impl_fullscreen (GdkWindow *window)
-{
- set_window_state (GDK_MIR_WINDOW_IMPL (window->impl), mir_window_state_fullscreen);
-}
-
-static void
-gdk_mir_window_impl_apply_fullscreen_mode (GdkWindow *window)
-{
-}
-
-static void
-gdk_mir_window_impl_unfullscreen (GdkWindow *window)
-{
- set_window_state (GDK_MIR_WINDOW_IMPL (window->impl), mir_window_state_restored);
-}
-
-static void
-gdk_mir_window_impl_set_keep_above (GdkWindow *window,
- gboolean setting)
-{
- /* We do not support keep above/below in Mir */
-}
-
-static void
-gdk_mir_window_impl_set_keep_below (GdkWindow *window,
- gboolean setting)
-{
- /* We do not support keep above/below in Mir */
-}
-
-static GdkWindow *
-gdk_mir_window_impl_get_group (GdkWindow *window)
-{
- return NULL;
-}
-
-static void
-gdk_mir_window_impl_set_group (GdkWindow *window,
- GdkWindow *leader)
-{
-}
-
-static void
-gdk_mir_window_impl_set_decorations (GdkWindow *window,
- GdkWMDecoration decorations)
-{
-}
-
-static gboolean
-gdk_mir_window_impl_get_decorations (GdkWindow *window,
- GdkWMDecoration *decorations)
-{
- return FALSE;
-}
-
-static void
-gdk_mir_window_impl_set_functions (GdkWindow *window,
- GdkWMFunction functions)
-{
-}
-
-static void
-gdk_mir_window_impl_begin_resize_drag (GdkWindow *window,
- GdkWindowEdge edge,
- GdkDevice *device,
- gint button,
- gint root_x,
- gint root_y,
- guint32 timestamp)
-{
-}
-
-static void
-gdk_mir_window_impl_begin_move_drag (GdkWindow *window,
- GdkDevice *device,
- gint button,
- gint root_x,
- gint root_y,
- guint32 timestamp)
-{
-}
-
-static void
-gdk_mir_window_impl_enable_synchronized_configure (GdkWindow *window)
-{
-}
-
-static void
-gdk_mir_window_impl_configure_finished (GdkWindow *window)
-{
-}
-
-static void
-gdk_mir_window_impl_set_opacity (GdkWindow *window,
- gdouble opacity)
-{
- // FIXME
-}
-
-static void
-gdk_mir_window_impl_set_composited (GdkWindow *window,
- gboolean composited)
-{
-}
-
-static void
-gdk_mir_window_impl_destroy_notify (GdkWindow *window)
-{
-}
-
-static GdkDragProtocol
-gdk_mir_window_impl_get_drag_protocol (GdkWindow *window,
- GdkWindow **target)
-{
- return 0;
-}
-
-static void
-gdk_mir_window_impl_register_dnd (GdkWindow *window)
-{
-}
-
-static GdkDragContext *
-gdk_mir_window_impl_drag_begin (GdkWindow *window,
- GdkDevice *device,
- GList *targets,
- gint x_root,
- gint y_root)
-{
- return NULL;
-}
-
-static void
-gdk_mir_window_impl_process_updates_recurse (GdkWindow *window,
- cairo_region_t *region)
-{
- cairo_rectangle_int_t rectangle;
-
- /* We redraw the whole region, but we should track the buffers and only redraw what has changed since we sent this buffer */
- rectangle.x = 0;
- rectangle.y = 0;
- rectangle.width = window->width;
- rectangle.height = window->height;
- cairo_region_union_rectangle (region, &rectangle);
-
- _gdk_window_process_updates_recurse (window, region);
-}
-
-static void
-gdk_mir_window_impl_sync_rendering (GdkWindow *window)
-{
- // FIXME: Only used for benchmarking
-}
-
-static gboolean
-gdk_mir_window_impl_simulate_key (GdkWindow *window,
- gint x,
- gint y,
- guint keyval,
- GdkModifierType modifiers,
- GdkEventType key_pressrelease)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_window_impl_simulate_button (GdkWindow *window,
- gint x,
- gint y,
- guint button,
- GdkModifierType modifiers,
- GdkEventType button_pressrelease)
-{
- return FALSE;
-}
-
-static gboolean
-gdk_mir_window_impl_get_property (GdkWindow *window,
- GdkAtom property,
- GdkAtom type,
- gulong offset,
- gulong length,
- gint pdelete,
- GdkAtom *actual_type,
- gint *actual_format,
- gint *actual_length,
- guchar **data)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkMirProperty *mir_property;
- GdkAtom dummy_actual_type;
- gint dummy_actual_format;
- gint dummy_actual_length;
- guint width;
-
- if (!actual_type)
- actual_type = &dummy_actual_type;
- if (!actual_format)
- actual_format = &dummy_actual_format;
- if (!actual_length)
- actual_length = &dummy_actual_length;
-
- *actual_type = GDK_NONE;
- *actual_format = 0;
- *actual_length = 0;
-
- if (data)
- *data = NULL;
-
- mir_property = g_hash_table_lookup (impl->properties, property);
-
- if (!mir_property)
- return FALSE;
-
- width = g_array_get_element_size (mir_property->array);
- *actual_type = mir_property->type;
- *actual_format = 8 * width;
-
- /* ICCCM 2.7: GdkAtoms can be 64-bit, but ATOMs and ATOM_PAIRs have format 32 */
- if (*actual_type == GDK_SELECTION_TYPE_ATOM || *actual_type == gdk_atom_intern_static_string ("ATOM_PAIR"))
- *actual_format = 32;
-
- if (type != GDK_NONE && type != mir_property->type)
- return FALSE;
-
- offset *= 4;
-
- /* round up to next nearest multiple of width */
- if (length < G_MAXULONG - width + 1)
- length = (length - 1 + width) / width * width;
- else
- length = G_MAXULONG / width * width;
-
- /* we're skipping the first offset bytes */
- if (length > mir_property->array->len * width - offset)
- length = mir_property->array->len * width - offset;
-
- /* leave room for null terminator */
- if (length > G_MAXULONG - width)
- length -= width;
-
- *actual_length = length;
-
- if (data)
- {
- *data = g_memdup (mir_property->array->data + offset, length + width);
- memset (*data + length, 0, width);
- }
-
- return TRUE;
-}
-
-static void
-request_targets (GdkWindow *window,
- const GdkAtom *available_targets,
- gint n_available_targets)
-{
- GArray *requested_targets;
- GdkAtom target_pair[2];
- gchar *target_location;
- GdkEvent *event;
- gint i;
-
- requested_targets = g_array_sized_new (TRUE, FALSE, sizeof (GdkAtom), 2 * n_available_targets);
-
- for (i = 0; i < n_available_targets; i++)
- {
- target_pair[0] = available_targets[i];
-
- if (target_pair[0] == gdk_atom_intern_static_string ("TIMESTAMP") ||
- target_pair[0] == gdk_atom_intern_static_string ("TARGETS") ||
- target_pair[0] == gdk_atom_intern_static_string ("MULTIPLE") ||
- target_pair[0] == gdk_atom_intern_static_string ("SAVE_TARGETS"))
- continue;
-
- target_location = g_strdup_printf ("REQUESTED_TARGET_U%u", requested_targets->len / 2);
- target_pair[1] = gdk_atom_intern (target_location, FALSE);
- g_free (target_location);
-
- g_array_append_vals (requested_targets, target_pair, 2);
- }
-
- gdk_property_delete (window, gdk_atom_intern_static_string ("AVAILABLE_TARGETS"));
- gdk_property_delete (window, gdk_atom_intern_static_string ("REQUESTED_TARGETS"));
-
- gdk_property_change (window,
- gdk_atom_intern_static_string ("REQUESTED_TARGETS"),
- GDK_SELECTION_TYPE_ATOM,
- 8 * sizeof (GdkAtom),
- GDK_PROP_MODE_REPLACE,
- (const guchar *) requested_targets->data,
- requested_targets->len);
-
- g_array_unref (requested_targets);
-
- event = gdk_event_new (GDK_SELECTION_REQUEST);
- event->selection.window = g_object_ref (window);
- event->selection.send_event = FALSE;
- event->selection.selection = GDK_SELECTION_CLIPBOARD;
- event->selection.target = gdk_atom_intern_static_string ("MULTIPLE");
- event->selection.property = gdk_atom_intern_static_string ("REQUESTED_TARGETS");
- event->selection.time = GDK_CURRENT_TIME;
- event->selection.requestor = g_object_ref (window);
-
- gdk_event_put (event);
- gdk_event_free (event);
-}
-
-static void
-create_paste (GdkWindow *window,
- const GdkAtom *requested_targets,
- gint n_requested_targets)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GPtrArray *paste_formats;
- GArray *paste_header;
- GByteArray *paste_data;
- gint sizes[4];
- GdkMirProperty *mir_property;
- const gchar *paste_format;
- gint i;
-
- paste_formats = g_ptr_array_new_full (n_requested_targets, g_free);
- paste_header = g_array_sized_new (FALSE, FALSE, sizeof (gint), 1 + 4 * n_requested_targets);
- paste_data = g_byte_array_new ();
-
- g_array_append_val (paste_header, sizes[0]);
-
- for (i = 0; i < n_requested_targets; i++)
- {
- if (requested_targets[i] == GDK_NONE)
- continue;
-
- mir_property = g_hash_table_lookup (impl->properties, requested_targets[i]);
-
- if (!mir_property)
- continue;
-
- paste_format = _gdk_atom_name_const (mir_property->type);
-
- /* skip non-MIME targets */
- if (!strchr (paste_format, '/'))
- {
- g_hash_table_remove (impl->properties, requested_targets[i]);
- continue;
- }
-
- sizes[0] = paste_data->len;
- sizes[1] = strlen (paste_format);
- sizes[2] = sizes[0] + sizes[1];
- sizes[3] = mir_property->array->len * g_array_get_element_size (mir_property->array);
-
- g_ptr_array_add (paste_formats, g_strdup (paste_format));
- g_array_append_vals (paste_header, sizes, 4);
- g_byte_array_append (paste_data, (const guint8 *) paste_format, sizes[1]);
- g_byte_array_append (paste_data, (const guint8 *) mir_property->array->data, sizes[3]);
-
- g_hash_table_remove (impl->properties, requested_targets[i]);
- }
-
- gdk_property_delete (window, gdk_atom_intern_static_string ("REQUESTED_TARGETS"));
-
- g_array_index (paste_header, gint, 0) = paste_formats->len;
-
- for (i = 0; i < paste_formats->len; i++)
- {
- g_array_index (paste_header, gint, 1 + 4 * i) += paste_header->len * sizeof (gint);
- g_array_index (paste_header, gint, 3 + 4 * i) += paste_header->len * sizeof (gint);
- }
-
- g_byte_array_prepend (paste_data,
- (const guint8 *) paste_header->data,
- paste_header->len * g_array_get_element_size (paste_header));
-
- g_ptr_array_add (paste_formats, NULL);
-
- _gdk_mir_display_create_paste (gdk_window_get_display (window),
- (const gchar * const *) paste_formats->pdata,
- paste_data->data,
- paste_data->len);
-
- g_byte_array_unref (paste_data);
- g_array_unref (paste_header);
- g_ptr_array_unref (paste_formats);
-}
-
-static void
-gdk_mir_window_impl_change_property (GdkWindow *window,
- GdkAtom property,
- GdkAtom type,
- gint format,
- GdkPropMode mode,
- const guchar *data,
- gint n_elements)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkMirProperty *mir_property;
- gboolean existed;
- GdkEvent *event;
-
- /* ICCCM 2.7: ATOMs and ATOM_PAIRs have format 32, but GdkAtoms can be 64-bit */
- if (type == GDK_SELECTION_TYPE_ATOM || type == gdk_atom_intern_static_string ("ATOM_PAIR"))
- format = 8 * sizeof (GdkAtom);
-
- if (mode != GDK_PROP_MODE_REPLACE)
- {
- mir_property = g_hash_table_lookup (impl->properties, property);
- existed = mir_property != NULL;
- }
- else
- {
- mir_property = NULL;
- existed = g_hash_table_contains (impl->properties, property);
- }
-
- if (!mir_property)
- {
- /* format is measured in bits, but we need to know this in bytes */
- mir_property = gdk_mir_property_new (type, format / 8, n_elements);
- g_hash_table_insert (impl->properties, property, mir_property);
- }
-
- /* format is measured in bits, but we need to know this in bytes */
- if (type != mir_property->type || format / 8 != g_array_get_element_size (mir_property->array))
- return;
-
- if (mode == GDK_PROP_MODE_PREPEND)
- g_array_prepend_vals (mir_property->array, data, n_elements);
- else
- g_array_append_vals (mir_property->array, data, n_elements);
-
- event = gdk_event_new (GDK_PROPERTY_NOTIFY);
- event->property.window = g_object_ref (window);
- event->property.send_event = FALSE;
- event->property.atom = property;
- event->property.time = GDK_CURRENT_TIME;
- event->property.state = GDK_PROPERTY_NEW_VALUE;
-
- gdk_event_put (event);
- gdk_event_free (event);
-
- if (property == gdk_atom_intern_static_string ("AVAILABLE_TARGETS"))
- request_targets (window, (const GdkAtom *) data, n_elements);
- else if (property == gdk_atom_intern_static_string ("REQUESTED_TARGETS") && existed)
- create_paste (window, (const GdkAtom *) data, n_elements);
-}
-
-static void
-gdk_mir_window_impl_delete_property (GdkWindow *window,
- GdkAtom property)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkEvent *event;
-
- if (g_hash_table_remove (impl->properties, property))
- {
- event = gdk_event_new (GDK_PROPERTY_NOTIFY);
- event->property.window = g_object_ref (window);
- event->property.send_event = FALSE;
- event->property.atom = property;
- event->property.time = GDK_CURRENT_TIME;
- event->property.state = GDK_PROPERTY_DELETE;
-
- gdk_event_put (event);
- gdk_event_free (event);
- }
-}
-
-static gint
-gdk_mir_window_impl_get_scale_factor (GdkWindow *window)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- return impl->output_scale;
-}
-
-static void
-gdk_mir_window_impl_set_opaque_region (GdkWindow *window,
- cairo_region_t *region)
-{
- /* FIXME: An optimisation to tell the compositor which regions of the window are fully transparent */
-}
-
-static void
-gdk_mir_window_impl_set_shadow_width (GdkWindow *window,
- gint left,
- gint right,
- gint top,
- gint bottom)
-{
-}
-
-static gboolean
-find_eglconfig_for_window (GdkWindow *window,
- EGLConfig *egl_config_out,
- GError **error)
-{
- GdkDisplay *display = gdk_window_get_display (window);
- EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display);
- GdkVisual *visual = gdk_window_get_visual (window);
- EGLint attrs[MAX_EGL_ATTRS];
- EGLint count;
- EGLConfig *configs;
- gboolean use_rgba;
-
- int i = 0;
-
- attrs[i++] = EGL_SURFACE_TYPE;
- attrs[i++] = EGL_WINDOW_BIT;
-
- attrs[i++] = EGL_COLOR_BUFFER_TYPE;
- attrs[i++] = EGL_RGB_BUFFER;
-
- attrs[i++] = EGL_RED_SIZE;
- attrs[i++] = 1;
- attrs[i++] = EGL_GREEN_SIZE;
- attrs[i++] = 1;
- attrs[i++] = EGL_BLUE_SIZE;
- attrs[i++] = 1;
-
- use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
-
- if (use_rgba)
- {
- attrs[i++] = EGL_ALPHA_SIZE;
- attrs[i++] = 1;
- }
- else
- {
- attrs[i++] = EGL_ALPHA_SIZE;
- attrs[i++] = 0;
- }
-
- attrs[i++] = EGL_NONE;
- g_assert (i < MAX_EGL_ATTRS);
-
- if (!eglChooseConfig (egl_display, attrs, NULL, 0, &count) || count < 1)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_FORMAT,
- _("No available configurations for the given pixel format"));
- return FALSE;
- }
-
- configs = g_new (EGLConfig, count);
-
- if (!eglChooseConfig (egl_display, attrs, configs, count, &count) || count < 1)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_FORMAT,
- _("No available configurations for the given pixel format"));
- return FALSE;
- }
-
- /* Pick first valid configuration i guess? */
-
- if (egl_config_out != NULL)
- *egl_config_out = configs[0];
-
- g_free (configs);
-
- return TRUE;
-}
-
-static GdkGLContext *
-gdk_mir_window_impl_create_gl_context (GdkWindow *window,
- gboolean attached,
- GdkGLContext *share,
- GError **error)
-{
- GdkDisplay *display = gdk_window_get_display (window);
- GdkMirGLContext *context;
- EGLConfig config;
-
- if (!_gdk_mir_display_init_egl_display (display))
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_NOT_AVAILABLE,
- _("No GL implementation is available"));
- return NULL;
- }
-
- if (!_gdk_mir_display_have_egl_khr_create_context (display))
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("3.2 core GL profile is not available on EGL implementation"));
- return NULL;
- }
-
- if (!find_eglconfig_for_window (window, &config, error))
- return NULL;
-
- context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
- "display", display,
- "window", window,
- "shared-context", share,
- NULL);
-
- context->egl_config = config;
- context->is_attached = attached;
-
- return GDK_GL_CONTEXT (context);
-}
-
-static void
-gdk_mir_window_impl_invalidate_for_new_frame (GdkWindow *window,
- cairo_region_t *update_area)
-{
- cairo_rectangle_int_t window_rect;
- GdkDisplay *display = gdk_window_get_display (window);
- GdkMirGLContext *context_mir;
- int buffer_age;
- gboolean invalidate_all;
- EGLSurface egl_surface;
-
- /* Minimal update is ok if we're not drawing with gl */
- if (window->gl_paint_context == NULL)
- return;
-
- context_mir = GDK_MIR_GL_CONTEXT (window->gl_paint_context);
- buffer_age = 0;
-
- egl_surface = _gdk_mir_window_get_egl_surface (window, context_mir->egl_config);
-
- if (_gdk_mir_display_have_egl_buffer_age (display))
- {
- gdk_gl_context_make_current (window->gl_paint_context);
- eglQuerySurface (_gdk_mir_display_get_egl_display (display), egl_surface,
- EGL_BUFFER_AGE_EXT, &buffer_age);
- }
-
- invalidate_all = FALSE;
- if (buffer_age == 0 || buffer_age >= 4)
- invalidate_all = TRUE;
- else
- {
- if (buffer_age >= 2)
- {
- if (window->old_updated_area[0])
- cairo_region_union (update_area, window->old_updated_area[0]);
- else
- invalidate_all = TRUE;
- }
- if (buffer_age >= 3)
- {
- if (window->old_updated_area[1])
- cairo_region_union (update_area, window->old_updated_area[1]);
- else
- invalidate_all = TRUE;
- }
- }
-
- if (invalidate_all)
- {
- window_rect.x = 0;
- window_rect.y = 0;
- window_rect.width = gdk_window_get_width (window);
- window_rect.height = gdk_window_get_height (window);
-
- /* If nothing else is known, repaint everything so that the back
- buffer is fully up-to-date for the swapbuffer */
- cairo_region_union_rectangle (update_area, &window_rect);
- }
-}
-
-EGLSurface
-_gdk_mir_window_get_egl_surface (GdkWindow *window,
- EGLConfig config)
-{
- GdkMirWindowImpl *impl;
-
- impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (!impl->egl_surface)
- {
- EGLDisplay egl_display;
- EGLNativeWindowType egl_window;
-
- ensure_no_mir_window (window);
- ensure_mir_window_full (window, mir_buffer_usage_hardware);
-
- egl_display = _gdk_mir_display_get_egl_display (gdk_window_get_display (window));
- egl_window = (EGLNativeWindowType) mir_buffer_stream_get_egl_native_window (impl->buffer_stream);
-
- impl->egl_surface =
- eglCreateWindowSurface (egl_display, config, egl_window, NULL);
- }
-
- return impl->egl_surface;
-}
-
-EGLSurface
-_gdk_mir_window_get_dummy_egl_surface (GdkWindow *window,
- EGLConfig config)
-{
- GdkMirWindowImpl *impl;
-
- impl = GDK_MIR_WINDOW_IMPL (window->impl);
-
- if (!impl->dummy_egl_surface)
- {
- GdkDisplay *display;
- EGLDisplay egl_display;
- EGLNativeWindowType egl_window;
-
- display = gdk_window_get_display (window);
- egl_display = _gdk_mir_display_get_egl_display (display);
- egl_window = (EGLNativeWindowType) mir_buffer_stream_get_egl_native_window (impl->buffer_stream);
-
- impl->dummy_egl_surface =
- eglCreateWindowSurface (egl_display, config, egl_window, NULL);
- }
-
- return impl->dummy_egl_surface;
-}
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-MirSurface *
-gdk_mir_window_get_mir_surface (GdkWindow *window)
-{
- return _gdk_mir_window_get_mir_window (window);
-}
-
-#pragma GCC diagnostic pop
-
-MirWindow *
-_gdk_mir_window_get_mir_window (GdkWindow *window)
-{
- g_return_val_if_fail (GDK_IS_MIR_WINDOW (window), NULL);
-
- return GDK_MIR_WINDOW_IMPL (window->impl)->mir_window;
-}
-
-void
-_gdk_mir_window_set_scale (GdkWindow *window,
- gdouble scale)
-{
- GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
- GdkRectangle area = {0, 0, window->width, window->height};
- cairo_region_t *region;
- gint new_scale = (gint) round (scale);
-
- if (impl->output_scale != new_scale)
- {
- impl->output_scale = new_scale;
-
- drop_cairo_surface (window);
-
- if (impl->buffer_stream)
- mir_buffer_stream_set_scale (impl->buffer_stream, (float) new_scale);
-
- region = cairo_region_create_rectangle (&area);
- _gdk_window_invalidate_for_expose (window, region);
- cairo_region_destroy (region);
- }
-}
-
-static void
-gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
-
- object_class->finalize = gdk_mir_window_impl_finalize;
-
- impl_class->ref_cairo_surface = gdk_mir_window_impl_ref_cairo_surface;
- impl_class->create_similar_image_surface = gdk_mir_window_impl_create_similar_image_surface;
- impl_class->show = gdk_mir_window_impl_show;
- impl_class->hide = gdk_mir_window_impl_hide;
- impl_class->withdraw = gdk_mir_window_impl_withdraw;
- impl_class->raise = gdk_mir_window_impl_raise;
- impl_class->lower = gdk_mir_window_impl_lower;
- impl_class->restack_under = gdk_mir_window_impl_restack_under;
- impl_class->restack_toplevel = gdk_mir_window_impl_restack_toplevel;
- impl_class->move_resize = gdk_mir_window_impl_move_resize;
- impl_class->move_to_rect = gdk_mir_window_impl_move_to_rect;
- impl_class->set_background = gdk_mir_window_impl_set_background;
- impl_class->get_events = gdk_mir_window_impl_get_events;
- impl_class->set_events = gdk_mir_window_impl_set_events;
- impl_class->reparent = gdk_mir_window_impl_reparent;
- impl_class->set_device_cursor = gdk_mir_window_impl_set_device_cursor;
- impl_class->get_geometry = gdk_mir_window_impl_get_geometry;
- impl_class->get_root_coords = gdk_mir_window_impl_get_root_coords;
- impl_class->get_device_state = gdk_mir_window_impl_get_device_state;
- impl_class->begin_paint = gdk_mir_window_impl_begin_paint;
- impl_class->end_paint = gdk_mir_window_impl_end_paint;
- impl_class->get_shape = gdk_mir_window_impl_get_shape;
- impl_class->get_input_shape = gdk_mir_window_impl_get_input_shape;
- impl_class->shape_combine_region = gdk_mir_window_impl_shape_combine_region;
- impl_class->input_shape_combine_region = gdk_mir_window_impl_input_shape_combine_region;
- impl_class->destroy = gdk_mir_window_impl_destroy;
- impl_class->destroy_foreign = gdk_mir_window_impl_destroy_foreign;
- impl_class->focus = gdk_mir_window_impl_focus;
- impl_class->set_type_hint = gdk_mir_window_impl_set_type_hint;
- impl_class->get_type_hint = gdk_mir_window_impl_get_type_hint;
- impl_class->set_modal_hint = gdk_mir_window_impl_set_modal_hint;
- impl_class->set_skip_taskbar_hint = gdk_mir_window_impl_set_skip_taskbar_hint;
- impl_class->set_skip_pager_hint = gdk_mir_window_impl_set_skip_pager_hint;
- impl_class->set_urgency_hint = gdk_mir_window_impl_set_urgency_hint;
- impl_class->set_geometry_hints = gdk_mir_window_impl_set_geometry_hints;
- impl_class->set_title = gdk_mir_window_impl_set_title;
- impl_class->set_role = gdk_mir_window_impl_set_role;
- impl_class->set_startup_id = gdk_mir_window_impl_set_startup_id;
- impl_class->set_transient_for = gdk_mir_window_impl_set_transient_for;
- impl_class->get_frame_extents = gdk_mir_window_impl_get_frame_extents;
- impl_class->set_override_redirect = gdk_mir_window_impl_set_override_redirect;
- impl_class->set_accept_focus = gdk_mir_window_impl_set_accept_focus;
- impl_class->set_focus_on_map = gdk_mir_window_impl_set_focus_on_map;
- impl_class->set_icon_list = gdk_mir_window_impl_set_icon_list;
- impl_class->set_icon_name = gdk_mir_window_impl_set_icon_name;
- impl_class->iconify = gdk_mir_window_impl_iconify;
- impl_class->deiconify = gdk_mir_window_impl_deiconify;
- impl_class->stick = gdk_mir_window_impl_stick;
- impl_class->unstick = gdk_mir_window_impl_unstick;
- impl_class->maximize = gdk_mir_window_impl_maximize;
- impl_class->unmaximize = gdk_mir_window_impl_unmaximize;
- impl_class->fullscreen = gdk_mir_window_impl_fullscreen;
- impl_class->apply_fullscreen_mode = gdk_mir_window_impl_apply_fullscreen_mode;
- impl_class->unfullscreen = gdk_mir_window_impl_unfullscreen;
- impl_class->set_keep_above = gdk_mir_window_impl_set_keep_above;
- impl_class->set_keep_below = gdk_mir_window_impl_set_keep_below;
- impl_class->get_group = gdk_mir_window_impl_get_group;
- impl_class->set_group = gdk_mir_window_impl_set_group;
- impl_class->set_decorations = gdk_mir_window_impl_set_decorations;
- impl_class->get_decorations = gdk_mir_window_impl_get_decorations;
- impl_class->set_functions = gdk_mir_window_impl_set_functions;
- impl_class->begin_resize_drag = gdk_mir_window_impl_begin_resize_drag;
- impl_class->begin_move_drag = gdk_mir_window_impl_begin_move_drag;
- impl_class->enable_synchronized_configure = gdk_mir_window_impl_enable_synchronized_configure;
- impl_class->configure_finished = gdk_mir_window_impl_configure_finished;
- impl_class->set_opacity = gdk_mir_window_impl_set_opacity;
- impl_class->set_composited = gdk_mir_window_impl_set_composited;
- impl_class->destroy_notify = gdk_mir_window_impl_destroy_notify;
- impl_class->get_drag_protocol = gdk_mir_window_impl_get_drag_protocol;
- impl_class->register_dnd = gdk_mir_window_impl_register_dnd;
- impl_class->drag_begin = gdk_mir_window_impl_drag_begin;
- impl_class->process_updates_recurse = gdk_mir_window_impl_process_updates_recurse;
- impl_class->sync_rendering = gdk_mir_window_impl_sync_rendering;
- impl_class->simulate_key = gdk_mir_window_impl_simulate_key;
- impl_class->simulate_button = gdk_mir_window_impl_simulate_button;
- impl_class->get_property = gdk_mir_window_impl_get_property;
- impl_class->change_property = gdk_mir_window_impl_change_property;
- impl_class->delete_property = gdk_mir_window_impl_delete_property;
- impl_class->get_scale_factor = gdk_mir_window_impl_get_scale_factor;
- impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
- impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
- impl_class->create_gl_context = gdk_mir_window_impl_create_gl_context;
- impl_class->invalidate_for_new_frame = gdk_mir_window_impl_invalidate_for_new_frame;
-}
diff --git a/gdk/mir/meson.build b/gdk/mir/meson.build
deleted file mode 100644
index db5acdac09..0000000000
--- a/gdk/mir/meson.build
+++ /dev/null
@@ -1 +0,0 @@
-error('Mir gdk backend not ported to meson yet')
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index e5fc5dbdaa..c3a1598210 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -42,9 +42,6 @@
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
#endif
-#ifdef GDK_WINDOWING_MIR
-#include "mir/gdkmir.h"
-#endif
/**
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5298470d6f..7239b658be 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -85,10 +85,6 @@
#include "broadway/gdkbroadway.h"
#endif
-#ifdef GDK_WINDOWING_MIR
-#include "mir/gdkmir.h"
-#endif
-
/**
* SECTION:gtkwindow
* @title: GtkWindow
@@ -6123,11 +6119,6 @@ gtk_window_should_use_csd (GtkWindow *window)
}
#endif
-#ifdef GDK_WINDOWING_MIR
- if (GDK_IS_MIR_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
- return TRUE;
-#endif
-
#ifdef GDK_WINDOWING_WIN32
if (g_strcmp0 (csd_env, "0") != 0 &&
GDK_IS_WIN32_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
diff --git a/meson.build b/meson.build
index 0029920675..21d62a39c4 100644
--- a/meson.build
+++ b/meson.build
@@ -131,7 +131,6 @@ wayland_enabled = get_option('wayland_backend')
broadway_enabled = get_option('broadway_backend')
quartz_enabled = get_option('quartz_backend')
win32_enabled = get_option('win32_backend')
-mir_enabled = get_option('mir_backend')
os_unix = false
os_linux = false
@@ -911,7 +910,7 @@ gdk_pcs = ['gdk-3.0.pc']
pkg_targets = ''
disabled_backends = []
-foreach backend: [ 'broadway', 'quartz', 'wayland', 'win32', 'x11', 'mir']
+foreach backend: [ 'broadway', 'quartz', 'wayland', 'win32', 'x11']
if get_variable('@0@_enabled'.format(backend))
gtk_pcs += ['gtk+-@0@-3.0.pc'.format(backend)]
gdk_pcs += ['gdk-@0@-3.0.pc'.format(backend)]
diff --git a/meson_options.txt b/meson_options.txt
index 4e51f9e6fc..7544389345 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,8 +9,6 @@ option('win32_backend', type: 'boolean', value: true,
description : 'Enable the Windows gdk backend (only when building on Windows)')
option('quartz_backend', type: 'boolean', value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
-option('mir_backend', type: 'boolean', value: false,
- description : 'Enable the Mir gdk backend')
# Optional dependencies
option('xinerama', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
diff --git a/po-properties/POTFILES.in b/po-properties/POTFILES.in
index 780733bf36..68ac89e2ef 100644
--- a/po-properties/POTFILES.in
+++ b/po-properties/POTFILES.in
@@ -14,8 +14,6 @@ gdk/gdkscreen.c
gdk/gdkseat.c
gdk/gdkwindow.c
gdk/keyname-table.h
-gdk/mir/gdkmirglcontext.c
-gdk/mir/gdkmirwindowimpl.c
gdk/quartz/gdkglcontext-quartz.c
gdk/wayland/gdkglcontext-wayland.c
gdk/win32/gdkglcontext-win32.c
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2f8849d986..f8bab66c22 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,8 +14,6 @@ gdk/gdkscreen.c
gdk/gdkseat.c
gdk/gdkwindow.c
gdk/keyname-table.h
-gdk/mir/gdkmirglcontext.c
-gdk/mir/gdkmirwindowimpl.c
gdk/quartz/gdkglcontext-quartz.c
gdk/wayland/gdkglcontext-wayland.c
gdk/win32/gdkglcontext-win32.c