From 550f2a11921b48bc1c876b5e7fcc42cc2a4da07f Mon Sep 17 00:00:00 2001 From: William Wold Date: Mon, 14 Sep 2020 02:14:34 -0700 Subject: Add initial Wayland backend --- src/daemon/Makefile.am | 5 +++++ src/daemon/daemon.c | 13 +++++++++++++ src/daemon/wayland.c | 39 +++++++++++++++++++++++++++++++++++++++ src/daemon/wayland.h | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 src/daemon/wayland.c create mode 100644 src/daemon/wayland.h diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 179e964..1cd972e 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -12,6 +12,11 @@ mate_notification_daemon_SOURCES = \ sound.h \ mnd-daemon.c +if ENABLE_WAYLAND +mate_notification_daemon_SOURCES += \ + wayland.c +endif + mate_notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS) mate_notification_daemon_CFLAGS = $(WARN_CFLAGS) diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index c42b2e6..7981bb0 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -45,6 +45,11 @@ #include #endif // HAVE_X11 +#ifdef HAVE_WAYLAND +#include +#include "wayland.h" +#endif // HAVE_WAYLAND + #include "daemon.h" #include "engines.h" #include "stack.h" @@ -1369,6 +1374,14 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, { nw = theme_create_notification (url_clicked_cb); g_object_set_data (G_OBJECT (nw), "_notify_daemon", daemon); + +#if HAVE_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) + { + wayland_init_notification (nw); + } +#endif // HAVE_WAYLAND + gtk_widget_realize (GTK_WIDGET (nw)); new_notification = TRUE; diff --git a/src/daemon/wayland.c b/src/daemon/wayland.c new file mode 100644 index 0000000..837e8a2 --- /dev/null +++ b/src/daemon/wayland.c @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2020 William Wold + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include "config.h" + +#ifndef HAVE_WAYLAND +#error file should only be built when HAVE_WAYLAND is enabled +#endif + +#include +#include +#include +#include + +#include + +#include "wayland.h" + +void wayland_init_notification (GtkWindow* nw) +{ + gtk_layer_init_for_window (nw); +} diff --git a/src/daemon/wayland.h b/src/daemon/wayland.h new file mode 100644 index 0000000..816eb74 --- /dev/null +++ b/src/daemon/wayland.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * Copyright (C) 2020 William Wold + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef _WAYLAND_H +#define _WAYLAND_H + +#ifdef PACKAGE_NAME // only check HAVE_WAYLAND if config.h has been included +#ifndef HAVE_WAYLAND +#error file should only be included when HAVE_WAYLAND is enabled +#endif +#endif + +#include + +void wayland_init_notification (GtkWindow* nw); + +#endif /* _WAYLAND_H */ -- cgit v1.2.1