Re: About execf, and about moving frames
"Bernhard R. Link" <[email protected]>
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <[email protected]> |
* Bernhard R. Link <[email protected]> [081010 10:31]: > * Yann Le Du <[email protected]> [081008 17:34]: > > 2/ If I have a window on one monitor, and try to switch it with a window > > on another monitor with the C-t x key binding, it fails. I'm using two > > separate X screens, and if I have a window in frame 0 on screen 0, and try > > to exchange it with another window in frame 2 on screen 1, it fails : the > > X server shuts down. > > If they are different screens (as opposed to Xinerama, where are > different virtual sub-screens of the same screen), then moving windows > should not be possible between them (as X does not support so). On the > other hand trying to do so should not shut down ratpoison or X. > > Hm, exchange_with_frame even has a comment in it that the caller has to > check it, and the comment and this code seems to be from me... > (Don't know if the cmd_swap is also from me, but I almost fear so...) Attached patch should make sure that swapped frames are on the same screen when not using Xinerame. I'm missing multiple screens, could you test if that works? Hochachtungsvoll, Bernhard R. Link _______________________________________________ Ratpoison-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/ratpoison-devel
ratpoison-swap-secure.diff
(text/x-diff, 1.8 KB)
diff --git a/src/actions.c b/src/actions.c
index 4365679..05b619a 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -4116,12 +4116,20 @@ cmd_exchangeright (int interactive, struct cmdarg **args)
cmdret *
cmd_swap (int interactive, struct cmdarg **args)
{
+ rp_screen *s;
rp_frame *dest_frame;
rp_frame *src_frame;
dest_frame = ARG(0, frame);
src_frame = args[1] ? ARG (1, frame) : current_frame();
-
+
+ if (!rp_have_xinerama)
+ {
+ s = find_screen_by_frame(src_frame);
+ if (screen_find_frame_by_frame(s, dest_frame) == NULL)
+ return cmdret_new (RET_FAILURE, "swap: frames on different screens");
+ }
+
exchange_with_frame (current_screen(), src_frame, dest_frame);
return cmdret_new (RET_SUCCESS, NULL);
diff --git a/src/ratpoison.h b/src/ratpoison.h
diff --git a/src/screen.c b/src/screen.c
index 88b95b7..f474996 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -161,6 +161,19 @@ find_screen (Window w)
return NULL;
}
+/* Given a frame, return the rp_screen struct it belongs to */
+rp_screen *
+find_screen_by_frame (rp_frame *f)
+{
+ int i;
+
+ for (i=0; i<num_screens; i++)
+ if (screen_find_frame_by_frame(&screens[i], f) != NULL)
+ return &screens[i];
+
+ return NULL;
+ }
+
/* Return 1 if w is a root window of any of the screens. */
int
is_a_root_window (unsigned int w)
diff --git a/src/screen.h b/src/screen.h
index d83ba4b..fe8d1cc 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -34,6 +34,7 @@ void screen_free_nums (rp_screen *s);
void frameset_free (struct list_head *head);
rp_frame *screen_get_frame (rp_screen *s, int frame_num);
rp_frame *screen_find_frame_by_frame (rp_screen *s, rp_frame *f);
+rp_screen *find_screen_by_frame (rp_frame *f);
void init_screens (int screen_arg, int screen_num);