summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-21 09:47:23 +0000
committersabetts <sabetts>2001-09-21 09:47:23 +0000
commit227c0da67ae7e8d1531d8091fa6a8c2046f61a52 (patch)
tree36f682e047fabb07a0e6b20e1ac4963d00291341
parentb953c9d532846ce07cbe1d065c9c30cf40d8903b (diff)
downloadratpoison-227c0da67ae7e8d1531d8091fa6a8c2046f61a52.zip
* src/split.h (find_frame_up): new prototype
(find_frame_down): likewise (find_frame_left): likewise (find_frame_right): likewise * src/split.c (find_frame_up): new function (find_frame_down): likewise (find_frame_left): likewise (find_frame_right): likewise * src/manage.c (move_window): use x11 gravity constants to denote gravity. * src/main.c (ratpoison_longopts): remove --kill and --restart. Dependant code updated. (init_defaults): use x11 gravity constants to denote gravity. (main): only display the startup message if defaults.startup_message is on. * src/list.c (update_window_gravity): rename from update_window_position. dependant code updated * src/events.c (client_msg): don't test for restart or kill client messages. (client_msg): properly handle iconify requests. (get_event): kill and restart the process here. * src/data.h (TOP_LEFT): remove define (TOP_CENTER): likewise (TOP_RIGHT): likewise (CENTER_LEFT): likewise (CENTER_CENTER): likewise (CENTER_RIGHT): likewise (BOTTOM_LEFT): likewise (BOTTOM_CENTER): likewise (BOTTOM_RIGHT): likewise (struct rp_window): rename field to position to gravity. (struct rp_defaults): rename win_pos to win_gravity, trans_pos to trans_gravity and maxsize_pos to maxsize_gravity. (rp_restart): remove global variable (rp_kill): likewise * src/communications.h (send_kill): remove prototype (send_restart): likewise * src/communications.c (send_restart): remove function. obsolete. (send_kill): likewise * src/bar.c (bar_x): Use X11 gravity constants to denote location. (bar_y): likewise * src/actions.h (cmd_focusup): new prototype (cmd_focusdown): likewise (cmd_focusleft): likewise (cmd_focusright): likewise (cmd_startup_message): likewise (cmd_restart): likewise * src/actions.c (cmd_quit): just set the kill_signalled variable. (parse_wingravity): use compass directions to describe the gravity (parse_wingravity): renamed from parse_winpos. dependant code updated. (cmd_gravity): renamed from cmd_pos. dependant code updated. (cmd_defwingravity): renamed from cmd_defwinpos. dependant code updated. (cmd_deftransgravity): renamed from cmd_deftranspos. dependant code updated. (cmd_defmaxsizegravity): renamed from cmd_defmaxsizepos. dependant code updated. (cmd_focusup): new function (cmd_focusdown): likewise (cmd_focusleft): likewise (cmd_focusright): likewise (cmd_restart): likewise (cmd_startup_message): likewise (user_commands): new commands "focusup" "focusdown" "focusright" "focusleft" "startup_message" "restart".
-rw-r--r--ChangeLog80
-rw-r--r--NEWS6
-rw-r--r--src/actions.c258
-rw-r--r--src/actions.h14
-rw-r--r--src/bar.c8
-rw-r--r--src/communications.c40
-rw-r--r--src/communications.h2
-rw-r--r--src/data.h30
-rw-r--r--src/events.c36
-rw-r--r--src/list.c23
-rw-r--r--src/list.h2
-rw-r--r--src/main.c42
-rw-r--r--src/manage.c42
-rw-r--r--src/split.c76
-rw-r--r--src/split.h5
15 files changed, 393 insertions, 271 deletions
diff --git a/ChangeLog b/ChangeLog
index 2040123..6e6f8bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2001-09-21 shawn <sabetts@vcn.bc.ca>
+
+ * src/split.h (find_frame_up): new prototype
+ (find_frame_down): likewise
+ (find_frame_left): likewise
+ (find_frame_right): likewise
+
+ * src/split.c (find_frame_up): new function
+ (find_frame_down): likewise
+ (find_frame_left): likewise
+ (find_frame_right): likewise
+
+ * src/manage.c (move_window): use x11 gravity constants to denote
+ gravity.
+
+ * src/main.c (ratpoison_longopts): remove --kill and
+ --restart. Dependant code updated.
+ (init_defaults): use x11 gravity constants to denote gravity.
+ (main): only display the startup message if
+ defaults.startup_message is on.
+
+ * src/list.c (update_window_gravity): rename from
+ update_window_position. dependant code updated
+
+ * src/events.c (client_msg): don't test for restart or kill client
+ messages.
+ (client_msg): properly handle iconify requests.
+ (get_event): kill and restart the process here.
+
+ * src/data.h (TOP_LEFT): remove define
+ (TOP_CENTER): likewise
+ (TOP_RIGHT): likewise
+ (CENTER_LEFT): likewise
+ (CENTER_CENTER): likewise
+ (CENTER_RIGHT): likewise
+ (BOTTOM_LEFT): likewise
+ (BOTTOM_CENTER): likewise
+ (BOTTOM_RIGHT): likewise
+ (struct rp_window): rename field to position to gravity.
+ (struct rp_defaults): rename win_pos to win_gravity, trans_pos to
+ trans_gravity and maxsize_pos to maxsize_gravity.
+ (rp_restart): remove global variable
+ (rp_kill): likewise
+
+ * src/communications.h (send_kill): remove prototype
+ (send_restart): likewise
+
+ * src/communications.c (send_restart): remove function. obsolete.
+ (send_kill): likewise
+
+ * src/bar.c (bar_x): Use X11 gravity constants to denote location.
+ (bar_y): likewise
+
+ * src/actions.h (cmd_focusup): new prototype
+ (cmd_focusdown): likewise
+ (cmd_focusleft): likewise
+ (cmd_focusright): likewise
+ (cmd_startup_message): likewise
+ (cmd_restart): likewise
+
+ * src/actions.c (cmd_quit): just set the kill_signalled variable.
+ (parse_wingravity): use compass directions to describe the gravity
+ (parse_wingravity): renamed from parse_winpos. dependant code
+ updated.
+ (cmd_gravity): renamed from cmd_pos. dependant code updated.
+ (cmd_defwingravity): renamed from cmd_defwinpos. dependant code
+ updated.
+ (cmd_deftransgravity): renamed from cmd_deftranspos. dependant
+ code updated.
+ (cmd_defmaxsizegravity): renamed from cmd_defmaxsizepos. dependant
+ code updated.
+ (cmd_focusup): new function
+ (cmd_focusdown): likewise
+ (cmd_focusleft): likewise
+ (cmd_focusright): likewise
+ (cmd_restart): likewise
+ (cmd_startup_message): likewise
+ (user_commands): new commands "focusup" "focusdown" "focusright"
+ "focusleft" "startup_message" "restart".
+
2001-09-18 shawn <sabetts@vcn.bc.ca>
* src/list.c (window_name): make sure the default window name is
diff --git a/NEWS b/NEWS
index b2863c3..d7f18c1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
* Changes since 1.0.0
+** Remove command line options --kill and --restart
+Use -c quit and -c restart instead.
+
+** New command restart
+Restart ratpoison.
+
** New command lastmsg
Display the last message.
diff --git a/src/actions.c b/src/actions.c
index ed91c8d..e08e493 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -42,6 +42,10 @@ static user_command user_commands[] =
{"escape", cmd_escape, arg_STRING},
{"exec", cmd_exec, arg_STRING},
{"focus", cmd_next_frame, arg_VOID},
+ {"focusup", cmd_focusup, arg_VOID},
+ {"focusdown", cmd_focusdown, arg_VOID},
+ {"focusleft", cmd_focusleft, arg_VOID},
+ {"focusright", cmd_focusright, arg_VOID},
{"meta", cmd_meta, arg_STRING},
{"help", cmd_help, arg_VOID},
{"hsplit", cmd_h_split, arg_VOID},
@@ -52,7 +56,7 @@ static user_command user_commands[] =
{"number", cmd_number, arg_STRING},
{"only", cmd_only, arg_VOID},
{"other", cmd_other, arg_VOID},
- {"pos", cmd_pos, arg_STRING},
+ {"gravity", cmd_gravity, arg_STRING},
{"prev", cmd_prev, arg_VOID},
{"quit", cmd_quit, arg_VOID},
{"remove", cmd_remove, arg_VOID},
@@ -70,22 +74,24 @@ static user_command user_commands[] =
{"unsetenv", cmd_unsetenv, arg_STRING},
{"info", cmd_info, arg_VOID},
{"lastmsg", cmd_lastmsg, arg_VOID},
+ {"restart", cmd_restart, arg_VOID},
+ {"startup_message", cmd_startup_message, arg_STRING},
/* Commands to set default behavior. */
- {"defbarloc", cmd_defbarloc, arg_STRING},
- {"msgwait", cmd_msgwait, arg_STRING},
- {"defborder", cmd_defborder, arg_STRING},
- {"deffont", cmd_deffont, arg_STRING},
- {"definputwidth", cmd_definputwidth, arg_STRING},
- {"defmaxsizepos", cmd_defmaxsizepos, arg_STRING},
- {"defpadding", cmd_defpadding, arg_STRING},
- {"deftranspos", cmd_deftranspos, arg_STRING},
- {"defwaitcursor", cmd_defwaitcursor, arg_STRING},
- {"defwinfmt", cmd_defwinfmt, arg_STRING},
- {"defwinname", cmd_defwinname, arg_STRING},
- {"defwinpos", cmd_defwinpos, arg_STRING},
- {"deffgcolor", cmd_deffgcolor, arg_STRING},
- {"defbgcolor", cmd_defbgcolor, arg_STRING},
+ {"defbarloc", cmd_defbarloc, arg_STRING},
+ {"msgwait", cmd_msgwait, arg_STRING},
+ {"defborder", cmd_defborder, arg_STRING},
+ {"deffont", cmd_deffont, arg_STRING},
+ {"definputwidth", cmd_definputwidth, arg_STRING},
+ {"defmaxsizegravity", cmd_defmaxsizegravity, arg_STRING},
+ {"defpadding", cmd_defpadding, arg_STRING},
+ {"deftransgravity", cmd_deftransgravity, arg_STRING},
+ {"defwaitcursor", cmd_defwaitcursor, arg_STRING},
+ {"defwinfmt", cmd_defwinfmt, arg_STRING},
+ {"defwinname", cmd_defwinname, arg_STRING},
+ {"defwingravity", cmd_defwingravity, arg_STRING},
+ {"deffgcolor", cmd_deffgcolor, arg_STRING},
+ {"defbgcolor", cmd_defbgcolor, arg_STRING},
/* Commands to help debug ratpoison. */
#ifdef DEBUG
@@ -917,16 +923,10 @@ cmd_newwm(int interactive, void *data)
return NULL;
}
-/* Quit ratpoison. Thanks to
-"Chr. v. Stuckrad" <stucki@math.fu-berlin.de> for the patch. */
char *
cmd_quit(int interactive, void *data)
{
- PRINT_DEBUG ("Exiting\n");
- clean_up ();
- exit (EXIT_SUCCESS);
-
- /* Never gets here. */
+ kill_signalled = 1;
return NULL;
}
@@ -1309,85 +1309,41 @@ cmd_rudeness (int interactive, void *data)
}
static int
-parse_winpos (char *data)
-{
- int ret = 0;
- char *x, *y;
-
- x = xmalloc (strlen (data) + 1);
- y = xmalloc (strlen (data) + 1);
-
- if (sscanf (data, "%s %s", x , y) < 2)
- {
- message (" pos: Two arguments needed ");
- free (x);
- free (y);
- return -3;
- }
-
- PRINT_DEBUG ("%s %s\n", x, y);
-
- switch (y[0])
- {
- case 't':
- case 'T':
- ret = TOP_LEFT;
- break;
-
- case 'c':
- case 'C':
- ret = CENTER_LEFT;
- break;
-
- case 'b':
- case 'B':
- ret = BOTTOM_LEFT;
- break;
-
- default:
- ret = -1;
- goto done;
- break;
- }
-
- switch (x[0])
- {
- case 'l':
- case 'L':
- break;
-
- case 'c':
- case 'C':
- ret += TOP_CENTER;
- break;
-
- case 'r':
- case 'R':
- ret += TOP_RIGHT;
- break;
-
- default:
- ret = -2;
- goto done;
- break;
- }
-
- done:
- free (x);
- free (y);
+parse_wingravity (char *data)
+{
+ int ret = -1;
+
+ if (!strcasecmp (data, "northwest") || !strcasecmp (data, "nw"))
+ ret = NorthWestGravity;
+ if (!strcasecmp (data, "north") || !strcasecmp (data, "n"))
+ ret = NorthGravity;
+ if (!strcasecmp (data, "northeast") || !strcasecmp (data, "ne"))
+ ret = NorthEastGravity;
+ if (!strcasecmp (data, "west") || !strcasecmp (data, "w"))
+ ret = WestGravity;
+ if (!strcasecmp (data, "center") || !strcasecmp (data, "c"))
+ ret = CenterGravity;
+ if (!strcasecmp (data, "East") || !strcasecmp (data, "e"))
+ ret = EastGravity;
+ if (!strcasecmp (data, "southwest") || !strcasecmp (data, "sw"))
+ ret = SouthWestGravity;
+ if (!strcasecmp (data, "South") || !strcasecmp (data, "s"))
+ ret = SouthGravity;
+ if (!strcasecmp (data, "southeast") || !strcasecmp (data, "se"))
+ ret = SouthEastGravity;
return ret;
}
char *
-cmd_pos (int interactive, void *data)
+cmd_gravity (int interactive, void *data)
{
- int pos;
+ int gravity;
rp_window *win;
if (data == NULL)
{
- message (" pos: Two arguments needed ");
+ message (" gravity: Two arguments needed ");
return NULL;
}
@@ -1395,13 +1351,13 @@ cmd_pos (int interactive, void *data)
win = current_window();
- if ((pos = parse_winpos (data)) < 0)
+ if ((gravity = parse_wingravity (data)) < 0)
{
- message (" pos: Unknown position ");
+ message (" gravity: Unknown gravity ");
}
else
{
- win->position = pos;
+ win->gravity = gravity;
maximize (win);
}
@@ -1409,69 +1365,69 @@ cmd_pos (int interactive, void *data)
}
char *
-cmd_defwinpos (int interactive, void *data)
+cmd_defwingravity (int interactive, void *data)
{
- int pos;
+ int gravity;
if (data == NULL)
{
- message (" defwinpos: Two arguments needed ");
+ message (" defwingravity: Two arguments needed ");
return NULL;
}
- if ((pos = parse_winpos (data)) < 0)
+ if ((gravity = parse_wingravity (data)) < 0)
{
- message (" defwinpos: Unknown position ");
+ message (" defwingravity: Unknown gravity ");
}
else
{
- defaults.win_pos = pos;
+ defaults.win_gravity = gravity;
}
return NULL;
}
char *
-cmd_deftranspos (int interactive, void *data)
+cmd_deftransgravity (int interactive, void *data)
{
- int pos;
+ int gravity;
if (data == NULL)
{
- message (" deftranspos: Two arguments needed ");
+ message (" deftransgravity: Two arguments needed ");
return NULL;
}
- if ((pos = parse_winpos (data)) < 0)
+ if ((gravity = parse_wingravity (data)) < 0)
{
- message (" pos: Unknown position ");
+ message (" gravity: Unknown gravity ");
}
else
{
- defaults.trans_pos = pos;
+ defaults.trans_gravity = gravity;
}
return NULL;
}
char *
-cmd_defmaxsizepos (int interactive, void *data)
+cmd_defmaxsizegravity (int interactive, void *data)
{
- int pos;
+ int gravity;
if (data == NULL)
{
- message (" defmaxsizepos: Two arguments needed ");
+ message (" defmaxsizegravity: Two arguments needed ");
return NULL;
}
- if ((pos = parse_winpos (data)) < 0)
+ if ((gravity = parse_wingravity (data)) < 0)
{
- message (" defmaxsizepos: Unknown position ");
+ message (" defmaxsizegravity: Unknown gravity ");
}
else
{
- defaults.maxsize_pos = pos;
+ defaults.maxsize_gravity = gravity;
}
return NULL;
@@ -1512,16 +1468,16 @@ cmd_defbarloc (int interactive, void *data)
switch (loc)
{
case 0:
- defaults.bar_location = TOP_LEFT;
+ defaults.bar_location = NorthWestGravity;
break;
case 1:
- defaults.bar_location = TOP_RIGHT;
+ defaults.bar_location = NorthEastGravity;
break;
case 2:
- defaults.bar_location = BOTTOM_RIGHT;
+ defaults.bar_location = SouthEastGravity;
break;
case 3:
- defaults.bar_location = BOTTOM_LEFT;
+ defaults.bar_location = SouthWestGravity;
break;
default:
@@ -1897,3 +1853,73 @@ cmd_lastmsg (int interactive, void *data)
show_last_message();
return NULL;
}
+
+char *
+cmd_focusup (int interactive, void *data)
+{
+ rp_window_frame *frame;
+
+ if ((frame = find_frame_up (rp_current_frame)))
+ set_active_frame (frame);
+
+ return NULL;
+}
+
+char *
+cmd_focusdown (int interactive, void *data)
+{
+ rp_window_frame *frame;
+
+ if ((frame = find_frame_down (rp_current_frame)))
+ set_active_frame (frame);
+
+ return NULL;
+}
+
+char *
+cmd_focusleft (int interactive, void *data)
+{
+ rp_window_frame *frame;
+
+ if ((frame = find_frame_left (rp_current_frame)))
+ set_active_frame (frame);
+
+ return NULL;
+}
+
+char *
+cmd_focusright (int interactive, void *data)
+{
+ rp_window_frame *frame;
+
+ if ((frame = find_frame_right (rp_current_frame)))
+ set_active_frame (frame);
+
+ return NULL;
+}
+
+char *
+cmd_restart (int interactive, void *data)
+{
+ hup_signalled = 1;
+ return NULL;
+}
+
+char *
+cmd_startup_message (int interactive, void *data)
+{
+ if (data == NULL)
+ {
+ message (" startup_message; One argument is required ");
+ return NULL;
+ }
+
+ if (!strcasecmp (data, "on"))
+ defaults.startup_message = 1;
+ else if (!strcasecmp (data, "off"))
+ defaults.startup_message = 0;
+ else
+ message (" startup_message; Invalid argument ");
+
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index d64cf87..cdbd410 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -75,10 +75,10 @@ char * cmd_quit(int interactive, void *data);
char * cmd_number (int interactive, void *data);
char * cmd_rudeness (int interactive, void *data);
char * cmd_unbind (int interactive, void *data);
-char * cmd_pos (int interactive, void *data);
-char * cmd_defwinpos (int interactive, void *data);
-char * cmd_deftranspos (int interactive, void *data);
-char * cmd_defmaxsizepos (int interactive, void *data);
+char * cmd_gravity (int interactive, void *data);
+char * cmd_defwingravity (int interactive, void *data);
+char * cmd_deftransgravity (int interactive, void *data);
+char * cmd_defmaxsizegravity (int interactive, void *data);
char * cmd_msgwait (int interactive, void *data);
char * cmd_defbarloc (int interactive, void *data);
char * cmd_deffont (int interactive, void *data);
@@ -95,6 +95,12 @@ char * cmd_chdir (int interactive, void *data);
char * cmd_unsetenv (int interactive, void *data);
char * cmd_info (int interactive, void *data);
char * cmd_lastmsg (int interactive, void *data);
+char * cmd_focusup (int interactive, void *data);
+char * cmd_focusdown (int interactive, void *data);
+char * cmd_focusleft (int interactive, void *data);
+char * cmd_focusright (int interactive, void *data);
+char * cmd_restart (int interactive, void *data);
+char * cmd_startup_message (int interactive, void *data);
/* void cmd_xterm (void *data); */
diff --git a/src/bar.c b/src/bar.c
index c359919..3189d5b 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -83,8 +83,8 @@ show_bar (screen_info *s)
int
bar_x (screen_info *s, int width)
{
- if (defaults.bar_location == BOTTOM_RIGHT
- || defaults.bar_location == TOP_RIGHT)
+ if (defaults.bar_location == SouthEastGravity
+ || defaults.bar_location == NorthEastGravity)
return s->root_attr.width - width - 2;
else
return 0;
@@ -93,8 +93,8 @@ bar_x (screen_info *s, int width)
int
bar_y (screen_info *s)
{
- if (defaults.bar_location == TOP_LEFT
- || defaults.bar_location == TOP_RIGHT )
+ if (defaults.bar_location == NorthWestGravity
+ || defaults.bar_location == NorthEastGravity )
return 0;
else
return s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2) - 2;
diff --git a/src/communications.c b/src/communications.c
index a4f97a0..ee01205 100644
--- a/src/communications.c
+++ b/src/communications.c
@@ -27,48 +27,8 @@
#include "ratpoison.h"
-void
-send_restart ()
-{
- XEvent ev;
- int status;
-
- ev.xclient.type = ClientMessage;
- ev.xclient.window = DefaultRootWindow (dpy);
- ev.xclient.message_type = rp_restart;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = rp_restart;
- ev.xclient.data.l[1] = CurrentTime;
-
- status = XSendEvent (dpy, DefaultRootWindow (dpy), False, SubstructureRedirectMask, &ev);
- if (status == 0)
- {
- PRINT_ERROR ("failed to send restart event\n");
- }
-}
-
-void
-send_kill ()
-{
- XEvent ev;
- int status;
-
- ev.xclient.type = ClientMessage;
- ev.xclient.window = DefaultRootWindow (dpy);
- ev.xclient.message_type = rp_kill;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = rp_kill;
- ev.xclient.data.l[1] = CurrentTime;
-
- status = XSendEvent (dpy, DefaultRootWindow (dpy), False, SubstructureRedirectMask, &ev);
- if (status == 0)
- {
- PRINT_ERROR ("failed to send kill event\n");
- }
-}
/* Sending commands to ratpoison */
-
static void
recieve_command_result (Window w)
{
diff --git a/src/communications.h b/src/communications.h
index ade37ac..0fd7937 100644
--- a/src/communications.h
+++ b/src/communications.h
@@ -22,8 +22,6 @@
#ifndef _RATPOISON_COMMUNICATIONS_H
#define _RATPOISON_COMMUNICATIONS_H 1
-void send_kill ();
-void send_restart ();
int send_command (unsigned char *cmd);
#endif /* ! _RATPOISON_COMMUNICATIONS_H */
diff --git a/src/data.h b/src/data.h
index b29047f..a1f799c 100644
--- a/src/data.h
+++ b/src/data.h
@@ -43,20 +43,6 @@ struct rp_window_frame
rp_window_frame *prev, *next;
};
-
-/* Possible positions for a window. */
-#define TOP_LEFT 0
-#define TOP_CENTER 1
-#define TOP_RIGHT 2
-
-#define CENTER_LEFT 3
-#define CENTER_CENTER 4
-#define CENTER_RIGHT 5
-
-#define BOTTOM_LEFT 6
-#define BOTTOM_CENTER 7
-#define BOTTOM_RIGHT 8
-
struct rp_window
{
screen_info *scr;
@@ -88,9 +74,9 @@ struct rp_window
/* Saved mouse position */
int mouse_x, mouse_y;
- /* The alignment of the window. To what side or corner should the
- window stick to. */
- int position;
+ /* The alignment of the window. Decides to what side or corner the
+ window sticks to. */
+ int gravity;
/* A window can be visible inside a frame but not the frame's
current window. This keeps track of what frame the window was
@@ -130,9 +116,9 @@ struct rp_defaults
{
/* Default positions for new normal windows, transient windows, and
normal windows with maxsize hints. */
- int win_pos;
- int trans_pos;
- int maxsize_pos;
+ int win_gravity;
+ int trans_gravity;
+ int maxsize_gravity;
int input_window_size;
int window_border_width;
@@ -157,6 +143,8 @@ struct rp_defaults
/* Which name to use: wm_name, res_name, res_class. */
int win_name;
+
+ int startup_message;
};
extern struct rp_defaults defaults;
@@ -195,8 +183,6 @@ extern int num_screens;
extern XEvent rp_current_event;
extern Display *dpy;
-extern Atom rp_restart;
-extern Atom rp_kill;
extern Atom rp_command;
extern Atom rp_command_request;
extern Atom rp_command_result;
diff --git a/src/events.c b/src/events.c
index bcf1631..dfd4f0b 100644
--- a/src/events.c
+++ b/src/events.c
@@ -336,29 +336,29 @@ client_msg (XClientMessageEvent *ev)
{
PRINT_DEBUG ("Received client message.\n");
- if (ev->message_type == rp_restart)
- {
- PRINT_DEBUG ("Restarting\n");
- clean_up ();
- execvp(myargv[0], myargv);
- }
- else if (ev->message_type == rp_kill)
- {
- PRINT_DEBUG ("Exiting\n");
- clean_up ();
- exit (EXIT_SUCCESS);
- }
- else if (ev->message_type == wm_change_state)
+ if (ev->message_type == wm_change_state)
{
rp_window *win;
+ PRINT_DEBUG ("WM_CHANGE_STATE\n")
+
win = find_window (ev->window);
if (win == NULL) return;
if (ev->format == 32 && ev->data.l[0] == IconicState)
{
+ /* FIXME: This means clients can hide themselves without the
+ user's intervention. This is bad, but Emacs is the only
+ program I know of that iconifies itself and this is
+ generally from the user pressing C-z. */
+ PRINT_DEBUG ("Iconify Request.\n");
if (win->state == NormalState)
{
- /* TODO: Handle iconify events */
+ rp_window *w = find_window_other();
+
+ if (w)
+ set_active_window (w);
+ else
+ blank_frame (rp_current_frame);
}
}
else
@@ -811,15 +811,15 @@ get_event (XEvent *ev)
if (hup_signalled > 0)
{
- PRINT_DEBUG ("Restarting with a fresh plate.\n");
- send_restart ();
+ clean_up ();
+ execvp(myargv[0], myargv);
}
if (kill_signalled > 0)
{
- fprintf (stderr, "ratpoison: Agg! I've been SHOT!\n");
+ PRINT_DEBUG ("Exiting\n");
clean_up ();
- exit (EXIT_FAILURE);
+ exit (EXIT_SUCCESS);
}
/* Is there anything in the event qeue? */
diff --git a/src/list.c b/src/list.c
index dbd5ea6..24ffd98 100644
--- a/src/list.c
+++ b/src/list.c
@@ -56,14 +56,21 @@ free_window (rp_window *w)
}
void
-update_window_position (rp_window *win)
+update_window_gravity (rp_window *win)
{
- if (win->transient)
- win->position = defaults.trans_pos;
- else if (win->hints->flags & PMaxSize)
- win->position = defaults.maxsize_pos;
- else
- win->position = defaults.win_pos;
+/* if (win->hints->win_gravity == ForgetGravity) */
+/* { */
+ if (win->transient)
+ win->gravity = defaults.trans_gravity;
+ else if (win->hints->flags & PMaxSize)
+ win->gravity = defaults.maxsize_gravity;
+ else
+ win->gravity = defaults.win_gravity;
+/* } */
+/* else */
+/* { */
+/* win->gravity = win->hints->win_gravity; */
+/* } */
}
char *
@@ -118,7 +125,7 @@ add_to_window_list (screen_info *s, Window w)
new_window->transient = XGetTransientForHint (dpy, new_window->w, &new_window->transient_for);
PRINT_DEBUG ("transient %d\n", new_window->transient);
- update_window_position (new_window);
+ update_window_gravity (new_window);
get_mouse_root_position (new_window, &new_window->mouse_x, &new_window->mouse_y);
diff --git a/src/list.h b/src/list.h
index b8991e8..44515c8 100644
--- a/src/list.h
+++ b/src/list.h
@@ -37,7 +37,7 @@ void give_window_focus (rp_window *win, rp_window *last_win);
void set_active_window (rp_window *win);
void goto_window (rp_window *win);
void set_current_window (rp_window *win);
-void update_window_position (rp_window *win);
+void update_window_gravity (rp_window *win);
char *window_name (rp_window *win);
#if 0
diff --git a/src/main.c b/src/main.c
index 72b1a02..9f43832 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,8 +52,6 @@ Atom wm_delete;
Atom wm_take_focus;
Atom wm_colormaps;
-Atom rp_restart;
-Atom rp_kill;
Atom rp_command;
Atom rp_command_request;
Atom rp_command_result;
@@ -82,8 +80,6 @@ int rp_honour_normal_map = 1;
static struct option ratpoison_longopts[] =
{ {"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
- {"restart", no_argument, 0, 'r'},
- {"kill", no_argument, 0, 'k'},
{"command", required_argument, 0, 'c'},
{0, 0, 0, 0} };
@@ -211,8 +207,6 @@ print_help ()
printf ("Help for %s %s\n\n", PACKAGE, VERSION);
printf ("-h, --help Display this help screen\n");
printf ("-v, --version Display the version\n");
- printf ("-r, --restart Restart ratpoison\n");
- printf ("-k, --kill Kill ratpoison\n");
printf ("-c, --command Send ratpoison a colon-command\n\n");
printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n");
@@ -356,15 +350,15 @@ show_welcome_message ()
static void
init_defaults ()
{
- defaults.win_pos = TOP_LEFT;
- defaults.trans_pos = CENTER_CENTER;
- defaults.maxsize_pos = CENTER_CENTER;
+ defaults.win_gravity = NorthWestGravity;
+ defaults.trans_gravity = CenterGravity;
+ defaults.maxsize_gravity = CenterGravity;
defaults.input_window_size = 200;
defaults.window_border_width = 1;
defaults.bar_x_padding = 0;
defaults.bar_y_padding = 0;
- defaults.bar_location = TOP_RIGHT;
+ defaults.bar_location = NorthEastGravity;
defaults.bar_timeout = 5;
defaults.frame_indicator_timeout = 1;
@@ -386,6 +380,7 @@ init_defaults ()
defaults.window_fmt = xstrdup ("%n%s%t");
defaults.win_name = 0;
+ defaults.startup_message = 1;
}
int
@@ -393,8 +388,6 @@ main (int argc, char *argv[])
{
int i;
int c;
- int do_kill = 0;
- int do_restart = 0;
char **command = NULL;
int cmd_count = 0;
@@ -416,12 +409,6 @@ main (int argc, char *argv[])
case 'v':
print_version ();
break;
- case 'k':
- do_kill = 1;
- break;
- case 'r':
- do_restart = 1;
- break;
case 'c':
if (!command)
{
@@ -448,26 +435,10 @@ main (int argc, char *argv[])
}
/* Set ratpoison specific Atoms. */
- rp_restart = XInternAtom (dpy, "RP_RESTART", False);
- rp_kill = XInternAtom (dpy, "RP_KILL", False);
rp_command = XInternAtom (dpy, "RP_COMMAND", False);
rp_command_request = XInternAtom (dpy, "RP_COMMAND_REQUEST", False);
rp_command_result = XInternAtom (dpy, "RP_COMMAND_RESULT", False);
- if (do_kill)
- {
- send_kill ();
- XSync (dpy, False);
- XCloseDisplay (dpy);
- return EXIT_SUCCESS;
- }
- if (do_restart)
- {
- send_restart ();
- XSync (dpy, False);
- XCloseDisplay (dpy);
- return EXIT_SUCCESS;
- }
if (cmd_count > 0)
{
int i;
@@ -520,7 +491,8 @@ main (int argc, char *argv[])
read_startup_files ();
/* Indicate to the user that ratpoison has booted. */
- show_welcome_message();
+ if (defaults.startup_message)
+ show_welcome_message();
/* If no window has focus, give the key_window focus. */
if (current_window() == NULL)
diff --git a/src/manage.c b/src/manage.c
index 60f7971..c389e22 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -263,7 +263,7 @@ update_window_information (rp_window *win)
/* Transient status */
win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for);
- update_window_position (win);
+ update_window_gravity (win);
}
void
@@ -370,41 +370,41 @@ move_window (rp_window *win)
return;
/* X coord. */
- switch (win->position)
+ switch (win->gravity)
{
- case TOP_LEFT:
- case CENTER_LEFT:
- case BOTTOM_LEFT:
+ case NorthWestGravity:
+ case WestGravity:
+ case SouthWestGravity:
win->x = win->frame->x;
break;
- case TOP_CENTER:
- case BOTTOM_CENTER:
- case CENTER_CENTER:
+ case NorthGravity:
+ case CenterGravity:
+ case SouthGravity:
win->x = win->frame->x + (win->frame->width - win->border * 2) / 2 - win->width / 2;
break;
- case TOP_RIGHT:
- case CENTER_RIGHT:
- case BOTTOM_RIGHT:
+ case NorthEastGravity:
+ case EastGravity:
+ case SouthEastGravity:
win->x = win->frame->x + win->frame->width - win->width - win->border;
break;
}
/* Y coord. */
- switch (win->position)
+ switch (win->gravity)
{
- case TOP_LEFT:
- case TOP_CENTER:
- case TOP_RIGHT:
+ case NorthEastGravity:
+ case NorthGravity:
+ case NorthWestGravity:
win->y = win->frame->y;
break;
- case CENTER_LEFT:
- case CENTER_CENTER:
- case CENTER_RIGHT:
+ case EastGravity:
+ case CenterGravity:
+ case WestGravity:
win->y = win->frame->y + (win->frame->height - win->border * 2) / 2 - win->height / 2;
break;
- case BOTTOM_LEFT:
- case BOTTOM_CENTER:
- case BOTTOM_RIGHT:
+ case SouthEastGravity:
+ case SouthGravity:
+ case SouthWestGravity:
win->y = win->frame->y + win->frame->height - win->height - win->border;
break;
}
diff --git a/src/split.c b/src/split.c
index 9fdeb66..e92f19d 100644
--- a/src/split.c
+++ b/src/split.c
@@ -583,3 +583,79 @@ show_frame_indicator ()
alarm (defaults.frame_indicator_timeout);
}
+
+rp_window_frame *
+find_frame_up (rp_window_frame *frame)
+{
+ rp_window_frame *cur;
+
+ for (cur = rp_window_frame_sentinel->next;
+ cur != rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (frame->y == cur->y + cur->height)
+ {
+ if (frame->x >= cur->x && frame->x < cur->x + cur->width)
+ return cur;
+ }
+ }
+
+ return NULL;
+}
+
+rp_window_frame *
+find_frame_down (rp_window_frame *frame)
+{
+ rp_window_frame *cur;
+
+ for (cur = rp_window_frame_sentinel->next;
+ cur != rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (frame->y + frame->height == cur->y)
+ {
+ if (frame->x >= cur->x && frame->x < cur->x + cur->width)
+ return cur;
+ }
+ }
+
+ return NULL;
+}
+
+rp_window_frame *
+find_frame_left (rp_window_frame *frame)
+{
+ rp_window_frame *cur;
+
+ for (cur = rp_window_frame_sentinel->next;
+ cur != rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (frame->x == cur->x + cur->width)
+ {
+ if (frame->y >= cur->y && frame->y < cur->y + cur->height)
+ return cur;
+ }
+ }
+
+ return NULL;
+}
+
+rp_window_frame *
+find_frame_right (rp_window_frame *frame)
+{
+ rp_window_frame *cur;
+
+ for (cur = rp_window_frame_sentinel->next;
+ cur != rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (frame->x + frame->width == cur->x)
+ {
+ if (frame->y >= cur->y && frame->y < cur->y + cur->height)
+ return cur;
+ }
+ }
+
+ return NULL;
+}
diff --git a/src/split.h b/src/split.h
index afc8c27..a2d8978 100644
--- a/src/split.h
+++ b/src/split.h
@@ -39,4 +39,9 @@ void blank_frame (rp_window_frame *frame);
void show_frame_indicator ();
void hide_frame_indicator ();
+rp_window_frame *find_frame_right (rp_window_frame *frame);
+rp_window_frame *find_frame_left (rp_window_frame *frame);
+rp_window_frame *find_frame_down (rp_window_frame *frame);
+rp_window_frame *find_frame_up (rp_window_frame *frame);
+
#endif