summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-08-23 16:58:28 +0000
committersabetts <sabetts>2001-08-23 16:58:28 +0000
commit64bf4e18b28591e8b6a6b133b440fa9f28d8e693 (patch)
tree80245a33b3fc14f3e5e72cd58a77e64848bddb4c /src
parentb4bbd9206ca9a5f9b0fec30bb70b04d29e84a8c8 (diff)
downloadratpoison-64bf4e18b28591e8b6a6b133b440fa9f28d8e693.zip
new rudeness command
Diffstat (limited to 'src')
-rw-r--r--src/actions.c26
-rw-r--r--src/actions.h1
-rw-r--r--src/bar.c27
-rw-r--r--src/bar.h1
-rw-r--r--src/data.h6
-rw-r--r--src/events.c85
-rw-r--r--src/main.c6
-rw-r--r--src/manage.c21
8 files changed, 148 insertions, 25 deletions
diff --git a/src/actions.c b/src/actions.c
index 9ca22eb..b88ce85 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -171,6 +171,7 @@ user_command user_commands[] =
{"help", cmd_help, arg_VOID},
{"quit", cmd_quit, arg_VOID},
{"number", cmd_number, arg_STRING},
+ {"rudeness", cmd_rudeness, arg_STRING},
/* the following screen commands may or may not be able to be
implemented. See the screen documentation for what should be
@@ -1169,3 +1170,28 @@ cmd_help (int interactive, void *data)
return NULL;
}
+
+char *
+cmd_rudeness (int interactive, void *data)
+{
+ int num;
+
+ if (data == NULL)
+ {
+ message ("Rudeness level required");
+ return NULL;
+ }
+
+ if (sscanf ((char *)data, "%d", &num) < 1)
+ {
+ message ("Bad rudeness level");
+ return NULL;
+ }
+
+ rp_honour_transient_raise = num & 1;
+ rp_honour_normal_raise = num & 2;
+ rp_honour_transient_map = num & 4;
+ rp_honour_normal_map = num & 8;
+
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index f4933cc..5a32952 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -73,6 +73,7 @@ char * cmd_curframe (int interactive, void *data);
char * cmd_help (int interactive, void *data);
char * cmd_quit(int interactive, void *data);
char * cmd_number (int interactive, void *data);
+char * cmd_rudeness (int interactive, void *data);
/* void cmd_xterm (void *data); */
diff --git a/src/bar.c b/src/bar.c
index 3208cac..305ff5c 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdarg.h>
#include "ratpoison.h"
@@ -106,6 +107,32 @@ update_window_names (screen_info *s)
}
void
+marked_message_printf (int mark_start, int mark_end, char *fmt, ...)
+{
+ int size, nchars;
+ char *buffer;
+ va_list ap;
+
+ va_start (ap, fmt);
+
+ /* A resonable starting value. */
+ size = strlen (fmt) + 1;
+ buffer = (char *)xmalloc (size);
+
+ nchars = vsnprintf (buffer, size, fmt, ap);
+ if (nchars >= size)
+ {
+ buffer = (char *)xrealloc (buffer, nchars + 1);
+ vsnprintf (buffer, nchars + 1, fmt, ap);
+ }
+
+ va_end (ap);
+
+ marked_message (buffer, mark_start, mark_end);
+ free (buffer);
+}
+
+void
marked_message (char *msg, int mark_start, int mark_end)
{
XGCValues lgv;
diff --git a/src/bar.h b/src/bar.h
index e98ccd8..96733eb 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -30,5 +30,6 @@ int bar_x (screen_info *s, int width);
#define message(msg) marked_message (msg, 0, 0)
void marked_message (char *msg, int hl_start, int hl_end);
+void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
#endif /* ! _RATPOISON_BAR_H */
diff --git a/src/data.h b/src/data.h
index 832fbb3..7bad7f1 100644
--- a/src/data.h
+++ b/src/data.h
@@ -183,4 +183,10 @@ extern int alarm_signalled;
extern int kill_signalled;
extern int hup_signalled;
+/* rudeness levels */
+extern int rp_honour_transient_raise;
+extern int rp_honour_normal_raise;
+extern int rp_honour_transient_map;
+extern int rp_honour_normal_map;
+
#endif /* _RATPOISON_DATA_H */
diff --git a/src/events.c b/src/events.c
index 3ae1fd8..e887022 100644
--- a/src/events.c
+++ b/src/events.c
@@ -181,7 +181,31 @@ map_request (XEvent *ev)
break;
case IconicState:
PRINT_DEBUG ("Mapped iconic window\n");
- set_active_window (win);
+ if (win->last_access == 0)
+ {
+ /* Depending on the rudeness level, actually map the
+ window. */
+ if ((rp_honour_transient_map && win->transient)
+ || (rp_honour_normal_map && !win->transient))
+ set_active_window (win);
+ }
+ else
+ {
+ /* Depending on the rudeness level, actually map the
+ window. */
+ if ((rp_honour_transient_raise && win->transient)
+ || (rp_honour_normal_raise && !win->transient))
+ set_active_window (win);
+ else
+ {
+ if (win->transient)
+ marked_message_printf (0, 0, "Raise request from transient window %d (%s)",
+ win->number, win->name);
+ else
+ marked_message_printf (0, 0, "Raise request from window %d (%s)",
+ win->number, win->name);
+ }
+ }
break;
}
}
@@ -251,20 +275,38 @@ configure_request (XConfigureRequestEvent *e)
PRINT_DEBUG("request CWY %d\n", e->y);
}
- if (e->value_mask & CWStackMode && win->state == NormalState)
+ if (e->value_mask & CWStackMode)
{
if (e->detail == Above)
{
- goto_window (win);
- }
- else if (e->detail == Below)
- {
- set_active_window (find_window_other ());
+ /* Depending on the rudeness level, actually map the
+ window. */
+ if ((rp_honour_transient_raise && win->transient)
+ || (rp_honour_normal_raise && !win->transient))
+ {
+ if (win->state == IconicState)
+ set_active_window (win);
+ }
+ else
+ {
+ if (win->transient)
+ marked_message_printf (0, 0, "Raise request from transient window %d (%s)",
+ win->number, win->name);
+ else
+ marked_message_printf (0, 0, "Raise request from window %d (%s)",
+ win->number, win->name);
+ }
+
+ if (find_windows_frame (win))
+ goto_window (win);
}
PRINT_DEBUG("request CWStackMode %d\n", e->detail);
}
+ PRINT_DEBUG ("'%s' window size: %d %d %d %d %d\n", win->name,
+ win->x, win->y, win->width, win->height, win->border);
+
if (e->value_mask & CWBorderWidth)
{
changes.border_width = e->border_width;
@@ -284,21 +326,22 @@ configure_request (XConfigureRequestEvent *e)
PRINT_DEBUG("request CWHeight %d\n", e->height);
}
- PRINT_DEBUG ("'%s' new window size: %d %d %d %d %d\n", win->name,
- win->x, win->y, win->width, win->height, win->border);
-
- if (win->state != NormalState)
- {
- /* The window isn't visible so grant it whatever it likes */
- XConfigureWindow (dpy, win->w, e->value_mask & (CWX|CWY|CWBorderWidth|CWWidth|CWHeight),
- &changes);
- send_configure (win);
- }
- else
+ if (e->value_mask & (CWX|CWY|CWBorderWidth|CWWidth|CWHeight))
{
- /* Draw the hard line. Get back in line, you misbehaving window! */
- maximize (win);
- send_configure (win);
+ if (win->state != NormalState)
+ {
+ /* The window isn't visible so grant it whatever it likes */
+ XConfigureWindow (dpy, win->w, e->value_mask & (CWX|CWY|CWBorderWidth|CWWidth|CWHeight),
+ &changes);
+ send_configure (win);
+ }
+ else
+ {
+ /* Draw the hard line. Get back in line, you misbehaving
+ window! */
+ maximize (win);
+ send_configure (win);
+ }
}
}
else
diff --git a/src/main.c b/src/main.c
index 4fb0cf2..7e2b7f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -74,6 +74,12 @@ struct rp_key prefix_key;
struct modifier_info rp_modifier_info;
+/* rudeness levels */
+int rp_honour_transient_raise = 1;
+int rp_honour_normal_raise = 1;
+int rp_honour_transient_map = 1;
+int rp_honour_normal_map = 1;
+
/* Command line options */
static struct option ratpoison_longopts[] =
{ {"help", no_argument, 0, 'h'},
diff --git a/src/manage.c b/src/manage.c
index d85e875..cbde3d2 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -403,14 +403,16 @@ maximize_normal (rp_window *win)
amount = maxx - win->width;
delta = amount % win->hints->width_inc;
- amount -= delta;
if (amount < 0 && delta) amount -= win->hints->width_inc;
+ amount -= delta;
maxx = amount + win->width;
+ PRINT_DEBUG ("maxy = %d height = %d", maxy, win->height);
+
amount = maxy - win->height;
delta = amount % win->hints->height_inc;
- amount -= delta;
if (amount < 0 && delta) amount -= win->hints->height_inc;
+ amount -= delta;
maxy = amount + win->height;
}
@@ -491,8 +493,19 @@ map_window (rp_window *win)
/* It is now considered iconic and set_active_window can handle the rest. */
set_state (win, IconicState);
- /* FIXME: We may not want a window to pop up out of nowhere */
- set_active_window (win);
+ /* Depending on the rudeness level, actually map the window. */
+ if ((rp_honour_transient_map && win->transient)
+ || (rp_honour_normal_map && !win->transient))
+ set_active_window (win);
+ else
+ {
+ if (win->transient)
+ marked_message_printf (0, 0, "New transient window %d (%s)",
+ win->number, win->name);
+ else
+ marked_message_printf (0, 0, "New window %d (%s)",
+ win->number, win->name);
+ }
}
void