Drop the GdkDeviceManager::display property

Move this to the backends, and stop deriving
from GdkDeviceManager.
This commit is contained in:
Matthias Clasen 2017-11-24 23:00:40 -05:00
parent 7c33baabd2
commit fd958939be
11 changed files with 149 additions and 135 deletions

View File

@ -144,97 +144,15 @@
* written code.
*/
static void gdk_device_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdk_device_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_ABSTRACT_TYPE (GdkDeviceManager, gdk_device_manager, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_DISPLAY
};
static void
gdk_device_manager_class_init (GdkDeviceManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gdk_device_manager_set_property;
object_class->get_property = gdk_device_manager_get_property;
g_object_class_install_property (object_class,
PROP_DISPLAY,
g_param_spec_object ("display",
P_("Display"),
P_("Display for the device manager"),
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
}
static void
gdk_device_manager_init (GdkDeviceManager *device_manager)
{
}
static void
gdk_device_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
GDK_DEVICE_MANAGER (object)->display = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_device_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
g_value_set_object (value, GDK_DEVICE_MANAGER (object)->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* gdk_device_manager_get_display:
* @device_manager: a #GdkDeviceManager
*
* Gets the #GdkDisplay associated to @device_manager.
*
* Returns: (nullable) (transfer none): the #GdkDisplay to which
* @device_manager is associated to, or %NULL. This memory is
* owned by GDK and must not be freed or unreferenced.
*
* Since: 3.0
**/
GdkDisplay *
gdk_device_manager_get_display (GdkDeviceManager *device_manager)
{
g_return_val_if_fail (GDK_IS_DEVICE_MANAGER (device_manager), NULL);
return device_manager->display;
}

View File

@ -34,8 +34,6 @@ G_BEGIN_DECLS
GType gdk_device_manager_get_type (void) G_GNUC_CONST;
GdkDisplay * gdk_device_manager_get_display (GdkDeviceManager *device_manager);
G_END_DECLS

View File

@ -33,9 +33,6 @@ typedef struct _GdkDeviceManagerClass GdkDeviceManagerClass;
struct _GdkDeviceManager
{
GObject parent_instance;
/*< private >*/
GdkDisplay *display;
};
struct _GdkDeviceManagerClass

View File

@ -39,6 +39,42 @@ static GdkDevice * gdk_quartz_device_manager_core_get_client_pointer (GdkDeviceM
G_DEFINE_TYPE (GdkQuartzDeviceManagerCore, gdk_quartz_device_manager_core, GDK_TYPE_DEVICE_MANAGER)
static void
gdk_device_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
GDK_QUARTZ_DEVICE_MANAGER_CORE (object)->display = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_device_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
g_value_set_object (value, GDK_QUARTZ_DEVICE_MANAGER_CORE (object)->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_quartz_device_manager_core_class_init (GdkQuartzDeviceManagerCoreClass *klass)
{
@ -47,6 +83,17 @@ gdk_quartz_device_manager_core_class_init (GdkQuartzDeviceManagerCoreClass *klas
object_class->finalize = gdk_quartz_device_manager_core_finalize;
object_class->constructed = gdk_quartz_device_manager_core_constructed;
object_class->set_property = gdk_device_manager_set_property;
object_class->get_property = gdk_device_manager_get_property;
g_object_class_install_property (object_class,
PROP_DISPLAY,
g_param_spec_object ("display",
P_("Display"),
P_("Display for the device manager"),
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
}
static GdkDevice *
@ -105,7 +152,7 @@ gdk_quartz_device_manager_core_constructed (GObject *object)
GdkSeat *seat;
device_manager = GDK_QUARTZ_DEVICE_MANAGER_CORE (object);
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
display = device_manager->display;
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);

View File

@ -27,7 +27,8 @@ G_BEGIN_DECLS
struct _GdkQuartzDeviceManagerCore
{
GdkDeviceManager parent_object;
GObject parent_object;
GdkDisplay *display;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
};

View File

@ -358,7 +358,7 @@ gdk_wayland_pointer_stop_cursor_animation (GdkWaylandPointerData *pointer)
}
static GdkWaylandTabletData *
gdk_wayland_device_manager_find_tablet (GdkWaylandSeat *seat,
gdk_wayland_seat_find_tablet (GdkWaylandSeat *seat,
GdkDevice *device)
{
GList *l;
@ -377,7 +377,7 @@ gdk_wayland_device_manager_find_tablet (GdkWaylandSeat *seat,
}
static GdkWaylandTabletPadData *
gdk_wayland_device_manager_find_pad (GdkWaylandSeat *seat,
gdk_wayland_seat_find_pad (GdkWaylandSeat *seat,
GdkDevice *device)
{
GList *l;
@ -405,7 +405,7 @@ gdk_wayland_device_update_window_cursor (GdkDevice *device)
gboolean retval = G_SOURCE_REMOVE;
GdkWaylandTabletData *tablet;
tablet = gdk_wayland_device_manager_find_tablet (seat, device);
tablet = gdk_wayland_seat_find_tablet (seat, device);
if (pointer->cursor)
{
@ -893,7 +893,7 @@ gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadData *data;
data = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
g_assert (data != NULL);
@ -908,7 +908,7 @@ gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
GdkWaylandTabletPadGroupData *group;
GdkWaylandTabletPadData *data;
data = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
g_assert (data != NULL);
@ -926,7 +926,7 @@ gdk_wayland_device_pad_get_n_features (GdkDevicePad *pad,
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadData *data;
data = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
g_assert (data != NULL);
@ -954,7 +954,7 @@ gdk_wayland_device_pad_get_feature_group (GdkDevicePad *pad,
GList *l;
gint i;
data = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
g_assert (data != NULL);
@ -4895,14 +4895,13 @@ gdk_wayland_seat_init (GdkWaylandSeat *seat)
void
_gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
GdkDisplay *display,
guint32 id,
struct wl_seat *wl_seat)
{
GdkDisplay *display;
GdkWaylandDisplay *display_wayland;
GdkWaylandSeat *seat;
display = gdk_device_manager_get_display (device_manager);
display_wayland = GDK_WAYLAND_DISPLAY (display);
seat = g_object_new (GDK_TYPE_WAYLAND_SEAT,
@ -4962,9 +4961,9 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
void
_gdk_wayland_device_manager_remove_seat (GdkDeviceManager *manager,
GdkDisplay *display,
guint32 id)
{
GdkDisplay *display = gdk_device_manager_get_display (manager);
GList *l, *seats;
seats = gdk_display_list_seats (display);
@ -5017,9 +5016,7 @@ gdk_wayland_device_manager_init (GdkWaylandDeviceManager *device_manager)
GdkDeviceManager *
_gdk_wayland_device_manager_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_WAYLAND_DEVICE_MANAGER,
"display", display,
NULL);
return g_object_new (GDK_TYPE_WAYLAND_DEVICE_MANAGER, NULL);
}
uint32_t
@ -5238,12 +5235,11 @@ gdk_wayland_device_get_node_path (GdkDevice *device)
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
seat = gdk_device_get_seat (device);
tablet = gdk_wayland_device_manager_find_tablet (GDK_WAYLAND_SEAT (seat),
device);
tablet = gdk_wayland_seat_find_tablet (GDK_WAYLAND_SEAT (seat), device);
if (tablet)
return tablet->path;
pad = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat), device);
pad = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat), device);
if (pad)
return pad->path;
@ -5271,8 +5267,7 @@ gdk_wayland_device_pad_set_feedback (GdkDevice *device,
GdkSeat *seat;
seat = gdk_device_get_seat (device);
pad = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
device);
pad = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat), device);
if (!pad)
return;

View File

@ -226,6 +226,7 @@ _gdk_wayland_display_add_seat (GdkWaylandDisplay *display_wayland,
id, &wl_seat_interface,
display_wayland->seat_version);
_gdk_wayland_device_manager_add_seat (display_wayland->device_manager,
GDK_DISPLAY (display_wayland),
id, seat);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
@ -527,7 +528,9 @@ gdk_registry_handle_global_remove (void *data,
GdkWaylandDisplay *display_wayland = data;
GDK_NOTE (MISC, g_message ("remove global %u", id));
_gdk_wayland_device_manager_remove_seat (display_wayland->device_manager, id);
_gdk_wayland_device_manager_remove_seat (display_wayland->device_manager,
GDK_DISPLAY (display_wayland),
id);
gdk_wayland_display_remove_output (display_wayland, id);
g_hash_table_remove (display_wayland->known_globals, GUINT_TO_POINTER (id));

View File

@ -171,9 +171,11 @@ gchar * _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
GdkDeviceManager *_gdk_wayland_device_manager_new (GdkDisplay *display);
void _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
GdkDisplay *display,
guint32 id,
struct wl_seat *seat);
void _gdk_wayland_device_manager_remove_seat (GdkDeviceManager *device_manager,
GdkDisplay *display,
guint32 id);
GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);

View File

@ -29,6 +29,7 @@
#include "gdkkeysyms.h"
#define HAS_FOCUS(toplevel) \
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
@ -43,10 +44,50 @@ static gboolean gdk_x11_device_manager_core_translate_event (GdkEventTranslator
XEvent *xevent);
G_DEFINE_TYPE_WITH_CODE (GdkX11DeviceManagerCore, gdk_x11_device_manager_core, GDK_TYPE_DEVICE_MANAGER,
G_DEFINE_TYPE_WITH_CODE (GdkX11DeviceManagerCore, gdk_x11_device_manager_core, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
gdk_x11_device_manager_event_translator_init))
enum {
PROP_0,
PROP_DISPLAY
};
static void
gdk_device_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
GDK_X11_DEVICE_MANAGER_CORE (object)->display = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_device_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_DISPLAY:
g_value_set_object (value, GDK_X11_DEVICE_MANAGER_CORE (object)->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_x11_device_manager_core_class_init (GdkX11DeviceManagerCoreClass *klass)
{
@ -54,6 +95,17 @@ gdk_x11_device_manager_core_class_init (GdkX11DeviceManagerCoreClass *klass)
object_class->finalize = gdk_x11_device_manager_core_finalize;
object_class->constructed = gdk_x11_device_manager_core_constructed;
object_class->set_property = gdk_device_manager_set_property;
object_class->get_property = gdk_device_manager_get_property;
g_object_class_install_property (object_class,
PROP_DISPLAY,
g_param_spec_object ("display",
"Display",
"Display for the device manager",
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
}
static void
@ -63,7 +115,7 @@ gdk_x11_device_manager_event_translator_init (GdkEventTranslatorIface *iface)
}
static GdkDevice *
create_core_pointer (GdkDeviceManager *device_manager,
create_core_pointer (GdkX11DeviceManagerCore *device_manager,
GdkDisplay *display)
{
return g_object_new (GDK_TYPE_X11_DEVICE_CORE,
@ -78,7 +130,7 @@ create_core_pointer (GdkDeviceManager *device_manager,
}
static GdkDevice *
create_core_keyboard (GdkDeviceManager *device_manager,
create_core_keyboard (GdkX11DeviceManagerCore *device_manager,
GdkDisplay *display)
{
return g_object_new (GDK_TYPE_X11_DEVICE_CORE,
@ -117,9 +169,9 @@ gdk_x11_device_manager_core_constructed (GObject *object)
GdkDisplay *display;
device_manager = GDK_X11_DEVICE_MANAGER_CORE (object);
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);
display = device_manager->display;
device_manager->core_pointer = create_core_pointer (device_manager, display);
device_manager->core_keyboard = create_core_keyboard (device_manager, display);
_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);
@ -291,7 +343,7 @@ get_event_window (GdkEventTranslator *translator,
GdkWindow *window;
device_manager = GDK_DEVICE_MANAGER (translator);
display = gdk_device_manager_get_display (device_manager);
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
/* Apply keyboard grabs to non-native windows */

View File

@ -20,6 +20,7 @@
#include "gdkx11devicemanager-xi2.h"
#include "gdkx11device-xi2.h"
#include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate-core.h"
#include "gdkdeviceprivate.h"
#include "gdkdevicetoolprivate.h"
@ -53,7 +54,7 @@ struct _GdkX11DeviceManagerXI2
struct _GdkX11DeviceManagerXI2Class
{
GdkDeviceManagerClass parent_class;
GdkX11DeviceManagerCoreClass parent_class;
};
static void gdk_x11_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface);
@ -146,7 +147,7 @@ _gdk_x11_device_manager_xi2_select_events (GdkDeviceManager *device_manager,
GdkDisplay *display;
Display *xdisplay;
display = gdk_device_manager_get_display (device_manager);
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
xdisplay = GDK_DISPLAY_XDISPLAY (display);
XISelectEvents (xdisplay, xwindow, event_mask, 1);
@ -518,7 +519,7 @@ ensure_seat_for_device_pair (GdkX11DeviceManagerXI2 *device_manager,
GdkDisplay *display;
GdkSeat *seat;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
seat = gdk_device_get_seat (device1);
if (!seat)
@ -548,7 +549,7 @@ add_device (GdkX11DeviceManagerXI2 *device_manager,
GdkDisplay *display;
GdkDevice *device;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
device = create_device (GDK_DEVICE_MANAGER (device_manager), display, dev);
g_hash_table_replace (device_manager->id_table,
@ -682,7 +683,7 @@ gdk_x11_device_manager_xi2_constructed (GObject *object)
G_OBJECT_CLASS (gdk_x11_device_manager_xi2_parent_class)->constructed (object);
device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
xdisplay = GDK_DISPLAY_XDISPLAY (display);
g_assert (device_manager->major == 2);
@ -768,7 +769,7 @@ gdk_x11_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager)
int device_id;
device_manager_xi2 = (GdkX11DeviceManagerXI2 *) device_manager;
display = gdk_device_manager_get_display (device_manager);
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display),
None, &device_id);
@ -850,7 +851,7 @@ handle_hierarchy_changed (GdkX11DeviceManagerXI2 *device_manager,
int ndevices;
gint i;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
xdisplay = GDK_DISPLAY_XDISPLAY (display);
for (i = 0; i < ev->num_info; i++)
@ -925,7 +926,7 @@ handle_device_changed (GdkX11DeviceManagerXI2 *device_manager,
GdkDisplay *display;
GdkDevice *device, *source_device;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
display = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->display;
device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (ev->deviceid));
source_device = g_hash_table_lookup (device_manager->id_table,
@ -1158,7 +1159,7 @@ get_event_window (GdkEventTranslator *translator,
GdkWindow *window = NULL;
gboolean should_have_window = TRUE;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (translator));
display = GDK_X11_DEVICE_MANAGER_CORE (translator)->display;
switch (ev->evtype)
{

View File

@ -21,20 +21,20 @@
#include <X11/Xlib.h>
#include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate.h"
G_BEGIN_DECLS
struct _GdkX11DeviceManagerCore
{
GdkDeviceManager parent_object;
GObject parent_instance;
GdkDisplay *display;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
};
struct _GdkX11DeviceManagerCoreClass
{
GdkDeviceManagerClass parent_class;
GObjectClass parent_class;
};
void _gdk_device_manager_core_handle_focus (GdkWindow *window,