Merge lp:~seb128/update-notifier/work-under-wayland into lp:update-notifier/ubuntu

Proposed by Sebastien Bacher
Status: Merged
Merged at revision: 915
Proposed branch: lp:~seb128/update-notifier/work-under-wayland
Merge into: lp:update-notifier/ubuntu
Diff against target: 147 lines (+17/-75)
4 files modified
debian/changelog (+8/-0)
src/Makefile.am (+0/-1)
src/clipboard.c (+0/-72)
src/update-notifier.c (+9/-2)
To merge this branch: bzr merge lp:~seb128/update-notifier/work-under-wayland
Reviewer Review Type Date Requested Status
Brian Murray Approve
Ubuntu Core Development Team Pending
Review via email: mp+330271@code.launchpad.net

Commit message

* src/clipboard.c, src/update-notifier.c, src/Makefile.am:
  - don't use the xorg clipboard to do single instance, that doesn't work
    under wayland, replace it with a file lock (lp: #1697381)

Description of the change

* src/clipboard.c, src/update-notifier.c, src/Makefile.am:
  - don't use the xorg clipboard to do single instance, that doesn't work
    under wayland, replace it with a file lock (lp: #1697381)

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good to me, aside of one in-line comment, thanks!

review: Needs Fixing
Revision history for this message
Sebastien Bacher (seb128) wrote :

ok, I don't think any change is needed, I connected the code and bug manually on launchpad, let me know if that's enough for you

Revision history for this message
Brian Murray (brian-murray) wrote :

That's fine then thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-09-05 21:48:13 +0000
3+++ debian/changelog 2017-09-06 09:34:16 +0000
4@@ -1,3 +1,11 @@
5+update-notifier (3.186) UNRELEASED; urgency=medium
6+
7+ * src/clipboard.c, src/update-notifier.c, src/Makefile.am:
8+ - don't use the xorg clipboard to do single instance, that doesn't work
9+ under wayland, replace it with a file lock (lp: #1697381)
10+
11+ -- Sebastien Bacher <seb128@ubuntu.com> Wed, 06 Sep 2017 11:29:31 +0200
12+
13 update-notifier (3.185) artful; urgency=medium
14
15 * src/livepatch.c: Use ngettext to correctly handle the plural form, thanks
16
17=== modified file 'src/Makefile.am'
18--- src/Makefile.am 2017-08-21 17:30:53 +0000
19+++ src/Makefile.am 2017-09-06 09:34:16 +0000
20@@ -17,7 +17,6 @@
21
22 update_notifier_SOURCES = update-notifier.c \
23 update-notifier.h \
24- clipboard.c \
25 rfc822.h\
26 rfc822.c\
27 hooks.h\
28
29=== removed file 'src/clipboard.c'
30--- src/clipboard.c 2011-07-13 14:54:42 +0000
31+++ src/clipboard.c 1970-01-01 00:00:00 +0000
32@@ -1,72 +0,0 @@
33-/*
34- * src/clipboard.c - X clipboard hack to detect if daemon is running
35- *
36- * Elliot Lee <sopwith@redhat.com>
37- *
38- * (C) Copyright 1999 Red Hat, Inc.
39- *
40- * Licensed under the GNU GPL v2. See COPYING.
41- */
42-
43-#include "config.h"
44-
45-#include <gdk/gdkx.h>
46-
47-#include "update-notifier.h"
48-
49-/*
50- * clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data ()
51- */
52-static void
53-clipboard_get_func (GtkClipboard *clipboard __attribute__((__unused__)),
54- GtkSelectionData *selection_data __attribute__((__unused__)),
55- guint info __attribute__((__unused__)),
56- gpointer user_data_or_owner __attribute__((__unused__)))
57-{
58-}
59-
60-/*
61- * clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data ()
62- */
63-static void
64-clipboard_clear_func (GtkClipboard *clipboard __attribute__((__unused__)),
65- gpointer user_data_or_owner __attribute__((__unused__)))
66-{
67-}
68-
69-/*
70- * up_get_clipboard - try and get the CLIPBOARD_NAME clipboard
71- *
72- * Returns TRUE if successfully retrieved and FALSE otherwise.
73- */
74-gboolean
75-up_get_clipboard (void)
76-{
77- static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} };
78- gboolean retval = FALSE;
79- GtkClipboard *clipboard;
80- Atom atom;
81- Display *display;
82-
83- atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME);
84- display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
85-
86- XGrabServer (display);
87-
88- if (XGetSelectionOwner (display, atom) != None)
89- goto out;
90-
91- clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE));
92-
93- if (gtk_clipboard_set_with_data (clipboard, targets,
94- G_N_ELEMENTS (targets),
95- clipboard_get_func,
96- clipboard_clear_func, NULL))
97- retval = TRUE;
98-
99-out:
100- XUngrabServer (display);
101- gdk_flush ();
102-
103- return retval;
104-}
105
106=== modified file 'src/update-notifier.c'
107--- src/update-notifier.c 2015-08-12 16:19:33 +0000
108+++ src/update-notifier.c 2017-09-06 09:34:16 +0000
109@@ -28,6 +28,8 @@
110 #include <sys/types.h>
111 #include <stdlib.h>
112 #include <signal.h>
113+#include <errno.h>
114+#include <sys/file.h>
115 #include <grp.h>
116 #include <pwd.h>
117 #include <limits.h>
118@@ -46,7 +48,6 @@
119 #include "trayappletui.h"
120
121 /* some prototypes */
122-extern gboolean up_get_clipboard (void);
123 gboolean update_timer_finished(gpointer data);
124
125 // the time when we check for fam events, in seconds
126@@ -535,6 +536,8 @@
127 {
128 UpgradeNotifier *un;
129 GError *error = NULL;
130+ int pid_file, rc;
131+ gchar *lockfn;
132
133 // init
134 if(!gtk_init_with_args (&argc, &argv,
135@@ -582,7 +585,11 @@
136 }
137
138 // check if it is running already
139- if (!up_get_clipboard ()) {
140+ lockfn = g_build_filename (g_get_user_runtime_dir (), "update-notifier.pid", NULL);
141+ pid_file = open (lockfn, O_CREAT | O_RDWR, 0600);
142+ g_free (lockfn);
143+ rc = flock(pid_file, LOCK_EX | LOCK_NB);
144+ if (rc) {
145 g_warning ("already running?");
146 return 1;
147 }

Subscribers

People subscribed via source and target branches

to all changes: