1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
3 /*
4 * Copyright (C) 2016 Red Hat
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 *
21 * Written by:
22 * Jonas Ådahl <jadahl@gmail.com>
23 */
24
25 #include "config.h"
26
27 #include "wayland/meta-wayland-input-device.h"
28
29 #include <wayland-server.h>
30
31 #include "wayland/meta-wayland-seat.h"
32
33 enum
34 {
35 PROP_0,
36
37 PROP_SEAT
38 };
39
40 typedef struct _MetaWaylandInputDevicePrivate
41 {
42 MetaWaylandSeat *seat;
43 } MetaWaylandInputDevicePrivate;
44
G_DEFINE_TYPE_WITH_PRIVATE(MetaWaylandInputDevice,meta_wayland_input_device,G_TYPE_OBJECT)45 G_DEFINE_TYPE_WITH_PRIVATE (MetaWaylandInputDevice,
46 meta_wayland_input_device,
47 G_TYPE_OBJECT)
48
49 MetaWaylandSeat *
50 meta_wayland_input_device_get_seat (MetaWaylandInputDevice *input_device)
51 {
52 MetaWaylandInputDevicePrivate *priv =
53 meta_wayland_input_device_get_instance_private (input_device);
54
55 return priv->seat;
56 }
57
58 uint32_t
meta_wayland_input_device_next_serial(MetaWaylandInputDevice * input_device)59 meta_wayland_input_device_next_serial (MetaWaylandInputDevice *input_device)
60 {
61 MetaWaylandSeat *seat = meta_wayland_input_device_get_seat (input_device);
62
63 return wl_display_next_serial (seat->wl_display);
64 }
65
66 static void
meta_wayland_input_device_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)67 meta_wayland_input_device_set_property (GObject *object,
68 guint prop_id,
69 const GValue *value,
70 GParamSpec *pspec)
71 {
72 MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (object);
73 MetaWaylandInputDevicePrivate *priv =
74 meta_wayland_input_device_get_instance_private (input_device);
75
76 switch (prop_id)
77 {
78 case PROP_SEAT:
79 priv->seat = g_value_get_pointer (value);
80 break;
81
82 default:
83 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
84 }
85 }
86
87 static void
meta_wayland_input_device_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)88 meta_wayland_input_device_get_property (GObject *object,
89 guint prop_id,
90 GValue *value,
91 GParamSpec *pspec)
92 {
93 MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (object);
94 MetaWaylandInputDevicePrivate *priv =
95 meta_wayland_input_device_get_instance_private (input_device);
96
97 switch (prop_id)
98 {
99 case PROP_SEAT:
100 g_value_set_pointer (value, priv->seat);
101 break;
102
103 default:
104 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
105 }
106 }
107
108 static void
meta_wayland_input_device_init(MetaWaylandInputDevice * input_device)109 meta_wayland_input_device_init (MetaWaylandInputDevice *input_device)
110 {
111 }
112
113 static void
meta_wayland_input_device_class_init(MetaWaylandInputDeviceClass * klass)114 meta_wayland_input_device_class_init (MetaWaylandInputDeviceClass *klass)
115 {
116 GObjectClass *object_class = G_OBJECT_CLASS (klass);
117 GParamSpec *pspec;
118
119 object_class->set_property = meta_wayland_input_device_set_property;
120 object_class->get_property = meta_wayland_input_device_get_property;
121
122 pspec = g_param_spec_pointer ("seat",
123 "MetaWaylandSeat",
124 "The seat",
125 G_PARAM_READWRITE |
126 G_PARAM_STATIC_STRINGS |
127 G_PARAM_CONSTRUCT_ONLY);
128 g_object_class_install_property (object_class, PROP_SEAT, pspec);
129 }
130