>From 84762849c8a34b744ef43314f0870ea31af6214c Mon Sep 17 00:00:00 2001
From: Bernhard R. Link
Date: Sat, 3 Jan 2009 16:21:34 +0100
Subject: [PATCH] Move screen activation code to new (de)activate_screen functions,
making sure _NET atoms are reset after tmpwm and deleted when exiting.
---
src/actions.c | 6 ++----
src/events.c | 10 ++++++++++
src/main.c | 2 ++
src/screen.c | 30 ++++++++++++++++++++++++------
src/screen.h | 2 ++
5 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index ab5162e..731e343 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -4628,8 +4628,7 @@ cmd_tmpwm (int interactive, struct cmdarg **args)
for (i=0; idisplay_string);
unhide_all_windows();
XSync(dpy, False);
+ for (i=0; i 0)
diff --git a/src/main.c b/src/main.c
index 540bb6a..0f213c8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -763,6 +763,8 @@ free_screen (rp_screen *s)
frame_free (s, frame);
}
+ deactivate_screen(s);
+
XDestroyWindow (dpy, s->bar_window);
XDestroyWindow (dpy, s->key_window);
XDestroyWindow (dpy, s->input_window);
diff --git a/src/screen.c b/src/screen.c
index 71a8f50..d978570 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -270,11 +270,6 @@ init_screen (rp_screen *s, int screen_num)
| StructureNotifyMask);
XSync (dpy, False);
- /* Add netwm support. FIXME: I think this is busted. */
- XChangeProperty (dpy, RootWindow (dpy, screen_num),
- _net_supported, XA_ATOM, 32, PropModeReplace,
- (unsigned char*)&_net_wm_pid, 1);
-
/* Set the numset for the frames to our global numset. */
s->frames_numset = rp_frame_numset;
@@ -327,7 +322,6 @@ init_screen (rp_screen *s, int screen_num)
WhitePixel (dpy, s->screen_num),
BlackPixel (dpy, s->screen_num));
XSelectInput (dpy, s->key_window, KeyPressMask | KeyReleaseMask);
- XMapWindow (dpy, s->key_window);
/* Create the input window. */
s->input_window = XCreateSimpleWindow (dpy, s->root, 0, 0, 1, 1,
@@ -344,6 +338,8 @@ init_screen (rp_screen *s, int screen_num)
s->height, 0, s->fg_color, s->bg_color);
XSelectInput (dpy, s->help_window, KeyPressMask);
+ activate_screen(s);
+
XSync (dpy, 0);
#ifdef USE_XFT_FONT
@@ -370,6 +366,28 @@ init_screen (rp_screen *s, int screen_num)
#endif
}
+void
+activate_screen (rp_screen *s)
+{
+ /* Add netwm support. FIXME: I think this is busted. */
+ XChangeProperty (dpy, RootWindow (dpy, s->screen_num),
+ _net_supported, XA_ATOM, 32, PropModeReplace,
+ (unsigned char*)&_net_wm_pid, 1);
+
+ XMapWindow (dpy, s->key_window);
+}
+
+void
+deactivate_screen (rp_screen *s)
+{
+ /* Unmap its key window */
+ XUnmapWindow (dpy, s->key_window);
+
+ /* delete everything so noone sees them while we are not there */
+ XDeleteProperty (dpy, RootWindow (dpy, s->screen_num),
+ _net_supported);
+}
+
static int
is_rp_window_for_given_screen (Window w, rp_screen *s)
{
diff --git a/src/screen.h b/src/screen.h
index d83ba4b..6bad555 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -36,6 +36,8 @@ rp_frame *screen_get_frame (rp_screen *s, int frame_num);
rp_frame *screen_find_frame_by_frame (rp_screen *s, rp_frame *f);
void init_screens (int screen_arg, int screen_num);
+void activate_screen (rp_screen *s);
+void deactivate_screen (rp_screen *s);
int is_rp_window_for_screen (Window w, rp_screen *s);
int is_a_root_window (unsigned int w);
--
1.4.4.4