hide focus debugging messages

This commit is contained in:
Dana Jansens 2007-04-21 21:04:35 +00:00
parent d713bdf462
commit 3f2d342de8
6 changed files with 79 additions and 46 deletions

View file

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
debug.c for the Openbox window manager debug.c for the Openbox window manager
Copyright (c) 2003 Ben Jansens Copyright (c) 2003-2007 Dana Jansens
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -16,6 +16,8 @@
See the COPYING file for a copy of the GNU General Public License. See the COPYING file for a copy of the GNU General Public License.
*/ */
#include "debug.h"
#include <glib.h> #include <glib.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@ -38,3 +40,24 @@ void ob_debug(const gchar *a, ...)
va_end(vl); va_end(vl);
} }
} }
static gboolean enabled_types[OB_DEBUG_TYPE_NUM] = {FALSE};
void ob_debug_enable(ObDebugType type, gboolean enable)
{
g_assert(type < OB_DEBUG_TYPE_NUM);
enabled_types[type] = enable;
}
void ob_debug_type(ObDebugType type, const gchar *a, ...)
{
va_list vl;
g_assert(type < OB_DEBUG_TYPE_NUM);
if (show && enabled_types[type]) {
va_start(vl, a);
vfprintf(stderr, a, vl);
va_end(vl);
}
}

View file

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
debug.h for the Openbox window manager debug.h for the Openbox window manager
Copyright (c) 2003 Ben Jansens Copyright (c) 2003-2007 Dana Jansens
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -25,4 +25,13 @@ void ob_debug_show_output(gboolean enable);
void ob_debug(const gchar *a, ...); void ob_debug(const gchar *a, ...);
typedef enum {
OB_DEBUG_FOCUS,
OB_DEBUG_TYPE_NUM
} ObDebugType;
void ob_debug_type(ObDebugType type, const gchar *a, ...);
void ob_debug_enable(ObDebugType type, gboolean enable);
#endif #endif

View file

@ -440,27 +440,28 @@ static void event_process(const XEvent *ec, gpointer data)
} }
} }
#if 1 /* focus debugging stuff */
if (e->type == FocusIn || e->type == FocusOut) { if (e->type == FocusIn || e->type == FocusOut) {
gint mode = e->xfocus.mode; gint mode = e->xfocus.mode;
gint detail = e->xfocus.detail; gint detail = e->xfocus.detail;
Window window = e->xfocus.window; Window window = e->xfocus.window;
if (detail == NotifyVirtual) { if (detail == NotifyVirtual) {
ob_debug("FOCUS %s NOTIFY VIRTUAL window 0x%x\n", ob_debug_type(OB_DEBUG_FOCUS,
(e->type == FocusIn ? "IN" : "OUT"), window); "FOCUS %s NOTIFY VIRTUAL window 0x%x\n",
(e->type == FocusIn ? "IN" : "OUT"), window);
} }
else if (detail == NotifyNonlinearVirtual) { else if (detail == NotifyNonlinearVirtual) {
ob_debug("FOCUS %s NOTIFY NONLINVIRTUAL window 0x%x\n", ob_debug_type(OB_DEBUG_FOCUS,
(e->type == FocusIn ? "IN" : "OUT"), window); "FOCUS %s NOTIFY NONLINVIRTUAL window 0x%x\n",
(e->type == FocusIn ? "IN" : "OUT"), window);
} }
else else
ob_debug("UNKNOWN FOCUS %s (d %d, m %d) window 0x%x\n", ob_debug_type(OB_DEBUG_FOCUS,
(e->type == FocusIn ? "IN" : "OUT"), "UNKNOWN FOCUS %s (d %d, m %d) window 0x%x\n",
detail, mode, window); (e->type == FocusIn ? "IN" : "OUT"),
detail, mode, window);
} }
#endif
event_set_curtime(e); event_set_curtime(e);
event_hack_mods(e); event_hack_mods(e);
@ -678,18 +679,18 @@ static void event_handle_client(ObClient *client, XEvent *e)
if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) { if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
/* There is no FocusIn, this means focus went to a window that /* There is no FocusIn, this means focus went to a window that
is not being managed, or a window on another screen. */ is not being managed, or a window on another screen. */
ob_debug("Focus went to a black hole !\n"); ob_debug_type(OB_DEBUG_FOCUS, "Focus went to a black hole !\n");
} else if (ce.xany.window == e->xany.window) { } else if (ce.xany.window == e->xany.window) {
/* If focus didn't actually move anywhere, there is nothing to do*/ /* If focus didn't actually move anywhere, there is nothing to do*/
break; break;
} else if (ce.xfocus.detail == NotifyPointerRoot || } else if (ce.xfocus.detail == NotifyPointerRoot ||
ce.xfocus.detail == NotifyDetailNone) { ce.xfocus.detail == NotifyDetailNone) {
ob_debug("Focus went to root\n"); ob_debug_type(OB_DEBUG_FOCUS, "Focus went to root\n");
/* Focus has been reverted to the root window or nothing, so fall /* Focus has been reverted to the root window or nothing, so fall
back to something other than the window which just had it. */ back to something other than the window which just had it. */
focus_fallback(FALSE); focus_fallback(FALSE);
} else if (ce.xfocus.detail == NotifyInferior) { } else if (ce.xfocus.detail == NotifyInferior) {
ob_debug("Focus went to parent\n"); ob_debug_type(OB_DEBUG_FOCUS, "Focus went to parent\n");
/* Focus has been reverted to parent, which is our frame window, /* Focus has been reverted to parent, which is our frame window,
or the root window, so fall back to something other than the or the root window, so fall back to something other than the
window which had it. */ window which had it. */
@ -701,8 +702,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
if (ed.ignored) { if (ed.ignored) {
/* The FocusIn was ignored, this means it was on a window /* The FocusIn was ignored, this means it was on a window
that isn't a client. */ that isn't a client. */
ob_debug("Focus went to an unmanaged window 0x%x !\n", ob_debug_type(OB_DEBUG_FOCUS,
ce.xfocus.window); "Focus went to an unmanaged window 0x%x !\n",
ce.xfocus.window);
focus_fallback(TRUE); focus_fallback(TRUE);
} }
} }
@ -780,21 +782,19 @@ static void event_handle_client(ObClient *client, XEvent *e)
if (e->xcrossing.mode == NotifyGrab || if (e->xcrossing.mode == NotifyGrab ||
e->xcrossing.mode == NotifyUngrab) e->xcrossing.mode == NotifyUngrab)
{ {
#ifdef DEBUG_FOCUS ob_debug_type(OB_DEBUG_FOCUS,
ob_debug("%sNotify mode %d detail %d on %lx IGNORED\n", "%sNotify mode %d detail %d on %lx IGNORED\n",
(e->type == EnterNotify ? "Enter" : "Leave"), (e->type == EnterNotify ? "Enter" : "Leave"),
e->xcrossing.mode, e->xcrossing.mode,
e->xcrossing.detail, client?client->window:0); e->xcrossing.detail, client?client->window:0);
#endif
} else { } else {
#ifdef DEBUG_FOCUS ob_debug_type(OB_DEBUG_FOCUS,
ob_debug("%sNotify mode %d detail %d on %lx, " "%sNotify mode %d detail %d on %lx, "
"focusing window: %d\n", "focusing window: %d\n",
(e->type == EnterNotify ? "Enter" : "Leave"), (e->type == EnterNotify ? "Enter" : "Leave"),
e->xcrossing.mode, e->xcrossing.mode,
e->xcrossing.detail, (client?client->window:0), e->xcrossing.detail, (client?client->window:0),
!nofocus); !nofocus);
#endif
if (!nofocus && config_focus_follow) if (!nofocus && config_focus_follow)
event_enter_client(client); event_enter_client(client);
} }
@ -910,14 +910,14 @@ static void event_handle_client(ObClient *client, XEvent *e)
} }
break; break;
case UnmapNotify: case UnmapNotify:
ob_debug("UnmapNotify for window 0x%x eventwin 0x%x sendevent %d "
"ignores left %d\n",
client->window, e->xunmap.event, e->xunmap.from_configure,
client->ignore_unmaps);
if (client->ignore_unmaps) { if (client->ignore_unmaps) {
client->ignore_unmaps--; client->ignore_unmaps--;
break; break;
} }
ob_debug("UnmapNotify for window 0x%x eventwin 0x%x sendevent %d "
"ignores left %d\n",
client->window, e->xunmap.event, e->xunmap.from_configure,
client->ignore_unmaps);
client_unmanage(client); client_unmanage(client);
break; break;
case DestroyNotify: case DestroyNotify:

