summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard R. Link <brlink@debian.org>2009-01-03 16:21:34 +0100
committerShawn <sabetts@juicebox.(none)>2009-01-16 15:57:40 -0800
commitffae4bf9413bec7efd5d4821e030b63a700fab69 (patch)
treea571f33a5043d162db60c4d190bb9949a20105c7
parent9888fccffbc7d9f5680512b03ace6dd5fc325094 (diff)
downloadratpoison-ffae4bf9413bec7efd5d4821e030b63a700fab69.zip
Move screen activation code to new (de)activate_screen functions,
making sure _NET atoms are reset after tmpwm and deleted when exiting.
-rw-r--r--src/actions.c6
-rw-r--r--src/events.c10
-rw-r--r--src/main.c2
-rw-r--r--src/screen.c30
-rw-r--r--src/screen.h2
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; i<num_screens; i++)
{
XSelectInput(dpy, RootWindow (dpy, screens[i].screen_num), 0);
- /* Unmap its key window */
- XUnmapWindow (dpy, screens[i].key_window);
+ deactivate_screen(&screens[i]);
}
/* Ungrab all our keys. */
@@ -4683,9 +4682,8 @@ cmd_tmpwm (int interactive, struct cmdarg **args)
} while (tmpwm_error_raised);
XSetErrorHandler (old_handler);
- /* Map the key windows. */
for (i=0; i<num_screens; i++)
- XMapWindow (dpy, screens[i].key_window);
+ activate_screen (&screens[i]);
/* Sort through all the windows in each group and pick out the ones
that are unmapped or destroyed. */
diff --git a/src/events.c b/src/events.c
index 0e122a2..d973639 100644
--- a/src/events.c
+++ b/src/events.c
@@ -931,11 +931,17 @@ handle_signals (void)
if (rp_exec_newwm)
{
+ int i;
+
PRINT_DEBUG (("Switching to %s\n", rp_exec_newwm));
putenv(current_screen()->display_string);
unhide_all_windows();
XSync(dpy, False);
+ for (i=0; i<num_screens; i++)
+ {
+ deactivate_screen(&screens[i]);
+ }
execlp(rp_exec_newwm, rp_exec_newwm, NULL);
/* Failed. Clean up. */
@@ -943,6 +949,10 @@ handle_signals (void)
perror(" failed");
free (rp_exec_newwm);
rp_exec_newwm = NULL;
+ for (i=0; i<num_screens; i++)
+ {
+ activate_screen(&screens[i]);
+ }
}
if (hup_signalled > 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);