From a3a5cbd125cdb3c65a530513ec30b80892d795e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 12 Feb 2011 01:18:32 +0000 Subject: [PATCH] [GB.DESKTOP] * BUG: Desktop.FindWindow() should work correctly now. * BUG: Reading X11 properties on 64 bits systems should work in all cases now. git-svn-id: svn://localhost/gambas/trunk@3557 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.desktop/src/desktop.c | 3 +-- gb.desktop/src/gb.desktop/.settings | 2 +- gb.desktop/src/x11.c | 15 ++++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gb.desktop/src/desktop.c b/gb.desktop/src/desktop.c index 796b37315..648113c05 100644 --- a/gb.desktop/src/desktop.c +++ b/gb.desktop/src/desktop.c @@ -97,11 +97,10 @@ BEGIN_METHOD(CDESKTOP_find, GB_STRING title; GB_STRING klass; GB_STRING role) for (i = 0; i < count; i++) { win = windows[i]; - //qDebug("win = %08X", win); + if (ltitle) { X11_get_window_title(win, &prop, &lprop); - //qDebug("title = %.*s", lprop, prop); if (!GB.MatchString(title, ltitle, prop, lprop)) continue; } diff --git a/gb.desktop/src/gb.desktop/.settings b/gb.desktop/src/gb.desktop/.settings index 9a69543e3..f1df9fe46 100644 --- a/gb.desktop/src/gb.desktop/.settings +++ b/gb.desktop/src/gb.desktop/.settings @@ -13,7 +13,7 @@ SearchString=True [OpenFile] Active=1 -File[1]=".src/Desktop.class:173.20" +File[1]=".src/Desktop.class:92.2" File[2]=".src/Main.module:8.2" File[3]=".src/_DesktopPasswords.class:65.56" File[4]=".src/Form1.form" diff --git a/gb.desktop/src/x11.c b/gb.desktop/src/x11.c index 8802cab5f..2e43edbdd 100644 --- a/gb.desktop/src/x11.c +++ b/gb.desktop/src/x11.c @@ -135,7 +135,7 @@ char *X11_get_property(Window wid, Atom prop, Atom *type, int *format, int *pcou *pcount = 0; - if (XGetWindowProperty(_display, wid, prop, 0, PROPERTY_START_READ / sizeof(long), + if (XGetWindowProperty(_display, wid, prop, 0, PROPERTY_START_READ / sizeof(int32_t), False, AnyPropertyType, type, format, &count, &after, &data) != Success) return NULL; @@ -148,17 +148,17 @@ char *X11_get_property(Window wid, Atom prop, Atom *type, int *format, int *pcou _property_value = GB.NewString((char *)data, count * size); XFree(data); - offset = count * size / sizeof(long); + offset = count * size / sizeof(int32_t); while (after) { - if (XGetWindowProperty(_display, wid, prop, offset, PROPERTY_NEXT_READ / sizeof(long), + if (XGetWindowProperty(_display, wid, prop, offset, PROPERTY_NEXT_READ / sizeof(int32_t), False, AnyPropertyType, type, format, &count, &after, &data) != Success) return NULL; *pcount += count; - offset += count * size / sizeof(long); + offset += count * size / sizeof(int32_t); GB.AddString(&_property_value, (char *)data, count * size); XFree(data); @@ -503,7 +503,12 @@ void X11_find_windows(Window **window_list, int *count) void X11_get_window_title(Window window, char **result, int *length) { - *result = get_property(window, XA_WM_NAME, length); + static Atom _net_wm_name = 0; + + if (!_net_wm_name) + _net_wm_name = XInternAtom(_display, "_NET_WM_NAME", True); + + *result = get_property(window, _net_wm_name, length); } void X11_get_window_class(Window window, char **result, int *length)