Index: src/actions.c =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/actions.c,v retrieving revision 1.124 diff -c -r1.124 actions.c *** src/actions.c 25 Apr 2002 13:30:46 -0000 1.124 --- src/actions.c 29 May 2002 07:49:01 -0000 *************** *** 86,91 **** --- 86,93 ---- {"unalias", cmd_unalias, arg_STRING}, {"prevscreen", cmd_prevscreen, arg_VOID}, {"nextscreen", cmd_nextscreen, arg_VOID}, + {"vscreen", cmd_vscreen, arg_STRING}, + {"vscreen_rel", cmd_vscreen_rel, arg_STRING}, /address@hidden (tag required for genrpbindings) */ /* Commands to set default behavior. */ *************** *** 2432,2437 **** --- 2434,2475 ---- alias_list_last++; } + return NULL; + } + + char * + cmd_vscreen (int interactive, void *data) + { + int num; + + if (data == NULL) + { + message (" vscreen: One argument required "); + return NULL; + } + + if( sscanf( data, "%i", &num ) > 0 ) { + set_virtual_screen( num, 0 ); + } + show_frame_indicator(); + return NULL; + } + + char * + cmd_vscreen_rel (int interactive, void *data) + { + int num; + + if (data == NULL) + { + message (" vscreen_rel: One argument required "); + return NULL; + } + + if( sscanf( data, "%i", &num ) > 0 ) { + set_virtual_screen( num, 1 ); + } + show_frame_indicator(); return NULL; } Index: src/actions.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/actions.h,v retrieving revision 1.49 diff -c -r1.49 actions.h *** src/actions.h 24 Mar 2002 06:05:03 -0000 1.49 --- src/actions.h 29 May 2002 07:49:01 -0000 *************** *** 107,112 **** --- 107,114 ---- char * cmd_defbarpadding (int interactive, void *data); char * cmd_license (int interactive, void *data); char * cmd_alias (int interactive, void *data); + char * cmd_vscreen (int interactive, void *data); + char * cmd_vscreen_rel (int interactive, void *data); char *cmd_defbarborder (int interactive, void *data); char *cmd_prevscreen (int interactive, void *data); char *cmd_nextscreen (int interactive, void *data); Index: src/conf.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/conf.h,v retrieving revision 1.28 diff -c -r1.28 conf.h *** src/conf.h 1 Feb 2002 09:17:44 -0000 1.28 --- src/conf.h 29 May 2002 07:49:01 -0000 *************** *** 68,71 **** --- 68,74 ---- /* Maximum depth of a link. Used in the 'link' command. */ #define MAX_LINK_DEPTH 16 + /* Number of virtual screens */ + #define NUM_VSCREENS 8 + #endif /* !_ _RATPOISON_CONF_H */ Index: src/data.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/data.h,v retrieving revision 1.37 diff -c -r1.37 data.h *** src/data.h 13 Mar 2002 08:23:30 -0000 1.37 --- src/data.h 29 May 2002 07:49:01 -0000 *************** *** 31,36 **** --- 31,37 ---- #define WIN_EVENTS (StructureNotifyMask | PropertyChangeMask | ColormapChangeMask | FocusChangeMask) typedef struct rp_window rp_window; + typedef struct vscreen_info vscreen_info; typedef struct screen_info screen_info; typedef struct rp_action rp_action; typedef struct rp_window_frame rp_window_frame; *************** *** 90,95 **** --- 91,107 ---- rp_window *next, *prev; }; + struct vscreen_info + { + /* A list of frames that may or may not contain windows. There should + always be one in the list. */ + rp_window_frame *rp_window_frame_sentinel; + + /* Pointer to the currently focused frame. One for each screen so + when you switch screens the focus doesn't get frobbed. */ + rp_window_frame *rp_current_frame; + }; + struct screen_info { GC normal_gc; *************** *** 102,107 **** --- 114,124 ---- unsigned long fg_color, bg_color; /* The pixel color. */ char *display_string; + + int num_vscreens; + int current_vscreen; + vscreen_info *vscreens; + /* A list of frames that may or may not contain windows. There should always be one in the list. */ Index: src/main.c =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/main.c,v retrieving revision 1.58 diff -c -r1.58 main.c *** src/main.c 27 Jan 2002 00:57:19 -0000 1.58 --- src/main.c 29 May 2002 07:49:01 -0000 *************** *** 658,663 **** --- 658,667 ---- XSelectInput (dpy, s->help_window, KeyPressMask); XSync (dpy, 0); + + s->num_vscreens = NUM_VSCREENS; + s->current_vscreen = 0; + s->vscreens = (vscreen_info*) malloc( NUM_VSCREENS*sizeof( vscreen_info ) ); } void Index: src/split.c =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/split.c,v retrieving revision 1.23 diff -c -r1.23 split.c *** src/split.c 13 Mar 2002 08:23:30 -0000 1.23 --- src/split.c 29 May 2002 07:49:01 -0000 *************** *** 51,73 **** static screen_info * frames_screen (rp_window_frame *frame) { ! int i; rp_window_frame *cur; ! for (i=0; inext; ! cur !=screens[i]. rp_window_frame_sentinel; cur = cur->next) { if (frame == cur) return &screens[i]; } ! /* This SHOULD be impossible to get to. FIXME: It'll crash higher up if we return NULL. */ return NULL; } void maximize_all_windows_in_frame (rp_window_frame *frame) { --- 51,101 ---- static screen_info * frames_screen (rp_window_frame *frame) { ! int i, j; rp_window_frame *cur; ! for (i=0; inum_vscreens; j++ ) { ! vscreen_info *vs = &s->vscreens[j]; ! for (cur = vs->rp_window_frame_sentinel->next; ! cur != vs->rp_window_frame_sentinel; cur = cur->next) { if (frame == cur) return &screens[i]; } ! } ! } /* This SHOULD be impossible to get to. FIXME: It'll crash higher up if we return NULL. */ return NULL; } + static int + frames_vscreen (rp_window_frame *frame) + { + int i, j; + rp_window_frame *cur; + + for (i=0; inum_vscreens; j++ ) { + vscreen_info *vs = &s->vscreens[j]; + for (cur = vs->rp_window_frame_sentinel->next; + cur != vs->rp_window_frame_sentinel; + cur = cur->next) + { + if (frame == cur) + return j; + } + } + } + /* This SHOULD be impossible to get to. FIXME: It'll crash higher up if we + return NULL. */ + return -1; + } + void maximize_all_windows_in_frame (rp_window_frame *frame) { *************** *** 116,122 **** screen->rp_window_frame_sentinel->prev = screen->rp_current_frame; screen->rp_current_frame->next = screen->rp_window_frame_sentinel; screen->rp_current_frame->prev = screen->rp_window_frame_sentinel; ! maximize_frame (screen->rp_current_frame); set_frames_window (screen->rp_current_frame, NULL); --- 144,150 ---- screen->rp_window_frame_sentinel->prev = screen->rp_current_frame; screen->rp_current_frame->next = screen->rp_window_frame_sentinel; screen->rp_current_frame->prev = screen->rp_window_frame_sentinel; ! maximize_frame (screen->rp_current_frame); set_frames_window (screen->rp_current_frame, NULL); *************** *** 134,145 **** void init_frame_list (screen_info *screen) { ! screen->rp_window_frame_sentinel = xmalloc (sizeof (rp_window_frame)); ! screen->rp_window_frame_sentinel->next = screen->rp_window_frame_sentinel; ! screen->rp_window_frame_sentinel->prev = screen->rp_window_frame_sentinel; ! create_initial_frame(screen); } rp_window_frame * --- 162,183 ---- void init_frame_list (screen_info *screen) { ! int i; ! for( i = screen->num_vscreens - 1; i >= 0; i-- ) { ! screen->rp_window_frame_sentinel = xmalloc (sizeof (rp_window_frame)); ! screen->rp_window_frame_sentinel->next = screen->rp_window_frame_sentinel; ! screen->rp_window_frame_sentinel->prev = screen->rp_window_frame_sentinel; ! screen->vscreens[i].rp_window_frame_sentinel = screen->rp_window_frame_sentinel; ! } ! for( i = screen->num_vscreens - 1; i >= 0; i-- ) { ! screen->rp_window_frame_sentinel = ! screen->vscreens[i].rp_window_frame_sentinel; ! ! create_initial_frame(screen); ! screen->vscreens[i].rp_current_frame = screen->rp_current_frame; ! } } rp_window_frame * *************** *** 169,183 **** { screen_info *s; rp_window_frame *cur; s = win->scr; ! for (cur = s->rp_window_frame_sentinel->next; ! cur != s->rp_window_frame_sentinel; ! cur = cur->next) { if (cur->win == win) return cur; } return NULL; } --- 207,228 ---- { screen_info *s; rp_window_frame *cur; + vscreen_info *vs; + int i; s = win->scr; ! /* search all virtual screens */ ! for( i = 0; i < s->num_vscreens; i++ ) { ! vs = &s->vscreens[i]; ! ! for (cur = vs->rp_window_frame_sentinel->next; ! cur != vs->rp_window_frame_sentinel; ! cur = cur->next) { if (cur->win == win) return cur; } + } return NULL; } *************** *** 618,625 **** { screen_info *old_s = current_screen(); screen_info *s = frames_screen (frame); rp_window_frame *old = current_screen()->rp_current_frame; ! /* Make the switch */ give_window_focus (frame->win, old->win); update_last_access (frame); --- 663,674 ---- { screen_info *old_s = current_screen(); screen_info *s = frames_screen (frame); + int vsnum = frames_vscreen (frame); rp_window_frame *old = current_screen()->rp_current_frame; ! ! if( vsnum != s->current_vscreen ) ! set_virtual_screen( vsnum, 0 ); ! /* Make the switch */ give_window_focus (frame->win, old->win); update_last_access (frame); *************** *** 641,647 **** { XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); ! } } void --- 690,696 ---- { XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); ! } } void *************** *** 771,774 **** --- 820,865 ---- } return NULL; + } + + /* virtual screen stuff added by Stefan S */ + + void + set_virtual_screen (int vscreen_num, int rel) + { + screen_info *s = current_screen(); + rp_window_frame *cur; + int num_vscreens = s->num_vscreens; + + if( rel ) vscreen_num = s->current_vscreen + vscreen_num; + + if( vscreen_num >= num_vscreens ) vscreen_num = num_vscreens-1; + if( vscreen_num < 0 ) vscreen_num = 0; + + if( s->current_vscreen != vscreen_num ) { + /* Iconify visible windows */ + for( cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next ) { + + hide_window( cur->win ); + set_frames_window( cur, cur->win ); + hide_others( cur->win ); + } + + /* Change virtual screen */ + s->vscreens[s->current_vscreen].rp_current_frame = s->rp_current_frame; + s->current_vscreen = vscreen_num; + s->rp_current_frame = s->vscreens[vscreen_num].rp_current_frame; + s->rp_window_frame_sentinel = s->vscreens[vscreen_num].rp_window_frame_sentinel; + /* Deiconify all windows */ + for( cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next ) { + set_frames_window( cur, cur->win ); + maximize_all_windows_in_frame (cur); + unhide_window( cur->win ); + } + set_active_frame( s->rp_current_frame ); + } } Index: src/split.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/split.h,v retrieving revision 1.9 diff -c -r1.9 split.h *** src/split.h 8 Feb 2002 02:46:00 -0000 1.9 --- src/split.h 29 May 2002 07:49:01 -0000 *************** *** 46,49 **** --- 46,51 ---- rp_window_frame *find_frame_up (rp_window_frame *frame); rp_window_frame *find_last_frame (screen_info *s); + void set_virtual_screen (int vscreen_num, int rel); + #endif