diff options
author | sabetts <sabetts> | 2003-03-18 03:56:57 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2003-03-18 03:56:57 +0000 |
commit | 7e2c4ccc01fbaf3ea93aa3963ba6cc2e9f5ce163 (patch) | |
tree | 412bb53a1b4aeaf9b6c60a8c6c116988b4c0fd0a /src | |
parent | d9712b14bec0317663b9464108d8155152e41cad (diff) | |
download | ratpoison-7e2c4ccc01fbaf3ea93aa3963ba6cc2e9f5ce163.zip |
* src/actions.c (initialize_default_keybindings): add keybindings
for fselect and resize. Move keybinding for curframe.
* src/split.c (create_initial_frame): call frame_new to allocate a frame.
(split_frame): likewise
* src/main.c (free_screen): call frame_free to free the screen
frames.
* src/frame.h (frame_new): new prototype
(frame_free): likewise
* src/frame.c (frame_new): new function.
(frame_free): likewise
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 7 | ||||
-rw-r--r-- | src/data.h | 20 | ||||
-rw-r--r-- | src/frame.c | 18 | ||||
-rw-r--r-- | src/frame.h | 3 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/split.c | 43 |
6 files changed, 76 insertions, 17 deletions
diff --git a/src/actions.c b/src/actions.c index cfce0aa..82fac46 100644 --- a/src/actions.c +++ b/src/actions.c @@ -340,8 +340,11 @@ initialize_default_keybindings (void) add_keybinding (XK_Tab, RP_META_MASK, "focuslast"); add_keybinding (XK_Q, 0, "only"); add_keybinding (XK_R, 0, "remove"); - add_keybinding (XK_f, 0, "curframe"); - add_keybinding (XK_f, RP_CONTROL_MASK, "curframe"); + add_keybinding (XK_f, 0, "fselect"); + add_keybinding (XK_f, RP_CONTROL_MASK, "fselect"); + add_keybinding (XK_F, 0, "curframe"); + add_keybinding (XK_r, 0, "resize"); + add_keybinding (XK_r, RP_CONTROL_MASK, "resize"); add_keybinding (XK_question, 0, "help"); } @@ -106,9 +106,8 @@ struct screen_info char *display_string; - /* A list of frames that may or may not contain windows. There should - always be one in the list. */ - struct list_head rp_window_frames; + /* A tree of frame splits. */ + rp_split_tree *split_tree; /* Keep track of which numbers have been given to frames. */ struct numset *frames_numset; @@ -118,6 +117,21 @@ struct screen_info rp_window_frame *rp_current_frame; }; +rp_split_tree +{ + /* The width and height of this node. */ + int width, height; + + /* The frame occupying this split. If this is a leaf node, then + frame will not be a pointer to an actual frame, otherwise it'll + be NULL. */ + rp_window_frame *frame; + + /* A list of rp_split_tree children. By convention this list is + always has 0 or 2 elements in it. */ + struct list_head children; +} + struct rp_action { KeySym key; diff --git a/src/frame.c b/src/frame.c index 3af78f3..6faf26e 100644 --- a/src/frame.c +++ b/src/frame.c @@ -106,3 +106,21 @@ frame_move_down (rp_window_frame *frame, int amount) { frame->y += amount; } + +rp_window_frame * +frame_new (screen_info *s) +{ + rp_window_frame *f; + + f = xmalloc (sizeof (rp_window_frame)); + f->number = numset_request (s->frames_numset); + + return f; +} + +void +frame_free (screen_info *s, rp_window_frame *f) +{ + numset_release (s->frames_numset, f->number); + free (f); +} diff --git a/src/frame.h b/src/frame.h index 6194bb0..f2e1e4b 100644 --- a/src/frame.h +++ b/src/frame.h @@ -36,4 +36,7 @@ int frame_right (rp_window_frame *frame); int frame_top (rp_window_frame *frame); int frame_left (rp_window_frame *frame); +rp_window_frame *frame_new (screen_info *s); +void frame_free (screen_info *s, rp_window_frame *f); + #endif @@ -709,7 +709,7 @@ free_screen (screen_info *s) list_for_each_safe_entry (frame, iter, tmp, &s->rp_window_frames, node) { - free (frame); + frame_free (s, frame); } XDestroyWindow (dpy, s->bar_window); diff --git a/src/split.c b/src/split.c index c39c1ce..29cb1a9 100644 --- a/src/split.c +++ b/src/split.c @@ -144,11 +144,10 @@ maximize_frame (rp_window_frame *frame) static void create_initial_frame (screen_info *screen) { - screen->rp_current_frame = xmalloc (sizeof (rp_window_frame)); + screen->rp_current_frame = frame_new (screen); list_add_tail (&screen->rp_current_frame->node, &screen->rp_window_frames); - screen->rp_current_frame->number = numset_request (screen->frames_numset); update_last_access (screen->rp_current_frame); maximize_frame (screen->rp_current_frame); @@ -284,10 +283,8 @@ split_frame (rp_window_frame *frame, int way, int pixels) s = frames_screen (frame); - new_frame = xmalloc (sizeof (rp_window_frame)); - - /* Give the frame a unique number. */ - new_frame->number = numset_request (s->frames_numset); + /* Make our new frame. */ + new_frame = frame_new (s); /* It seems intuitive to make the last frame the newly created frame. */ @@ -384,9 +381,7 @@ remove_all_splits () if (frame != s->rp_current_frame) { list_del (&frame->node); - - numset_release (s->frames_numset, frame->number); - free (frame); + frame_free (s, frame); } } @@ -726,7 +721,6 @@ remove_frame (rp_window_frame *frame) area = total_frame_area(s); PRINT_DEBUG (("Total Area: %d\n", area)); - numset_release (s->frames_numset, frame->number); list_del (&frame->node); hide_window (frame->win); hide_others (frame->win); @@ -824,7 +818,7 @@ remove_frame (rp_window_frame *frame) } } - free (frame); + frame_free (s, frame); } /* Switch the input focus to another frame, and therefore a different @@ -994,3 +988,30 @@ find_frame_number (screen_info *s, int num) return NULL; } + +/* Frame split tree code. */ + +rp_frame_split * +find_frame_parent (screen_info *s, rp_window_frame *frame) +{ + return find_frame_parent_helper (s->split_tree, frame); +} + +rp_frame_split * +find_frame_parent_helper (rp_frame_split *split, rp_window_frame *frame) +{ + rp_frame_split *cur; + + if (split->frame == frame) + return split; + + /* Look for the frame in each child. If find_frame_parent_helper + returns not NULL, then we found it. */ + list_for_each_entry (cur, &split->children, node) + { + if (find_frame_parent_helper (cur, frame);) + return split; + } + + return NULL; +} |