diff options
author | sabetts <sabetts> | 2001-09-09 02:59:23 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-09-09 02:59:23 +0000 |
commit | 1bd2211aa5c392d9873c74ffc998bea744007a29 (patch) | |
tree | b695cac6f169042430a4d7c1a9cc0ac9bda63304 /src/list.c | |
parent | 52cd2d7d10d543fe989e3cde617faf7453dcc494 (diff) | |
download | ratpoison-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/list.c')
-rw-r--r-- | src/list.c | 137 |
1 files changed, 116 insertions, 21 deletions
@@ -45,12 +45,52 @@ free_window (rp_window *w) { if (w == NULL) return; - free (w->name); + free (w->user_name); + free (w->res_name); + free (w->res_class); + free (w->wm_name); + XFree (w->hints); free (w); } +void +update_window_position (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; +} + +char * +window_name (rp_window *win) +{ + if (win == NULL) return NULL; + + if (win->named) + return win->user_name; + + switch (defaults.win_name) + { + case 0: + return win->wm_name; + + case 1: + return win->res_name; + + case 2: + return win->res_class; + + default: + return win->wm_name; + } + + return NULL; +} /* Allocate a new window and add it to the list of managed windows */ rp_window * @@ -72,13 +112,18 @@ 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); + get_mouse_root_position (new_window, &new_window->mouse_x, &new_window->mouse_y); XSelectInput (dpy, new_window->w, WIN_EVENTS); - new_window->name = xmalloc (strlen ("Unnamed") + 1); + new_window->user_name = xmalloc (strlen ("Unnamed") + 1); - strcpy (new_window->name, "Unnamed"); + strcpy (new_window->user_name, "Unnamed"); + new_window->wm_name = NULL; + new_window->res_name = NULL; + new_window->res_class = NULL; /* Add the window to the end of the unmapped list. */ append_to_list (new_window, rp_unmapped_window_sentinel); @@ -177,7 +222,7 @@ find_window_name (char *name) /* if (w->state == STATE_UNMAPPED) */ /* continue; */ - if (str_comp (name, w->name, strlen (name))) + if (str_comp (name, window_name (w), strlen (name))) return w; } @@ -514,8 +559,8 @@ set_active_window (rp_window *win) last_win = set_frames_window (rp_current_frame, win); - if (last_win) PRINT_DEBUG ("last window: %s\n", last_win->name); - PRINT_DEBUG ("new window: %s\n", win->name); + if (last_win) PRINT_DEBUG ("last window: %s\n", window_name (last_win)); + PRINT_DEBUG ("new window: %s\n", window_name (win)); /* Make sure the window comes up full screen */ maximize (win); @@ -560,18 +605,78 @@ goto_window (rp_window *win) void print_window_information (rp_window *win) { - marked_message_printf (0, 0, MESSAGE_WINDOW_INFORMATION, win->number, win->name); + marked_message_printf (0, 0, MESSAGE_WINDOW_INFORMATION, + win->number, window_name (win)); +} + +/* format options + N - Window number + - - Window status (current window, last window, etc) + W - Window Name + w - Window res name + c - Window res class + n - X11 Window ID + + */ +static void +format_window_name (char *fmt, rp_window *win, rp_window *other_win, + struct sbuf *buffer) +{ + char dbuf[10]; + + for(; *fmt; fmt++) + { + switch (*fmt) + { + case 'N': + snprintf (dbuf, 10, "%d", win->number); + sbuf_concat (buffer, dbuf); + break; + + case '-': + if (win == current_window()) + sbuf_concat (buffer, "*"); + else if (win == other_win) + sbuf_concat (buffer, "+"); + else + sbuf_concat (buffer, "-"); + break; + + case 'W': + sbuf_concat (buffer, window_name (win)); + break; + + case 'w': + sbuf_concat (buffer, win->res_name); + break; + + case 'c': + sbuf_concat (buffer, win->res_class); + break; + + case 'n': + snprintf (dbuf, 9, "%ld", (unsigned long)win->w); + sbuf_concat (buffer, dbuf); + break; + + default: + dbuf[0] = *fmt; + dbuf[1] = 0; + sbuf_concat (buffer, dbuf); + break; + } + } } /* get the window list and store it in buffer delimiting each window with delim. mark_start and mark_end will be filled with the text positions for the start and end of the current window. */ void -get_window_list (char *delim, struct sbuf *buffer, int *mark_start, int *mark_end) +get_window_list (char *fmt, char *delim, struct sbuf *buffer, + int *mark_start, int *mark_end) { rp_window *w; rp_window *other_window; - char dbuf[10]; if (buffer == NULL) return; @@ -582,7 +687,7 @@ get_window_list (char *delim, struct sbuf *buffer, int *mark_start, int *mark_en w != rp_mapped_window_sentinel; w = w->next) { - PRINT_DEBUG ("%d-%s\n", w->number, w->name); + PRINT_DEBUG ("%d-%s\n", w->number, window_name (w)); if (w == current_window()) *mark_start = strlen (sbuf_get (buffer)); @@ -592,17 +697,7 @@ get_window_list (char *delim, struct sbuf *buffer, int *mark_start, int *mark_en if (!delim) sbuf_concat (buffer, " "); - sprintf (dbuf, "%d", w->number); - sbuf_concat (buffer, dbuf); - - if (w == current_window()) - sbuf_concat (buffer, "*"); - else if (w == other_window) - sbuf_concat (buffer, "+"); - else - sbuf_concat (buffer, "-"); - - sbuf_concat (buffer, w->name); + format_window_name (fmt, w, other_window, buffer); /* A hack, pad the window with a space at the beginning and end if there is no delimiter. */ |