Use layer shell
This commit is contained in:
@ -8,6 +8,7 @@ sources = [
|
||||
'server-service.c',
|
||||
'server-context-service.c',
|
||||
'server-main.c',
|
||||
'wayland.c',
|
||||
'../eek/eek.c',
|
||||
'../eek/eek-container.c',
|
||||
'../eek/eek-element.c',
|
||||
@ -29,6 +30,7 @@ sources = [
|
||||
'../eek/eek-theme-node.c',
|
||||
'../eek/eek-types.c',
|
||||
'../eek/eek-xml-layout.c',
|
||||
'../eek/layersurface.c',
|
||||
dbus_src,
|
||||
enums,
|
||||
keysym_entries,
|
||||
@ -38,6 +40,7 @@ sources = [
|
||||
'../eekboard/eekboard-context.c',
|
||||
'../eekboard/eekboard-service.c',
|
||||
# '../eekboard/eekboard-xklutil.c',
|
||||
wl_proto_sources,
|
||||
]
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
@ -48,6 +51,7 @@ deps = [
|
||||
dependency('gio-2.0', version: '>=2.26.0'),
|
||||
dependency('gtk+-3.0', version: '>=3.0'),
|
||||
dependency('libcroco-0.6'),
|
||||
dependency('wayland-client', version: '>=1.14'),
|
||||
cc.find_library('m'),
|
||||
# dependency('libxklavier'), # FIXME remove
|
||||
]
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "eek/eek-gtk.h"
|
||||
#include "eek/layersurface.h"
|
||||
#include "wayland.h"
|
||||
|
||||
#include "server-context-service.h"
|
||||
|
||||
@ -298,7 +300,20 @@ update_widget (ServerContextService *context)
|
||||
gtk_widget_set_has_tooltip (context->widget, TRUE);
|
||||
|
||||
if (!context->window) {
|
||||
context->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
context->window = GTK_WIDGET(g_object_new (
|
||||
PHOSH_TYPE_LAYER_SURFACE,
|
||||
"layer-shell", squeak_wayland->layer_shell,
|
||||
"wl-output", g_ptr_array_index(squeak_wayland->outputs, 0), // TODO: select output as needed,
|
||||
"height", 200,
|
||||
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM
|
||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
|
||||
"layer", ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
||||
"kbd-interactivity", FALSE,
|
||||
"exclusive-zone", 200,
|
||||
//"namespace", "phosh home",
|
||||
NULL
|
||||
));
|
||||
g_signal_connect (context->window, "destroy",
|
||||
G_CALLBACK(on_destroy), context);
|
||||
context->notify_visible_handler =
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
* Copyright (C) 2018-2019 Purism SPC
|
||||
* SPDX-License-Identifier: GPL-3.0+
|
||||
* Author: Guido Günther <agx@sigxcpu.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,20 +33,14 @@
|
||||
|
||||
#include "server-service.h"
|
||||
#include "eek/eek.h"
|
||||
#include "wayland.h"
|
||||
|
||||
#include <gdk/gdkwayland.h>
|
||||
|
||||
static gboolean opt_system = FALSE;
|
||||
static gboolean opt_session = FALSE;
|
||||
static gchar *opt_address = NULL;
|
||||
|
||||
static const GOptionEntry options[] = {
|
||||
{"system", 'y', 0, G_OPTION_ARG_NONE, &opt_system,
|
||||
N_("Connect to the system bus")},
|
||||
{"session", 'e', 0, G_OPTION_ARG_NONE, &opt_session,
|
||||
N_("Connect to the session bus")},
|
||||
{"address", 'a', 0, G_OPTION_ARG_STRING, &opt_address,
|
||||
N_("Connect to the given D-Bus address")},
|
||||
{NULL}
|
||||
};
|
||||
// D-Bus
|
||||
|
||||
static void
|
||||
on_name_acquired (GDBusConnection *connection,
|
||||
@ -69,6 +66,44 @@ on_destroyed (ServerService *service,
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
// Wayland
|
||||
|
||||
static void
|
||||
registry_handle_global (void *data,
|
||||
struct wl_registry *registry,
|
||||
uint32_t name,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
struct squeak_wayland *wayland = data;
|
||||
|
||||
if (!strcmp (interface, zwlr_layer_shell_v1_interface.name)) {
|
||||
wayland->layer_shell = wl_registry_bind (registry, name,
|
||||
&zwlr_layer_shell_v1_interface, 1);
|
||||
} else if (!strcmp (interface, "wl_output")) {
|
||||
struct wl_output *output = wl_registry_bind (registry, name,
|
||||
&wl_output_interface, 2);
|
||||
g_ptr_array_add (wayland->outputs, output);
|
||||
} else if (!strcmp(interface, "wl_seat")) {
|
||||
wayland->seat = wl_registry_bind(registry, name,
|
||||
&wl_seat_interface, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
registry_handle_global_remove (void *data,
|
||||
struct wl_registry *registry,
|
||||
uint32_t name)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
registry_handle_global,
|
||||
registry_handle_global_remove
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -131,6 +166,20 @@ main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
// Set up Wayland
|
||||
gdk_set_allowed_backends ("wayland");
|
||||
GdkDisplay *gdk_display = gdk_display_get_default ();
|
||||
struct wl_display *display = gdk_wayland_display_get_wl_display (gdk_display);
|
||||
|
||||
if (display == NULL) {
|
||||
g_error ("Failed to get display: %m\n");
|
||||
}
|
||||
|
||||
struct squeak_wayland wayland;
|
||||
squeak_wayland_init (&wayland);
|
||||
struct wl_registry *registry = wl_display_get_registry (display);
|
||||
wl_registry_add_listener (registry, ®istry_listener, &wayland);
|
||||
squeak_wayland_set_global(&wayland);
|
||||
service = server_service_new (EEKBOARD_SERVICE_PATH, connection);
|
||||
|
||||
if (service == NULL) {
|
||||
@ -161,5 +210,6 @@ main (int argc, char **argv)
|
||||
g_object_unref (connection);
|
||||
g_main_loop_unref (loop);
|
||||
|
||||
squeak_wayland_deinit (&wayland);
|
||||
return 0;
|
||||
}
|
||||
|
||||
3
src/wayland.c
Normal file
3
src/wayland.c
Normal file
@ -0,0 +1,3 @@
|
||||
#include "wayland.h"
|
||||
|
||||
struct squeak_wayland *squeak_wayland = NULL;
|
||||
31
src/wayland.h
Normal file
31
src/wayland.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef WAYLAND_H
|
||||
#define WAYLAND_H
|
||||
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
#include <gmodule.h>
|
||||
|
||||
|
||||
struct squeak_wayland {
|
||||
struct zwlr_layer_shell_v1 *layer_shell;
|
||||
GPtrArray *outputs; // *wl_output
|
||||
struct wl_seat *seat;
|
||||
};
|
||||
|
||||
|
||||
extern struct squeak_wayland *squeak_wayland;
|
||||
|
||||
|
||||
static inline void squeak_wayland_init(struct squeak_wayland *wayland) {
|
||||
wayland->outputs = g_ptr_array_new();
|
||||
}
|
||||
|
||||
static inline void squeak_wayland_set_global(struct squeak_wayland *wayland) {
|
||||
squeak_wayland = wayland;
|
||||
}
|
||||
|
||||
static inline void squeak_wayland_deinit(struct squeak_wayland *wayland) {
|
||||
g_ptr_array_free(wayland->outputs, TRUE);
|
||||
}
|
||||
|
||||
#endif // WAYLAND_H
|
||||
Reference in New Issue
Block a user