ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] Ratpoison and multiple screens...


From: Mike Meyer
Subject: [RP] Ratpoison and multiple screens...
Date: Fri Nov 16 19:39:01 2001

Just because I want Shawn as deprived of sleep as I am, here are
patches - against the CVS version, with no other patches applied - to
get rp to behave somewhat reasonably given multiple screens.

Note that this doing this adds a new possibility to the mix - you can
select a window that isn't displayed and can't be displayed in the
current frame, because it's on a different screen. I decided to make
it display in the last active frame on that screen, meaning screens
now carry around a reference to their last active frame. If rp ever
grows the ability to remove a frame other than the active frame, this
will have to be dealt with.

The usefulness of names and/or numbers for frames becomes even more
pressing when you are using multiple screens. Not to mention how
useful the frames command would have been while working on this
stuff. This is a much smaller patch than the frames stuff.

        <mike
--
Mike Meyer <address@hidden>                     http://www.mired.org/home/mwm/
Q: How do you make the gods laugh?              A: Tell them your plans.

? ratpoison.gmon
? ratpoison.core
Index: actions.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/actions.c,v
retrieving revision 1.95
diff -u -r1.95 actions.c
--- actions.c   2001/10/18 22:47:45     1.95
+++ actions.c   2001/11/17 03:20:35
@@ -919,7 +942,8 @@
        {
          /* Some process setup to make sure the spawned process runs
             in its own session. */
-         putenv(DisplayString(dpy));
+         if (rp_current_frame->scr->display)
+           putenv(rp_current_frame->scr->display);
 #ifdef HAVE_SETSID
          setsid();
 #endif
@@ -955,7 +980,8 @@
 
   PRINT_DEBUG ("Switching to %s\n", prog);
 
-  putenv(DisplayString(dpy));   
+  if (rp_current_frame->scr->display)
+    putenv(rp_current_frame->scr->display);   
   execlp(prog, prog, 0);
 
   PRINT_ERROR ("exec %s ", prog);
@@ -1187,13 +1213,16 @@
 {
   rp_window_frame *frame;
 
-  frame = find_frame_next (rp_current_frame);
+  if (!(frame = find_frame_next (rp_current_frame))) return NULL;
 
-  if (frame)
+  while (frame->scr != rp_current_frame->scr)
     {
-      remove_frame (rp_current_frame);
-      set_active_frame (frame);
+      frame = find_frame_next (frame);
+      if (frame == rp_current_frame) return NULL;
     }
+
+  remove_frame (rp_current_frame);
+  set_active_frame (frame);
 
   return NULL;
 }
Index: data.h
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/data.h,v
retrieving revision 1.33
diff -u -r1.33 data.h
--- data.h      2001/10/18 07:51:30     1.33
+++ data.h      2001/11/17 03:20:36
@@ -39,6 +39,7 @@
 {
   int x, y, width, height;
   rp_window *win;
+  screen_info *scr;
 
   /* For determining the last frame. */
   int last_access;
@@ -99,6 +100,8 @@
   Colormap def_cmap;
   Cursor rat;
   unsigned long fg_color, bg_color; /* The pixel color. */
+  rp_window_frame *last_frame;
+  char *display;               /* And the display string for children */
 };
 
 struct rp_action
Index: events.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/events.c,v
retrieving revision 1.66
diff -u -r1.66 events.c
--- events.c    2001/10/18 07:51:59     1.66
+++ events.c    2001/11/17 03:20:41
@@ -49,7 +49,9 @@
 
   s = find_screen (e->parent);
   win = find_window (e->window);
-
+  PRINT_DEBUG ("Opening window '%s' on screen %d\n", window_name (win),
+              s->screen_num);
+  
   if (s && win == NULL
       && e->window != s->key_window 
       && e->window != s->bar_window 
Index: list.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/list.c,v
retrieving revision 1.40
diff -u -r1.40 list.c
--- list.c      2001/10/10 05:35:00     1.40
+++ list.c      2001/11/17 03:20:42
@@ -177,7 +177,7 @@
 void
 set_current_window (rp_window *win)
 {
-  set_frames_window (rp_current_frame, win);
+  set_frames_window (win->scr->last_frame, win);
 }
 
 void
@@ -258,7 +258,7 @@
     {
       if (cur == rp_mapped_window_sentinel) continue;
 
-      if (!find_windows_frame (cur))
+      if (!find_windows_frame (cur) && cur->scr == rp_current_frame->scr)
        {
          return cur;
        }
@@ -282,7 +282,7 @@
     {
       if (cur == rp_mapped_window_sentinel) continue;
 
-      if (!find_windows_frame (cur))
+      if (!find_windows_frame (cur) && cur->scr == rp_current_frame->scr)
        {
          return cur;
        }
@@ -304,7 +304,8 @@
     {
       if (cur->last_access >= last_access 
          && cur != current_window()
-         && !find_windows_frame (cur))
+         && !find_windows_frame (cur)
+         && cur->scr == rp_current_frame->scr)
        {
          most_recent = cur;
          last_access = cur->last_access;
@@ -570,7 +571,7 @@
 
   if (win == NULL) return;
 
-  last_win = set_frames_window (rp_current_frame, win);
+  last_win = set_frames_window (win->scr->last_frame, win);
 
   if (last_win) PRINT_DEBUG ("last window: %s\n", window_name (last_win));
   PRINT_DEBUG ("new window: %s\n", window_name (win));
@@ -589,7 +590,7 @@
 #endif
     hide_others(win);
 
-  give_window_focus (win, last_win);
+  set_active_frame(win->scr->last_frame);
 
   /* Make sure the program bar is always on the top */
   update_window_names (win->scr);
Index: main.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/main.c,v
retrieving revision 1.49
diff -u -r1.49 main.c
--- main.c      2001/09/28 04:50:00     1.49
+++ main.c      2001/11/17 03:20:44
@@ -514,6 +514,7 @@
 init_screen (screen_info *s, int screen_num)
 {
   XGCValues gv;
+  char *displayname, *dot;
 
   /* Select on some events on the root window, if this fails, then
      there is already a WM running and the X Error handler will catch
@@ -523,9 +524,22 @@
                | SubstructureRedirectMask | SubstructureNotifyMask );
   XSync (dpy, False);
 
+  /* Build the display string for each screen */
+  displayname = DisplayString (dpy);
+  if (!strrchr(displayname, ':')) s->display = 0;
+  else
+    {
+      s->display = xmalloc (strlen(displayname) + 21);
+      sprintf (s->display, "DISPLAY=%s", displayname);
+      dot = strrchr(s->display, '.');
+      if (dot == NULL) dot = strrchr(s->display, '\0');
+      sprintf(dot, ".%i", screen_num);
+    }
+
   s->screen_num = screen_num;
   s->root = RootWindow (dpy, screen_num);
   s->def_cmap = DefaultColormap (dpy, screen_num);
+  s->last_frame = create_initial_frame (s);
   XGetWindowAttributes (dpy, s->root, &s->root_attr);
   
   init_rat_cursor (s);
Index: manage.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/manage.c,v
retrieving revision 1.49
diff -u -r1.49 manage.c
--- manage.c    2001/09/21 09:47:23     1.49
+++ manage.c    2001/11/17 03:20:45
@@ -64,10 +64,7 @@
 screen_info*
 current_screen ()
 {
-  if (current_window())
-    return current_window()->scr;
-  else
-    return &screens[0];
+  return rp_current_frame->scr;
 }
 
 void
Index: split.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/split.c,v
retrieving revision 1.20
diff -u -r1.20 split.c
--- split.c     2001/10/18 22:47:45     1.20
+++ split.c     2001/11/17 03:20:57
@@ -25,7 +25,7 @@
 
 #include "ratpoison.h"
 
-rp_window_frame *rp_window_frame_sentinel;
+rp_window_frame *rp_window_frame_sentinel = NULL;
 rp_window_frame *rp_current_frame;
 
 static void
@@ -42,10 +42,18 @@
 {
   rp_window *last_win;
 
+  if (win)
+    {
+      if (win->scr != frame->scr)
+       {
+         PRINT_DEBUG("Trying to set window to frame on different screen!\n");
+         return NULL;
+       }
+      win->frame = frame;
+    }
+      
   last_win = frame->win;
   frame->win = win;
-  if (win)
-    win->frame = frame;
 
   return last_win;
 }
@@ -80,27 +88,28 @@
   frame->x = defaults.padding_left;
   frame->y = defaults.padding_top;
 
-  /* FIXME: what about multiple screens? */
-  frame->width = DisplayWidth (dpy, 0) - defaults.padding_right - 
defaults.padding_left;
-  frame->height = DisplayHeight (dpy, 0) - defaults.padding_bottom - 
defaults.padding_top;
+  frame->width = DisplayWidth (dpy, frame->scr->screen_num) - 
defaults.padding_right - defaults.padding_left;
+  frame->height = DisplayHeight (dpy, frame->scr->screen_num) - 
defaults.padding_bottom - defaults.padding_top;
 }
 
 /* Create a full screen frame */
-static void
-create_initial_frame ()
+rp_window_frame *
+create_initial_frame (screen_info *scr)
 {
   rp_current_frame = xmalloc (sizeof (rp_window_frame));
 
   update_last_access (rp_current_frame);
 
-  rp_window_frame_sentinel->next = rp_current_frame;
+  rp_current_frame->prev = rp_window_frame_sentinel->prev;
+  rp_window_frame_sentinel->prev->next = rp_current_frame;
   rp_window_frame_sentinel->prev = rp_current_frame;
   rp_current_frame->next = rp_window_frame_sentinel;
-  rp_current_frame->prev = rp_window_frame_sentinel;
+  rp_current_frame->scr = scr;
 
   maximize_frame (rp_current_frame);
-
   set_frames_window (rp_current_frame, NULL);
+
+  return rp_current_frame;
 }
 
 void
@@ -110,8 +119,6 @@
 
   rp_window_frame_sentinel->next = rp_window_frame_sentinel;
   rp_window_frame_sentinel->prev = rp_window_frame_sentinel;
-
-  create_initial_frame();
 }
 
 rp_window_frame *
@@ -226,6 +233,7 @@
        cur = cur->next)
     {
       if (cur != current_window() 
+         && cur->scr == frame->scr
          && !find_windows_frame (cur)
          && cur->last_access >= last_access
          && window_fits_in_frame (cur, frame)
@@ -259,6 +267,7 @@
   rp_window_frame_sentinel->prev = new_frame;
   new_frame->next = rp_window_frame_sentinel;
 
+  new_frame->scr = frame->scr;
   set_frames_window (new_frame, NULL);
 
   if (way)
@@ -328,28 +337,34 @@
   rp_window *cur_window;
   rp_window_frame *frame, *cur_frame;
   rp_window *win;
+  screen_info *scr;
 
   cur_window = current_window();
-  cur_frame  = rp_current_frame;
+  cur_frame = rp_current_frame;
+  scr = rp_current_frame->scr;
 
-  while (rp_window_frame_sentinel->next != rp_window_frame_sentinel)
+  for (frame = rp_window_frame_sentinel->next;
+       frame != rp_window_frame_sentinel;
+       frame = frame->next)
     {
-      frame = rp_window_frame_sentinel->next;
-      delete_frame_from_list (frame);
-      if (frame != rp_current_frame)
+      if (frame->scr == scr)
        {
-         for (win = rp_mapped_window_sentinel->next;
-              win != rp_mapped_window_sentinel;
-              win = win->next)
+         delete_frame_from_list (frame);
+         if (frame != rp_current_frame)
            {
-             if (win->frame == frame)
-               hide_window (win);
+             for (win = rp_mapped_window_sentinel->next;
+                  win != rp_mapped_window_sentinel;
+                  win = win->next)
+               {
+                 if (win->frame == frame)
+                   hide_window (win);
+               }
            }
+         free (frame);
        }
-      free (frame);
     }
 
-  create_initial_frame ();
+  create_initial_frame (scr);
   
   /* Maximize all the windows that were in the current frame. */
   for (win = rp_mapped_window_sentinel->next;
@@ -430,6 +445,8 @@
 static int
 frames_overlap (rp_window_frame *f1, rp_window_frame *f2)
 {
+  if (f1->scr != f2->scr) return 0;
+
   if (f1->x >= f2->x + f2->width 
       || f1->y >= f2->y + f2->height
       || f2->x >= f1->x + f1->width 
@@ -480,6 +497,8 @@
       rp_window_frame tmp_frame;
       int fits = 0;
 
+      if (cur->scr != frame->scr) continue;
+
       if (cur->win)
        {
          PRINT_DEBUG ("Trying frame containing window '%s'\n", window_name 
(cur->win));
@@ -579,6 +598,7 @@
   give_window_focus (frame->win, rp_current_frame->win);
   update_last_access (frame);
   rp_current_frame = frame;
+  frame->scr->last_frame = frame;
 
   if (old != rp_current_frame && num_frames() > 1)
     {
@@ -650,11 +670,10 @@
        cur != rp_window_frame_sentinel; 
        cur = cur->next)
     {
-      if (frame->y == cur->y + cur->height)
-       {
-         if (frame->x >= cur->x && frame->x < cur->x + cur->width)
-           return cur;
-       }
+      if ((frame->y == cur->y + cur->height)
+         && (frame->x >= cur->x && frame->x < cur->x + cur->width)
+         && (frame->scr == cur->scr))
+       return cur;
     }
 
   return NULL;
@@ -669,11 +688,10 @@
        cur != rp_window_frame_sentinel; 
        cur = cur->next)
     {
-      if (frame->y + frame->height == cur->y)
-       {
-         if (frame->x >= cur->x && frame->x < cur->x + cur->width)
+      if ((frame->y + frame->height == cur->y)
+         && (frame->x >= cur->x && frame->x < cur->x + cur->width)
+         && (frame->scr == cur->scr))
            return cur;
-       }
     }
 
   return NULL;
@@ -688,11 +706,10 @@
        cur != rp_window_frame_sentinel; 
        cur = cur->next)
     {
-      if (frame->x == cur->x + cur->width)
-       {
-         if (frame->y >= cur->y && frame->y < cur->y + cur->height)
+      if ((frame->x == cur->x + cur->width)
+         && (frame->y >= cur->y && frame->y < cur->y + cur->height)
+         && (frame->scr == cur->scr))
            return cur;
-       }
     }
 
   return NULL;
@@ -707,11 +724,10 @@
        cur != rp_window_frame_sentinel; 
        cur = cur->next)
     {
-      if (frame->x + frame->width == cur->x)
-       {
-         if (frame->y >= cur->y && frame->y < cur->y + cur->height)
+      if ((frame->x + frame->width == cur->x)
+         && (frame->y >= cur->y && frame->y < cur->y + cur->height)
+         && (frame->scr == cur ->scr))
            return cur;
-       }
     }
 
   return NULL;
Index: split.h
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/split.h,v
retrieving revision 1.7
diff -u -r1.7 split.h
--- split.h     2001/10/18 07:51:59     1.7
+++ split.h     2001/11/17 03:20:59
@@ -34,6 +34,7 @@
 rp_window_frame *find_frame_prev (rp_window_frame *frame);
 rp_window *current_window ();
 void init_frame_list ();
+rp_window_frame *create_initial_frame (screen_info *scr);
 void set_active_frame (rp_window_frame *frame);
 void blank_frame (rp_window_frame *frame);
 void show_frame_indicator ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]