Commit a80d73a5 authored by Guido Gunther's avatar Guido Gunther Committed by Guido Gunther
Browse files

wayland: Provide seat capabilities



We don't bother to introduce a separate PhoshWlSeat object
for that yet.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 1f6112ea
......@@ -19,6 +19,7 @@ phosh_enum_headers = [
'monitor/monitor.h',
'notifications/notification.h',
'notifications/notify-manager.h',
'phosh-wayland.h',
] + schema_enum_headers
phosh_enums = gnome.mkenums('phosh-enums',
......
......@@ -7,6 +7,7 @@
#include "monitor/monitor.h"
#include "notifications/notification.h"
#include "notifications/notify-manager.h"
#include "phosh-wayland.h"
#include "wwan/phosh-wwan-backend.h"
#include "phosh-enums.h"
......
......@@ -9,6 +9,7 @@
#define G_LOG_DOMAIN "phosh-wayland"
#include "config.h"
#include "phosh-enums.h"
#include "phosh-wayland.h"
#include <gdk/gdkwayland.h>
......@@ -26,6 +27,7 @@
enum {
PHOSH_WAYLAND_PROP_0,
PHOSH_WAYLAND_PROP_WL_OUTPUTS,
PHOSH_WAYLAND_PROP_SEAT_CAPABILITIES,
PHOSH_WAYLAND_PROP_LAST_PROP,
};
static GParamSpec *props[PHOSH_WAYLAND_PROP_LAST_PROP];
......@@ -48,6 +50,7 @@ struct _PhoshWayland {
struct zxdg_output_manager_v1 *zxdg_output_manager_v1;
struct wl_shm *wl_shm;
GHashTable *wl_outputs;
PhoshWaylandSeatCapabilities seat_capabilities;
};
G_DEFINE_TYPE (PhoshWayland, phosh_wayland, G_TYPE_OBJECT)
......@@ -181,6 +184,9 @@ phosh_wayland_get_property (GObject *object,
case PHOSH_WAYLAND_PROP_WL_OUTPUTS:
g_value_set_boxed (value, self->wl_outputs);
break;
case PHOSH_WAYLAND_PROP_SEAT_CAPABILITIES:
g_value_set_flags (value, self->seat_capabilities);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -188,6 +194,37 @@ phosh_wayland_get_property (GObject *object,
}
static void
seat_handle_capabilities (void *data,
struct wl_seat *wl_seat,
uint32_t capabilities)
{
PhoshWayland *self = PHOSH_WAYLAND (data);
if (self->seat_capabilities != capabilities) {
g_debug ("Seat capabilities: %d", capabilities);
self->seat_capabilities = capabilities;
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_WAYLAND_PROP_SEAT_CAPABILITIES]);
}
}
static void
seat_handle_name (void *data,
struct wl_seat *wl_seat,
const char *name)
{
/* nothing to do */
}
static const struct wl_seat_listener seat_listener =
{
seat_handle_capabilities,
seat_handle_name,
};
static void
phosh_wayland_constructed (GObject *object)
{
......@@ -229,6 +266,8 @@ phosh_wayland_constructed (GObject *object)
if (!self->phosh_private) {
g_info ("Could not find phosh private interface, disabling some features");
}
wl_seat_add_listener (self->wl_seat, &seat_listener, self);
}
......@@ -238,6 +277,7 @@ phosh_wayland_dispose (GObject *object)
PhoshWayland *self = PHOSH_WAYLAND (object);
g_clear_pointer (&self->wl_outputs, g_hash_table_destroy);
G_OBJECT_CLASS (phosh_wayland_parent_class)->dispose (object);
}
......@@ -258,6 +298,15 @@ phosh_wayland_class_init (PhoshWaylandClass *klass)
"The currently known wayland outputs",
G_TYPE_HASH_TABLE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
props[PHOSH_WAYLAND_PROP_SEAT_CAPABILITIES] =
g_param_spec_flags ("seat-capabilities",
"Seat capabilities",
"The current seat capabilities",
PHOSH_TYPE_WAYLAND_SEAT_CAPABILITIES,
PHOSH_WAYLAND_SEAT_CAPABILITY_NONE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PHOSH_WAYLAND_PROP_LAST_PROP, props);
}
......@@ -426,3 +475,12 @@ phosh_wayland_roundtrip (PhoshWayland *self)
wl_display_roundtrip(self->display);
}
PhoshWaylandSeatCapabilities
phosh_wayland_get_seat_capabilities (PhoshWayland *self)
{
g_return_val_if_fail (PHOSH_IS_WAYLAND (self), PHOSH_WAYLAND_SEAT_CAPABILITY_NONE);
return self->seat_capabilities;
}
......@@ -23,6 +23,22 @@
G_BEGIN_DECLS
/**
* PhoshWaylandSeatCapabilities:
* @PHOSH_WAYLAND_SEAT_CAPABILITY_NONE: no device detected
* @PHOSH_WAYLAND_SEAT_CAPABILITY_POINTER: the seat has pointer devices
* @PHOSH_WAYLAND_SEAT_CAPABILITY_KEYBOARD: the seat has one or more keyboards
* @PHOSH_WAYLAND_SEAT_CAPABILITY_TOUCH: the seat has touch devices
*
* These match wl_seat_capabilities
*/
typedef enum {
PHOSH_WAYLAND_SEAT_CAPABILITY_NONE = 0,
PHOSH_WAYLAND_SEAT_CAPABILITY_POINTER = (1 << 0),
PHOSH_WAYLAND_SEAT_CAPABILITY_KEYBOARD = (1 << 1),
PHOSH_WAYLAND_SEAT_CAPABILITY_TOUCH = (1 << 2),
} PhoshWaylandSeatCapabilities;
#define PHOSH_TYPE_WAYLAND phosh_wayland_get_type()
G_DECLARE_FINAL_TYPE (PhoshWayland, phosh_wayland, PHOSH, WAYLAND, GObject)
......@@ -44,5 +60,6 @@ struct zwlr_output_manager_v1 *phosh_wayland_get_zwlr_output_manager_v1 (
struct zwlr_output_power_manager_v1 *phosh_wayland_get_zwlr_output_power_manager_v1 (PhoshWayland *self);
struct zxdg_output_manager_v1 *phosh_wayland_get_zxdg_output_manager_v1 (PhoshWayland *self);
void phosh_wayland_roundtrip (PhoshWayland *self);
PhoshWaylandSeatCapabilities phosh_wayland_get_seat_capabilities (PhoshWayland *self);
G_END_DECLS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment