summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2007-03-08 08:43:35 +0000
committersabetts <sabetts>2007-03-08 08:43:35 +0000
commit91f51337b0470f31e4dbca0b8a27345b9cfa52e8 (patch)
tree345ab3fe99dec5d93d21105776e0466758f06df9
parentc54d996f7a123eecbd4702414bd163a9f33327d0 (diff)
downloadratpoison-91f51337b0470f31e4dbca0b8a27345b9cfa52e8.zip
* src/split.c (set_active_frame): call switch_frame hook
(show_frame_indicator): only show frame indicator (set_active_frame): new arg force_indicator. all callers updated. (show_frame_indicator): new arg force. all callers updated. * src/main.c (init_defaults): init bar_in_padding * src/globals.c (rp_switch_screen_hook): new hook * src/data.h (struct rp_defaults): new slot, bar_in_padding * src/bar.c (bar_x): honour bar_in_padding setting (bar_y): likewise * src/actions.c (init_set_vars): add barinpadding (set_barinpadding): new function * src/globals.h: new global rp_switch_screen_hook
-rw-r--r--ChangeLog21
-rw-r--r--doc/ratpoison.15
-rw-r--r--doc/ratpoison.texi11
-rw-r--r--src/actions.c61
-rw-r--r--src/bar.c14
-rw-r--r--src/data.h1
-rw-r--r--src/events.c4
-rw-r--r--src/globals.c2
-rw-r--r--src/globals.h1
-rw-r--r--src/main.c1
-rw-r--r--src/split.c23
-rw-r--r--src/split.h4
-rw-r--r--src/window.c8
13 files changed, 113 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e3d092..48aeb6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-03-08 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/split.c (set_active_frame): call switch_frame hook
+ (show_frame_indicator): only show frame indicator
+ (set_active_frame): new arg force_indicator. all callers updated.
+ (show_frame_indicator): new arg force. all callers updated.
+
+ * src/main.c (init_defaults): init bar_in_padding
+
+ * src/globals.c (rp_switch_screen_hook): new hook
+
+ * src/data.h (struct rp_defaults): new slot, bar_in_padding
+
+ * src/bar.c (bar_x): honour bar_in_padding setting
+ (bar_y): likewise
+
+ * src/actions.c (init_set_vars): add barinpadding
+ (set_barinpadding): new function
+
+ * src/globals.h: new global rp_switch_screen_hook
+
2007-01-31 Bernhard R. Link <brlink@debian.org>
* src/frame.c (frame_read): fix bug to never set dedicated
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index 6497bd1..3d83fb1 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -739,6 +739,11 @@ Default is 1.
Determine the width of the input window.
.br
Default is 200.
+.var barinpadding \fB0 | \fB1
+If there is padding, determines whether the bar appears at the edge of the
+screen (\fB1\fP) or at the edge of the window area (\fB0\fP).
+.br
+Default is 0.
.var topkmap kmap
Make \fIkmap\fP the top keymap ratpoison graps directly.
The default value is \fBtop\fP.
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 75a98ac..9b8ec84 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -1362,6 +1362,17 @@ When called with no arguments, the current setting is returned.
@end deffn
+@deffn Command {set barinpadding} @var{n}
+@c @deffnx Command defbarinpadding @var{n}
+Set whether the bar window appears at the edge of the screen when there is
+padding -- that is, within the "padding" area -- or whether it appears at the
+edge of the window area. "1" represents the former, "0" the latter. See the
+@command{set padding} and @command{set bargravity} commands.
+
+When called with no arguments, the current setting is returned.
+@end deffn
+
+
@node Using Other Window Managers, Other Commands, The Status Bar, Top
@chapter Using Other Window Managers
diff --git a/src/actions.c b/src/actions.c
index 70136d8..dd325c6 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -53,6 +53,7 @@ static cmdret * set_font (struct cmdarg **args);
static cmdret * set_padding (struct cmdarg **args);
static cmdret * set_border (struct cmdarg **args);
static cmdret * set_barborder (struct cmdarg **args);
+static cmdret * set_barinpadding (struct cmdarg **args);
static cmdret * set_inputwidth (struct cmdarg **args);
static cmdret * set_waitcursor (struct cmdarg **args);
static cmdret * set_winfmt (struct cmdarg **args);
@@ -108,6 +109,7 @@ init_set_vars(void)
"", arg_NUMBER, "", arg_NUMBER, "", arg_NUMBER, "", arg_NUMBER);
add_set_var ("border", set_border, 1, "", arg_NUMBER);
add_set_var ("barborder", set_barborder, 1, "", arg_NUMBER);
+ add_set_var ("barinpadding", set_barinpadding, 1, "", arg_NUMBER);
add_set_var ("inputwidth", set_inputwidth, 1, "", arg_NUMBER);
add_set_var ("waitcursor", set_waitcursor, 1, "", arg_NUMBER);
add_set_var ("winfmt", set_winfmt, 1, "", arg_REST);
@@ -1136,7 +1138,7 @@ cmd_prev_frame (int interactive, struct cmdarg **args)
if (!frame)
return cmdret_new (RET_FAILURE, "%s", MESSAGE_NO_OTHER_FRAME);
else
- set_active_frame (frame);
+ set_active_frame (frame, 0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -1167,7 +1169,7 @@ cmd_next_frame (int interactive, struct cmdarg **args)
if (!frame)
return cmdret_new (RET_FAILURE, "%s", MESSAGE_NO_OTHER_FRAME);
else
- set_active_frame (frame);
+ set_active_frame (frame, 0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -2863,8 +2865,8 @@ cmd_remove (int interactive, struct cmdarg **args)
if (frame)
{
remove_frame (current_frame());
- set_active_frame (frame);
- show_frame_indicator();
+ set_active_frame (frame, 0);
+ show_frame_indicator(0);
}
return cmdret_new (RET_SUCCESS, NULL);
@@ -3091,7 +3093,7 @@ cmd_curframe (int interactive, struct cmdarg **args)
{
if (interactive)
{
- show_frame_indicator();
+ show_frame_indicator(1);
return cmdret_new (RET_SUCCESS, NULL);
}
else
@@ -3644,6 +3646,23 @@ set_barborder (struct cmdarg **args)
}
static cmdret *
+set_barinpadding (struct cmdarg **args)
+{
+ int new_value;
+
+ if (args[0] == NULL)
+ return cmdret_new (RET_SUCCESS, "%d", defaults.bar_border_width);
+
+ new_value = ARG(0,number);
+ if (new_value < 0)
+ return cmdret_new (RET_FAILURE, "defbarborder: invalid argument");
+
+ defaults.bar_in_padding = new_value;
+
+ return cmdret_new (RET_SUCCESS, NULL);
+}
+
+static cmdret *
set_inputwidth (struct cmdarg **args)
{
if (args[0] == NULL)
@@ -3943,9 +3962,9 @@ cmd_focusup (int interactive, struct cmdarg **args)
rp_frame *frame;
if ((frame = find_frame_up (current_frame())))
- set_active_frame (frame);
+ set_active_frame (frame, 0);
else
- show_frame_indicator();
+ show_frame_indicator(0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -3956,9 +3975,9 @@ cmd_focusdown (int interactive, struct cmdarg **args)
rp_frame *frame;
if ((frame = find_frame_down (current_frame())))
- set_active_frame (frame);
+ set_active_frame (frame, 0);
else
- show_frame_indicator();
+ show_frame_indicator(0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -3969,9 +3988,9 @@ cmd_focusleft (int interactive, struct cmdarg **args)
rp_frame *frame;
if ((frame = find_frame_left (current_frame())))
- set_active_frame (frame);
+ set_active_frame (frame, 0);
else
- show_frame_indicator();
+ show_frame_indicator(0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -3982,9 +4001,9 @@ cmd_focusright (int interactive, struct cmdarg **args)
rp_frame *frame;
if ((frame = find_frame_right (current_frame())))
- set_active_frame (frame);
+ set_active_frame (frame, 0);
else
- show_frame_indicator();
+ show_frame_indicator(0);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -4076,7 +4095,7 @@ cmd_focuslast (int interactive, struct cmdarg **args)
rp_frame *frame = find_last_frame();
if (frame)
- set_active_frame (frame);
+ set_active_frame (frame, 0);
else
return cmdret_new (RET_FAILURE, "focuslast: no other frame");
@@ -4180,7 +4199,7 @@ cmd_nextscreen (int interactive, struct cmdarg **args)
if (new_screen >= num_screens)
new_screen = 0;
- set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame));
+ set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame), 1);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -4198,7 +4217,7 @@ cmd_prevscreen (int interactive, struct cmdarg **args)
if (new_screen < 0)
new_screen = num_screens - 1;
- set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame));
+ set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame), 1);
return cmdret_new (RET_SUCCESS, NULL);
}
@@ -4213,7 +4232,7 @@ cmd_sselect(int interactive, struct cmdarg **args)
return cmdret_new (RET_FAILURE, "sselect: out of range");
if (new_screen < num_screens)
- set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame));
+ set_active_frame (screen_get_frame (&screens[new_screen], screens[new_screen].current_frame), 1);
else
return cmdret_new (RET_FAILURE, "sselect: out of range");
@@ -4282,7 +4301,7 @@ sync_wins (rp_screen *s)
{
cleanup_frame (frame);
if (frame->number == win->scr->current_frame)
- set_active_frame (frame);
+ set_active_frame (frame, 0);
}
withdraw_window (win);
}
@@ -4476,7 +4495,7 @@ cmd_tmpwm (int interactive, struct cmdarg **args)
cmdret *
cmd_fselect (int interactive, struct cmdarg **args)
{
- set_active_frame (ARG(0,frame));
+ set_active_frame (ARG(0,frame), 1);
if (interactive)
return cmdret_new (RET_SUCCESS, NULL);
else
@@ -4623,9 +4642,9 @@ frestore (char *data, rp_screen *s)
}
}
- set_active_frame (current_frame());
+ set_active_frame (current_frame(), 0);
update_bar (s);
- show_frame_indicator();
+ show_frame_indicator(0);
PRINT_DEBUG (("Done.\n"));
return cmdret_new (RET_SUCCESS, NULL);
diff --git a/src/bar.c b/src/bar.c
index 08c8d23..e87f4e5 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -111,17 +111,19 @@ bar_x (rp_screen *s, int width)
case NorthWestGravity:
case WestGravity:
case SouthWestGravity:
- x = s->left + defaults.padding_left;
+ x = s->left + (defaults.bar_in_padding ? 0 : defaults.padding_left);
break;
case NorthGravity:
case CenterGravity:
case SouthGravity:
- x = s->left + (s->width - width - defaults.bar_border_width * 2) / 2 - defaults.padding_right;
+ x = s->left + (s->width - width - defaults.bar_border_width * 2) / 2
+ - (defaults.bar_in_padding ? 0 : defaults.padding_left);
break;
case NorthEastGravity:
case EastGravity:
case SouthEastGravity:
- x = s->left + s->width - width - defaults.bar_border_width * 2 - defaults.padding_right;
+ x = s->left + s->width - width - defaults.bar_border_width * 2
+ - (defaults.bar_in_padding ? 0 : defaults.padding_right);
break;
}
@@ -138,21 +140,21 @@ bar_y (rp_screen *s, int height)
case NorthEastGravity:
case NorthGravity:
case NorthWestGravity:
- y = s->top + defaults.padding_top;
+ y = s->top + (defaults.bar_in_padding ? 0 : defaults.padding_top);
break;
case EastGravity:
case CenterGravity:
case WestGravity:
y = s->top + (s->height - height
- defaults.bar_border_width * 2) / 2
- - defaults.padding_top;
+ - (defaults.bar_in_padding ? 0 : defaults.padding_top);
break;
case SouthEastGravity:
case SouthGravity:
case SouthWestGravity:
y = s->top + (s->height - height
- defaults.bar_border_width * 2)
- - defaults.padding_top;
+ - (defaults.bar_in_padding ? 0 : defaults.padding_top);
break;
}
diff --git a/src/data.h b/src/data.h
index af274ac..090c083 100644
--- a/src/data.h
+++ b/src/data.h
@@ -211,6 +211,7 @@ struct rp_defaults
int bar_location;
int bar_timeout;
int bar_border_width;
+ int bar_in_padding;
int frame_indicator_timeout;
int frame_resize_unit;
diff --git a/src/events.c b/src/events.c
index f42d7db..bdc288f 100644
--- a/src/events.c
+++ b/src/events.c
@@ -138,7 +138,7 @@ unmap_notify (XEvent *ev)
cleanup_frame (frame);
if (frame->number == win->scr->current_frame
&& current_screen() == win->scr)
- set_active_frame (frame);
+ set_active_frame (frame, 0);
}
withdraw_window (win);
@@ -232,7 +232,7 @@ destroy_window (XDestroyWindowEvent *ev)
cleanup_frame (frame);
if (frame->number == win->scr->current_frame
&& current_screen() == win->scr)
- set_active_frame (frame);
+ set_active_frame (frame, 0);
}
withdraw_window (win);
}
diff --git a/src/globals.c b/src/globals.c
index 42fc985..844e9d4 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -223,6 +223,7 @@ LIST_HEAD (rp_key_hook);
LIST_HEAD (rp_switch_win_hook);
LIST_HEAD (rp_switch_frame_hook);
LIST_HEAD (rp_switch_group_hook);
+LIST_HEAD (rp_switch_screen_hook);
LIST_HEAD (rp_quit_hook);
LIST_HEAD (rp_restart_hook);
LIST_HEAD (rp_delete_window_hook);
@@ -232,6 +233,7 @@ struct rp_hook_db_entry rp_hook_db[]=
{"switchwin", &rp_switch_win_hook},
{"switchframe", &rp_switch_frame_hook},
{"switchgroup", &rp_switch_group_hook},
+ {"switchscreen", &rp_switch_screen_hook},
{"deletewindow", &rp_delete_window_hook},
{"quit", &rp_quit_hook},
{"restart", &rp_restart_hook},
diff --git a/src/globals.h b/src/globals.h
index d603472..f4215d3 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -150,6 +150,7 @@ extern struct list_head rp_key_hook;
extern struct list_head rp_switch_win_hook;
extern struct list_head rp_switch_frame_hook;
extern struct list_head rp_switch_group_hook;
+extern struct list_head rp_switch_screen_hook;
extern struct list_head rp_delete_window_hook;
extern struct list_head rp_quit_hook;
extern struct list_head rp_restart_hook;
diff --git a/src/main.c b/src/main.c
index fab8a11..779ae46 100644
--- a/src/main.c
+++ b/src/main.c
@@ -507,6 +507,7 @@ init_defaults (void)
defaults.bar_location = NorthEastGravity;
defaults.bar_timeout = 5;
defaults.bar_border_width = 1;
+ defaults.bar_in_padding = 0;
defaults.frame_indicator_timeout = 1;
defaults.frame_resize_unit = 10;
diff --git a/src/split.c b/src/split.c
index ce9bb35..f5012d8 100644
--- a/src/split.c
+++ b/src/split.c
@@ -362,7 +362,7 @@ split_frame (rp_frame *frame, int way, int pixels)
}
update_bar (s);
- show_frame_indicator();
+ show_frame_indicator(0);
}
/* Splits the window vertically leaving the original with 'pixels'
@@ -823,7 +823,7 @@ remove_frame (rp_frame *frame)
/* Switch the input focus to another frame, and therefore a different
window. */
void
-set_active_frame (rp_frame *frame)
+set_active_frame (rp_frame *frame, int force_indicator)
{
rp_screen *old_s = current_screen();
rp_screen *s = frames_screen (frame);
@@ -856,7 +856,7 @@ set_active_frame (rp_frame *frame)
if ((old != s->current_frame && num_frames(s) > 1)
|| s != old_s)
{
- show_frame_indicator();
+ show_frame_indicator(force_indicator);
/* run the frame switch hook. We call it in here because this is
when a frame switch ACTUALLY (for sure) happens. */
@@ -869,6 +869,10 @@ set_active_frame (rp_frame *frame)
{
set_window_focus (s->key_window);
}
+
+ /* Call the switchscreen hook, when appropriate. */
+ if (s != old_s)
+ hook_run (&rp_switch_screen_hook);
}
void
@@ -906,7 +910,7 @@ exchange_with_frame (rp_screen *s, rp_frame *cur, rp_frame *frame)
{
s->current_frame = frame->number;
/* mark it as active */
- show_frame_indicator();
+ show_frame_indicator(0);
}
update_bar (s);
@@ -957,11 +961,14 @@ hide_frame_indicator (void)
}
void
-show_frame_indicator (void)
+show_frame_indicator (int force)
{
- hide_frame_indicator ();
- show_frame_message (defaults.frame_fmt);
- alarm (defaults.frame_indicator_timeout);
+ if (num_frames (current_screen()) > 1 || force)
+ {
+ hide_frame_indicator ();
+ show_frame_message (defaults.frame_fmt);
+ alarm (defaults.frame_indicator_timeout);
+ }
}
void
diff --git a/src/split.h b/src/split.h
index 2dc4fcf..8332037 100644
--- a/src/split.h
+++ b/src/split.h
@@ -40,10 +40,10 @@ rp_frame *find_frame_prev (rp_frame *frame);
rp_window *current_window (void);
void init_frame_lists (void);
void init_frame_list (rp_screen *screen);
-void set_active_frame (rp_frame *frame);
+void set_active_frame (rp_frame *frame, int force_indicator);
void exchange_with_frame (rp_screen *s, rp_frame *cur, rp_frame *frame);
void blank_frame (rp_frame *frame);
-void show_frame_indicator (void);
+void show_frame_indicator (int force);
void hide_frame_indicator (void);
void show_frame_message (char *msg);
diff --git a/src/window.c b/src/window.c
index 737cc40..1ae5201 100644
--- a/src/window.c
+++ b/src/window.c
@@ -614,7 +614,7 @@ set_active_window_body (rp_window *win, int force)
{
if (!cur->dedicated)
{
- set_active_frame (cur);
+ set_active_frame (cur, 0);
last_frame = frame;
frame = cur;
done = 1;
@@ -633,7 +633,7 @@ set_active_window_body (rp_window *win, int force)
{
if (!cur->dedicated)
{
- set_active_frame (cur);
+ set_active_frame (cur, 0);
last_frame = frame;
frame = cur;
done = 1; /* Break outer loop. */
@@ -667,7 +667,7 @@ set_active_window_body (rp_window *win, int force)
/* If we switched frame, go back to the old one. */
if (last_frame)
- set_active_frame (last_frame);
+ set_active_frame (last_frame, 0);
/* Call the switch window hook */
hook_run (&rp_switch_win_hook);
@@ -687,7 +687,7 @@ goto_window (rp_window *win)
frame = find_windows_frame (win);
if (frame)
{
- set_active_frame (frame);
+ set_active_frame (frame, 0);
}
else
{