davidedmundson / xembed-sni-proxy

Convert XEmbed system tray icons to SNI icons
GNU General Public License v2.0
32 stars 6 forks source link

no image fetched from embedded client :( #3

Open cpfeiffer opened 9 years ago

cpfeiffer commented 9 years ago

Huge thanks for working on this, much appreciated.

I have to use IBM Notes/Sametime, which display a tray icon for new mails and the Sametime online status. xembed-sni-proxy does reserve some space for the two and interacting with the context menu works great. However it doesn't display an icon for them.

The output from xembed-sni-proxy is "no image fetched from embedded client :("

ghost commented 9 years ago

Same issue here. Using package from aur (archlinux).

davidedmundson commented 9 years ago

can you tell me how to get sametime in Arch so I can reproduce?

ghost commented 9 years ago

Its just a digital clock widget. This is all widgets i got: application dashboard, icons-only taskmanager, folder view, folder view, pager, resource monitor, weather widget, system tray, spacer, digital clock.

davidedmundson commented 9 years ago

Huh? As in how do I get the app which shows the "Sametime online status." from the first post.

ghost commented 9 years ago

Sorry, already forgot that i read about "sametime" in the first post and misinterpreted it. My bad, sorry. Though this problem occurs for me for remmina/hexchat/pidgin too.

davidedmundson commented 9 years ago

Can I have the output of

qdbus org.kde.KWin /KWin supportInformation

ghost commented 9 years ago
~/bin % qdbus org.kde.KWin /KWin supportInformation
KWin Support Information:
The following information should be used when requesting support on e.g. http://forum.kde.org.
It provides information about the currently running instance, which options are used,
what OpenGL driver and which effects are running.
Please post the information provided underneath this introductory text to a paste bin service
like http://paste.kde.org instead of pasting into support threads.

==========================

Version
=======
KWin version: 5.4.1
Qt Version: 5.5.0
Qt compile version: 5.5.0
XCB compile version: 1.11.1

Operation Mode: X11 only

Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_WAYLAND: yes
HAVE_WAYLAND_EGL: yes
HAVE_WAYLAND_CURSOR: yes
HAVE_XKB: yes
HAVE_INPUT: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_X11_XCB: yes

X11
===
Vendor: The X.Org Foundation
Vendor Release: 11702000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11
RANDR: yes; Version: 0x14
DAMAGE: yes; Version: 0x11
Composite: yes; Version: 0x4
RENDER: yes; Version: 0xb
XFIXES: yes; Version: 0x50
SYNC: yes; Version: 0x31
GLX: yes; Version: 0x0

Decoration
==========
Plugin: org.kde.breeze
Theme: 
Blur: 0
onAllDesktopsAvailable: true
alphaChannelSupported: true
closeOnDoubleClickOnMenu: false
decorationButtonsLeft: 0, 2
decorationButtonsRight: 6, 3, 4, 5
borderSize: 3
gridUnit: 10
font: Oxygen-Sans,10,-1,5,50,0,0,0,0,0
smallSpacing: 2
largeSpacing: 10

Options
=======
focusPolicy: 0
nextFocusPrefersMouse: false
clickRaise: true
autoRaise: false
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: false
placement: 4
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
legacyFullscreenSupport: false
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 30
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 30
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 31
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
inactiveTabsSkipTaskbar: false
autogroupSimilarWindows: false
autogroupInForeground: true
compositingMode: 2
useCompositing: true
compositingInitialized: true
hiddenPreviews: 1
unredirectFullscreen: false
glSmoothScale: 1
colorCorrected: false
xrenderSmoothScale: false
maxFpsInterval: 16666666
refreshRate: 0
vBlankTime: 6000000
glStrictBinding: true
glStrictBindingFollowsDriver: true
glCoreProfile: false
glPreferBufferSwap: 97
glPlatformInterface: 1

Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: false
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 0
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0

Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 1

Screen 0:
---------
Name: DVI-I-3
Geometry: 0,0,1920x1080
Refresh Rate: 60

Compositing
===========
Compositing is active
Compositing Type: XRender

Loaded Effects:
---------------
zoom
slidingpopups
kwin4_effect_login
slide
screenshot
kwin4_effect_windowaperture
minimizeanimation
desktopgrid
kwin4_effect_translucency
kwin4_effect_fade
kwin4_effect_maximize
presentwindows
kwin4_effect_dialogparent
highlightwindow
logout
dashboard
screenedge
kscreen

Currently Active Effects:
-------------------------

Effect Settings:
----------------
zoom:
zoomFactor: 1.2
mousePointer: 0
mouseTracking: 0
enableFocusTracking: false
followFocus: true
focusDelay: 350
moveFactor: 20
targetZoom: 1

slidingpopups:
fadeInTime: 150
fadeOutTime: 250

kwin4_effect_login:

slide:

screenshot:

kwin4_effect_windowaperture:

minimizeanimation:

desktopgrid:
zoomDuration: 300
border: 10
desktopNameAlignment: 0
layoutMode: 0
customLayoutRows: 2
usePresentWindows: true

kwin4_effect_translucency:

kwin4_effect_fade:

kwin4_effect_maximize:

presentwindows:
layoutMode: 1
showCaptions: true
showIcons: true
doNotCloseWindows: false
ignoreMinimized: false
accuracy: 20
fillGaps: true
fadeDuration: 150
showPanel: false
leftButtonWindow: 1
rightButtonWindow: 2
middleButtonWindow: 0
leftButtonDesktop: 2
middleButtonDesktop: 0
rightButtonDesktop: 0

kwin4_effect_dialogparent:

highlightwindow:

logout:
useBlur: true

dashboard:
brightness: 0.5
saturation: 0.5
blur: false

screenedge:

kscreen:
cpfeiffer commented 9 years ago

Here's my output: https://paste.kde.org/ppaisixky

davidedmundson commented 9 years ago

Are you guys able to run patches?

can you change QImage image(xcb_get_image_data(reply.data()), s_embedSize, s_embedSize, s_embedSize*4, QImage::Format_ARGB32);

to

QImage image(xcb_get_image_data(reply.data()), s_embedSize, s_embedSize, s_embedSize*4, QImage::Format_RGB32);

on a machine (kubuntu in virtualbox) I'm getting all zeroes in the alpha channel.

paulolieuthier commented 9 years ago

@davidedmundson I use Thunderbird with the Firetray extension. Left click and context menu are perfect. However, I get the same sad message ("no image fetched from embedded client :(") and a white square as the icon. Changing Format_ARGB32 to Format_RGB32 made no difference.

It probably makes no difference, but I had to change s_embedSize's type to uint32_t and also two other unrelated casts to be able to compile.

ghost commented 9 years ago

@davidedmundson with said change i can see hexchat and remmina icons inside a white square (result of no transparency). Pidgin icon still invisible though. Interesting is that without your change i cant see icons and console only says "docking" multiple times. But with your change i start seeing "no image fetched from embedded client :(" too.

paulolieuthier commented 9 years ago

@davidedmundson I know you're only using XCB, but just for a proof of concept, apply the following patch. It pulls Xlib. With it I got perfect icons from Thunderbird, XChat and Pidgin. Got it from LXQt's system tray plugin.

From d70a8012a2a2a070df5c9e108431f11e1f22afde Mon Sep 17 00:00:00 2001
From: Paulo Lieuthier <paulolieuthier@gmail.com>
Date: Thu, 1 Oct 2015 13:40:34 -0300
Subject: [PATCH] Use Xlib to reliably get apps' icons

---
 CMakeLists.txt |   2 +
 fixx11h.h      | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sniproxy.cpp   |  33 +++++---
 3 files changed, 268 insertions(+), 11 deletions(-)
 create mode 100644 fixx11h.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ab74b0..fc717df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@ find_package(XCB
         UTIL
 )

+find_package(X11 REQUIRED)

 add_definitions(-Wall -std=c++11)

@@ -81,6 +82,7 @@ target_link_libraries(xembedsniproxy
     Qt5::DBus
     KF5::WindowSystem
     ${kwin_XCB_LIBS}
+    ${X11_LIBRARIES}
 )

 install(TARGETS xembedsniproxy ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/fixx11h.h b/fixx11h.h
new file mode 100644
index 0000000..51e2409
--- /dev/null
+++ b/fixx11h.h
@@ -0,0 +1,244 @@
+//#ifdef    don't do this, this file is supposed to be included
+//#define   multiple times
+
+/* Usage:
+
+ If you get compile errors caused by X11 includes (the line
+ where first error appears contains word like None, Unsorted,
+ Below, etc.), put #include <fixx11h.h> in the .cpp file 
+ (not .h file!) between the place where X11 headers are
+ included and the place where the file with compile
+ error is included (or the place where the compile error
+ in the .cpp file occurs).
+ 
+ This file remaps X11 #defines to const variables or
+ inline functions. The side effect may be that these
+ symbols may now refer to different variables
+ (e.g. if X11 #defined NoButton, after this file
+ is included NoButton would no longer be X11's
+ NoButton, but Qt::NoButton instead). At this time,
+ there's no conflict known that could cause problems.
+
+ The original X11 symbols are still accessible
+ (e.g. for None) as X::None, XNone, and also still
+ None, unless name lookup finds different None
+ first (in the current class, etc.)
+
+ Use 'Unsorted', 'Bool' and 'index' as templates.
+
+*/
+
+namespace X
+{
+
+// template --->
+// Affects: Should be without side effects.
+#ifdef Unsorted
+#ifndef FIXX11H_Unsorted
+#define FIXX11H_Unsorted
+const int XUnsorted = Unsorted;
+#undef Unsorted
+const int Unsorted = XUnsorted;
+#endif
+#undef Unsorted
+#endif
+// template <---
+
+// Affects: Should be without side effects.
+#ifdef None
+#ifndef FIXX11H_None
+#define FIXX11H_None
+const XID XNone = None;
+#undef None
+const XID None = XNone;
+#endif
+#undef None
+#endif
+
+// template --->
+// Affects: Should be without side effects.
+#ifdef Bool
+#ifndef FIXX11H_Bool
+#define FIXX11H_Bool
+typedef Bool XBool;
+#undef Bool
+typedef XBool Bool;
+#endif
+#undef Bool
+#endif
+
+#ifdef FontChange
+#ifndef FIXX11H_FontChange
+#define FIXX11H_FontChange
+const int XFontChange = FontChange;
+#undef FontChange
+const int FontChange = XFontChange;
+#endif
+#undef FontChange
+#endif
+// template <---
+
+// Affects: Should be without side effects.
+#ifdef KeyPress
+#ifndef FIXX11H_KeyPress
+#define FIXX11H_KeyPress
+const int XKeyPress = KeyPress;
+#undef KeyPress
+const int KeyPress = XKeyPress;
+#endif
+#undef KeyPress
+#endif
+
+// Affects: Should be without side effects.
+#ifdef KeyRelease
+#ifndef FIXX11H_KeyRelease
+#define FIXX11H_KeyRelease
+const int XKeyRelease = KeyRelease;
+#undef KeyRelease
+const int KeyRelease = XKeyRelease;
+#endif
+#undef KeyRelease
+#endif
+
+// Affects: Should be without side effects.
+#ifdef Above
+#ifndef FIXX11H_Above
+#define FIXX11H_Above
+const int XAbove = Above;
+#undef Above
+const int Above = XAbove;
+#endif
+#undef Above
+#endif
+
+// Affects: Should be without side effects.
+#ifdef Below
+#ifndef FIXX11H_Below
+#define FIXX11H_Below
+const int XBelow = Below;
+#undef Below
+const int Below = XBelow;
+#endif
+#undef Below
+#endif
+
+// Affects: Should be without side effects.
+#ifdef FocusIn
+#ifndef FIXX11H_FocusIn
+#define FIXX11H_FocusIn
+const int XFocusIn = FocusIn;
+#undef FocusIn
+const int FocusIn = XFocusIn;
+#endif
+#undef FocusIn
+#endif
+
+// Affects: Should be without side effects.
+#ifdef FocusOut
+#ifndef FIXX11H_FocusOut
+#define FIXX11H_FocusOut
+const int XFocusOut = FocusOut;
+#undef FocusOut
+const int FocusOut = XFocusOut;
+#endif
+#undef FocusOut
+#endif
+
+// Affects: Should be without side effects.
+#ifdef Always
+#ifndef FIXX11H_Always
+#define FIXX11H_Always
+const int XAlways = Always;
+#undef Always
+const int Always = XAlways;
+#endif
+#undef Always
+#endif
+
+// Affects: Should be without side effects.
+#ifdef Success
+#ifndef FIXX11H_Success
+#define FIXX11H_Success
+const int XSuccess = Success;
+#undef Success
+const int Success = XSuccess;
+#endif
+#undef Success
+#endif
+
+// Affects: Should be without side effects.
+#ifdef GrayScale
+#ifndef FIXX11H_GrayScale
+#define FIXX11H_GrayScale
+const int XGrayScale = GrayScale;
+#undef GrayScale
+const int GrayScale = XGrayScale;
+#endif
+#undef GrayScale
+#endif
+
+// Affects: Should be without side effects.
+#ifdef Status
+#ifndef FIXX11H_Status
+#define FIXX11H_Status
+typedef Status XStatus;
+#undef Status
+typedef XStatus Status;
+#endif
+#undef Status
+#endif
+
+// Affects: Should be without side effects.
+#ifdef CursorShape
+#ifndef FIXX11H_CursorShape
+#define FIXX11H_CursorShape
+const int XCursorShape = CursorShape;
+#undef CursorShape
+const int CursorShape = CursorShape;
+#endif
+#undef CursorShape
+#endif
+
+// template --->
+// Affects: Should be without side effects.
+#ifdef index
+#ifndef FIXX11H_index
+#define FIXX11H_index
+inline
+char* Xindex( const char* s, int c )
+    {
+    return index( s, c );
+    }
+#undef index
+inline
+char* index( const char* s, int c )
+    {
+    return Xindex( s, c );
+    }
+#endif
+#undef index
+#endif
+// template <---
+
+#ifdef rindex
+// Affects: Should be without side effects.
+#ifndef FIXX11H_rindex
+#define FIXX11H_rindex
+inline
+char* Xrindex( const char* s, int c )
+    {
+    return rindex( s, c );
+    }
+#undef rindex
+inline
+char* rindex( const char* s, int c )
+    {
+    return Xrindex( s, c );
+    }
+#endif
+#undef rindex
+#endif
+}
+
+using namespace X;
+
diff --git a/sniproxy.cpp b/sniproxy.cpp
index 376488a..e6867d0 100644
--- a/sniproxy.cpp
+++ b/sniproxy.cpp
@@ -40,8 +40,11 @@
 #include "statusnotifieritemadaptor.h"
 #include "statusnotifierwatcher_interface.h"

+#include <X11/Xutil.h>
+#include "fixx11h.h"
+
 static const char s_statusNotifierWatcherServiceName[] = "org.kde.StatusNotifierWatcher";
-static int s_embedSize = 48;
+static uint32_t s_embedSize = 48;

 int SNIProxy::s_serviceCount = 0;

@@ -167,18 +170,26 @@ SNIProxy::~SNIProxy()

 void SNIProxy::update()
 {
-    //get pixmap (xcb_drawable)
-    auto getImageCookie = xcb_get_image(QX11Info::connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, m_windowId, 0, 0, s_embedSize, s_embedSize, 0xFFFFFF);
-
-    //get image from that
-    QScopedPointer<xcb_get_image_reply_t, QScopedPointerPodDeleter> reply(xcb_get_image_reply(QX11Info::connection(), getImageCookie, Q_NULLPTR));
-    if (!reply) {
-        qDebug() << "no image fetched from embedded client :(";
+    // get pixmap (xcb_drawable)
+    XWindowAttributes attr;
+    if (!XGetWindowAttributes(QX11Info::display(), m_windowId, &attr))
+    {
+        qWarning() << "couldn't get icon attributes :(";
         return;
     }

-    QImage image(xcb_get_image_data(reply.data()), s_embedSize, s_embedSize, s_embedSize*4, QImage::Format_ARGB32);
-    m_pixmap = QPixmap::fromImage(image).copy(); //copy as image refers to temporary data in reply
+    QImage image;
+    XImage* ximage = XGetImage(QX11Info::display(), m_windowId, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap);
+    if (ximage)
+    {
+        image = QImage((const uchar*) ximage->data, ximage->width, ximage->height, ximage->bytes_per_line, QImage::Format_ARGB32);
+        XDestroyImage(ximage);
+    }
+    else
+        qWarning() << "no image fetched from embedded client :(";
+
+    // copy as image refers to temporary data in reply
+    m_pixmap = QPixmap::fromImage(image).copy(); 

     emit NewIcon();
 }
@@ -263,7 +274,7 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y)
     const uint32_t stackAboveData[] = {XCB_STACK_MODE_ABOVE};
     xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackAboveData);

-    const uint32_t config_vals[4] = {x, y, s_embedSize, s_embedSize };
+    const uint32_t config_vals[4] = {static_cast<uint32_t>(x), static_cast<uint32_t>(y), s_embedSize, s_embedSize };
     xcb_configure_window(c, m_containerWid,
                              XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
                              config_vals);
-- 
2.6.0
davidedmundson commented 9 years ago

Thanks I'd just finished a port from xcb_get_image to xcb_image_get which is basically the same as above.

branch: image_get

Maybe that's a route to go down?

davidedmundson commented 9 years ago

...and it made no difference in my Kubuntu virtualbox where I can reproduce the problem

paulolieuthier commented 9 years ago

I get a segfault with your image_get branch running pidgin.

ghost commented 9 years ago

@paulolieuthier i tried your patch but it did not work. Then i tried this:

image = QImage((const uchar*) ximage->data, ximage->width, ximage->height, ximage->bytes_per_line, QImage::Format_ARGB32);
uint32_t transparent = image.pixel(0, 0);
for (int x = 0; x < image.width(); x++)
{
    for (int y = 0; y < image.width(); y++)
    {
        unsigned int argb = image.pixel(x, y);
        if (argb != transparent)
            image.setPixel(x, y, (argb & 0x00FFFFFF) | (0xFF << 24));
    }
}

What i did here is taking top-left pixel and treating it as supposedly transparent pixel. Then i looped each pixel and if its not same as supposedly transparent top-left pixel - i set alpha to 0xFF to make it non-transparent. Result: asdasd Somehow X does not return correct alpha channel in some cases. I know nothing of how X works though.. Hope this helps.

EDIT: Still no icons visible with image_get branch.

davidedmundson commented 9 years ago

@paulolieuthier can you retry, I was rushing a bit to get it pushed online whilst you did your patch

paulolieuthier commented 9 years ago

@davidedmundson just tested it and it's working well. I run thunderbird, xchat, pidgin and nm-applet. Specially pidgin, multiple times. Two times the icon got a black background, and one time I saw a segfault. But I couldn't reproduce it again. nm-applet's left click and context menu don't work, but that's another issue.

Just for you to know, I'm running LXQt on Arch.

davidedmundson commented 9 years ago

OK, so I'll merge that in.

I don't think that closes everything, I think we have 3 bugs going on, and this is just 1 down

cpfeiffer commented 9 years ago

Status report with current master (0d6ed0396e04ae2629a1f115d001a73e5f52d881) and IBM Notes:

Thanks and keep up the good work!

cpfeiffer commented 9 years ago

Ohhh! There is an icon! Just one, but still :-) There should be one tray icon for Notes when there is new mail and one for sametime (all the time). The latter is missing:

