summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-09 02:59:23 +0000
committersabetts <sabetts>2001-09-09 02:59:23 +0000
commit1bd2211aa5c392d9873c74ffc998bea744007a29 (patch)
treeb695cac6f169042430a4d7c1a9cc0ac9bda63304 /src/main.c
parent52cd2d7d10d543fe989e3cde617faf7453dcc494 (diff)
downloadratpoison-1bd2211aa5c392d9873c74ffc998bea744007a29.zip
* src/list.h (update_window_position): new prototype
(window_name): new prototype (get_window_list): update prototype * src/events.c (grab_rat): Don't wrap in an #ifdef (ungrab_rat): likewise (handle_key): record if the rat is grabbed and only ungrab it at the end if it was first grabbed. * src/actions.h (cmd_pos): new prototype (cmd_defwinpos): new prototype (cmd_deftranspos): new prototype (cmd_defmaxsizepos): new prototype (cmd_defbartimeout): new prototype (cmd_defbarloc): new prototype (cmd_deffont): new prototype (cmd_defpadding): new prototype (cmd_defborder): new prototype (cmd_definputwidth): new prototype (cmd_defwaitcursor): new prototype (cmd_defwinfmt): new prototype (cmd_defwinname): new prototype * src/messages.h (MESSAGE_FRAME_STRING): new message * src/manage.c (get_wmname): renamed from get_window_name (get_class_hints): new function (get_res_name): likewise (get_res_class): likewise (update_window_name): update the window's wm_name, res_name, and res_class fields. (update_window_name): calls functions get_wmname, get_res_name, get_res_class. (update_window_name): Don't crop the window name. (update_window_information): call update_window_position. (move_window): new function (maximize_transient): only set the window's width and height fields. (maximize_normal): likewise (maximize): call move_window (force_maximize): likewise (force_maximize): if the window has resize hints, resize it 1 resize unit. * src/main.c: new global variable, defaults. remove static variable, font, and move to defaults. Dependant code updated. (init_defaults): new function (main): call init_defaults. (init_screen): initialize the screen's fg_color to black and bg_color to white. * src/list.c (free_window): free the fields user_name, res_name, res_class, and wm_name. (update_window_position): new function (window_name): new function. Code accessing a window's name uses this function. All code updated. (add_to_window_list): call update_window_position (add_to_window_list): initialize wm_name, res_name, and res_class for the new window. (format_window_name): new function (get_window_list): Add parameter fmt. All callers updated. (get_window_list): call format_window_name. * src/conf.h: move Configuration variables to the global variable, defaults. Dependant code updated. * src/data.h (TOP_LEFT): new 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): new fields user_name, wm_name, res_name, res_class, position. (struct rp_window): remove field name. Replaced with user_name. Dependant code updated. (struct screen_info): remove field font. dependant code updated. (struct screen_info): new fields fg_color, bg_color. (struct rp_defaults): new struct (defaults): new global * src/actions.c (parse_winpos): new function (cmd_pos): likewise (cmd_defwinpos): likewise (cmd_deftranspos): likewise (cmd_defmaxsizepos): likewise (cmd_defbartimeout): likewise (cmd_defbarloc): likewise (cmd_deffont): likewise (cmd_defpadding): likewise (cmd_defborder): likewise (cmd_definputwidth): likewise (cmd_defwaitcursor): likewise (cmd_defwinfmt): likewise (cmd_defwinname): likewise (user_commands): New commands defbarloc, defbartimeout, defborder, deffont, defintputwidth, defmaxsizepos, defpadding, deftranspos, defwaitcursor, defwinfmt, defwinname, defwinpos.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c85
1 files changed, 54 insertions, 31 deletions
diff --git a/src/main.c b/src/main.c
index 8d555aa..498029d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -62,9 +62,9 @@ screen_info *screens;
int num_screens;
Display *dpy;
-int ignore_badwindow = 0;
+struct rp_defaults defaults;
-static XFontStruct *font;
+int ignore_badwindow = 0;
char **myargv;
@@ -345,6 +345,46 @@ show_welcome_message ()
free (prefix);
}
+static void
+init_defaults ()
+{
+ defaults.win_pos = TOP_LEFT;
+ defaults.trans_pos = CENTER_CENTER;
+ defaults.maxsize_pos = CENTER_CENTER;
+
+ 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_timeout = 5;
+
+ defaults.frame_indicator_timeout = 1;
+
+ defaults.padding_left = 0;
+ defaults.padding_right = 0;
+ defaults.padding_top = 0;
+ defaults.padding_bottom = 0;
+
+ defaults.font = XLoadQueryFont (dpy, "9x15bold");
+ if (defaults.font == NULL)
+ {
+ fprintf (stderr, "ratpoison: Cannot load font %s.\n", "9x15bold");
+ exit (EXIT_FAILURE);
+ }
+
+ defaults.wait_for_key_cursor = 1;
+
+ defaults.window_fmt = strdup ("N-W");
+ if (defaults.window_fmt == NULL)
+ {
+ PRINT_ERROR ("Not enough memory\n");
+ exit (EXIT_FAILURE);
+ }
+
+ defaults.win_name = 0;
+}
+
int
main (int argc, char *argv[])
{
@@ -440,19 +480,13 @@ main (int argc, char *argv[])
set_sig_handler (SIGHUP, hup_handler);
/* Setup ratpoison's internal structures */
+ init_defaults();
init_numbers ();
init_window_list ();
init_frame_list ();
update_modifier_map ();
initialize_default_keybindings ();
- font = XLoadQueryFont (dpy, FONT);
- if (font == NULL)
- {
- fprintf (stderr, "ratpoison: Cannot load font %s.\n", FONT);
- exit (EXIT_FAILURE);
- }
-
num_screens = ScreenCount (dpy);
screens = (screen_info *)xmalloc (sizeof (screen_info) * num_screens);
@@ -483,8 +517,6 @@ init_rat_cursor (screen_info *s)
static void
init_screen (screen_info *s, int screen_num)
{
- XColor fg_color, bg_color,/* bold_color, */ junk;
-
/* Select on some events on the root window, if this fails, then
there is already a WM running and the X Error handler will catch
it, terminating ratpoison. */
@@ -497,29 +529,20 @@ init_screen (screen_info *s, int screen_num)
s->screen_num = screen_num;
s->root = RootWindow (dpy, screen_num);
s->def_cmap = DefaultColormap (dpy, screen_num);
- s->font = font;
XGetWindowAttributes (dpy, s->root, &s->root_attr);
init_rat_cursor (s);
- /* Get our program bar colors */
- if (!XAllocNamedColor (dpy, s->def_cmap, FOREGROUND, &fg_color, &junk))
- {
- fprintf (stderr, "ratpoison: Unknown color '%s'\n", FOREGROUND);
- }
-
- if (!XAllocNamedColor (dpy, s->def_cmap, BACKGROUND, &bg_color, &junk))
- {
- fprintf (stderr, "ratpoison: Unknown color '%s'\n", BACKGROUND);
- }
+ s->fg_color = BlackPixel (dpy, s->screen_num);
+ s->bg_color = WhitePixel (dpy, s->screen_num);
/* Setup the GC for drawing the font. */
- gv.foreground = fg_color.pixel;
- gv.background = bg_color.pixel;
+ gv.foreground = s->fg_color;
+ gv.background = s->bg_color;
gv.function = GXcopy;
gv.line_width = 1;
gv.subwindow_mode = IncludeInferiors;
- gv.font = font->fid;
+ gv.font = defaults.font->fid;
s->normal_gc = XCreateGC(dpy, s->root,
GCForeground | GCBackground | GCFunction
| GCLineWidth | GCSubwindowMode | GCFont,
@@ -528,28 +551,28 @@ init_screen (screen_info *s, int screen_num)
/* Create the program bar window. */
s->bar_is_raised = 0;
s->bar_window = XCreateSimpleWindow (dpy, s->root, 0, 0,
- 1, 1, 1, fg_color.pixel, bg_color.pixel);
+ 1, 1, 1, s->fg_color, s->bg_color);
XSelectInput (dpy, s->bar_window, StructureNotifyMask);
/* Setup the window that will recieve all keystrokes once the prefix
key has been pressed. */
- s->key_window = XCreateSimpleWindow (dpy, s->root, 0, 0, 1, 1, 0, WhitePixel (dpy, 0), BlackPixel (dpy, 0));
+ s->key_window = XCreateSimpleWindow (dpy, s->root, 0, 0, 1, 1, 0, WhitePixel (dpy, s->screen_num), BlackPixel (dpy, s->screen_num));
XSelectInput (dpy, s->key_window, KeyPressMask );
XMapWindow (dpy, s->key_window);
/* Create the input window. */
s->input_window = XCreateSimpleWindow (dpy, s->root, 0, 0,
- 1, 1, 1, fg_color.pixel, bg_color.pixel);
+ 1, 1, 1, s->fg_color, s->bg_color);
XSelectInput (dpy, s->input_window, KeyPressMask );
/* Create the frame indicator window */
s->frame_window = XCreateSimpleWindow (dpy, s->root, 1, 1, 1, 1, 1,
- fg_color.pixel, bg_color.pixel);
+ s->fg_color, s->bg_color);
XSelectInput (dpy, s->frame_window, KeyPressMask );
/* Create the help window */
s->help_window = XCreateSimpleWindow (dpy, s->root, 0, 0, s->root_attr.width,
- s->root_attr.height, 1, fg_color.pixel, bg_color.pixel);
+ s->root_attr.height, 1, s->fg_color, s->bg_color);
XSelectInput (dpy, s->help_window, KeyPressMask);
XSync (dpy, 0);
@@ -589,7 +612,7 @@ clean_up ()
XFreeGC (dpy, screens[i].normal_gc);
}
- XFreeFont (dpy, font);
+ XFreeFont (dpy, defaults.font);
XSetInputFocus (dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XCloseDisplay (dpy);