From 8a9a4aba7769b30689e03f43cc668cbe4978293a Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 15 Dec 2002 21:59:38 +0000 Subject: [PATCH] get window name before anything else. 2002-12-15 Havoc Pennington * src/window.c (meta_window_new): get window name before anything else. * src/xprops.c (validate_or_free_results): instead of suggesting how to get window title etc. with xprop, just print out the window title. much better. --- ChangeLog | 9 +++++++++ src/window.c | 7 +++++-- src/xprops.c | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index deb3d93aa..bedf4bdcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-12-15 Havoc Pennington + + * src/window.c (meta_window_new): get window name before anything + else. + + * src/xprops.c (validate_or_free_results): instead of suggesting + how to get window title etc. with xprop, just print out the + window title. much better. + 2002-12-15 Havoc Pennington * src/xprops.c (validate_or_free_results): make the warning about diff --git a/src/window.c b/src/window.c index a79e6001f..82039e6aa 100644 --- a/src/window.c +++ b/src/window.c @@ -436,11 +436,14 @@ meta_window_new (MetaDisplay *display, window->initial_workspace = 0; /* not used */ meta_display_register_x_window (display, &window->xwindow, window); - /* Fill these in the order we want them to be gotten */ + /* Fill these in the order we want them to be gotten. + * we want to get window name and class first + * so we can use them in error messages and such. + */ i = 0; + initial_props[i++] = display->atom_net_wm_name; initial_props[i++] = display->atom_wm_client_machine; initial_props[i++] = display->atom_net_wm_pid; - initial_props[i++] = display->atom_net_wm_name; initial_props[i++] = XA_WM_NAME; initial_props[i++] = display->atom_net_wm_icon_name; initial_props[i++] = XA_WM_ICON_NAME; diff --git a/src/xprops.c b/src/xprops.c index 06ea0e19b..88f7e17d4 100644 --- a/src/xprops.c +++ b/src/xprops.c @@ -87,6 +87,7 @@ from The Open Group. #include "metacity-Xatomtype.h" #include #include +#include "window.h" typedef struct { @@ -109,7 +110,11 @@ validate_or_free_results (GetPropertyResults *results, char *type_name; char *expected_name; char *prop_name; - + const char *title; + const char *res_class; + const char *res_name; + MetaWindow *w; + if (expected_format == results->format && expected_type == results->type && (!must_have_items || results->n_items > 0)) @@ -121,14 +126,38 @@ validate_or_free_results (GetPropertyResults *results, prop_name = XGetAtomName (results->display->xdisplay, results->xatom); meta_error_trap_pop (results->display, TRUE); - meta_warning (_("Window 0x%lx has property %s\nthat was expected to have type %s format %d\nand actually has type %s format %d n_items %d.\nThis is most likely an application bug.\nUse \"xprop -id 0x%lx\" to print all properties on the problematic window.\nThe _NET_WM_NAME or WM_NAME or WM_CLASS properties should identify the application.\n"), + w = meta_display_lookup_x_window (results->display, results->xwindow); + + if (w != NULL) + { + title = w->title; + res_class = w->res_class; + res_name = w->res_name; + } + else + { + title = NULL; + res_class = NULL; + res_name = NULL; + } + + if (title == NULL) + title = "unknown"; + + if (res_class == NULL) + res_class = "unknown"; + + if (res_name == NULL) + res_name = "unknown"; + + meta_warning (_("Window 0x%lx has property %s\nthat was expected to have type %s format %d\nand actually has type %s format %d n_items %d.\nThis is most likely an application bug not a window manager bug.\nThe window has title=\"%s\" class=\"%s\" name=\"%s\"\n"), results->xwindow, prop_name ? prop_name : "(bad atom)", expected_name ? expected_name : "(bad atom)", expected_format, type_name ? type_name : "(bad atom)", results->format, (int) results->n_items, - results->xwindow); + title, res_class, res_name); if (type_name) XFree (type_name);