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
=== modified file 'debian/changelog'
--- debian/changelog 2017-09-05 21:48:13 +0000
+++ debian/changelog 2017-09-06 09:34:16 +0000
@@ -1,3 +1,11 @@
1update-notifier (3.186) UNRELEASED; urgency=medium
2
3 * src/clipboard.c, src/update-notifier.c, src/Makefile.am:
4 - don't use the xorg clipboard to do single instance, that doesn't work
5 under wayland, replace it with a file lock (lp: #1697381)
6
7 -- Sebastien Bacher <seb128@ubuntu.com> Wed, 06 Sep 2017 11:29:31 +0200
8
1update-notifier (3.185) artful; urgency=medium9update-notifier (3.185) artful; urgency=medium
210
3 * src/livepatch.c: Use ngettext to correctly handle the plural form, thanks11 * src/livepatch.c: Use ngettext to correctly handle the plural form, thanks
412
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2017-08-21 17:30:53 +0000
+++ src/Makefile.am 2017-09-06 09:34:16 +0000
@@ -17,7 +17,6 @@
1717
18update_notifier_SOURCES = update-notifier.c \18update_notifier_SOURCES = update-notifier.c \
19 update-notifier.h \19 update-notifier.h \
20 clipboard.c \
21 rfc822.h\20 rfc822.h\
22 rfc822.c\21 rfc822.c\
23 hooks.h\22 hooks.h\
2423
=== removed file 'src/clipboard.c'
--- src/clipboard.c 2011-07-13 14:54:42 +0000
+++ src/clipboard.c 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * src/clipboard.c - X clipboard hack to detect if daemon is running
3 *
4 * Elliot Lee <sopwith@redhat.com>
5 *
6 * (C) Copyright 1999 Red Hat, Inc.
7 *
8 * Licensed under the GNU GPL v2. See COPYING.
9 */
10
11#include "config.h"
12
13#include <gdk/gdkx.h>
14
15#include "update-notifier.h"
16
17/*
18 * clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data ()
19 */
20static void
21clipboard_get_func (GtkClipboard *clipboard __attribute__((__unused__)),
22 GtkSelectionData *selection_data __attribute__((__unused__)),
23 guint info __attribute__((__unused__)),
24 gpointer user_data_or_owner __attribute__((__unused__)))
25{
26}
27
28/*
29 * clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data ()
30 */
31static void
32clipboard_clear_func (GtkClipboard *clipboard __attribute__((__unused__)),
33 gpointer user_data_or_owner __attribute__((__unused__)))
34{
35}
36
37/*
38 * up_get_clipboard - try and get the CLIPBOARD_NAME clipboard
39 *
40 * Returns TRUE if successfully retrieved and FALSE otherwise.
41 */
42gboolean
43up_get_clipboard (void)
44{
45 static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} };
46 gboolean retval = FALSE;
47 GtkClipboard *clipboard;
48 Atom atom;
49 Display *display;
50
51 atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME);
52 display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
53
54 XGrabServer (display);
55
56 if (XGetSelectionOwner (display, atom) != None)
57 goto out;
58
59 clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE));
60
61 if (gtk_clipboard_set_with_data (clipboard, targets,
62 G_N_ELEMENTS (targets),
63 clipboard_get_func,
64 clipboard_clear_func, NULL))
65 retval = TRUE;
66
67out:
68 XUngrabServer (display);
69 gdk_flush ();
70
71 return retval;
72}
730
=== modified file 'src/update-notifier.c'
--- src/update-notifier.c 2015-08-12 16:19:33 +0000
+++ src/update-notifier.c 2017-09-06 09:34:16 +0000
@@ -28,6 +28,8 @@
28#include <sys/types.h>28#include <sys/types.h>
29#include <stdlib.h>29#include <stdlib.h>
30#include <signal.h>30#include <signal.h>
31#include <errno.h>
32#include <sys/file.h>
31#include <grp.h>33#include <grp.h>
32#include <pwd.h>34#include <pwd.h>
33#include <limits.h>35#include <limits.h>
@@ -46,7 +48,6 @@
46#include "trayappletui.h"48#include "trayappletui.h"
4749
48/* some prototypes */50/* some prototypes */
49extern gboolean up_get_clipboard (void);
50gboolean update_timer_finished(gpointer data);51gboolean update_timer_finished(gpointer data);
5152
52// the time when we check for fam events, in seconds53// the time when we check for fam events, in seconds
@@ -535,6 +536,8 @@
535{536{
536 UpgradeNotifier *un;537 UpgradeNotifier *un;
537 GError *error = NULL;538 GError *error = NULL;
539 int pid_file, rc;
540 gchar *lockfn;
538541
539 // init542 // init
540 if(!gtk_init_with_args (&argc, &argv,543 if(!gtk_init_with_args (&argc, &argv,
@@ -582,7 +585,11 @@
582 }585 }
583586
584 // check if it is running already587 // check if it is running already
585 if (!up_get_clipboard ()) {588 lockfn = g_build_filename (g_get_user_runtime_dir (), "update-notifier.pid", NULL);
589 pid_file = open (lockfn, O_CREAT | O_RDWR, 0600);
590 g_free (lockfn);
591 rc = flock(pid_file, LOCK_EX | LOCK_NB);
592 if (rc) {
586 g_warning ("already running?");593 g_warning ("already running?");
587 return 1;594 return 1;
588 }595 }

Subscribers

People subscribed via source and target branches

to all changes: