diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | configure.in | 14 | ||||
-rw-r--r-- | src/actions.c | 42 | ||||
-rw-r--r-- | src/bar.c | 4 | ||||
-rw-r--r-- | src/events.c | 92 | ||||
-rw-r--r-- | src/input.c | 34 | ||||
-rw-r--r-- | src/list.c | 16 | ||||
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/manage.c | 36 | ||||
-rw-r--r-- | src/ratpoison.h | 34 | ||||
-rw-r--r-- | src/split.c | 26 |
12 files changed, 161 insertions, 167 deletions
@@ -1,5 +1,13 @@ 2003-02-22 Shawn Betts <sabetts@sfu.ca> + * configure.in: don't check for variable argument support in + preprocessor. + + * src/ratpoison.h (PRINT_LINE): new macro. + (PRE_PRINT_LOCATION): remove macro + (PRINT_ERROR): takes one argument which is the argument list + ,parens and all, to be passed to printf. Callers updated. + * src/linkedlist.h (list_direction_entry): no longer returns NULL if there is only one element in the list. Instead, returns the same element again and again. @@ -1,6 +1,10 @@ ratpoison NEWS --- history of user-visible changes. -*- outline -*- * Changes since 1.1.1 +** error and debug reporting +The format has been changed to the more standard format used by C +compilers. + ** New commands 'resize', 'shrink' resize resizes a frame and shrink shrinks a frame to the size of the window in it. diff --git a/configure.in b/configure.in index 1e0c528..7c60e43 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.32 2002/12/11 20:35:17 sabetts Exp $ +dnl $Id: configure.in,v 1.33 2003/02/23 01:40:42 sabetts Exp $ AC_INIT(src/main.c) AM_INIT_AUTOMAKE(ratpoison, 1.2.0-cvs) @@ -51,18 +51,6 @@ if test "x$CC" = "xgcc"; then CFLAGS="$CFLAGS -Wall -O2" fi -dnl Check for vararg macros (some preprocessors don't have variable argument macros) -AC_PROG_CPP -AC_MSG_CHECKING(for vararg macros) -AC_TRY_CPP([ -#define VARARGS(first, more...) foo(first, ## more) -VARARGS(bar, gazonk) -VARARGS(bar, gazonk, blahonga) -], AC_DEFINE_UNQUOTED(HAVE_VARARG_MACROS, "1", The c preprocessor has support for vararg macros) AC_MSG_RESULT(yes), -AC_MSG_RESULT(no)) - - - dnl check for an x terminal emulator AC_MSG_CHECKING(terminal emulator) AC_MSG_RESULT($term_prog) diff --git a/src/actions.c b/src/actions.c index 6bec5d1..39f2df0 100644 --- a/src/actions.c +++ b/src/actions.c @@ -213,7 +213,7 @@ add_keybinding (KeySym keysym, int state, char *cmd) /* double the key table size */ key_actions_table_size *= 2; key_actions = (rp_action*) xrealloc (key_actions, sizeof (rp_action) * key_actions_table_size); - PRINT_DEBUG ("realloc()ed key_table %d\n", key_actions_table_size); + PRINT_DEBUG (("realloc()ed key_table %d\n", key_actions_table_size)); } key_actions[key_actions_last].key = keysym; @@ -561,19 +561,19 @@ cmd_meta (int interactive, void *data) if (current_window() == NULL) return NULL; - PRINT_DEBUG ("type==%d\n", ev.xkey.type); - PRINT_DEBUG ("serial==%ld\n", ev.xkey.serial); - PRINT_DEBUG ("send_event==%d\n", ev.xkey.send_event); - PRINT_DEBUG ("display=%p\n", ev.xkey.display); + PRINT_DEBUG (("type==%d\n", ev.xkey.type)); + PRINT_DEBUG (("serial==%ld\n", ev.xkey.serial)); + PRINT_DEBUG (("send_event==%d\n", ev.xkey.send_event)); + PRINT_DEBUG (("display=%p\n", ev.xkey.display)); /* PRINT_DEBUG ("root==%x ???\n", ev.xkey.root); */ /* PRINT_DEBUG ("window==%x ???\n", ev.xkey.window); */ /* PRINT_DEBUG ("subwindow==%x ???\n", ev.xkey.subwindow); */ - PRINT_DEBUG ("time==%ld\n", ev.xkey.time); - PRINT_DEBUG ("x==%d y==%d\n", ev.xkey.x, ev.xkey.y); - PRINT_DEBUG ("x_root==%d y_root==%d\n", ev.xkey.x_root, ev.xkey.y_root); - PRINT_DEBUG ("state==%d\n", ev.xkey.state); - PRINT_DEBUG ("keycode==%d\n", ev.xkey.keycode); - PRINT_DEBUG ("same_screen=%d\n", ev.xkey.same_screen); + PRINT_DEBUG (("time==%ld\n", ev.xkey.time)); + PRINT_DEBUG (("x==%d y==%d\n", ev.xkey.x, ev.xkey.y)); + PRINT_DEBUG (("x_root==%d y_root==%d\n", ev.xkey.x_root, ev.xkey.y_root)); + PRINT_DEBUG (("state==%d\n", ev.xkey.state)); + PRINT_DEBUG (("keycode==%d\n", ev.xkey.keycode)); + PRINT_DEBUG (("same_screen=%d\n", ev.xkey.same_screen)); /* I am not sure which of the following fields I have to fill in or what to fill them in with (rcy) I wouldnt be suprised if this @@ -823,7 +823,7 @@ cmd_delete (int interactive, void *data) status = XSendEvent(dpy, current_window()->w, False, 0, &ev); if (status == 0) - PRINT_DEBUG ("Delete window failed\n"); + PRINT_DEBUG (("Delete window failed\n")); return NULL; } @@ -879,7 +879,7 @@ command (int interactive, char *data) rest = NULL; } - PRINT_DEBUG ("cmd==%s rest==%s\n", cmd, (char*)rest); + PRINT_DEBUG (("cmd==%s rest==%s\n", cmd, (char*)rest)); /* Look for it in the aliases, first. */ for (i=0; i<alias_list_last; i++) @@ -1000,7 +1000,7 @@ spawn(void *data) } /* wait((int *) 0); */ - PRINT_DEBUG ("spawned %s\n", cmd); + PRINT_DEBUG (("spawned %s\n", cmd)); } /* Switch to a different Window Manager. Thanks to @@ -1019,12 +1019,12 @@ cmd_newwm(int interactive, void *data) if (prog == NULL) return NULL; - PRINT_DEBUG ("Switching to %s\n", prog); + PRINT_DEBUG (("Switching to %s\n", prog)); putenv(current_screen()->display_string); execlp(prog, prog, 0); - PRINT_ERROR ("exec %s ", prog); + PRINT_ERROR (("exec %s ", prog)); perror(" failed"); free (prog); @@ -1107,7 +1107,7 @@ cmd_number (int interactive, void *data) { int win_number; - PRINT_DEBUG ("2nd: '%s'\n", tmp); + PRINT_DEBUG (("2nd: '%s'\n", tmp)); win_number = string_to_window_number (tmp); if (win_number < 0) @@ -1121,7 +1121,7 @@ cmd_number (int interactive, void *data) } else { - PRINT_DEBUG ("2nd: NULL\n"); + PRINT_DEBUG (("2nd: NULL\n")); win = current_window(); } @@ -1773,7 +1773,7 @@ wingravity_to_string (int g) return "se"; } - PRINT_DEBUG ("Unknown gravity!\n"); + PRINT_DEBUG (("Unknown gravity!\n")); return "Unknown"; } @@ -2165,7 +2165,7 @@ cmd_defwinname (int interactive, void *data) case 2: return xstrdup ("class"); default: - PRINT_DEBUG ("Unknown win_name\n"); + PRINT_DEBUG (("Unknown win_name\n")); return xstrdup ("unknown"); } @@ -2285,7 +2285,7 @@ cmd_setenv (int interactive, void *data) free (value); /* Stick it in the environment. */ - PRINT_DEBUG("%s\n", sbuf_get(env)); + PRINT_DEBUG(("%s\n", sbuf_get(env))); putenv (sbuf_get (env)); /* According to the docs, the actual string is placed in the @@ -178,7 +178,7 @@ marked_message (char *msg, int mark_start, int mark_end) 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); + PRINT_DEBUG (("%s\n", msg)); /* Map the bar if needed */ if (!s->bar_is_raised) @@ -245,7 +245,7 @@ marked_message (char *msg, int mark_start, int mark_end) width = end - start; - PRINT_DEBUG ("start = %d, end = %d, width = %d\n", start, end, width); + PRINT_DEBUG (("start = %d, end = %d, width = %d\n", start, end, width)); lgv.foreground = current_screen()->fg_color; lgv.function = GXxor; diff --git a/src/events.c b/src/events.c index 3699a80..51f31d7 100644 --- a/src/events.c +++ b/src/events.c @@ -115,11 +115,11 @@ unmap_notify (XEvent *ev) switch (win->state) { case IconicState: - PRINT_DEBUG ("Withdrawing iconized window '%s'\n", window_name (win)); + PRINT_DEBUG (("Withdrawing iconized window '%s'\n", window_name (win))); if (ev->xunmap.send_event) withdraw_window (win); break; case NormalState: - PRINT_DEBUG ("Withdrawing normal window '%s'\n", window_name (win)); + PRINT_DEBUG (("Withdrawing normal window '%s'\n", window_name (win))); /* If the window was inside a frame, fill the frame with another window. */ frame = find_windows_frame (win); @@ -141,31 +141,31 @@ map_request (XEvent *ev) win = find_window (ev->xmap.window); if (win == NULL) { - PRINT_DEBUG ("Map request from an unknown window.\n"); + PRINT_DEBUG (("Map request from an unknown window.\n")); XMapWindow (dpy, ev->xmap.window); return; } - PRINT_DEBUG ("Map request from a managed window\n"); + PRINT_DEBUG (("Map request from a managed window\n")); switch (win->state) { case WithdrawnState: if (unmanaged_window (win->w)) { - PRINT_DEBUG ("Mapping Unmanaged Window\n"); + PRINT_DEBUG (("Mapping Unmanaged Window\n")); XMapWindow (dpy, win->w); break; } else { - PRINT_DEBUG ("Mapping Withdrawn Window\n"); + PRINT_DEBUG (("Mapping Withdrawn Window\n")); map_window (win); break; } break; case IconicState: - PRINT_DEBUG ("Mapping Iconic window\n"); + PRINT_DEBUG (("Mapping Iconic window\n")); if (win->last_access == 0) { /* Depending on the rudeness level, actually map the @@ -254,46 +254,46 @@ configure_request (XConfigureRequestEvent *e) } - PRINT_DEBUG("request CWStackMode %d\n", e->detail); + PRINT_DEBUG(("request CWStackMode %d\n", e->detail)); } - PRINT_DEBUG ("'%s' window size: %d %d %d %d %d\n", window_name (win), - win->x, win->y, win->width, win->height, win->border); + PRINT_DEBUG (("'%s' window size: %d %d %d %d %d\n", window_name (win), + win->x, win->y, win->width, win->height, win->border)); /* Collect the changes to be granted. */ if (e->value_mask & CWBorderWidth) { changes.border_width = e->border_width; win->border = e->border_width; - PRINT_DEBUG("request CWBorderWidth %d\n", e->border_width); + PRINT_DEBUG(("request CWBorderWidth %d\n", e->border_width)); } if (e->value_mask & CWWidth) { changes.width = e->width; win->width = e->width; - PRINT_DEBUG("request CWWidth %d\n", e->width); + PRINT_DEBUG(("request CWWidth %d\n", e->width)); } if (e->value_mask & CWHeight) { changes.height = e->height; win->height = e->height; - PRINT_DEBUG("request CWHeight %d\n", e->height); + PRINT_DEBUG(("request CWHeight %d\n", e->height)); } if (e->value_mask & CWX) { changes.x = e->x; win->x = e->x; - PRINT_DEBUG("request CWX %d\n", e->x); + PRINT_DEBUG(("request CWX %d\n", e->x)); } if (e->value_mask & CWY) { changes.y = e->y; win->y = e->y; - PRINT_DEBUG("request CWY %d\n", e->y); + PRINT_DEBUG(("request CWY %d\n", e->y)); } if (e->value_mask & (CWX|CWY|CWBorderWidth|CWWidth|CWHeight)) @@ -325,13 +325,13 @@ configure_request (XConfigureRequestEvent *e) static void client_msg (XClientMessageEvent *ev) { - PRINT_DEBUG ("Received client message.\n"); + PRINT_DEBUG (("Received client message.\n")); if (ev->message_type == wm_change_state) { rp_window *win; - PRINT_DEBUG ("WM_CHANGE_STATE\n"); + PRINT_DEBUG (("WM_CHANGE_STATE\n")); win = find_window (ev->window); if (win == NULL) return; @@ -341,7 +341,7 @@ client_msg (XClientMessageEvent *ev) 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"); + PRINT_DEBUG (("Iconify Request.\n")); if (win->state == NormalState) { rp_window *w = find_window_other(); @@ -354,7 +354,7 @@ client_msg (XClientMessageEvent *ev) } else { - PRINT_ERROR ("Non-standard WM_CHANGE_STATE format\n"); + PRINT_ERROR (("Non-standard WM_CHANGE_STATE format\n")); } } } @@ -384,7 +384,7 @@ handle_key (screen_info *s) unsigned int mod; /* Modifiers */ int rat_grabbed = 0; - PRINT_DEBUG ("handling key...\n"); + PRINT_DEBUG (("handling key...\n")); /* All functions hide the program bar and the frame indicator. */ if (defaults.bar_timeout > 0) hide_bar (s); @@ -490,14 +490,14 @@ execute_remote_command (Window w) { if (req) { - PRINT_DEBUG ("command: %s\n", req); + PRINT_DEBUG (("command: %s\n", req)); result = command (0, req); } XFree (req); } else { - PRINT_DEBUG ("Couldn't get RP_COMMAND Property\n"); + PRINT_DEBUG (("Couldn't get RP_COMMAND Property\n")); } return result; @@ -548,10 +548,10 @@ receive_command () } else { - PRINT_DEBUG ("Couldn't get RP_COMMAND_REQUEST Property\n"); + PRINT_DEBUG (("Couldn't get RP_COMMAND_REQUEST Property\n")); } - PRINT_DEBUG ("command requests: %ld\n", nitems); + PRINT_DEBUG (("command requests: %ld\n", nitems)); } } while (nitems > 0); @@ -562,13 +562,13 @@ property_notify (XEvent *ev) { rp_window *win; - PRINT_DEBUG ("atom: %ld\n", ev->xproperty.atom); + PRINT_DEBUG (("atom: %ld\n", ev->xproperty.atom)); if (ev->xproperty.atom == rp_command_request && ev->xproperty.window == DefaultRootWindow (dpy) && ev->xproperty.state == PropertyNewValue) { - PRINT_DEBUG ("ratpoison command\n"); + PRINT_DEBUG (("ratpoison command\n")); receive_command(); } @@ -579,25 +579,25 @@ property_notify (XEvent *ev) switch (ev->xproperty.atom) { case XA_WM_NAME: - PRINT_DEBUG ("updating window name\n"); + PRINT_DEBUG (("updating window name\n")); update_window_name (win); update_window_names (win->scr); break; case XA_WM_NORMAL_HINTS: - PRINT_DEBUG ("updating window normal hints\n"); + PRINT_DEBUG (("updating window normal hints\n")); update_normal_hints (win); if (win->state == NormalState) maximize (win); break; case XA_WM_TRANSIENT_FOR: - PRINT_DEBUG ("Transient for\n"); + PRINT_DEBUG (("Transient for\n")); win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for); break; default: - PRINT_DEBUG ("Unhandled property notify event\n"); + PRINT_DEBUG (("Unhandled property notify event\n")); break; } } @@ -642,7 +642,7 @@ focus_change (XFocusChangeEvent *ev) if (win != NULL) { - PRINT_DEBUG ("Re-grabbing prefix key\n"); + PRINT_DEBUG (("Re-grabbing prefix key\n")); grab_prefix_key (win->w); } } @@ -682,62 +682,62 @@ delegate_event (XEvent *ev) switch (ev->type) { case ConfigureRequest: - PRINT_DEBUG ("--- Handling ConfigureRequest ---\n"); + PRINT_DEBUG (("--- Handling ConfigureRequest ---\n")); configure_request (&ev->xconfigurerequest); break; case CreateNotify: - PRINT_DEBUG ("--- Handling CreateNotify ---\n"); + PRINT_DEBUG (("--- Handling CreateNotify ---\n")); new_window (&ev->xcreatewindow); break; case DestroyNotify: - PRINT_DEBUG ("--- Handling DestroyNotify ---\n"); + PRINT_DEBUG (("--- Handling DestroyNotify ---\n")); destroy_window (&ev->xdestroywindow); break; case ClientMessage: - PRINT_DEBUG ("--- Handling ClientMessage ---\n"); + PRINT_DEBUG (("--- Handling ClientMessage ---\n")); client_msg (&ev->xclient); break; case ColormapNotify: - PRINT_DEBUG ("--- Handling ColormapNotify ---\n"); + PRINT_DEBUG (("--- Handling ColormapNotify ---\n")); colormap_notify (ev); break; case PropertyNotify: - PRINT_DEBUG ("--- Handling PropertyNotify ---\n"); + PRINT_DEBUG (("--- Handling PropertyNotify ---\n")); property_notify (ev); break; case MapRequest: - PRINT_DEBUG ("--- Handling MapRequest ---\n"); + PRINT_DEBUG (("--- Handling MapRequest ---\n")); map_request (ev); break; case KeyPress: - PRINT_DEBUG ("--- Handling KeyPress ---\n"); + PRINT_DEBUG (("--- Handling KeyPress ---\n")); key_press (ev); break; case UnmapNotify: - PRINT_DEBUG ("--- Handling UnmapNotify ---\n"); + PRINT_DEBUG (("--- Handling UnmapNotify ---\n")); unmap_notify (ev); break; case FocusOut: - PRINT_DEBUG ("--- Handling FocusOut ---\n"); + PRINT_DEBUG (("--- Handling FocusOut ---\n")); focus_change (&ev->xfocus); break; case FocusIn: - PRINT_DEBUG ("--- Handling FocusIn ---\n"); + PRINT_DEBUG (("--- Handling FocusIn ---\n")); focus_change (&ev->xfocus); break; case MappingNotify: - PRINT_DEBUG ("--- Handling MappingNotify ---\n"); + PRINT_DEBUG (("--- Handling MappingNotify ---\n")); mapping_notify( &ev->xmapping ); break; @@ -756,7 +756,7 @@ delegate_event (XEvent *ev) break; default: - PRINT_DEBUG ("--- Unknown event %d ---\n",- ev->type); + PRINT_DEBUG (("--- Unknown event %d ---\n",- ev->type)); } } @@ -768,7 +768,7 @@ handle_signals () { int i; - PRINT_DEBUG ("Alarm recieved.\n"); + PRINT_DEBUG (("Alarm recieved.\n")); /* Only hide the bar if it times out. */ if (defaults.bar_timeout > 0) @@ -793,7 +793,7 @@ handle_signals () if (kill_signalled > 0) { - PRINT_DEBUG ("Exiting\n"); + PRINT_DEBUG (("Exiting\n")); clean_up (); exit (EXIT_SUCCESS); } diff --git a/src/input.c b/src/input.c index b0ae865..1f46508 100644 --- a/src/input.c +++ b/src/input.c @@ -40,7 +40,7 @@ x11_mask_to_rp_mask (unsigned int mask) { unsigned int result = 0; - PRINT_DEBUG ("x11 mask = %x\n", mask); + PRINT_DEBUG (("x11 mask = %x\n", mask)); result |= mask & ControlMask ? RP_CONTROL_MASK:0; result |= mask & rp_modifier_info.meta_mod_mask ? RP_META_MASK:0; @@ -48,7 +48,7 @@ x11_mask_to_rp_mask (unsigned int mask) result |= mask & rp_modifier_info.hyper_mod_mask ? RP_HYPER_MASK:0; result |= mask & rp_modifier_info.super_mod_mask ? RP_SUPER_MASK:0; - PRINT_DEBUG ("rp mask = %x\n", mask); + PRINT_DEBUG (("rp mask = %x\n", mask)); return result; } @@ -61,7 +61,7 @@ rp_mask_to_x11_mask (unsigned int mask) { unsigned int result = 0; - PRINT_DEBUG ("rp mask = %x\n", mask); + PRINT_DEBUG (("rp mask = %x\n", mask)); result |= mask & RP_CONTROL_MASK ? ControlMask:0; result |= mask & RP_META_MASK ? rp_modifier_info.meta_mod_mask:0; @@ -69,7 +69,7 @@ rp_mask_to_x11_mask (unsigned int mask) result |= mask & RP_HYPER_MASK ? rp_modifier_info.hyper_mod_mask:0; result |= mask & RP_SUPER_MASK ? rp_modifier_info.super_mod_mask:0; - PRINT_DEBUG ("x11 mask = %x\n", mask); + PRINT_DEBUG (("x11 mask = %x\n", mask)); return result; } @@ -105,41 +105,41 @@ update_modifier_map () case XK_Meta_L: case XK_Meta_R: rp_modifier_info.meta_mod_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found Meta on %d\n", - rp_modifier_info.meta_mod_mask); + PRINT_DEBUG (("Found Meta on %d\n", + rp_modifier_info.meta_mod_mask)); break; case XK_Alt_L: case XK_Alt_R: rp_modifier_info.alt_mod_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found Alt on %d\n", - rp_modifier_info.alt_mod_mask); + PRINT_DEBUG (("Found Alt on %d\n", + rp_modifier_info.alt_mod_mask)); break; case XK_Super_L: case XK_Super_R: rp_modifier_info.super_mod_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found Super on %d\n", - rp_modifier_info.super_mod_mask); + PRINT_DEBUG (("Found Super on %d\n", + rp_modifier_info.super_mod_mask)); break; case XK_Hyper_L: case XK_Hyper_R: rp_modifier_info.hyper_mod_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found Hyper on %d\n", - rp_modifier_info.hyper_mod_mask); + PRINT_DEBUG (("Found Hyper on %d\n", + rp_modifier_info.hyper_mod_mask)); break; case XK_Num_Lock: rp_modifier_info.num_lock_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found NumLock on %d\n", - rp_modifier_info.num_lock_mask); + PRINT_DEBUG (("Found NumLock on %d\n", + rp_modifier_info.num_lock_mask)); break; case XK_Scroll_Lock: rp_modifier_info.scroll_lock_mask |= modmasks[row - 3]; - PRINT_DEBUG ("Found ScrollLock on %d\n", - rp_modifier_info.scroll_lock_mask); + PRINT_DEBUG (("Found ScrollLock on %d\n", + rp_modifier_info.scroll_lock_mask)); break; default: break; @@ -360,7 +360,7 @@ get_more_input (char *prompt, char *preinput) nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize); while (ch != XK_Return) { - PRINT_DEBUG ("key %ld\n", ch); + PRINT_DEBUG (("key %ld\n", ch)); if (ch == XK_BackSpace) { if (cur_len > 0) cur_len--; @@ -122,7 +122,7 @@ add_to_window_list (screen_info *s, Window w) new_window->hints = XAllocSizeHints (); new_window->colormap = DefaultColormap (dpy, s->screen_num); new_window->transient = XGetTransientForHint (dpy, new_window->w, &new_window->transient_for); - PRINT_DEBUG ("transient %d\n", new_window->transient); + PRINT_DEBUG (("transient %d\n", new_window->transient)); update_window_gravity (new_window); @@ -377,7 +377,7 @@ unhide_transient_for (rp_window *win) transient_for = find_window (win->transient_for); if (transient_for == NULL) { - PRINT_DEBUG ("Can't find transient_for for '%s'", win->name ); + PRINT_DEBUG (("Can't find transient_for for '%s'", win->name )); return; } @@ -386,7 +386,7 @@ unhide_transient_for (rp_window *win) set_frames_window (frame, transient_for); maximize (transient_for); - PRINT_DEBUG ("unhide transient window: %s\n", transient_for->name); + PRINT_DEBUG (("unhide transient window: %s\n", transient_for->name)); unhide_window_below (transient_for); @@ -417,13 +417,13 @@ hide_transient_for_between (rp_window *win, rp_window *last) transient_for = find_window (win->transient_for); if (transient_for == last) { - PRINT_DEBUG ("Can't find transient_for for '%s'", win->name ); + PRINT_DEBUG (("Can't find transient_for for '%s'", win->name )); return; } if (find_windows_frame (transient_for) == NULL) { - PRINT_DEBUG ("hide transient window: %s\n", transient_for->name); + PRINT_DEBUG (("hide transient window: %s\n", transient_for->name)); hide_window (transient_for); } @@ -478,8 +478,8 @@ set_active_window (rp_window *win) last_win = set_frames_window (win->scr->rp_current_frame, win); - if (last_win) PRINT_DEBUG ("last window: %s\n", window_name (last_win)); - PRINT_DEBUG ("new window: %s\n", window_name (win)); + 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); @@ -638,7 +638,7 @@ get_window_list (char *fmt, char *delim, struct sbuf *buffer, list_for_each_entry (w,&rp_mapped_window,node) { - PRINT_DEBUG ("%d-%s\n", w->number, window_name (w)); + PRINT_DEBUG (("%d-%s\n", w->number, window_name (w))); if (w == current_window()) *mark_start = strlen (sbuf_get (buffer)); @@ -113,7 +113,7 @@ xrealloc (void *ptr, size_t size) register void *value = realloc (ptr, size); if (value == 0) fatal ("Virtual memory exhausted"); - PRINT_DEBUG("realloc: %d\n", size); + PRINT_DEBUG (("realloc: %d\n", size)); return value; } @@ -216,7 +216,7 @@ chld_handler (int signum) if (pid <= 0) break; - PRINT_DEBUG("Child status: %d\n", WEXITSTATUS (status)); + PRINT_DEBUG(("Child status: %d\n", WEXITSTATUS (status))); /* Tell ratpoison about the CHLD signal. We are only interested in reporting commands that failed to execute. These processes @@ -270,7 +270,7 @@ set_sig_handler (int sig, void (*action)(int)) /* check setting for sig */ if (sigaction (sig, NULL, &act)) { - PRINT_ERROR ("Error %d fetching SIGALRM handler\n", errno ); + PRINT_ERROR (("Error %d fetching SIGALRM handler\n", errno )); } else { @@ -283,7 +283,7 @@ set_sig_handler (int sig, void (*action)(int)) act.sa_flags = 0; if (sigaction (sig, &act, NULL)) { - PRINT_ERROR ("Error %d setting SIGALRM handler\n", errno ); + PRINT_ERROR (("Error %d setting SIGALRM handler\n", errno )); } } } @@ -344,7 +344,7 @@ read_rc_file (FILE *file) if (*(line + strlen(line) - 1) == '\n') *(line + strlen(line) - 1) = '\0'; - PRINT_DEBUG ("rcfile line: %s\n", line); + PRINT_DEBUG (("rcfile line: %s\n", line)); /* do it */ if (*line != '#') @@ -378,7 +378,7 @@ read_startup_files () homedir = getenv ("HOME"); if (!homedir) { - PRINT_ERROR ("ratpoison: $HOME not set!?\n"); + PRINT_ERROR (("ratpoison: $HOME not set!?\n")); } else { @@ -388,12 +388,12 @@ read_startup_files () if ((fileptr = fopen (filename, "r")) == NULL) { /* we probably don't need to report this, its not an error */ - PRINT_DEBUG ("ratpoison: could not open %s\n", filename); + PRINT_DEBUG (("ratpoison: could not open %s\n", filename)); if ((fileptr = fopen ("/etc/ratpoisonrc", "r")) == NULL) { /* neither is this */ - PRINT_DEBUG ("ratpoison: could not open /etc/ratpoisonrc\n"); + PRINT_DEBUG (("ratpoison: could not open /etc/ratpoisonrc\n")); } } @@ -577,7 +577,7 @@ main (int argc, char *argv[]) /* Initialize the screens */ num_screens = ScreenCount (dpy); screens = (screen_info *)xmalloc (sizeof (screen_info) * num_screens); - PRINT_DEBUG ("%d screens.\n", num_screens); + PRINT_DEBUG (("%d screens.\n", num_screens)); for (i=0; i<num_screens; i++) { diff --git a/src/manage.c b/src/manage.c index 5306a1c..9c62a66 100644 --- a/src/manage.c +++ b/src/manage.c @@ -77,13 +77,13 @@ update_normal_hints (rp_window *win) /* Print debugging output for window hints. */ #ifdef DEBUG if (win->hints->flags & PMinSize) - PRINT_DEBUG ("minx: %d miny: %d\n", win->hints->min_width, win->hints->min_height); + PRINT_DEBUG (("minx: %d miny: %d\n", win->hints->min_width, win->hints->min_height)); if (win->hints->flags & PMaxSize) - PRINT_DEBUG ("maxx: %d maxy: %d\n", win->hints->max_width, win->hints->max_height); + PRINT_DEBUG (("maxx: %d maxy: %d\n", win->hints->max_width, win->hints->max_height)); if (win->hints->flags & PResizeInc) - PRINT_DEBUG ("incx: %d incy: %d\n", win->hints->width_inc, win->hints->height_inc); + PRINT_DEBUG (("incx: %d incy: %d\n", win->hints->width_inc, win->hints->height_inc)); #endif } @@ -99,13 +99,13 @@ get_wmname (Window w) if (!XGetWMName (dpy, w, &text)) { - PRINT_DEBUG ("I can't get the WMName.\n"); + PRINT_DEBUG (("I can't get the WMName.\n")); return NULL; } if (!XTextPropertyToStringList (&text, &name_list, &list_len)) { - PRINT_DEBUG ("Error retrieving TextList.\n"); + PRINT_DEBUG (("Error retrieving TextList.\n")); return NULL; } @@ -134,7 +134,7 @@ get_class_hints (Window w) if (class == NULL) { - PRINT_ERROR ("Not enough memory for WM_CLASS structure.\n"); + PRINT_ERROR (("Not enough memory for WM_CLASS structure.\n")); exit (EXIT_FAILURE); } @@ -305,7 +305,7 @@ scanwins(screen_info *s) Window dw1, dw2, *wins; XQueryTree(dpy, s->root, &dw1, &dw2, &wins, &nwins); - PRINT_DEBUG ("windows: %d\n", nwins); + PRINT_DEBUG (("windows: %d\n", nwins)); for (i = 0; i < nwins; i++) { @@ -320,7 +320,7 @@ scanwins(screen_info *s) win = add_to_window_list (s, wins[i]); - PRINT_DEBUG ("map_state: %d\n", attr.map_state); + PRINT_DEBUG (("map_state: %d\n", attr.map_state)); /* Collect mapped and iconized windows. */ if (attr.map_state == IsViewable @@ -466,8 +466,8 @@ maximize_transient (rp_window *win) /* Fit the window inside its frame (if it has one) */ if (frame) { - PRINT_DEBUG ("frame width=%d height=%d\n", - frame->width, frame->height); + PRINT_DEBUG (("frame width=%d height=%d\n", + frame->width, frame->height)); if (maxx + win->border * 2 > frame->width) maxx = frame->width - win->border * 2; if (maxy + win->border * 2 > frame->height) maxy = frame->height - win->border * 2; @@ -493,7 +493,7 @@ maximize_transient (rp_window *win) maxy = amount + win->height; } - PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy); + PRINT_DEBUG (("maxsize: %d %d\n", maxx, maxy)); win->width = maxx; win->height = maxy; @@ -531,8 +531,8 @@ maximize_normal (rp_window *win) /* Fit the window inside its frame (if it has one) */ if (frame) { - PRINT_DEBUG ("frame width=%d height=%d\n", - frame->width, frame->height); + PRINT_DEBUG (("frame width=%d height=%d\n", + frame->width, frame->height)); if (maxx > frame->width) maxx = frame->width - win->border * 2; if (maxy > frame->height) maxy = frame->height - win->border * 2; @@ -558,7 +558,7 @@ maximize_normal (rp_window *win) maxy = amount + win->height; } - PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy); + PRINT_DEBUG (("maxsize: %d %d\n", maxx, maxy)); win->width = maxx; win->height = maxy; @@ -581,8 +581,8 @@ maximize (rp_window *win) /* Reposition the window. */ move_window (win); - PRINT_DEBUG ("Resizing window '%s' to x:%d y:%d w:%d h:%d\n", window_name (win), - win->x, win->y, win->width, win->height); + PRINT_DEBUG (("Resizing window '%s' to x:%d y:%d w:%d h:%d\n", window_name (win), + win->x, win->y, win->width, win->height)); /* Actually do the maximizing. */ @@ -631,7 +631,7 @@ force_maximize (rp_window *win) void map_window (rp_window *win) { - PRINT_DEBUG ("Mapping the unmapped window %s\n", window_name (win)); + PRINT_DEBUG (("Mapping the unmapped window %s\n", window_name (win))); /* Fill in the necessary data about the window */ update_window_information (win); @@ -715,7 +715,7 @@ withdraw_window (rp_window *win) { if (win == NULL) return; - PRINT_DEBUG ("withdraw_window on '%s'\n", window_name (win)); + PRINT_DEBUG (("withdraw_window on '%s'\n", window_name (win))); /* Give back the window number. the window will get another one, if it is remapped. */ diff --git a/src/ratpoison.h b/src/ratpoison.h index 99b6409..ca2d169 100644 --- a/src/ratpoison.h +++ b/src/ratpoison.h @@ -31,32 +31,26 @@ #include <stdarg.h> #include <X11/Xlib.h> -/* Some error reporting macros */ -#define PRE_PRINT_LOCATION fprintf (stderr, "%s:%s():%d: ", __FILE__, __FUNCTION__, __LINE__); +/* Helper macro for error and debug reporting. */ +#define PRINT_LINE(type) printf (PACKAGE ":%s:%d: %s: ",__FILE__, __LINE__, #type) -/* FIXME: Some preprocessors don't have variable args. In that case - they don't get error or debugging output. */ -#ifdef HAVE_VARARG_MACROS +/* Error and debug reporting macros. */ +#define PRINT_ERROR(fmt) \ +do { \ + PRINT_LINE (error); \ + printf fmt; \ +} while (0) -#define PRINT_ERROR(format, args...) \ - { fprintf (stderr, PACKAGE ":error -- "); PRE_PRINT_LOCATION; fprintf (stderr, format, ## args); } - -/* Some debugging macros */ #ifdef DEBUG -# define PRINT_DEBUG(format, args...) \ - { fprintf (stderr, PACKAGE ":debug -- "); PRE_PRINT_LOCATION; fprintf (stderr, format, ## args); } +#define PRINT_DEBUG(fmt) \ +do { \ + PRINT_LINE (debug); \ + printf fmt; \ +} while (0) #else -# define PRINT_DEBUG(format, args...) +#define PRINT_DEBUG(fmt) #endif /* DEBUG */ -#else /* !HAVE_VARARG_MACROS */ - -#define PRINT_ERROR (void) -#define PRINT_DEBUG (void) - -#endif /* HAVE_VARARG_MACROS */ - - extern XGCValues gv; #include "conf.h" diff --git a/src/split.c b/src/split.c index 68f6cfb..1d276c4 100644 --- a/src/split.c +++ b/src/split.c @@ -287,7 +287,7 @@ split_frame (rp_window_frame *frame, int way, int pixels) win = find_window_for_frame (new_frame); if (win) { - PRINT_DEBUG ("Found a window for the frame!\n"); + PRINT_DEBUG (("Found a window for the frame!\n")); set_frames_window (new_frame, win); @@ -297,7 +297,7 @@ split_frame (rp_window_frame *frame, int way, int pixels) } else { - PRINT_DEBUG ("No window fits the frame.\n"); + PRINT_DEBUG (("No window fits the frame.\n")); set_frames_window (new_frame, NULL); } @@ -655,7 +655,7 @@ remove_frame (rp_window_frame *frame) s = frames_screen (frame); area = total_frame_area(s); - PRINT_DEBUG ("Total Area: %d\n", area); + PRINT_DEBUG (("Total Area: %d\n", area)); list_del (&frame->node); hide_window (frame->win); @@ -668,11 +668,11 @@ remove_frame (rp_window_frame *frame) if (cur->win) { - PRINT_DEBUG ("Trying frame containing window '%s'\n", window_name (cur->win)); + PRINT_DEBUG (("Trying frame containing window '%s'\n", window_name (cur->win))); } else { - PRINT_DEBUG ("Trying some empty frame\n"); + PRINT_DEBUG (("Trying some empty frame\n")); } /* Backup the frame */ @@ -686,8 +686,8 @@ remove_frame (rp_window_frame *frame) cur->height += frame->height; } - PRINT_DEBUG ("Attempting vertical Frame y=%d height=%d\n", cur->y, cur->height); - PRINT_DEBUG ("New Total Area: %d\n", total_frame_area(s)); + PRINT_DEBUG (("Attempting vertical Frame y=%d height=%d\n", cur->y, cur->height)); + PRINT_DEBUG (("New Total Area: %d\n", total_frame_area(s))); /* If the area is bigger than before, the frame takes up too much space. If the current frame and the deleted frame DON'T @@ -698,14 +698,14 @@ remove_frame (rp_window_frame *frame) frame but obviously didn't fit. */ if (total_frame_area(s) > area || !frames_overlap (cur, frame) || frame_overlaps (cur)) { - PRINT_DEBUG ("Didn't fit vertically\n"); + PRINT_DEBUG (("Didn't fit vertically\n")); /* Restore the current window's frame */ memcpy (cur, &tmp_frame, sizeof (rp_window_frame)); } else { - PRINT_DEBUG ("It fit vertically!!\n"); + PRINT_DEBUG (("It fit vertically!!\n")); /* update the frame backup */ memcpy (&tmp_frame, cur, sizeof (rp_window_frame)); @@ -720,20 +720,20 @@ remove_frame (rp_window_frame *frame) cur->width += frame->width; } - PRINT_DEBUG ("Attempting horizontal Frame x=%d width=%d\n", cur->x, cur->width); - PRINT_DEBUG ("New Total Area: %d\n", total_frame_area(s)); + PRINT_DEBUG (("Attempting horizontal Frame x=%d width=%d\n", cur->x, cur->width)); + PRINT_DEBUG (("New Total Area: %d\n", total_frame_area(s))); /* Same test as the vertical test, above. */ if (total_frame_area(s) > area || !frames_overlap (cur, frame) || frame_overlaps (cur)) { - PRINT_DEBUG ("Didn't fit horizontally\n"); + PRINT_DEBUG (("Didn't fit horizontally\n")); /* Restore the current window's frame */ memcpy (cur, &tmp_frame, sizeof (rp_window_frame)); } else { - PRINT_DEBUG ("It fit horizontally!!\n"); + PRINT_DEBUG (("It fit horizontally!!\n")); fits = 1; } |