View file

@ -158,18 +158,16 @@ void focus_set_client(ObClient *client)
Window active; Window active;
ObClient *old; ObClient *old;
#ifdef DEBUG_FOCUS ob_debug_type(OB_DEBUG_FOCUS,
ob_debug("focus_set_client 0x%lx\n", client ? client->window : 0); "focus_set_client 0x%lx\n", client ? client->window : 0);
#endif
/* uninstall the old colormap, and install the new one */ /* uninstall the old colormap, and install the new one */
screen_install_colormap(focus_client, FALSE); screen_install_colormap(focus_client, FALSE);
screen_install_colormap(client, TRUE); screen_install_colormap(client, TRUE);
if (client == NULL) { if (client == NULL) {
#ifdef DEBUG_FOCUS ob_debug_type(OB_DEBUG_FOCUS, "actively focusing NONWINDOW\n");
ob_debug("actively focusing NONWINDOW\n");
#endif
/* when nothing will be focused, send focus to the backup target */ /* when nothing will be focused, send focus to the backup target */
XSetInputFocus(ob_display, screen_support_win, RevertToNone, XSetInputFocus(ob_display, screen_support_win, RevertToNone,
event_curtime); event_curtime);
@ -207,13 +205,13 @@ ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old)
ObClient *target = NULL; ObClient *target = NULL;
ObClient *desktop = NULL; ObClient *desktop = NULL;
ob_debug("trying pointer stuff\n"); ob_debug_type(OB_DEBUG_FOCUS, "trying pointer stuff\n");
if (config_focus_follow && !config_focus_last) if (config_focus_follow && !config_focus_last)
{ {
if ((target = client_under_pointer())) if ((target = client_under_pointer()))
if (allow_refocus || target != old) if (allow_refocus || target != old)
if (client_normal(target) && client_can_focus(target)) { if (client_normal(target) && client_can_focus(target)) {
ob_debug("found in pointer stuff\n"); ob_debug_type(OB_DEBUG_FOCUS, "found in pointer stuff\n");
return target; return target;
} }
} }
@ -232,12 +230,12 @@ ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old)
} }
#endif #endif
ob_debug("trying omnipresentness\n"); ob_debug_type(OB_DEBUG_FOCUS, "trying omnipresentness\n");
if (allow_refocus && old && old->desktop == DESKTOP_ALL) if (allow_refocus && old && old->desktop == DESKTOP_ALL)
return old; return old;
ob_debug("trying the focus order\n"); ob_debug_type(OB_DEBUG_FOCUS, "trying the focus order\n");
for (it = focus_order; it; it = g_list_next(it)) for (it = focus_order; it; it = g_list_next(it))
if (allow_refocus || it->data != old) { if (allow_refocus || it->data != old) {
ObClient *c = it->data; ObClient *c = it->data;
@ -257,7 +255,7 @@ ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old)
!c->iconic) !c->iconic)
{ {
if (client_normal(c)) { if (client_normal(c)) {
ob_debug("found in focus order\n"); ob_debug_type(OB_DEBUG_FOCUS, "found in focus order\n");
return it->data; return it->data;
} else if (c->type == OB_CLIENT_TYPE_DESKTOP && !desktop) } else if (c->type == OB_CLIENT_TYPE_DESKTOP && !desktop)
desktop = c; desktop = c;

View file

@ -100,6 +100,9 @@ gint main(gint argc, gchar **argv)
{ {
#ifdef DEBUG #ifdef DEBUG
ob_debug_show_output(TRUE); ob_debug_show_output(TRUE);
#ifdef DEBUG_FOCUS
ob_debug_enable(OB_DEBUG_FOCUS, TRUE);
#endif
#endif #endif
state = OB_STATE_STARTING; state = OB_STATE_STARTING;

View file

@ -166,7 +166,7 @@ gboolean screen_annex()
CopyFromParent, InputOutput, CopyFromParent, InputOutput,
CopyFromParent, CopyFromParent,
CWOverrideRedirect, &attrib); CWOverrideRedirect, &attrib);
XMapRaised(ob_display, screen_support_win); XMapWindow(ob_display, screen_support_win);
if (!replace_wm()) { if (!replace_wm()) {
XDestroyWindow(ob_display, screen_support_win); XDestroyWindow(ob_display, screen_support_win);