Merge lp:~agateau/notify-osd/no-bubble-in-fullscreen into lp:notify-osd/trunk

Proposed by Aurélien Gâteau
Status: Merged
Merged at revision: not available
Proposed branch: lp:~agateau/notify-osd/no-bubble-in-fullscreen
Merge into: lp:notify-osd/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~agateau/notify-osd/no-bubble-in-fullscreen
Reviewer Review Type Date Requested Status
David Barth (community) Approve
Review via email: mp+7192@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Do not show notifications if a fullscreen application is running on the default screen.

Revision history for this message
David Barth (dbarth) wrote :

The fix comes with a test. Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-04-16 14:02:12 +0000
+++ src/Makefile.am 2009-06-02 16:28:26 +0000
@@ -80,6 +80,7 @@
80 $(GLIB_CFLAGS) \80 $(GLIB_CFLAGS) \
81 $(GCONF_CFLAGS) \81 $(GCONF_CFLAGS) \
82 $(DBUS_CFLAGS) \82 $(DBUS_CFLAGS) \
83 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \
83 $(WNCK_CFLAGS) \84 $(WNCK_CFLAGS) \
84 $(NULL)85 $(NULL)
8586
8687
=== modified file 'src/dnd.c'
--- src/dnd.c 2009-05-15 08:17:36 +0000
+++ src/dnd.c 2009-06-03 09:18:29 +0000
@@ -40,6 +40,8 @@
40#include <X11/Xatom.h>40#include <X11/Xatom.h>
41#include <gdk/gdkx.h>41#include <gdk/gdkx.h>
4242
43#include <libwnck/libwnck.h>
44
43#include "dbus.h"45#include "dbus.h"
4446
45static DBusGProxy *gsmgr = NULL;47static DBusGProxy *gsmgr = NULL;
@@ -167,6 +169,29 @@
167 return FALSE;169 return FALSE;
168}170}
169171
172static int
173is_fullscreen_cb (WnckWindow *window, WnckWorkspace *workspace)
174{
175 if (wnck_window_is_visible_on_workspace (window, workspace)
176 && wnck_window_is_fullscreen (window))
177 {
178 return 0;
179 } else {
180 return 1;
181 }
182}
183
184gboolean
185dnd_has_one_fullscreen_window (void)
186{
187 WnckScreen *screen = wnck_screen_get_default ();
188 wnck_screen_force_update (screen);
189 WnckWorkspace *workspace = wnck_screen_get_active_workspace (screen);
190 GList *list = wnck_screen_get_windows (screen);
191 GList *item = g_list_find_custom (list, workspace, (GCompareFunc) is_fullscreen_cb);
192 return item != NULL;
193}
194
170/* Tries to determine whether the user is in "do not disturb" mode */195/* Tries to determine whether the user is in "do not disturb" mode */
171gboolean196gboolean
172dnd_dont_disturb_user (void)197dnd_dont_disturb_user (void)
@@ -175,5 +200,6 @@
175 || dnd_is_xscreensaver_active()200 || dnd_is_xscreensaver_active()
176 || dnd_is_screensaver_active()201 || dnd_is_screensaver_active()
177 || dnd_is_screensaver_inhibited()202 || dnd_is_screensaver_inhibited()
203 || dnd_has_one_fullscreen_window()
178 );204 );
179}205}
180206
=== modified file 'src/dnd.h'
--- src/dnd.h 2009-03-19 10:53:20 +0000
+++ src/dnd.h 2009-06-02 16:28:26 +0000
@@ -44,6 +44,8 @@
44gboolean44gboolean
45dnd_is_screensaver_active (void);45dnd_is_screensaver_active (void);
4646
47gboolean
48dnd_has_one_fullscreen_window (void);
4749
48G_END_DECLS50G_END_DECLS
4951
5052
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2009-05-15 08:27:09 +0000
+++ tests/Makefile.am 2009-06-02 16:28:26 +0000
@@ -43,6 +43,7 @@
43 -Wall -Werror -std=c99 \43 -Wall -Werror -std=c99 \
44 $(GLIB_CFLAGS) \44 $(GLIB_CFLAGS) \
45 $(GTK_CFLAGS) \45 $(GTK_CFLAGS) \
46 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \
46 $(WNCK_CFLAGS) \47 $(WNCK_CFLAGS) \
47 $(DBUS_CFLAGS) \48 $(DBUS_CFLAGS) \
48 -I$(top_srcdir)/src49 -I$(top_srcdir)/src
4950
=== modified file 'tests/test-dnd.c'
--- tests/test-dnd.c 2009-03-19 14:52:08 +0000
+++ tests/test-dnd.c 2009-06-03 09:18:29 +0000
@@ -32,6 +32,8 @@
3232
33#include "dnd.h"33#include "dnd.h"
3434
35#include <libwnck/libwnck.h>
36
35#define TEST_DBUS_NAME "org.freedesktop.Notificationstest"37#define TEST_DBUS_NAME "org.freedesktop.Notificationstest"
3638
37static39static
@@ -49,20 +51,77 @@
49 g_debug ("screensaver is active");51 g_debug ("screensaver is active");
50}52}
5153
54static
55gboolean
56check_fullscreen (GMainLoop *loop)
57{
58 g_assert (dnd_has_one_fullscreen_window());
59 g_main_loop_quit (loop);
60 return FALSE;
61}
62
63static
64gboolean
65check_no_fullscreen (GMainLoop *loop)
66{
67 g_assert (!dnd_has_one_fullscreen_window());
68 g_main_loop_quit (loop);
69 return FALSE;
70}
71
72static
73WnckWorkspace *
74find_free_workspace (WnckScreen *screen)
75{
76 WnckWorkspace *active_workspace = wnck_screen_get_active_workspace (screen);
77 GList *lst = wnck_screen_get_workspaces (screen);
78
79 if (lst->data != active_workspace) {
80 return WNCK_WORKSPACE(lst->data);
81 }
82 lst = g_list_next (lst);
83 g_assert (lst);
84 return WNCK_WORKSPACE(lst->data);
85}
86
87static
88void
89test_dnd_fullscreen (void)
90{
91 g_assert (!dnd_has_one_fullscreen_window());
92
93 GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
94 gtk_window_fullscreen (GTK_WINDOW (window));
95 gtk_widget_show_now (window);
96
97 GMainLoop* loop = g_main_loop_new (NULL, FALSE);
98 g_timeout_add (2000, (GSourceFunc) check_fullscreen, loop);
99 g_main_loop_run (loop);
100
101 // Move window to a free workspace, dnd_has_one_fullscreen_window should
102 // not find it anymore
103 WnckScreen *screen = wnck_screen_get_default ();
104 WnckWindow *wnck_window = wnck_screen_get_active_window (screen);
105 g_assert (wnck_window);
106 WnckWorkspace *free_workspace = find_free_workspace (screen);
107 g_assert (free_workspace);
108 wnck_window_move_to_workspace (wnck_window, free_workspace);
109
110 g_timeout_add (2000, (GSourceFunc) check_no_fullscreen, loop);
111 g_main_loop_run (loop);
112
113 gtk_widget_destroy (window);
114}
115
52GTestSuite *116GTestSuite *
53test_dnd_create_test_suite (void)117test_dnd_create_test_suite (void)
54{118{
55 GTestSuite *ts = NULL;119 GTestSuite *ts = NULL;
56 GTestCase *tc = NULL;
57120
58 ts = g_test_create_suite ("dnd");121 ts = g_test_create_suite ("dnd");
59 tc = g_test_create_case ("detect screensaver",122#define TC(x) g_test_create_case(#x, 0, NULL, NULL, x, NULL)
60 0,123 g_test_suite_add (ts, TC(test_dnd_screensaver));
61 NULL,124 g_test_suite_add (ts, TC(test_dnd_fullscreen));
62 NULL,
63 test_dnd_screensaver,
64 NULL);
65 g_test_suite_add (ts, tc);
66125
67 return ts;126 return ts;
68}127}

Subscribers

People subscribed via source and target branches