summaryrefslogtreecommitdiff
path: root/src/split.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-07 05:17:34 +0000
committersabetts <sabetts>2001-04-07 05:17:34 +0000
commit8b6f270c70d8fa6898e7d6c3b9533026c757f48c (patch)
treed060b6c8e452ca1d89b6b16ec1de18d0074cff7b /src/split.c
parent061f1abef270b3e79326f8f7a4cac1b3a49b7bc1 (diff)
downloadratpoison-8b6f270c70d8fa6898e7d6c3b9533026c757f48c.zip
* src/split.h (hide_frame_indicator): new prototype
(show_frame_indicator): likewise * src/split.c: include <unistd.h> (split_frame): set the new_frame's window to NULL (split_frame): calls show_frame_indicator once the split is done. (set_active_frame): only call show_frame_indicator if the frame has no window or if we switched to a different frame. (update_frame_indicator): prints FRAME_STRING in the frame indicator window. (hide_frame_indicator): new function (show_frame_indicator): likewise * src/main.c (rp_rat_bits): new variable (rp_rat_mask_bits): likewise (alrm_handler): calls hide_frame_indicator (init_rat_cursor): new function (init_screen): calls init_rat_cursor * src/events.c (unmap_notify): calls set_active_frame if the window being unmapped was in the current frame (destroy_window): calls set_active_frame if the window being destroyed was in the current frame (grab_rat): new function (grab_rat): likewise (handle_key): calls grab_rat and ungrab_rat * src/data.h (struct screen_info): new variable rat * src/conf.h (FRAME_INDICATOR_TIMEOUT): new #define (FRAME_STRING): likewise (RAT_HEIGHT): likewise (RAT_WIDTH): likewise (RAT_HOT_X): likewise (RAT_HOT_Y): likewise * src/actions.h (cmd_curframe): new prototype * src/actions.c (initialize_default_keybindings): new key binds for "curframe" (user_commands): new command "curframe" (cmd_curframe): new function * src/split.c (remove_all_splits): only maximize the current window if there is one. (maximize_frame): remove unused code to retrieve the current screen_info. * src/actions.c (cmd_h_split): calls h_split_frame on the current frame. (cmd_v_split): likewise (cmd_only): even if the current frame is empty, call remove_all_splits. * src/split.c (maximize_frame): new function (create_initial_frame): calls maximize_frame to fill in the initial frame's fields. (num_frames): comment out (remove_frame): remove special case when there is only 1 frame left. * src/split.h (h_split_frame): renamed frome h_split_window (v_split_frame): renamed frome v_split_window (split_frame): renamed frome split_window (remove_all_splits): renamed frome remove_all_frames (find_windows_frame): new prototype (find_frame_next): likewise (find_frame_prev): likewise (current_window): likewise (init_frame_list): likewise (set_active_frame): likewise * src/split.c (create_initial_frame): new function (init_frame_list): likewise (find_windows_frame): likewise (find_frame_next): likewise (find_frame_prev): likewise (current_window): likewise (update_frame_indicator): likewise (set_active_frame): likewise (split_frame): rename from split_window (v_split_frame): rename from v_split_window (h_split_frame): rename from h_split_window (remove_all_splits): renamed frome remove_all_frames (total_frame_area): traverses rp_window_frame list (num_frames): likewise (frame_overlaps): likewise (remove_frame): likewise (remove_frame): calls delete_frame_from_list * src/main.c (main): calls init_frame_list (init_screen): create and map the frame_window * src/events.c (new_window): the screen's frame_window is not managed (cleanup_frame): new function (unmap_notify): calls cleanup_frame if window exists in a frame (destroy_window): likewise * src/data.h (struct screen_info): remove frame field (struct rp_window_frame): new fields win, prev, next (rp_window_frame_sentinel): new global * src/actions.c (cmd_prev): jumps to last accessed window if current frame is empty. (cmd_next): likewise (cmd_remove): nothing is done if only 1 frame exists * src/data.h (struct screen_info): new field frame_window (rp_current_frame): new global (rp_current_window): removed. All dependant code updated.
Diffstat (limited to 'src/split.c')
-rw-r--r--src/split.c61
1 files changed, 51 insertions, 10 deletions
diff --git a/src/split.c b/src/split.c
index a257921..0533de0 100644
--- a/src/split.c
+++ b/src/split.c
@@ -21,6 +21,8 @@
* Functions for handling window splitting and tiling.
*/
+#include <unistd.h>
+
#include "ratpoison.h"
rp_window_frame *rp_window_frame_sentinel;
@@ -175,14 +177,6 @@ find_window_for_frame (rp_window_frame *frame)
return most_recent;
}
-static void
-update_frame_indicator ()
-{
- XMoveWindow (dpy, current_screen()->frame_window,
- rp_current_frame->x + rp_current_frame->width / 2 - 5,
- rp_current_frame->y + rp_current_frame->height / 2 - 5);
-}
-
/* Splits the frame in 2. if way is 0 then split vertically otherwise
split it horizontally. */
static void
@@ -202,6 +196,8 @@ split_frame (rp_window_frame *frame, int way)
rp_window_frame_sentinel->prev = new_frame;
new_frame->next = rp_window_frame_sentinel;
+ new_frame->win = NULL;
+
if (way)
{
new_frame->x = frame->x;
@@ -242,7 +238,7 @@ split_frame (rp_window_frame *frame, int way)
maximize (frame->win);
XRaiseWindow (dpy, frame->win->w);
- update_frame_indicator();
+ show_frame_indicator();
}
/* Splits the window vertically in 2. */
@@ -471,10 +467,15 @@ remove_frame (rp_window_frame *frame)
void
set_active_frame (rp_window_frame *frame)
{
+ rp_window_frame *old = rp_current_frame;
+
give_window_focus (frame->win);
rp_current_frame = frame;
- update_frame_indicator();
+ if (!frame->win || old != rp_current_frame)
+ {
+ show_frame_indicator();
+ }
if( !frame->win )
{
@@ -482,3 +483,43 @@ set_active_frame (rp_window_frame *frame)
RevertToPointerRoot, CurrentTime);
}
}
+
+static void
+update_frame_indicator ()
+{
+ screen_info *s = current_screen ();
+ int width, height;
+
+ width = BAR_X_PADDING * 2 + XTextWidth (s->font, FRAME_STRING, strlen (FRAME_STRING));
+ height = (FONT_HEIGHT (s->font) + BAR_Y_PADDING * 2);
+
+ XMoveResizeWindow (dpy, current_screen()->frame_window,
+ rp_current_frame->x + rp_current_frame->width / 2 - width / 2,
+ rp_current_frame->y + rp_current_frame->height / 2 - height / 2,
+ width, height);
+
+ XClearWindow (dpy, s->frame_window);
+ XDrawString (dpy, s->frame_window, s->normal_gc,
+ BAR_X_PADDING,
+ BAR_Y_PADDING + s->font->max_bounds.ascent,
+ FRAME_STRING, strlen (FRAME_STRING));
+}
+
+void
+hide_frame_indicator ()
+{
+ /* Only hide the frame indicator if a window occupies the frame */
+ if (rp_current_frame->win)
+ {
+ XUnmapWindow (dpy, current_screen()->frame_window);
+ }
+}
+
+void
+show_frame_indicator ()
+{
+ XMapRaised (dpy, current_screen()->frame_window);
+
+ update_frame_indicator();
+ alarm (FRAME_INDICATOR_TIMEOUT);
+}