summaryrefslogtreecommitdiff
blob: 7bfbc6e9ade0f511a061116edb4baa0db91d3100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
https://github.com/fcitx/fcitx/issues/241
https://github.com/fcitx/fcitx/commit/c737618fffa84bfe5a6caf55cee9b9288a791bbf
https://github.com/fcitx/fcitx/commit/353683e29be4ef26409b9a05e0cb647a5180fa8c
https://github.com/fcitx/fcitx/commit/fe2732db27a1c2e183400ceeb3283559e10a4ca8
https://github.com/fcitx/fcitx/commit/440c431d29876a8e4871159d289bc9a573f9a41b

--- /src/module/notificationitem/notificationitem.c
+++ /src/module/notificationitem/notificationitem.c
@@ -565,8 +565,17 @@
 
 boolean FcitxNotificationItemEnable(FcitxNotificationItem* notificationitem, FcitxNotificationItemAvailableCallback callback, void* data)
 {
-    if (!callback || notificationitem->callback)
+    if (!callback)
         return false;
+
+    if (notificationitem->callback == callback) {
+        return true;
+    }
+
+    if (notificationitem->callback) {
+        return false;
+    }
+
     if (notificationitem->serviceName) {
         FcitxLog(ERROR, "This should not happen, please report bug.");
         return false;
--- /src/ui/classic/TrayWindow.c
+++ /src/ui/classic/TrayWindow.c
@@ -48,7 +48,7 @@
     Display *dpy = classicui->dpy;
     int iScreen = classicui->iScreen;
     char   strWindowName[] = "Fcitx Tray Window";
-    if (!classicui->bUseTrayIcon || classicui->isSuspend)
+    if (!classicui->bUseTrayIcon || classicui->isSuspend || classicui->notificationItemAvailable)
         return;
 
     if (trayWindow->window == None && trayWindow->dockWindow != None) {
@@ -61,12 +61,12 @@
             wsa.colormap = colormap;
             wsa.background_pixel = 0;
             wsa.border_pixel = 0;
-            trayWindow->window = XCreateWindow(dpy, p, -1, -1, 1, 1,
+            trayWindow->window = XCreateWindow(dpy, p, -1, -1, 22, 22,
                                             0, vi->depth, InputOutput, vi->visual,
                                             CWBackPixmap | CWBackPixel | CWBorderPixel | CWColormap, &wsa);
         } else {
             trayWindow->window = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
-                                -1, -1, 1, 1, 0,
+                                -1, -1, 22, 22, 0,
                                 BlackPixel(dpy, DefaultScreen(dpy)),
                                 WhitePixel(dpy, DefaultScreen(dpy)));
             XSetWindowBackgroundPixmap(dpy, trayWindow->window, ParentRelative);
@@ -74,6 +74,7 @@
         if (trayWindow->window == (Window) NULL)
             return;
 
+        trayWindow->size = 22;
         XSizeHints size_hints;
         size_hints.flags = PWinGravity | PBaseSize;
         size_hints.base_width = trayWindow->size;
@@ -161,7 +162,7 @@
     png_surface = image->image;
 
     c = cairo_create(trayWindow->cs);
-    cairo_set_source_rgba(c, 0, 0, 0, 0);
+    cairo_set_source_rgba(c, 1, 1, 1, 0);
     cairo_set_operator(c, CAIRO_OPERATOR_SOURCE);
     cairo_paint(c);
 
@@ -226,8 +227,6 @@
         if (event->xclient.message_type == trayWindow->atoms[ATOM_MANAGER]
             && event->xclient.data.l[1] == trayWindow->atoms[ATOM_SELECTION]
             && trayWindow->dockWindow == None) {
-            if (classicui->notificationItemAvailable)
-                return true;
             trayWindow->dockWindow = event->xclient.data.l[2];
             TrayWindowRelease(trayWindow);
             TrayWindowInit(trayWindow);
@@ -245,6 +244,7 @@
             int size = event->xconfigure.height;
             if (size != trayWindow->size) {
                 trayWindow->size = size;
+                XResizeWindow(dpy, trayWindow->window, size, size);
                 XSizeHints size_hints;
                 size_hints.flags = PWinGravity | PBaseSize;
                 size_hints.base_width = trayWindow->size;
@@ -286,6 +286,14 @@
             return true;
         }
         break;
+    case PropertyNotify:
+        if (event->xproperty.atom == trayWindow->atoms[ATOM_VISUAL] &&
+            event->xproperty.window == trayWindow->dockWindow) {
+            TrayWindowRelease(trayWindow);
+            TrayWindowInit(trayWindow);
+            return true;
+        }
+        break;
     }
     return false;
 }
--- /src/ui/classic/classicui.c
+++ /src/ui/classic/classicui.c
@@ -168,7 +168,7 @@
 void ClassicUIDelayedInitTray(void* arg) {
     FcitxClassicUI* classicui = (FcitxClassicUI*) arg;
     // FcitxLog(INFO, "yeah we delayed!");
-    if (!classicui->bUseTrayIcon)
+    if (!classicui->bUseTrayIcon || classicui->isSuspend)
         return;
     /*
      * if this return false, something wrong happened and callback
@@ -187,7 +187,7 @@
 {
     FcitxClassicUI* classicui = (FcitxClassicUI*) arg;
     classicui->trayTimeout = 0;
-    if (!classicui->bUseTrayIcon)
+    if (!classicui->bUseTrayIcon || classicui->isSuspend)
         return;
 
     if (!classicui->trayWindow->bTrayMapped) {
--- /src/ui/classic/tray.c
+++ /src/ui/classic/tray.c
@@ -106,8 +106,9 @@
 
     XWindowAttributes attr;
     XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attr);
-    if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
-        XSelectInput(dpy, DefaultRootWindow(dpy), attr.your_event_mask | StructureNotifyMask); // for MANAGER selection
+    int neededMask = StructureNotifyMask;
+    if ((attr.your_event_mask & neededMask) != neededMask) {
+        XSelectInput(dpy, DefaultRootWindow(dpy), attr.your_event_mask | neededMask); // for MANAGER selection
     }
     return True;
 }
@@ -123,7 +124,7 @@
     Display* dpy = tray->owner->dpy;
 
     if (tray->dockWindow != None) {
-        XSelectInput(dpy, tray->dockWindow, StructureNotifyMask);
+        XSelectInput(dpy, tray->dockWindow, PropertyChangeMask | StructureNotifyMask);
         TraySendOpcode(tray, SYSTEM_TRAY_REQUEST_DOCK, tray->window, 0, 0);
         tray->bTrayMapped = True;
         return 1;