diff options
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | configure.in | 5 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/bar.c | 117 | ||||
-rw-r--r-- | src/bar.h | 5 | ||||
-rw-r--r-- | src/events.c | 30 | ||||
-rw-r--r-- | src/group.c | 12 | ||||
-rw-r--r-- | src/linkedlist.c | 166 | ||||
-rw-r--r-- | src/linkedlist.h | 163 | ||||
-rw-r--r-- | src/window.c | 9 |
10 files changed, 276 insertions, 258 deletions
@@ -1,3 +1,27 @@ +2003-05-20 Shawn Betts <sabetts@sfu.ca> + + * src/linkedlist.h: Move all C function to linkedlist.c + +2003-05-19 Shawn Betts <sabetts@sfu.ca> + + * src/window.c (find_window): add debugging output describing + which window list the window was found in. + + * src/group.c (group_new): assign the group's number the number + passed as an argument. + + * src/events.c (destroy_window): withdraw iconified and normal + windows before unmanaging them. + (handle_signals): delete the node from the list before freeing it. + + * src/bar.h (message): remove define. + (marked_wrapped_message): remove prototype + (message): new prototype + + * src/bar.c (message): new function + (marked_wrapped_message): renamed to marked_message. remove + marked_message. + 2003-05-18 Shawn Betts <sabetts@sfu.ca> * src/bar.c (marked_wrapped_message): Free the GC's created with diff --git a/configure.in b/configure.in index 526ad54..9b83c6d 100644 --- a/configure.in +++ b/configure.in @@ -17,7 +17,7 @@ dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl $Id: configure.in,v 1.35 2003/05/17 10:26:19 sabetts Exp $ +dnl $Id: configure.in,v 1.36 2003/05/20 07:20:14 sabetts Exp $ AC_INIT(src/main.c) AM_INIT_AUTOMAKE(ratpoison, 1.3.0-cvs) @@ -69,6 +69,9 @@ CFLAGS="$CFLAGS $X_CFLAGS" AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR([*** Can't find libX11])) +dnl Check for electric fence library +dnl AC_CHECK_LIB(efence,malloc,,) + dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT diff --git a/src/Makefile.am b/src/Makefile.am index 3e7fd4c..457acfb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,7 +17,7 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -## $Id: Makefile.am,v 1.16 2003/05/16 23:25:07 sabetts Exp $ +## $Id: Makefile.am,v 1.17 2003/05/20 07:20:15 sabetts Exp $ bin_PROGRAMS = ratpoison @@ -43,6 +43,7 @@ ratpoison_SOURCES = actions.c \ input.c \ input.h \ linkedlist.h \ + linkedlist.c \ main.c \ manage.c \ manage.h \ @@ -148,7 +148,7 @@ update_bar (rp_screen *s) } else { - /* The bar is showing a window list. */ + /* bar is showing a window list. */ update_window_names (s); } } @@ -172,7 +172,7 @@ update_window_names (rp_screen *s) else { get_window_list (defaults.window_fmt, "\n", bar_buffer, &mark_start, &mark_end); - marked_wrapped_message (sbuf_get (bar_buffer), mark_start, mark_end); + marked_message (sbuf_get (bar_buffer), mark_start, mark_end); } @@ -181,6 +181,12 @@ update_window_names (rp_screen *s) } void +message (char *s) +{ + marked_message (s, 0, 0); +} + +void marked_message_printf (int mark_start, int mark_end, char *fmt, ...) { char *buffer; @@ -269,7 +275,7 @@ line_beginning (char* msg, int pos) } void -marked_wrapped_message (char *msg, int mark_start, int mark_end) +marked_message (char *msg, int mark_start, int mark_end) { XGCValues lgv; GC lgc; @@ -430,111 +436,6 @@ marked_wrapped_message (char *msg, int mark_start, int mark_end) last_mark_end = mark_end; } - - -void -marked_message (char *msg, int mark_start, int mark_end) -{ - XGCValues lgv; - GC lgc; - unsigned long mask; - rp_screen *s = current_screen (); - - int width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, msg, strlen (msg)); - int height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2); - - PRINT_DEBUG (("%s\n", msg)); - - /* Map the bar if needed */ - if (!s->bar_is_raised) - { - s->bar_is_raised = BAR_IS_MESSAGE; - XMapRaised (dpy, s->bar_window); - } - - /* Reset the alarm to auto-hide the bar in BAR_TIMEOUT seconds. */ - alarm (defaults.bar_timeout); - alarm_signalled = 0; - - XMoveResizeWindow (dpy, s->bar_window, - bar_x (s, width), bar_y (s, height), - width, - height); - - XRaiseWindow (dpy, s->bar_window); - XClearWindow (dpy, s->bar_window); - XSync (dpy, False); - XDrawString (dpy, s->bar_window, s->normal_gc, - defaults.bar_x_padding, - defaults.bar_y_padding + defaults.font->max_bounds.ascent, - msg, strlen (msg)); - XSync (dpy, False); - - /* Crop to boundary conditions. */ - if (mark_start < 0) - mark_start = 0; - - if (mark_end < 0) - mark_end = 0; - - if (mark_start > strlen (msg)) - mark_start = strlen (msg); - - if (mark_end > strlen (msg)) - mark_end = strlen (msg); - - if (mark_start > mark_end) - { - int tmp; - tmp = mark_start; - mark_start = mark_end; - mark_end = tmp; - } - - /* xor the string representing the current window */ - if (mark_start != mark_end) - { - int start; - int end; - int width; - - if (mark_start == 0) - start = 0; - else - start = XTextWidth (defaults.font, msg, mark_start) + defaults.bar_x_padding; - - if (mark_end == strlen (msg)) - end = XTextWidth (defaults.font, msg, mark_end) + defaults.bar_x_padding * 2; - else - end = XTextWidth (defaults.font, msg, mark_end) + defaults.bar_x_padding; - - width = end - start; - - PRINT_DEBUG (("start = %d, end = %d, width = %d\n", start, end, width)); - - lgv.foreground = current_screen()->fg_color; - lgv.function = GXxor; - mask = GCForeground | GCFunction; - lgc = XCreateGC(dpy, s->root, mask, &lgv); - - XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); - XFreeGC (dpy, lgc); - - lgv.foreground = s->bg_color; - lgc = XCreateGC(dpy, s->root, mask, &lgv); - - XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); - XFreeGC (dpy, lgc); - } - - /* Keep a record of the message. */ - if (last_msg) - free (last_msg); - last_msg = xstrdup (msg); - last_mark_start = mark_start; - last_mark_end = mark_end; -} - void show_last_message () { @@ -29,9 +29,8 @@ int hide_bar (rp_screen *s); int bar_y (rp_screen *s, int height); int bar_x (rp_screen *s, int width); -#define message(msg) marked_message ((msg), 0, 0) -void marked_message (char *msg, int hl_start, int hl_end); -void marked_wrapped_message (char *msg, int hl_start, int hl_end); +void message (char *s); +void marked_message (char *s, int mark_start, int mark_end); void marked_message_printf (int mark_start, int mark_end, char *fmt, ...); void show_last_message (); void free_bar (); diff --git a/src/events.c b/src/events.c index b827751..02a30d7 100644 --- a/src/events.c +++ b/src/events.c @@ -176,7 +176,33 @@ destroy_window (XDestroyWindowEvent *ev) win = find_window (ev->window); if (win == NULL) return; - ignore_badwindow++; + ignore_badwindow++; + + /* If, somehow, the window is not withdrawn before it is destroyed, + perform the necessary steps to withdraw the window before it is + unmanaged. */ + if (win->state == IconicState) + { + PRINT_DEBUG (("Destroying Iconic Window (%s)\n", window_name (win))); + withdraw_window (win); + } + else if (win->state == NormalState) + { + rp_frame *frame; + + PRINT_DEBUG (("Destroying Normal Window (%s)\n", window_name (win))); + frame = find_windows_frame (win); + if (frame) + { + cleanup_frame (frame); + if (frame->number == win->scr->current_frame) + set_active_frame (frame); + } + withdraw_window (win); + } + + /* Now that the window is guaranteed to be in the unmapped window + list, we can safely stop managing it. */ unmanage (win); ignore_badwindow--; } @@ -787,9 +813,9 @@ handle_signals () if (cur->status != 0) marked_message_printf (0,0, " /bin/sh -c \"%s\" finished (%d) ", cur->cmd, cur->status); + list_del (&cur->node); free (cur->cmd); free (cur); - list_del (&cur->node); } } diff --git a/src/group.c b/src/group.c index 6b268f0..b09e2e3 100644 --- a/src/group.c +++ b/src/group.c @@ -23,7 +23,7 @@ group_new (int number) g = xmalloc (sizeof (rp_group)); - g->number = numset_request (group_numset); + g->number = number; g->numset = numset_new(); INIT_LIST_HEAD (&g->unmapped_windows); INIT_LIST_HEAD (&g->mapped_windows); @@ -172,6 +172,16 @@ group_del_window (rp_group *g, rp_window *win) free (cur); } } + + /* Make sure the window isn't in the list of mapped windows. This + would mean there is a bug. */ +#ifdef DEBUG + list_for_each_entry (cur, &g->mapped_windows, node) + { + if (cur->win == win) + PRINT_DEBUG (("This window wasn't removed from the mapped window list.\n")); + } +#endif } /* Remove the window from any groups in resides in. */ diff --git a/src/linkedlist.c b/src/linkedlist.c new file mode 100644 index 0000000..21df745 --- /dev/null +++ b/src/linkedlist.c @@ -0,0 +1,166 @@ +#include "linkedlist.h" + +void +prefetch(const void *x) +{;} + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +void +__list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +void +list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + +/** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ +void +list_add_tail(struct list_head *new, struct list_head *head) +{ + __list_add(new, head->prev, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +void +__list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is + * in an undefined state. + */ +void +list_del(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +void +list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ +void +list_move(struct list_head *list, struct list_head *head) +{ + __list_del(list->prev, list->next); + list_add(list, head); +} + +/** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ +void +list_move_tail(struct list_head *list, + struct list_head *head) +{ + __list_del(list->prev, list->next); + list_add_tail(list, head); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +int +list_empty(struct list_head *head) +{ + return head->next == head; +} + +void +__list_splice(struct list_head *list, + struct list_head *head) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; +} + +/** + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +void +list_splice(struct list_head *list, struct list_head *head) +{ + if (!list_empty(list)) + __list_splice(list, head); +} + +/** + * list_splice_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ +void +list_splice_init(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) { + __list_splice(list, head); + INIT_LIST_HEAD(list); + } +} diff --git a/src/linkedlist.h b/src/linkedlist.h index d36f07f..e9181ee 100644 --- a/src/linkedlist.h +++ b/src/linkedlist.h @@ -5,8 +5,6 @@ #ifndef _RATPOISON_LINKLIST_H #define _RATPOISON_LINKLIST_H -static inline void prefetch(const void *x) {;} - /* * Simple doubly linked list implementation. * @@ -30,154 +28,35 @@ struct list_head { (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_add(struct list_head *new, - struct list_head *prev, - struct list_head *next) -{ - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; -} +/* Prototypes of C functions. */ +void list_splice_init(struct list_head *list, + struct list_head *head); -/** - * list_add - add a new entry - * @new: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void list_add(struct list_head *new, struct list_head *head) -{ - __list_add(new, head, head->next); -} +void list_splice_init(struct list_head *list, + struct list_head *head); -/** - * list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) -{ - __list_add(new, head->prev, head); -} +void list_splice(struct list_head *list, struct list_head *head); -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_del(struct list_head * prev, struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} +void __list_splice(struct list_head *list, + struct list_head *head); -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty on entry does not return true after this, the entry is - * in an undefined state. - */ -static inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); -} +int list_empty(struct list_head *head); -/** - * list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -static inline void list_del_init(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - INIT_LIST_HEAD(entry); -} +void list_move_tail(struct list_head *list, + struct list_head *head); -/** - * list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ -static inline void list_move(struct list_head *list, struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add(list, head); -} - -/** - * list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -static inline void list_move_tail(struct list_head *list, - struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add_tail(list, head); -} - -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(struct list_head *head) -{ - return head->next == head; -} +void list_move(struct list_head *list, struct list_head *head); -static inline void __list_splice(struct list_head *list, - struct list_head *head) -{ - struct list_head *first = list->next; - struct list_head *last = list->prev; - struct list_head *at = head->next; +void list_del_init(struct list_head *entry); +void list_del(struct list_head *entry); +void __list_del(struct list_head * prev, struct list_head * next); +void list_add_tail(struct list_head *new, struct list_head *head); +void list_add(struct list_head *new, struct list_head *head); +void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next); +void prefetch(const void *x); - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; -} - -/** - * list_splice - join two lists - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice(struct list_head *list, struct list_head *head) -{ - if (!list_empty(list)) - __list_splice(list, head); -} - -/** - * list_splice_init - join two lists and reinitialise the emptied list. - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * The list at @list is reinitialised - */ -static inline void list_splice_init(struct list_head *list, - struct list_head *head) -{ - if (!list_empty(list)) { - __list_splice(list, head); - INIT_LIST_HEAD(list); - } -} /** * container_of - cast a member of a structure out to the containing structure diff --git a/src/window.c b/src/window.c index ec7b088..88403cf 100644 --- a/src/window.c +++ b/src/window.c @@ -167,11 +167,20 @@ find_window (Window w) { rp_window *win = NULL; + win = find_window_in_list (w, &rp_mapped_window); if (!win) { win = find_window_in_list (w, &rp_unmapped_window); + if (win) + PRINT_DEBUG (("Window found in unmapped window list\n")); + else + PRINT_DEBUG (("Window not found.\n")); + } + else + { + PRINT_DEBUG (("Window found in mapped window list.\n")); } return win; |