2010-11-12 12:18:58 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-12 12:18:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gdkdevicemanager-broadway.h"
|
|
|
|
|
|
|
|
#include "gdktypes.h"
|
|
|
|
#include "gdkdevicemanager.h"
|
|
|
|
#include "gdkdevice-broadway.h"
|
|
|
|
#include "gdkkeysyms.h"
|
|
|
|
#include "gdkprivate-broadway.h"
|
2015-12-14 14:43:54 +00:00
|
|
|
#include "gdkseatdefaultprivate.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
#define HAS_FOCUS(toplevel) \
|
|
|
|
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static void gdk_broadway_device_manager_finalize (GObject *object);
|
|
|
|
static void gdk_broadway_device_manager_constructed (GObject *object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
static GList * gdk_broadway_device_manager_list_devices (GdkDeviceManager *device_manager,
|
|
|
|
GdkDeviceType type);
|
|
|
|
static GdkDevice * gdk_broadway_device_manager_get_client_pointer (GdkDeviceManager *device_manager);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
G_DEFINE_TYPE (GdkBroadwayDeviceManager, gdk_broadway_device_manager, GDK_TYPE_DEVICE_MANAGER)
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_class_init (GdkBroadwayDeviceManagerClass *klass)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
object_class->finalize = gdk_broadway_device_manager_finalize;
|
|
|
|
object_class->constructed = gdk_broadway_device_manager_constructed;
|
|
|
|
device_manager_class->list_devices = gdk_broadway_device_manager_list_devices;
|
|
|
|
device_manager_class->get_client_pointer = gdk_broadway_device_manager_get_client_pointer;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
|
|
|
create_core_pointer (GdkDeviceManager *device_manager,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
2010-11-12 12:18:58 +00:00
|
|
|
"name", "Core Pointer",
|
|
|
|
"type", GDK_DEVICE_TYPE_MASTER,
|
|
|
|
"input-source", GDK_SOURCE_MOUSE,
|
|
|
|
"input-mode", GDK_MODE_SCREEN,
|
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", display,
|
|
|
|
"device-manager", device_manager,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
|
|
|
create_core_keyboard (GdkDeviceManager *device_manager,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
2010-11-12 12:18:58 +00:00
|
|
|
"name", "Core Keyboard",
|
|
|
|
"type", GDK_DEVICE_TYPE_MASTER,
|
|
|
|
"input-source", GDK_SOURCE_KEYBOARD,
|
|
|
|
"input-mode", GDK_MODE_SCREEN,
|
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
"device-manager", device_manager,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-12 15:11:15 +00:00
|
|
|
static GdkDevice *
|
|
|
|
create_touchscreen (GdkDeviceManager *device_manager,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
|
|
|
|
"name", "Touchscreen",
|
|
|
|
"type", GDK_DEVICE_TYPE_SLAVE,
|
|
|
|
"input-source", GDK_SOURCE_TOUCHSCREEN,
|
|
|
|
"input-mode", GDK_MODE_SCREEN,
|
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
"device-manager", device_manager,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_init (GdkBroadwayDeviceManager *device_manager)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_finalize (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDeviceManager *device_manager;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
device_manager = GDK_BROADWAY_DEVICE_MANAGER (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
g_object_unref (device_manager->core_pointer);
|
|
|
|
g_object_unref (device_manager->core_keyboard);
|
2013-11-12 15:11:15 +00:00
|
|
|
g_object_unref (device_manager->touchscreen);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
G_OBJECT_CLASS (gdk_broadway_device_manager_parent_class)->finalize (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_constructed (GObject *object)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDeviceManager *device_manager;
|
2010-11-12 12:18:58 +00:00
|
|
|
GdkDisplay *display;
|
2015-12-14 14:43:54 +00:00
|
|
|
GdkSeat *seat;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
device_manager = GDK_BROADWAY_DEVICE_MANAGER (object);
|
2010-11-12 12:18:58 +00:00
|
|
|
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
|
|
|
|
device_manager->core_pointer = create_core_pointer (GDK_DEVICE_MANAGER (device_manager), display);
|
|
|
|
device_manager->core_keyboard = create_core_keyboard (GDK_DEVICE_MANAGER (device_manager), display);
|
2013-11-12 15:11:15 +00:00
|
|
|
device_manager->touchscreen = create_touchscreen (GDK_DEVICE_MANAGER (device_manager), display);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
_gdk_device_set_associated_device (device_manager->core_pointer, device_manager->core_keyboard);
|
|
|
|
_gdk_device_set_associated_device (device_manager->core_keyboard, device_manager->core_pointer);
|
2013-11-12 15:11:15 +00:00
|
|
|
_gdk_device_set_associated_device (device_manager->touchscreen, device_manager->core_pointer);
|
|
|
|
_gdk_device_add_slave (device_manager->core_pointer, device_manager->touchscreen);
|
2015-12-14 14:43:54 +00:00
|
|
|
|
|
|
|
seat = gdk_seat_default_new_for_master_pair (device_manager->core_pointer,
|
|
|
|
device_manager->core_keyboard);
|
|
|
|
gdk_display_add_seat (display, seat);
|
|
|
|
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), device_manager->touchscreen);
|
|
|
|
g_object_unref (seat);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GList *
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_list_devices (GdkDeviceManager *device_manager,
|
|
|
|
GdkDeviceType type)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDeviceManager *broadway_device_manager = (GdkBroadwayDeviceManager *) device_manager;
|
2010-11-12 12:18:58 +00:00
|
|
|
GList *devices = NULL;
|
|
|
|
|
|
|
|
if (type == GDK_DEVICE_TYPE_MASTER)
|
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
devices = g_list_prepend (devices, broadway_device_manager->core_keyboard);
|
|
|
|
devices = g_list_prepend (devices, broadway_device_manager->core_pointer);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
2013-11-12 15:11:15 +00:00
|
|
|
if (type == GDK_DEVICE_TYPE_SLAVE)
|
|
|
|
{
|
|
|
|
devices = g_list_prepend (devices, broadway_device_manager->touchscreen);
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
2011-01-06 22:36:44 +00:00
|
|
|
gdk_broadway_device_manager_get_client_pointer (GdkDeviceManager *device_manager)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
GdkBroadwayDeviceManager *broadway_device_manager = (GdkBroadwayDeviceManager *) device_manager;
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2011-01-06 22:36:44 +00:00
|
|
|
return broadway_device_manager->core_pointer;
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkDeviceManager *
|
2011-01-06 22:36:44 +00:00
|
|
|
_gdk_broadway_device_manager_new (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
2011-01-06 22:36:44 +00:00
|
|
|
return g_object_new (GDK_TYPE_BROADWAY_DEVICE_MANAGER,
|
2010-11-12 12:18:58 +00:00
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|