Commit 6b0b87b7 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

clipboard: move to separate process

#50
parent 23ffb0a0
Pipeline #174177 passed with stages
in 7 minutes and 48 seconds
......@@ -3,6 +3,7 @@ NULL =
SUBDIRS = \
data \
dbus \
daemons \
backends \
gvc \
gnome-flashback \
......
......@@ -400,12 +400,14 @@ AC_CONFIG_FILES([
dbus/Makefile
daemons/Makefile
daemons/clipboard/Makefile
gnome-flashback/Makefile
gnome-flashback/liba11y-keyboard/Makefile
gnome-flashback/libaudio-device-selection/Makefile
gnome-flashback/libautomount-manager/Makefile
gnome-flashback/libcommon/Makefile
gnome-flashback/libclipboard/Makefile
gnome-flashback/libdesktop/Makefile
gnome-flashback/libend-session-dialog/Makefile
gnome-flashback/libidle-monitor/Makefile
......
NULL =
SUBDIRS = \
clipboard \
$(NULL)
-include $(top_srcdir)/git.mk
NULL =
noinst_LTLIBRARIES = \
libclipboard.la \
libexec_PROGRAMS = \
gnome-flashback-clipboard \
$(NULL)
libclipboard_la_CPPFLAGS = \
-I$(top_builddir)/gnome-flashback/libclipboard \
gnome_flashback_clipboard_CPPFLAGS = \
-DG_LOG_DOMAIN=\"gnome-flashback-clipboard\" \
-DG_LOG_USE_STRUCTURED=1 \
-I$(top_srcdir) \
$(NULL)
libclipboard_la_CFLAGS = \
gnome_flashback_clipboard_CFLAGS = \
$(CLIPBOARD_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
libclipboard_la_SOURCES = \
gnome_flashback_clipboard_SOURCES = \
gf-clipboard-main.c \
gf-clipboard.c \
gf-clipboard.h \
gsd-clipboard-manager.c \
......@@ -25,12 +28,13 @@ libclipboard_la_SOURCES = \
xutils.h \
$(NULL)
libclipboard_la_LDFLAGS = \
gnome_flashback_clipboard_LDFLAGS = \
$(WARN_LDFLAGS) \
$(AM_LDFLAGS) \
$(NULL)
libclipboard_la_LIBADD = \
gnome_flashback_clipboard_LDADD = \
$(top_builddir)/dbus/libdbus.la \
$(CLIPBOARD_LIBS) \
$(LIBM) \
$(NULL)
......
/*
* Copyright (C) 2020 Alberts Muktupāvels
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib-unix.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include "dbus/gf-session-manager-gen.h"
#include "dbus/gf-sm-client-private-gen.h"
#include "gf-clipboard.h"
static char *startup_id = NULL;
static GMainLoop *loop = NULL;
static GfSmClientPrivateGen *client_private = NULL;
static gboolean
on_term_signal (gpointer user_data)
{
g_main_loop_quit (loop);
return G_SOURCE_REMOVE;
}
static gboolean
on_int_signal (gpointer user_data)
{
g_main_loop_quit (loop);
return G_SOURCE_REMOVE;
}
static void
respond_to_end_session (void)
{
gf_sm_client_private_gen_call_end_session_response (client_private,
TRUE,
"",
NULL,
NULL,
NULL);
}
static void
end_session_cb (GfSmClientPrivateGen *object,
guint flags,
gpointer user_data)
{
respond_to_end_session ();
}
static void
query_end_session_cb (GfSmClientPrivateGen *object,
guint flags,
gpointer user_data)
{
respond_to_end_session ();
}
static void
stop_cb (GfSmClientPrivateGen *object,
gpointer user_data)
{
g_main_loop_quit (loop);
}
static void
client_private_ready_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
error = NULL;
client_private = gf_sm_client_private_gen_proxy_new_for_bus_finish (res,
&error);
if (error != NULL)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to get a client private proxy: %s", error->message);
g_error_free (error);
return;
}
g_signal_connect (client_private,
"end-session",
G_CALLBACK (end_session_cb),
NULL);
g_signal_connect (client_private,
"query-end-session",
G_CALLBACK (query_end_session_cb),
NULL);
g_signal_connect (client_private,
"stop",
G_CALLBACK (stop_cb),
NULL);
}
static void
register_client_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
char *client_id;
error = NULL;
gf_session_manager_gen_call_register_client_finish (GF_SESSION_MANAGER_GEN (source_object),
&client_id,
res,
&error);
if (error != NULL)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to register client: %s", error->message);
g_error_free (error);
return;
}
gf_sm_client_private_gen_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
"org.gnome.SessionManager",
client_id,
NULL,
client_private_ready_cb,
NULL);
g_free (client_id);
}
static void
session_manager_ready_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
GfSessionManagerGen *session_manager;
error = NULL;
session_manager = gf_session_manager_gen_proxy_new_for_bus_finish (res,
&error);
if (error != NULL)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to get session manager proxy: %s", error->message);
g_error_free (error);
return;
}
gf_session_manager_gen_call_register_client (session_manager,
"gnome-flashback-clipboard",
startup_id,
NULL,
register_client_cb,
NULL);
g_object_unref (session_manager);
}
int
main (int argc,
char *argv[])
{
const char *autostart_id;
GfClipboard *clipboard;
autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
startup_id = g_strdup (autostart_id != NULL ? autostart_id : "");
g_unsetenv ("DESKTOP_AUTOSTART_ID");
gtk_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
clipboard = gf_clipboard_new ();
g_unix_signal_add (SIGTERM, on_term_signal, NULL);
g_unix_signal_add (SIGINT, on_int_signal, NULL);
gf_session_manager_gen_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
NULL,
session_manager_ready_cb,
NULL);
g_main_loop_run (loop);
g_main_loop_unref (loop);
g_object_unref (clipboard);
g_clear_object (&client_private);
g_free (startup_id);
return EXIT_SUCCESS;
}
......@@ -114,4 +114,3 @@ get_server_time (Display *display,
return xevent.xproperty.time;
}
NULL =
autostart_in_files = \
gnome-flashback-nm-applet.desktop.in \
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = \
gnome-flashback-clipboard.desktop \
gnome-flashback-nm-applet.desktop \
$(NULL)
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
%.desktop.in: %.desktop.in.in
$(AM_V_GEN) sed -e 's,[@]libexecdir[@],$(libexecdir),g' < $< > $@
%.desktop: %.desktop.in
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -o $@-t \
-d $(top_srcdir)/po && mv $@-t $@
EXTRA_DIST = \
$(autostart_in_files) \
gnome-flashback-clipboard.desktop.in.in \
gnome-flashback-nm-applet.desktop.in \
$(NULL)
CLEANFILES = \
$(autostart_DATA) \
gnome-flashback-clipboard.desktop.in \
gnome-flashback-clipboard.desktop \
gnome-flashback-nm-applet.desktop \
$(NULL)
-include $(top_srcdir)/git.mk
[Desktop Entry]
Type=Application
Name=Clipboard (GNOME Flashback)
Exec=@libexecdir@/gnome-flashback-clipboard
AutostartCondition=GSettings org.gnome.gnome-flashback clipboard
OnlyShowIn=GNOME-Flashback;
NoDisplay=true
X-GNOME-Autostart-Phase=Initialization
X-GNOME-Autostart-Notify=true
X-GNOME-AutoRestart=true
......@@ -5,7 +5,6 @@ SUBDIRS = \
libaudio-device-selection \
libautomount-manager \
libcommon \
libclipboard \
libdesktop \
libend-session-dialog \
libidle-monitor \
......@@ -62,7 +61,6 @@ gnome_flashback_LDADD = \
$(top_builddir)/gnome-flashback/liba11y-keyboard/liba11y-keyboard.la \
$(top_builddir)/gnome-flashback/libaudio-device-selection/libaudio-device-selection.la \
$(top_builddir)/gnome-flashback/libautomount-manager/libautomount-manager.la \
$(top_builddir)/gnome-flashback/libclipboard/libclipboard.la \
$(top_builddir)/gnome-flashback/libdesktop/libdesktop.la \
$(top_builddir)/gnome-flashback/libend-session-dialog/libend-session-dialog.la \
$(top_builddir)/gnome-flashback/libidle-monitor/libidle-monitor.la \
......
......@@ -26,7 +26,6 @@
#include "liba11y-keyboard/gf-a11y-keyboard.h"
#include "libaudio-device-selection/gf-audio-device-selection.h"
#include "libautomount-manager/gsd-automount-manager.h"
#include "libclipboard/gf-clipboard.h"
#include "libdesktop/gf-desktop.h"
#include "libend-session-dialog/gf-end-session-dialog.h"
#include "libidle-monitor/flashback-idle-monitor.h"
......@@ -59,7 +58,6 @@ struct _GfApplication
FlashbackShell *shell;
GfA11yKeyboard *a11y_keyboard;
GfAudioDeviceSelection *audio_device_selection;
GfClipboard *clipboard;
GfDesktop *desktop;
GfEndSessionDialog *dialog;
GfInputSettings *input_settings;
......@@ -218,7 +216,6 @@ settings_changed (GSettings *settings,
SETTING_CHANGED (a11y_keyboard, "a11y-keyboard", gf_a11y_keyboard_new)
SETTING_CHANGED (audio_device_selection, "audio-device-selection", gf_audio_device_selection_new)
SETTING_CHANGED (desktop, "desktop", gf_desktop_new)
SETTING_CHANGED (clipboard, "clipboard", gf_clipboard_new)
SETTING_CHANGED (dialog, "end-session-dialog", gf_end_session_dialog_new)
SETTING_CHANGED (input_settings, "input-settings", gf_input_settings_new)
SETTING_CHANGED (input_sources, "input-sources", gf_input_sources_new)
......@@ -269,7 +266,6 @@ gf_application_dispose (GObject *object)
g_clear_object (&application->a11y_keyboard);
g_clear_object (&application->audio_device_selection);
g_clear_object (&application->desktop);
g_clear_object (&application->clipboard);
g_clear_object (&application->dialog);
g_clear_object (&application->input_settings);
g_clear_object (&application->input_sources);
......
......@@ -2,6 +2,7 @@
# Please keep this file sorted alphabetically.
backends/gf-monitor.c
data/applications/gnome-flashback.desktop.in.in
data/autostart/gnome-flashback-clipboard.desktop.in.in
data/autostart/gnome-flashback-nm-applet.desktop.in
data/directories/X-GNOME-Flashback-Settings.directory.desktop.in
data/directories/X-GNOME-Flashback-Settings-System.directory.desktop.in
......
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