image

minlexx commented 9 years ago

I decided not to start a new issue, because all are about the same. For me, also as in issue #6 , xembed-sni-proxy does not display some icons.

I also tried to write a XEMBED<->DBUS SNI proxy, but not like you, I didn't use any QtDbus / KF5Notifications, just raw X11 and libdbus, also I started from forking wmsystemtray (all my in https://github.com/minlexx/wmsystemtray-plasma5 )

What I've noticed from my tests, my program has the same bugs: sometimes is does display icons, sometimes not. Also I've noticed, some of embedding windows give images as depth 24, others 32. I have tested Viber (produces 32-bit image, and it is almost always displayed correctly), Audacious gives 24-bit image, and I have to manually set alpha byte to 0xFF. Icons from wine apps also give 24-bit when trying to screenshot, but I couldn't get correct image from wine's tray :(

I take screenshot with XGetImage(), then copy bits from image and store it to later send over dbus. See the bottom of the file https://github.com/minlexx/wmsystemtray-plasma5/blob/master/src/dbus-snitem.c - maybe this will give some thoughts, maybe not

For now i still dodn't find a reason why this happens. Could it be that some effects from window manager make window look different when taking its snapshot or somethig?

Finally some screens to illustrate: Audacious no icon Audacious has icon after 3rd restart it finally displayed icon, reason still unknown. Log of my app when docking audacious icon (contains information about X image format):

wmsystemtray: fdtray: Dock request for window 2dd1b42 
wmsystemtray: Adding tray icon 2dd1b42 of type 0
wmsystemtray: DBus: SNI: will try to register new SNI with name [org.freedesktop.StatusNotifierItem-25741-1]
wmsystemtray: DBus: SNI: will use icon/tooltip title [Audacious]
wmsystemtray: DBus: SNI: Request name [org.freedesktop.StatusNotifierItem-25741-1] OK!
wmsystemtray:   DBus: SIGNAL NameAcquired(): [org.freedesktop.StatusNotifierItem-25741-1]
wmsystemtray: Mapping tray icon 2dd1b42
wmsystemtray: Updating display: page 1 of 1
wmsystemtray: Drawing window 0 (4800008)
wmsystemtray:   Drawing tray icon
wmsystemtray:   [0] Tray icon 2dd1b42 at 0 (8,4)
wmsystemtray:     Reparenting 2dd1b42 to 4800008
wmsystemtray:   DBus: attrs for window: [24x24], map_state=2
wmsystemtray:   DBus: SNI: got image (24 x 24), depth=24, byte_order=0, bytes_per_line=96, bits_per_pixel=32, bitmap_unit=32, bytes_per_line=96
wmsystemtray:     Masks: R ff0000 G ff00 B ff
wmsystemtray: X time is 47548289
wmsystemtray: DBus: SNI: Properties.GetAll( "org.kde.StatusNotifierItem" )`

this is output part when docking Viber icon (32-bit):

wmsystemtray:   DBus: attrs for window: [24x24], map_state=2
wmsystemtray:   DBus: SNI: got image (24 x 24), depth=32, byte_order=0, bytes_per_line=96, bits_per_pixel=32, bitmap_unit=32, bytes_per_line=96

And this is how Viber icon looks like in original wmsystemtray host window and when (after series of restarts) it finally got SNI icon: Viber got icon

Maybe we should update icon every time (send DBUS signal NewIcon()) when embedded X window is repainted? If you ever find a solution, I would like to know it :) Because I don't know if it is me sending image over DBUS in incorrect format, or bug in plasma shell systray widget not displaying it correctly.

P.S. if I use icon name (IconName property) instead of IconPixmap in DBUS message, it is always displayed correctly.

Thanks for your time.

davidedmundson commented 9 years ago

Oh wow. Maybe we can join forces?

I'm seeing the same thing, I can force alpha to always be set properly, but then I obviously get the background. Weirdly my windows I'm embedding claim to have the same depth but clearly don't.

Maybe we should update icon every time (send DBUS signal NewIcon()) when embedded X window is repainted?

Mine does that using the XDamage extension to know when a repaint happened, and my pixmap serialisation code is taken directly from KNotification (advantage of using Qt code)

As for the bugs,

Ideas I'm toying with:

The latter would break the nice proxy aspect to the approach but might work better. Also I'm not sure how well glXCreatePixmap would work in a wayland GL context....

BTW, how did you solve making clicks work consistently? Mine took a bit of a brutal hack to make it work properly.

minlexx commented 9 years ago

Oh wow. Maybe we can join forces?

I'm not sure how I can help, but if I find something interesting, I'll tell you :)

BTW, how did you solve making clicks work consistently?

I didn't for now, because I started exploring this not a long time ago, I haven't gone that far, and stuck with icons problem. One problem at a time :)

To check that my pixmap serialization code works fine, I tried to read some PNG image using libpng and send its contents over DBus, and it worked fine, so now I'm sure that I can properly send pixmaps over DBus and there is no error. That means, that X server does not always return me a correct image with XGetImage(). Then I decided to save sequence of PNG images, one at each screenshot / redraw operation, to test - does X actually return me an image? In this commit - https://github.com/minlexx/wmsystemtray-plasma5/commit/7c23cb302f72017f73d7212330ddd723b7b04e19 I had finally fixed the code, and guess what I saw as result? :) Frames I come to conclusion that sometimes X server just doesn't want to give me window screenshot. Or we have to force the window to repaint itself somehow and then take it's screenshot. I'm sorry, I'm new to all this Xlib deep details =( Now I don't have any more ideas for today.

indywidualny commented 9 years ago

Same here - no icons, just empty, fully functioning space. Arch Linux with Plasma 5 :(

2015-10-10-160447_1920x1080_scrot

uname -a Linux indywidualni 4.2.2-1-ARCH #1 SMP PREEMPT Tue Sep 29 22:21:33 CEST 2015 x86_64 GNU/Linux

qdbus org.kde.KWin /KWin supportInformation

Version
=======
KWin version: 5.4.2
Qt Version: 5.5.0
Qt compile version: 5.5.0
XCB compile version: 1.11.1
Operation Mode: X11 only
Build Options
=============
KWIN_BUILD_DECORATIONS: yes
KWIN_BUILD_TABBOX: yes
KWIN_BUILD_ACTIVITIES: yes
HAVE_WAYLAND: yes
HAVE_WAYLAND_EGL: yes
HAVE_WAYLAND_CURSOR: yes
HAVE_XKB: yes
HAVE_INPUT: yes
HAVE_DRM: yes
HAVE_GBM: yes
HAVE_X11_XCB: yes
X11
===
Vendor: The X.Org Foundation
Vendor Release: 11702000
Protocol Version/Revision: 11/0
SHAPE: yes; Version: 0x11
RANDR: yes; Version: 0x14
DAMAGE: yes; Version: 0x11
Composite: yes; Version: 0x4
RENDER: yes; Version: 0xb
XFIXES: yes; Version: 0x50
SYNC: yes; Version: 0x31
GLX: yes; Version: 0x0
Decoration
==========
Plugin: org.kde.breeze
Theme: 
Blur: 0
onAllDesktopsAvailable: true
alphaChannelSupported: true
closeOnDoubleClickOnMenu: false
decorationButtonsLeft: 0, 2
decorationButtonsRight: 6, 3, 4, 5
borderSize: 2
gridUnit: 10
font: DejaVu Sans,10,-1,5,50,0,0,0,0,0
smallSpacing: 2
largeSpacing: 10
Options
=======
focusPolicy: 0
nextFocusPrefersMouse: false
clickRaise: true
autoRaise: false
autoRaiseInterval: 0
delayFocusInterval: 0
shadeHover: false
shadeHoverInterval: 250
separateScreenFocus: false
placement: 4
focusPolicyIsReasonable: true
borderSnapZone: 10
windowSnapZone: 10
centerSnapZone: 0
snapOnlyWhenOverlapping: false
rollOverDesktops: true
focusStealingPreventionLevel: 1
legacyFullscreenSupport: false
operationTitlebarDblClick: 5000
operationMaxButtonLeftClick: 5000
operationMaxButtonMiddleClick: 5015
operationMaxButtonRightClick: 5014
commandActiveTitlebar1: 0
commandActiveTitlebar2: 30
commandActiveTitlebar3: 2
commandInactiveTitlebar1: 4
commandInactiveTitlebar2: 30
commandInactiveTitlebar3: 2
commandWindow1: 7
commandWindow2: 8
commandWindow3: 8
commandWindowWheel: 31
commandAll1: 10
commandAll2: 3
commandAll3: 14
keyCmdAllModKey: 16777251
showGeometryTip: false
condensedTitle: false
electricBorderMaximize: true
electricBorderTiling: true
electricBorderCornerRatio: 0.25
borderlessMaximizedWindows: false
killPingTimeout: 5000
hideUtilityWindowsForInactive: true
inactiveTabsSkipTaskbar: false
autogroupSimilarWindows: false
autogroupInForeground: true
compositingMode: 1
useCompositing: true
compositingInitialized: true
hiddenPreviews: 1
unredirectFullscreen: false
glSmoothScale: 0
colorCorrected: false
xrenderSmoothScale: false
maxFpsInterval: 16666666
refreshRate: 0
vBlankTime: 6000000
glStrictBinding: false
glStrictBindingFollowsDriver: true
glCoreProfile: true
glPreferBufferSwap: 0
glPlatformInterface: 1
Screen Edges
============
desktopSwitching: false
desktopSwitchingMovingClients: true
cursorPushBackDistance: 1x1
timeThreshold: 150
reActivateThreshold: 350
actionTopLeft: 0
actionTop: 0
actionTopRight: 0
actionRight: 0
actionBottomRight: 0
actionBottom: 0
actionBottomLeft: 0
actionLeft: 0
Screens
=======
Multi-Head: no
Active screen follows mouse:  no
Number of Screens: 1
Screen 0:
---------
Name: HDMI-0
Geometry: 0,0,1920x1080
Refresh Rate: 60
Compositing
===========
Compositing is active
Compositing Type: OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 660/PCIe/SSE2
OpenGL version string: 3.1.0 NVIDIA 355.11
OpenGL platform interface: GLX
OpenGL shading language version string: 1.40 NVIDIA via Cg compiler
Driver: NVIDIA
Driver version: 355.11
GPU class: Unknown
OpenGL version: 3.1
GLSL version: 1.40
X server version: 1.17.2
Linux kernel version: 4.2.2
Direct rendering: Requires strict binding: no
GLSL shaders:  yes
Texture NPOT support:  yes
Virtual Machine:  no
OpenGL 2 Shaders are used
Painting blocks for vertical retrace:  yes
Loaded Effects:
---------------
zoom
dimscreen
slidingpopups
wobblywindows
slide
screenshot
minimizeanimation
kwin4_effect_translucency
flipswitch
kwin4_effect_scalein
desktopgrid
kwin4_effect_windowaperture
coverswitch
kwin4_effect_maximize
kwin4_effect_fade
presentwindows
kwin4_effect_dialogparent
highlightwindow
blur
logout
dashboard
startupfeedback
screenedge
kscreen
Currently Active Effects:
-------------------------
blur
Effect Settings:
----------------
zoom:
zoomFactor: 1.2
mousePointer: 0
mouseTracking: 0
enableFocusTracking: false
followFocus: true
focusDelay: 350
moveFactor: 20
targetZoom: 1
dimscreen:
slidingpopups:
fadeInTime: 150
fadeOutTime: 250
wobblywindows:
stiffness: 0.14999999999999999
drag: 0.80000000000000004
moveFactor: 0.10000000000000001
xTesselation: 20
yTesselation: 20
minVelocity: 0
maxVelocity: 1000
stopVelocity: 0.5
minAcceleration: 0
maxAcceleration: 1000
stopAcceleration: 0.5
moveEffectEnabled: true
openEffectEnabled: false
closeEffectEnabled: false
moveWobble: true
resizeWobble: true
slide:
screenshot:
minimizeanimation:
kwin4_effect_translucency:
flipswitch:
tabBox: true
tabBoxAlternative: false
duration: 200
angle: 30
xPosition: 0.33000001311302185
yPosition: 1
windowTitle: true
kwin4_effect_scalein:
desktopgrid:
zoomDuration: 300
border: 10
desktopNameAlignment: 0
layoutMode: 0
customLayoutRows: 2
usePresentWindows: true
kwin4_effect_windowaperture:
coverswitch:
animationDuration: 200
animateSwitch: true
animateStart: true
animateStop: true
reflection: true
windowTitle: true
zPosition: 900
primaryTabBox: false
secondaryTabBox: false
kwin4_effect_maximize:
kwin4_effect_fade:
presentwindows:
layoutMode: 0
showCaptions: true
showIcons: true
doNotCloseWindows: false
ignoreMinimized: false
accuracy: 20
fillGaps: true
fadeDuration: 150
showPanel: false
leftButtonWindow: 1
rightButtonWindow: 2
middleButtonWindow: 0
leftButtonDesktop: 2
middleButtonDesktop: 0
rightButtonDesktop: 0
kwin4_effect_dialogparent:
highlightwindow:
blur:
blurRadius: 12
cacheTexture: true
logout:
useBlur: true
dashboard:
brightness: 0.5
saturation: 0.5
blur: false
startupfeedback:
type: 1
screenedge:
kscreen:
FadeMind commented 9 years ago

@indywidualny Usuń appindicator ( i jego zależności). Mam najnowszą wersję xembed-sni-proxy-git oraz najnowszą stockową wersję dropboxa. Ikona jest widoczna.: qdbus org.kde.KWin /KWin supportInformation results: https://pastebin.com/5VUCFDJ7 a archlinux x64 testing branch. Shutter także używa xembedsniproxy do wyświetlania ikony.

ENG: Just remove all appindicator packages (with deps). I have lastest version of xembed-sni-proxy-git. Shutter and radiotray using xembedsniproxy for display trayicon too.

The appindicator packages list for REMOVING: libappindicator-gtk2 libappindicator-gtk3 libappindicator-sharp perl-gtk2-appindicator libdbusmenu-gtk2 libdbusmenu-gtk3 libindicator-gtk2 libindicator-gtk3

Reboot after.

indywidualny commented 9 years ago

It's even worse. I lost Chromium (and its extensions) icons as well as any icons I had before thanks to those compatibility packages.

Now all the icons I'm using should be displayed thanks to xembed-sni-proxy but I can see only blank spaces - like before :(

I tried branch image_get - still no icons.

davidedmundson commented 9 years ago

To be clear, you shouldn't remove libappindicator.

libappindicator uses SNI directlywhich is 100000% the correct way to go for doing system trays

This project exists solely for the cases where one can't use SNIs, like obscure java/wine programs.

(and yes, I know libappindicator has some silly bugs, but they need fixing not avoiding)

indywidualny commented 9 years ago

Well, libappindicator was slowing my login time. Startup was 10 times slower than now so it's buggy for sure.

The only hope is in this project. I'm looking forward to the next version with working icons. Good luck :)

For now I'm using Trayer. It's a prefect workaround although KDE Tray is useless for me now. Trayer creates another tray for all the icons.

FadeMind commented 9 years ago

@davidedmundson one click launch from icon tray not working on shutter app when appindicator libs are installed. When xembedsniproxy only is installed one click launching for shutter working fine.

dos1 made patched libappindicator-activate for this. But with lastest KDE libs (KF5 and KDE Plasma) one click not working anymore.

https://aur4.archlinux.org/pkgbase/libappindicator-activate/

One more: Arch don't have fully appindicator support... AUR packages are not completed.

diederikdehaas commented 8 years ago

Just got word that a package for your program was uploaded to the Debian archives (version 0~git20151005-77d78c3-2), thus I installed it and here's what I found:

With deluge-gtk (python-gtk app) I didn't see an icon, but otherwise it was fully functional :+1: whereas there was no systray functionality at all before installing your package. At first I had the libappindicator1 package installed and with that I had a systray for pidgin before installing your package, but left-clicking on it didn't open or minimize it; I had to right-click on it and choose Show/Hide. The icon was visible no matter what the 'Show system tray icon' preference was set too. After purging the libappindicator1 package and a reboot, pidgin's systray behavior was perfect ... apart from that it (also) didn't show an icon.

I am really pleased with your program already as it seems to work great apart from the missing icons. Before I only had partially working or not working at all workarounds.

qdbus org.kde.KWin /KWin supportInformation : https://gist.github.com/diederikdehaas/76fe11e7fadc1268e46b

indywidualny commented 8 years ago

I just updated. Still no icons. Good job anyway, it's good to see the project is under constant development.

tehnick commented 8 years ago

@minlexx You may try something similar to my fix from #22 for filtering transparent xembed icons.

indywidualny commented 8 years ago

New version gives me this output. I don't know whether it helps.

$  ~  xembedsniproxy
kde.xembedsniproxy: starting
kde.xembedsniproxy: Manager selection claimed
kde.xembedsniproxy: trying to dock window  8388730
kde.xembedsniproxy: adding damage watch for  8388730
kde.xembedsniproxy: trying to dock window  48234515
kde.xembedsniproxy: adding damage watch for  48234515
kde.xembedsniproxy: trying to dock window  8388733
kde.xembedsniproxy: adding damage watch for  8388733
kde.xembedsniproxy: trying to dock window  52429194
kde.xembedsniproxy: adding damage watch for  52429194
kde.xembedsniproxy: trying to dock window  8388736
kde.xembedsniproxy: adding damage watch for  8388736
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Skip transparent xembed icon
kde.xembedsniproxy: Sending click  3 to 1813 0
kde.xembedsniproxy: Sending click  1 to 1813 0
Crazy-Hopper commented 8 years ago

@indywidualny Could you please try this patch 79a1179 ?

indywidualny commented 8 years ago

Unfortunately still nothing :(

tehnick commented 8 years ago

@Crazy-Hopper With your patch icons of all Wine applications are shown immediately at startup. And finally I do not see transparent icons at all. Nor in Wine apps, nor in Gtk+ based apps, nor in Java-based apps...

Crazy-Hopper commented 8 years ago

Glad to hear, thank you. But there is a problem with this patch though. Now that conatiner is on-screen, you get black flickering when container window is stacked up and down in non-composited environments.

Crazy-Hopper commented 8 years ago

Qt4 had QX11Info::isCompositingManagerRunning(). Qt5 doesn't. :-( If we could somehow make sure that compositing is running then there would be no need at all for stacking container window up and down. We'd just leave it there. (Well, have to be cautious about icons being moved around the screen).

minlexx commented 8 years ago

There was a code to check that compositing window manager is running, in recordmydesktop app (that records video from desktop, so it needs to know)

example code: rmd_wm_is_compositing.c, rmd_wm_check.c

During capture, it outputs the following:

Your window manager appears to be KWin
Detected compositing window manager.
Reverting to full screen capture at every frame.

if that helps...