Commit b065b16b authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Use layer shell

parent 6ff33b48
This diff is collapsed.
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*/
/*
WARNING: this file is taken directly from phosh, with no modificaions apart from this message. Please update phosh instead of changing this file. Please copy the file back here afterwards, with the same notice.
*/
#pragma once
#include <gtk/gtk.h>
/* TODO: We use the enum constants from here, use glib-mkenums */
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#define PHOSH_TYPE_LAYER_SURFACE (phosh_layer_surface_get_type ())
G_DECLARE_DERIVABLE_TYPE (PhoshLayerSurface, phosh_layer_surface, PHOSH, LAYER_SURFACE, GtkWindow)
/**
* PhoshLayerSurfaceClass
* @parent_class: The parent class
*/
struct _PhoshLayerSurfaceClass
{
GtkWindowClass parent_class;
/* Signals
*/
void (*configured) (PhoshLayerSurface *self);
};
GtkWidget *phosh_layer_surface_new (gpointer layer_shell,
gpointer wl_output);
struct zwlr_layer_surface_v1 *phosh_layer_surface_get_layer_surface(PhoshLayerSurface *self);
struct wl_surface *phosh_layer_surface_get_wl_surface(PhoshLayerSurface *self);
......@@ -13,5 +13,6 @@ pkgdatadir = join_paths(datadir, meson.project_name())
dbusdir = join_paths(datadir, 'dbus-1/interfaces')
subdir('data')
subdir('protocols')
subdir('eek')
subdir('src')
wayland_protos = dependency('wayland-protocols', version: '>=1.12')
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
wl_scanner = find_program('wayland-scanner')
gen_scanner_client_header = generator(wl_scanner,
output: '@BASENAME@-client-protocol.h',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'])
gen_scanner_client_code = generator(wl_scanner,
output: '@BASENAME@-protocol.c',
arguments: ['code', '@INPUT@', '@OUTPUT@'])
wl_protos = [
wl_protocol_dir + '/stable/xdg-shell/xdg-shell.xml',
'wlr-layer-shell-unstable-v1.xml',
]
wl_proto_sources = []
foreach proto: wl_protos
wl_proto_sources += gen_scanner_client_header.process(proto)
wl_proto_sources += gen_scanner_client_code.process(proto)
endforeach
This diff is collapsed.
......@@ -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 =
......
/*
* 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, &registry_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;
}
#include "wayland.h"
struct squeak_wayland *squeak_wayland = NULL;
#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
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