diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | src/actions.c | 97 | ||||
-rw-r--r-- | src/globals.c | 3 | ||||
-rw-r--r-- | src/globals.h | 2 | ||||
-rw-r--r-- | src/screen.c | 20 | ||||
-rw-r--r-- | src/screen.h | 2 | ||||
-rw-r--r-- | src/split.c | 32 | ||||
-rw-r--r-- | src/split.h | 4 |
8 files changed, 120 insertions, 55 deletions
@@ -1,5 +1,20 @@ 2004-02-27 Shawn Betts <sabetts@vcn.bc.ca> + * src/screen.c (screen_free_nums): new function. prototype added + (init_screens): init rp_frame_numset + (init_screen): set screen's frames_numset to rp_frame_numset + + * src/globals.h: new global prototype, rp_frame_numset + + * src/globals.c: new global, rp_frame_numset + + * src/split.c (find_last_frame): find the last from of all the + screens. prototype updated. Callers updated. + (find_frame_number): search all screens. prototype + updated. callers updated. + + * src/actions.c (cmd_fselect): select from frames in all screens. + * src/window.c (give_window_focus): save the mouse position before checking if win is NULL. (give_window_focus): set rp_current_screen to xine_screen_num of diff --git a/src/actions.c b/src/actions.c index 59221e0..1f0b501 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2846,7 +2846,7 @@ cmd_startup_message (int interactive, char *data) char * cmd_focuslast (int interactive, char *data) { - rp_frame *frame = find_last_frame(current_screen()); + rp_frame *frame = find_last_frame(); if (frame) set_active_frame (frame); @@ -3270,7 +3270,6 @@ char * cmd_fselect (int interactive, char *data) { rp_frame *frame; - rp_screen *s = current_screen(); int fnum = -1; /* If the command was specified on the command line or an argument @@ -3300,57 +3299,67 @@ cmd_fselect (int interactive, char *data) KeySym c; unsigned int mod; Window *wins; - XSetWindowAttributes attr; - int i; + int i, j; rp_frame *cur; + int frames; - /* Set up the window attributes to be used in the loop. */ - attr.border_pixel = s->fg_color; - attr.background_pixel = s->bg_color; - attr.override_redirect = True; + frames = 0; + for (j=0; j<num_screens; j++) + frames += num_frames(&screens[j]); - wins = xmalloc (sizeof (Window) * num_frames (s)); + wins = xmalloc (sizeof (Window) * frames); /* Loop through each frame and display its number in it's top left corner. */ i = 0; - list_for_each_entry (cur, &s->frames, node) + for (j=0; j<num_screens; j++) { - int width, height; - char *num; - - /* Create the string to be displayed in the window and - determine the height and width of the window. */ - num = xsprintf (" %d ", cur->number); - width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, num, strlen (num)); - height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2); - - /* Create and map the window. */ - wins[i] = XCreateWindow (dpy, s->root, s->left + cur->x, s->top + cur->y, width, height, 1, - CopyFromParent, CopyFromParent, CopyFromParent, - CWOverrideRedirect | CWBorderPixel | CWBackPixel, - &attr); - XMapWindow (dpy, wins[i]); - XClearWindow (dpy, wins[i]); - - /* Display the frame's number inside the window. */ - XDrawString (dpy, wins[i], s->normal_gc, - defaults.bar_x_padding, - defaults.bar_y_padding + defaults.font->max_bounds.ascent, - num, strlen (num)); - - free (num); - i++; + XSetWindowAttributes attr; + rp_screen *s = &screens[j]; + + /* Set up the window attributes to be used in the loop. */ + attr.border_pixel = s->fg_color; + attr.background_pixel = s->bg_color; + attr.override_redirect = True; + + list_for_each_entry (cur, &s->frames, node) + { + int width, height; + char *num; + + /* Create the string to be displayed in the window and + determine the height and width of the window. */ + num = xsprintf (" %d ", cur->number); + width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, num, strlen (num)); + height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2); + + /* Create and map the window. */ + wins[i] = XCreateWindow (dpy, s->root, s->left + cur->x, s->top + cur->y, width, height, 1, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBorderPixel | CWBackPixel, + &attr); + XMapWindow (dpy, wins[i]); + XClearWindow (dpy, wins[i]); + + /* Display the frame's number inside the window. */ + XDrawString (dpy, wins[i], s->normal_gc, + defaults.bar_x_padding, + defaults.bar_y_padding + defaults.font->max_bounds.ascent, + num, strlen (num)); + + free (num); + i++; + } } XSync (dpy, False); /* Read a key. */ - XGrabKeyboard (dpy, s->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); + XGrabKeyboard (dpy, current_screen()->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); read_key (&c, &mod, NULL, 0); XUngrabKeyboard (dpy, CurrentTime); /* Destroy our number windows and free the array. */ - for (i=0; i<num_frames (s); i++) + for (i=0; i<frames; i++) XDestroyWindow (dpy, wins[i]); free (wins); @@ -3365,7 +3374,7 @@ cmd_fselect (int interactive, char *data) /* Now that we have a frame number to go to, let's try to jump to it. */ - frame = find_frame_number (s, fnum); + frame = find_frame_number (fnum); if (frame) set_active_frame (frame); else @@ -3450,9 +3459,12 @@ cmd_frestore (int interactively, char *data) blank_frame (cur); } + /* Get rid of the frames' numbers */ + screen_free_nums (s); + /* Splice in our new frameset. */ screen_restore_frameset (s, &fset); - numset_clear (s->frames_numset); +/* numset_clear (s->frames_numset); */ /* Process the frames a bit to make sure everything lines up. */ list_for_each_entry (cur, &s->frames, node) @@ -3468,8 +3480,11 @@ cmd_frestore (int interactively, char *data) max = cur->last_access; } - /* Grab the frame's number. */ - numset_add_num (s->frames_numset, cur->number); + /* Grab the frame's number, but if it already exists request a + new one. */ + if (!numset_add_num (s->frames_numset, cur->number)) { + cur->number = numset_request (s->frames_numset); + } /* Update the window the frame points to. */ if (cur->win_number != EMPTY) diff --git a/src/globals.c b/src/globals.c index 8fbe737..c9c02cc 100644 --- a/src/globals.c +++ b/src/globals.c @@ -67,6 +67,9 @@ int rp_honour_normal_map = 1; char *rp_error_msg = NULL; +/* Global frame numset */ +struct numset *rp_frame_numset; + /* The hook dictionary globals. */ LIST_HEAD (rp_prefix_hook); diff --git a/src/globals.h b/src/globals.h index 4a4ed46..4cd6ae4 100644 --- a/src/globals.h +++ b/src/globals.h @@ -144,4 +144,6 @@ void set_window_focus (Window window); extern int rp_have_xinerama; extern int xine_screen_count; +extern struct numset *rp_frame_numset; + #endif diff --git a/src/screen.c b/src/screen.c index f46e3ca..5d7329d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -91,6 +91,19 @@ screen_restore_frameset (rp_screen *s, struct list_head *head) list_splice (head, &s->frames); } + +/* Given a screen, free the frames' numbers from the numset. */ +void +screen_free_nums (rp_screen *s) +{ + rp_frame *cur; + + list_for_each_entry (cur, &s->frames, node) + { + numset_release (s->frames_numset, cur->number); + } +} + /* Given a list of frames, free them, but don't remove their numbers from the numset. */ void @@ -168,6 +181,9 @@ init_screens (int screen_arg, int screen_num) num_screens = 1; } + /* Create our global frame numset */ + rp_frame_numset = numset_new(); + /* Initialize the screens */ screens = (rp_screen *)xmalloc (sizeof (rp_screen) * num_screens); PRINT_DEBUG (("%d screens.\n", num_screens)); @@ -227,8 +243,8 @@ init_screen (rp_screen *s, int screen_num) | SubstructureRedirectMask | SubstructureNotifyMask ); XSync (dpy, False); - /* Create the numset for the frames. */ - s->frames_numset = numset_new (); + /* Set the numset for the frames to our global numset. */ + s->frames_numset = rp_frame_numset; /* Build the display string for each screen */ s->display_string = xmalloc (strlen(DisplayString (dpy)) + 21); diff --git a/src/screen.h b/src/screen.h index 7d41901..d009f5d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -30,6 +30,7 @@ int screen_width (rp_screen *s); struct list_head *screen_copy_frameset (rp_screen *s); void screen_restore_frameset (rp_screen *s, struct list_head *head); +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); @@ -37,4 +38,5 @@ void init_screens (int screen_arg, int screen_num); int is_rp_window_for_screen (Window w, rp_screen *s); + #endif diff --git a/src/split.c b/src/split.c index 787c587..086c645 100644 --- a/src/split.c +++ b/src/split.c @@ -194,18 +194,24 @@ init_frame_list (rp_screen *screen) } rp_frame * -find_last_frame (rp_screen *s) +find_last_frame () { rp_frame *cur, *last = NULL; int last_access = -1; + int i; - list_for_each_entry (cur, &s->frames, node) + for (i=0; i<num_screens; i++) { - if (cur->number != s->current_frame - && cur->last_access > last_access) + rp_screen *s = &screens[i]; + + list_for_each_entry (cur, &s->frames, node) { - last_access = cur->last_access; - last = cur; + if (cur->number != current_screen()->current_frame + && cur->last_access > last_access) + { + last_access = cur->last_access; + last = cur; + } } } @@ -1013,14 +1019,20 @@ find_frame_right (rp_frame *frame) } rp_frame * -find_frame_number (rp_screen *s, int num) +find_frame_number (int num) { + int i; rp_frame *cur; - list_for_each_entry (cur, &s->frames, node) + for (i=0; i<num_screens; i++) { - if (cur->number == num) - return cur; + rp_screen *s = &screens[i]; + + list_for_each_entry (cur, &s->frames, node) + { + if (cur->number == num) + return cur; + } } return NULL; diff --git a/src/split.h b/src/split.h index ac87f4d..fee3af8 100644 --- a/src/split.h +++ b/src/split.h @@ -51,8 +51,8 @@ rp_frame *find_frame_right (rp_frame *frame); rp_frame *find_frame_left (rp_frame *frame); rp_frame *find_frame_down (rp_frame *frame); rp_frame *find_frame_up (rp_frame *frame); -rp_frame *find_last_frame (rp_screen *s); -rp_frame *find_frame_number (rp_screen *s, int num); +rp_frame *find_last_frame (); +rp_frame * find_frame_number (int num); rp_frame *current_frame (); |