[BeFree CVS] panel/src ChangeLog,1.4,1.5 x11panelwindow.cpp,1.2,1.3 xutils.cpp,1.3,1.4 xutils.h,1.2,
Status: Planning
Brought to you by:
plfiorini
|
From: Pier L. F. <plf...@us...> - 2005-01-07 03:28:05
|
Update of /cvsroot/befree/panel/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10463 Modified Files: ChangeLog x11panelwindow.cpp xutils.cpp xutils.h Log Message: First, get leader icon Index: xutils.cpp =================================================================== RCS file: /cvsroot/befree/panel/src/xutils.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- xutils.cpp 7 Jan 2005 02:44:54 -0000 1.3 +++ xutils.cpp 7 Jan 2005 03:27:54 -0000 1.4 @@ -33,6 +33,7 @@ #include <QRect> #include <QSize> #include <QList> +#include <QIcon> #include <QBitmap> #include <QImage> @@ -573,11 +574,30 @@ return true; } +QPixmap xutils_get_leader_icon(Window leader) +{ + Atom atom = XInternAtom(qt_xdisplay(), "_NET_WM_ICON_NAME", False); + + QString iconName = xutils_get_utf8_string_atom(leader, atom); + if (!iconName.isEmpty()) + { + QIcon icon = BNeptuneXDG::iconTheme()->loadIcon(iconName); + QPixmap retval = icon.pixmap(Qt::LargeIconSize, QIcon::Normal); + + // Return pixmap only if it's not null + if (!retval.isNull()) + return retval; + } + + return xutils_get_window_icon(leader); +} + QPixmap xutils_get_window_icon(Window win) { WindowIcons icons; QPixmap retval; + // Search first available icon if (xutils_get_icons(win, &icons)) { for (Q_INT32 i = 0; i < icons.size(); ++i) @@ -608,56 +628,58 @@ } } } - else - { - // Try with window hints - XWMHints *h = XGetWMHints(qt_xdisplay(), win); - Pixmap pixmap_p = None, bitmap_p = None; - if (h->flags & IconPixmapHint) - pixmap_p = h->icon_pixmap; - if (h->flags & IconMaskHint) - bitmap_p = h->icon_mask; + // Try with window hints + XWMHints *h = XGetWMHints(qt_xdisplay(), win); + Pixmap pixmap_p = None, bitmap_p = None; - XFree(h); + // Return immediately if we have no hints + if (!h) + return retval; - if (pixmap_p != None) + if (h->flags & IconPixmapHint) + pixmap_p = h->icon_pixmap; + if (h->flags & IconMaskHint) + bitmap_p = h->icon_mask; + + XFree(h); + + if (pixmap_p != None) + { + Window root; + Q_INT32 x, y; + Q_UINT32 w = 0, h = 0, border, depth; + + XGetGeometry(qt_xdisplay(), pixmap_p, &root, &x, &y, &w, &h, &border, &depth); + + if ((w > 0) && (h > 0)) { - Window root; - Q_INT32 x, y; - Q_UINT32 w = 0, h = 0, border, depth; + // Create pixmap + QPixmap pixmap = QPixmap(w, h, depth); + pixmap.detach(); - XGetGeometry(qt_xdisplay(), pixmap_p, &root, &x, &y, &w, &h, &border, &depth); + // Copy X11 pixmap into QPixmap + XCopyArea(qt_xdisplay(), pixmap_p, pixmap.handle(), + qt_xget_temp_gc(qt_xscreen(), depth==1), + 0, 0, w, h, 0, 0); - if ((w > 0) && (h > 0)) + if (bitmap_p != None) { - // Create pixmap - QPixmap pixmap = QPixmap(w, h, depth); - pixmap.detach(); + QBitmap bitmap(w, h); - // Copy X11 pixmap into QPixmap - XCopyArea(qt_xdisplay(), pixmap_p, pixmap.handle(), - qt_xget_temp_gc(qt_xscreen(), depth==1), + // Copy X11 mask into QBitmap + XCopyArea(qt_xdisplay(), bitmap_p, bitmap.handle(), + qt_xget_temp_gc(qt_xscreen(), true), 0, 0, w, h, 0, 0); + pixmap.setMask(bitmap); + } - if (bitmap_p != None) - { - QBitmap bitmap(w, h); - - // Copy X11 mask into QBitmap - XCopyArea(qt_xdisplay(), bitmap_p, bitmap.handle(), - qt_xget_temp_gc(qt_xscreen(), true), - 0, 0, w, h, 0, 0); - pixmap.setMask(bitmap); - } - - if (!pixmap.isNull()) - { - if ((w != 48) && (h != 48)) - retval = pixmap.scale(48, 48); - else - retval = pixmap; - } + if (!pixmap.isNull()) + { + if ((w != 48) && (h != 48)) + retval = pixmap.scale(48, 48); + else + retval = pixmap; } } } Index: xutils.h =================================================================== RCS file: /cvsroot/befree/panel/src/xutils.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- xutils.h 7 Jan 2005 02:43:53 -0000 1.2 +++ xutils.h 7 Jan 2005 03:27:54 -0000 1.3 @@ -25,6 +25,8 @@ #include <qglobal.h> +#include <libneptune-xdg/bneptunexdg.h> + #ifdef Q_WS_X11 #include <QString> @@ -50,6 +52,7 @@ Window xutils_get_group_leader(Window win); QString xutils_get_name(Window win); QString xutils_get_class(Window win); +QPixmap xutils_get_leader_icon(Window leader); QPixmap xutils_get_window_icon(Window win); bool xutils_skip_taskbar(Window win); Index: x11panelwindow.cpp =================================================================== RCS file: /cvsroot/befree/panel/src/x11panelwindow.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- x11panelwindow.cpp 7 Jan 2005 02:43:53 -0000 1.2 +++ x11panelwindow.cpp 7 Jan 2005 03:27:54 -0000 1.3 @@ -68,6 +68,9 @@ if (!xutils_get_client_list(&list, &nitems)) return tasks; + QString name; + QPixmap icon; + for (Q_INT32 i = 0; i < nitems; i++) { Window win = list[i]; @@ -80,11 +83,12 @@ continue; // Get window name and icon - QString name = xutils_get_name(win); - QPixmap icon = xutils_get_window_icon(win); + name = xutils_get_name(win); if (has_task(tasks, leader, &task)) { + icon = xutils_get_window_icon(win); + // Add this window to its task TaskWindow taskWin(task, name, icon); taskWin.setId(win); @@ -92,6 +96,8 @@ } else { + icon = xutils_get_leader_icon(leader); + // Create a new task task = new Task; task->setId(leader); Index: ChangeLog =================================================================== RCS file: /cvsroot/befree/panel/src/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ChangeLog 7 Jan 2005 02:43:53 -0000 1.4 +++ ChangeLog 7 Jan 2005 03:27:54 -0000 1.5 @@ -1,6 +1,11 @@ 2005-01-07 Pier Luigi Fiorini <pie...@mo...> * x11panelwindow.cpp (X11PanelWindow::tasksList): + First check for leader icon name. + + * xutils.cpp (xutils_get_leader_icon): Get leader icon. + + * x11panelwindow.cpp (X11PanelWindow::tasksList): Skip if window has "skip taskbar". * xutils.cpp (xutils_get_atom_list): Get atom list. |