2009-01-20 21:16:54 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* Tint2 : systraybar
|
|
|
|
*
|
2010-11-02 11:40:50 +00:00
|
|
|
* Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution
|
2009-06-19 21:08:34 +00:00
|
|
|
* based on 'docker-1.5' from Ben Jansens.
|
2009-01-20 21:16:54 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <Imlib2.h>
|
2010-01-03 00:33:07 +00:00
|
|
|
#include <X11/extensions/Xdamage.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2010-01-31 14:04:58 +00:00
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
|
2009-01-20 21:16:54 +00:00
|
|
|
|
|
|
|
#include "systraybar.h"
|
|
|
|
#include "server.h"
|
2009-02-10 23:16:10 +00:00
|
|
|
#include "panel.h"
|
2009-01-20 21:16:54 +00:00
|
|
|
|
2009-02-10 23:16:10 +00:00
|
|
|
GSList *icons;
|
2009-01-20 21:16:54 +00:00
|
|
|
|
2009-02-10 23:16:10 +00:00
|
|
|
/* defined in the systray spec */
|
|
|
|
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
|
|
|
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
|
|
|
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
|
|
|
|
2015-04-13 20:18:28 +00:00
|
|
|
#define FORCE_COMPOSITED_RENDERING 1
|
|
|
|
|
2009-02-25 20:04:43 +00:00
|
|
|
// selection window
|
2010-01-07 21:23:15 +00:00
|
|
|
Window net_sel_win = None;
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2009-02-27 22:18:30 +00:00
|
|
|
// freedesktop specification doesn't allow multi systray
|
|
|
|
Systraybar systray;
|
2009-06-20 15:08:33 +00:00
|
|
|
int refresh_systray;
|
2009-10-30 17:18:44 +00:00
|
|
|
int systray_enabled;
|
2010-04-16 18:50:03 +00:00
|
|
|
int systray_max_icon_size;
|
2015-01-23 18:40:31 +00:00
|
|
|
int systray_monitor;
|
2009-02-27 22:18:30 +00:00
|
|
|
|
2010-01-06 19:30:55 +00:00
|
|
|
// background pixmap if we render ourselves the icons
|
2010-04-18 12:07:36 +00:00
|
|
|
static Pixmap render_background;
|
2010-01-06 19:30:55 +00:00
|
|
|
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2010-04-18 12:07:36 +00:00
|
|
|
void default_systray()
|
|
|
|
{
|
|
|
|
memset(&systray, 0, sizeof(Systraybar));
|
|
|
|
render_background = 0;
|
|
|
|
systray.alpha = 100;
|
|
|
|
systray.sort = 3;
|
|
|
|
systray.area._draw_foreground = draw_systray;
|
2010-09-25 21:18:47 +00:00
|
|
|
systray.area._on_change_layout = on_change_systray;
|
2010-08-08 14:06:15 +00:00
|
|
|
systray.area.size_mode = SIZE_BY_CONTENT;
|
2010-04-18 12:07:36 +00:00
|
|
|
systray.area._resize = resize_systray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup_systray()
|
|
|
|
{
|
2010-04-22 15:08:21 +00:00
|
|
|
stop_net();
|
2010-04-18 12:07:36 +00:00
|
|
|
systray_enabled = 0;
|
|
|
|
systray_max_icon_size = 0;
|
2015-01-23 18:40:31 +00:00
|
|
|
systray_monitor = 0;
|
2010-04-18 12:07:36 +00:00
|
|
|
systray.area.on_screen = 0;
|
|
|
|
free_area(&systray.area);
|
|
|
|
if (render_background) {
|
|
|
|
XFreePixmap(server.dsp, render_background);
|
|
|
|
render_background = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-15 17:22:48 +00:00
|
|
|
void init_systray()
|
2009-02-10 23:16:10 +00:00
|
|
|
{
|
2009-10-30 17:18:44 +00:00
|
|
|
start_net();
|
2009-02-15 17:22:48 +00:00
|
|
|
|
2009-10-30 17:18:44 +00:00
|
|
|
if (!systray_enabled)
|
2009-02-27 22:18:30 +00:00
|
|
|
return;
|
2009-02-15 17:22:48 +00:00
|
|
|
|
2010-02-28 07:58:50 +00:00
|
|
|
if (!server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) {
|
|
|
|
printf("No 32 bit visual for your X implementation. 'systray_asb = 100 0 0' will be forced\n");
|
|
|
|
systray.alpha = 100;
|
|
|
|
systray.brightness = systray.saturation = 0;
|
|
|
|
}
|
2009-10-18 17:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void init_systray_panel(void *p)
|
|
|
|
{
|
|
|
|
systray.area.parent = p;
|
|
|
|
systray.area.panel = p;
|
2015-04-11 09:51:10 +00:00
|
|
|
if (!systray.area.bg)
|
2011-01-06 23:28:16 +00:00
|
|
|
systray.area.bg = &g_array_index(backgrounds, Background, 0);
|
|
|
|
|
2010-09-18 18:06:29 +00:00
|
|
|
GSList *l;
|
|
|
|
int count = 0;
|
|
|
|
for (l = systray.list_icons; l ; l = l->next) {
|
2015-05-11 19:19:36 +00:00
|
|
|
if (((TrayWindow*)l->data)->hide)
|
|
|
|
continue;
|
|
|
|
count++;
|
2010-09-18 18:06:29 +00:00
|
|
|
}
|
|
|
|
if (count == 0)
|
2010-09-22 19:33:10 +00:00
|
|
|
hide(&systray.area);
|
2010-09-18 18:06:29 +00:00
|
|
|
else
|
2010-09-22 19:33:10 +00:00
|
|
|
show(&systray.area);
|
2010-09-18 18:06:29 +00:00
|
|
|
refresh_systray = 0;
|
2009-02-15 17:22:48 +00:00
|
|
|
}
|
2009-02-10 23:16:10 +00:00
|
|
|
|
|
|
|
|
2010-01-09 00:11:01 +00:00
|
|
|
void draw_systray(void *obj, cairo_t *c)
|
2009-06-20 15:08:33 +00:00
|
|
|
{
|
2015-04-13 20:18:28 +00:00
|
|
|
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
2010-01-06 19:30:55 +00:00
|
|
|
if (render_background) XFreePixmap(server.dsp, render_background);
|
|
|
|
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
|
2010-01-09 00:11:01 +00:00
|
|
|
XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
|
2010-01-06 19:30:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-20 15:08:33 +00:00
|
|
|
refresh_systray = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-16 23:24:25 +00:00
|
|
|
int resize_systray(void *obj)
|
2009-02-28 23:04:53 +00:00
|
|
|
{
|
|
|
|
Systraybar *sysbar = obj;
|
|
|
|
GSList *l;
|
2010-09-18 22:00:16 +00:00
|
|
|
int count;
|
2009-02-28 23:04:53 +00:00
|
|
|
|
2009-06-24 20:17:57 +00:00
|
|
|
if (panel_horizontal)
|
2010-09-18 22:00:16 +00:00
|
|
|
sysbar->icon_size = sysbar->area.height;
|
2009-06-24 20:17:57 +00:00
|
|
|
else
|
2010-09-18 22:00:16 +00:00
|
|
|
sysbar->icon_size = sysbar->area.width;
|
|
|
|
sysbar->icon_size = sysbar->icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy);
|
|
|
|
if (systray_max_icon_size > 0 && sysbar->icon_size > systray_max_icon_size)
|
|
|
|
sysbar->icon_size = systray_max_icon_size;
|
2009-09-27 21:33:44 +00:00
|
|
|
count = 0;
|
|
|
|
for (l = systray.list_icons; l ; l = l->next) {
|
2015-05-11 19:19:36 +00:00
|
|
|
if (((TrayWindow*)l->data)->hide || ((TrayWindow*)l->data)->empty)
|
|
|
|
continue;
|
|
|
|
count++;
|
2009-09-27 21:33:44 +00:00
|
|
|
}
|
|
|
|
//printf("count %d\n", count);
|
2009-02-28 23:04:53 +00:00
|
|
|
|
2009-06-24 20:17:57 +00:00
|
|
|
if (panel_horizontal) {
|
2010-09-18 18:06:29 +00:00
|
|
|
int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
|
|
|
|
// here icons_per_column always higher than 0
|
2010-09-18 22:00:16 +00:00
|
|
|
sysbar->icons_per_column = (height+sysbar->area.paddingx) / (sysbar->icon_size+sysbar->area.paddingx);
|
|
|
|
sysbar->marging = height - (sysbar->icons_per_column-1)*(sysbar->icon_size+sysbar->area.paddingx) - sysbar->icon_size;
|
|
|
|
sysbar->icons_per_row = count / sysbar->icons_per_column + (count%sysbar->icons_per_column != 0);
|
|
|
|
systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_row) + ((sysbar->icons_per_row-1) * systray.area.paddingx);
|
2009-06-24 20:17:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-09-18 18:06:29 +00:00
|
|
|
int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
|
|
|
|
// here icons_per_row always higher than 0
|
2010-09-18 22:00:16 +00:00
|
|
|
sysbar->icons_per_row = (width+sysbar->area.paddingx) / (sysbar->icon_size+sysbar->area.paddingx);
|
|
|
|
sysbar->marging = width - (sysbar->icons_per_row-1)*(sysbar->icon_size+sysbar->area.paddingx) - sysbar->icon_size;
|
|
|
|
sysbar->icons_per_column = count / sysbar->icons_per_row+ (count%sysbar->icons_per_row != 0);
|
|
|
|
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_column) + ((sysbar->icons_per_column-1) * systray.area.paddingx);
|
2009-06-19 21:08:34 +00:00
|
|
|
}
|
2010-09-16 23:24:25 +00:00
|
|
|
return 1;
|
2009-02-28 23:04:53 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 20:19:09 +00:00
|
|
|
|
2010-09-25 21:18:47 +00:00
|
|
|
void on_change_systray (void *obj)
|
|
|
|
{
|
2010-11-07 17:43:14 +00:00
|
|
|
// here, systray.area.posx/posy are defined by rendering engine. so we can calculate position of tray icon.
|
2010-09-25 21:18:47 +00:00
|
|
|
Systraybar *sysbar = obj;
|
2015-01-22 17:31:56 +00:00
|
|
|
if (sysbar->icons_per_column == 0 || sysbar->icons_per_row == 0)
|
|
|
|
return;
|
|
|
|
|
2010-11-09 19:32:45 +00:00
|
|
|
Panel *panel = sysbar->area.panel;
|
2010-09-25 21:18:47 +00:00
|
|
|
int i, posx, posy;
|
2010-11-09 19:32:45 +00:00
|
|
|
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy + sysbar->marging/2;
|
2010-09-25 21:18:47 +00:00
|
|
|
if (panel_horizontal) {
|
|
|
|
posy = start;
|
|
|
|
posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
posx = start;
|
|
|
|
posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrayWindow *traywin;
|
|
|
|
GSList *l;
|
|
|
|
for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
|
|
|
|
traywin = (TrayWindow*)l->data;
|
2015-05-11 19:19:36 +00:00
|
|
|
if (traywin->hide)
|
|
|
|
continue;
|
2010-09-25 21:18:47 +00:00
|
|
|
|
|
|
|
traywin->y = posy;
|
|
|
|
traywin->x = posx;
|
2015-05-11 19:19:36 +00:00
|
|
|
// printf("systray %d : pos %d, %d\n", traywin->tray_id, posx, posy);
|
2010-09-25 21:18:47 +00:00
|
|
|
traywin->width = sysbar->icon_size;
|
|
|
|
traywin->height = sysbar->icon_size;
|
|
|
|
if (panel_horizontal) {
|
|
|
|
if (i % sysbar->icons_per_column)
|
|
|
|
posy += sysbar->icon_size + sysbar->area.paddingx;
|
|
|
|
else {
|
|
|
|
posy = start;
|
|
|
|
posx += (sysbar->icon_size + systray.area.paddingx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (i % sysbar->icons_per_row)
|
|
|
|
posx += sysbar->icon_size + systray.area.paddingx;
|
|
|
|
else {
|
|
|
|
posx = start;
|
|
|
|
posy += (sysbar->icon_size + systray.area.paddingx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// position and size the icon window
|
2015-04-13 20:18:28 +00:00
|
|
|
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
|
2010-09-25 21:18:47 +00:00
|
|
|
XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-29 18:39:44 +00:00
|
|
|
// ***********************************************
|
|
|
|
// systray protocol
|
2009-02-28 23:04:53 +00:00
|
|
|
|
2009-10-30 17:18:44 +00:00
|
|
|
void start_net()
|
2009-02-25 20:04:43 +00:00
|
|
|
{
|
2009-10-30 17:18:44 +00:00
|
|
|
if (net_sel_win) {
|
|
|
|
// protocol already started
|
|
|
|
if (!systray_enabled)
|
|
|
|
stop_net();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (!systray_enabled)
|
|
|
|
return;
|
|
|
|
|
2009-08-30 16:20:44 +00:00
|
|
|
Window win = XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN);
|
|
|
|
|
2009-06-29 18:39:44 +00:00
|
|
|
// freedesktop systray specification
|
2009-08-30 16:20:44 +00:00
|
|
|
if (win != None) {
|
|
|
|
// search pid
|
|
|
|
Atom _NET_WM_PID, actual_type;
|
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes_after;
|
2009-09-25 19:11:50 +00:00
|
|
|
unsigned char *prop = 0;
|
2009-08-30 16:20:44 +00:00
|
|
|
int pid;
|
|
|
|
|
|
|
|
_NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True);
|
|
|
|
int ret = XGetWindowProperty(server.dsp, win, _NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
|
|
|
|
|
|
|
|
fprintf(stderr, "tint2 : another systray is running");
|
2009-09-25 19:11:50 +00:00
|
|
|
if (ret == Success && prop) {
|
2009-08-30 16:20:44 +00:00
|
|
|
pid = prop[1] * 256;
|
|
|
|
pid += prop[0];
|
|
|
|
fprintf(stderr, " pid=%d", pid);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
2009-10-30 17:18:44 +00:00
|
|
|
return;
|
2009-03-07 10:05:15 +00:00
|
|
|
}
|
|
|
|
|
2009-02-25 20:04:43 +00:00
|
|
|
// init systray protocol
|
2009-09-07 21:41:21 +00:00
|
|
|
net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
|
2009-02-25 20:04:43 +00:00
|
|
|
|
2010-01-07 21:23:15 +00:00
|
|
|
// v0.3 trayer specification. tint2 always horizontal.
|
2009-09-27 21:33:44 +00:00
|
|
|
// Vertical panel will draw the systray horizontal.
|
2010-09-12 22:00:00 +00:00
|
|
|
long orient = 0;
|
2009-02-25 20:04:43 +00:00
|
|
|
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1);
|
2010-02-28 07:58:50 +00:00
|
|
|
VisualID vid;
|
2015-04-13 20:18:28 +00:00
|
|
|
if (server.visual32 && (FORCE_COMPOSITED_RENDERING || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0))
|
2010-02-28 07:58:50 +00:00
|
|
|
vid = XVisualIDFromVisual(server.visual32);
|
|
|
|
else
|
|
|
|
vid = XVisualIDFromVisual(server.visual);
|
2009-12-30 23:27:31 +00:00
|
|
|
XChangeProperty(server.dsp, net_sel_win, XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_VISUAL", False), XA_VISUALID, 32, PropModeReplace, (unsigned char*)&vid, 1);
|
2009-02-25 20:04:43 +00:00
|
|
|
|
|
|
|
XSetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime);
|
|
|
|
if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) {
|
2009-10-30 17:18:44 +00:00
|
|
|
stop_net();
|
2009-02-25 20:04:43 +00:00
|
|
|
fprintf(stderr, "tint2 : can't get systray manager\n");
|
2009-10-30 17:18:44 +00:00
|
|
|
return;
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2009-02-25 20:04:43 +00:00
|
|
|
|
2009-10-30 17:18:44 +00:00
|
|
|
//fprintf(stderr, "tint2 : systray started\n");
|
2009-09-07 21:41:21 +00:00
|
|
|
XClientMessageEvent ev;
|
2009-02-25 20:04:43 +00:00
|
|
|
ev.type = ClientMessage;
|
2009-09-07 21:41:21 +00:00
|
|
|
ev.window = server.root_win;
|
2009-02-25 20:04:43 +00:00
|
|
|
ev.message_type = server.atom.MANAGER;
|
|
|
|
ev.format = 32;
|
|
|
|
ev.data.l[0] = CurrentTime;
|
|
|
|
ev.data.l[1] = server.atom._NET_SYSTEM_TRAY_SCREEN;
|
|
|
|
ev.data.l[2] = net_sel_win;
|
|
|
|
ev.data.l[3] = 0;
|
|
|
|
ev.data.l[4] = 0;
|
2009-02-27 22:18:30 +00:00
|
|
|
XSendEvent(server.dsp, server.root_win, False, StructureNotifyMask, (XEvent*)&ev);
|
2009-02-25 20:04:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 17:18:44 +00:00
|
|
|
void stop_net()
|
2009-03-07 10:05:15 +00:00
|
|
|
{
|
2009-10-30 17:18:44 +00:00
|
|
|
//fprintf(stderr, "tint2 : systray stopped\n");
|
|
|
|
if (systray.list_icons) {
|
|
|
|
// remove_icon change systray.list_icons
|
|
|
|
while(systray.list_icons)
|
|
|
|
remove_icon((TrayWindow*)systray.list_icons->data);
|
|
|
|
|
|
|
|
g_slist_free(systray.list_icons);
|
2015-04-11 09:51:10 +00:00
|
|
|
systray.list_icons = NULL;
|
2009-10-30 17:18:44 +00:00
|
|
|
}
|
|
|
|
|
2009-03-07 10:05:15 +00:00
|
|
|
if (net_sel_win != None) {
|
2009-09-07 21:41:21 +00:00
|
|
|
XDestroyWindow(server.dsp, net_sel_win);
|
|
|
|
net_sel_win = None;
|
2009-03-07 10:05:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2009-04-01 20:19:09 +00:00
|
|
|
|
2009-02-10 23:16:10 +00:00
|
|
|
gboolean error;
|
|
|
|
int window_error_handler(Display *d, XErrorEvent *e)
|
|
|
|
{
|
2009-06-18 20:26:40 +00:00
|
|
|
d=d;e=e;
|
|
|
|
error = TRUE;
|
|
|
|
if (e->error_code != BadWindow) {
|
|
|
|
printf("error_handler %d\n", e->error_code);
|
|
|
|
}
|
|
|
|
return 0;
|
2009-02-10 23:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-29 22:09:29 +00:00
|
|
|
static gint compare_traywindows(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
const TrayWindow * traywin_a = (TrayWindow*)a;
|
|
|
|
const TrayWindow * traywin_b = (TrayWindow*)b;
|
2015-05-11 19:19:36 +00:00
|
|
|
|
|
|
|
if (traywin_a->empty && !traywin_b->empty)
|
|
|
|
return 1;
|
|
|
|
if (!traywin_a->empty && traywin_b->empty)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (systray.sort < 2)
|
|
|
|
return 0;
|
|
|
|
|
2009-08-29 22:09:29 +00:00
|
|
|
XTextProperty name_a, name_b;
|
|
|
|
|
2010-01-03 00:33:07 +00:00
|
|
|
if(XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) {
|
2009-08-29 22:09:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2010-01-03 00:33:07 +00:00
|
|
|
else if(XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) {
|
2009-08-29 22:09:29 +00:00
|
|
|
XFree(name_a.value);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) * systray.sort;
|
|
|
|
XFree(name_a.value);
|
|
|
|
XFree(name_b.value);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 21:08:34 +00:00
|
|
|
gboolean add_icon(Window id)
|
2009-02-10 23:16:10 +00:00
|
|
|
{
|
2009-06-19 21:08:34 +00:00
|
|
|
TrayWindow *traywin;
|
2009-06-18 20:26:40 +00:00
|
|
|
XErrorHandler old;
|
|
|
|
Panel *panel = systray.area.panel;
|
2009-09-27 21:33:44 +00:00
|
|
|
int hide = 0;
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2015-05-11 19:19:36 +00:00
|
|
|
int pid = 0;
|
|
|
|
{
|
|
|
|
Atom actual_type;
|
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes_after;
|
|
|
|
unsigned char *prop = 0;
|
|
|
|
int ret = XGetWindowProperty(server.dsp, id, server.atom._NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
|
|
|
|
if (ret == Success && prop) {
|
|
|
|
pid = prop[1] * 256;
|
|
|
|
pid += prop[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-04 23:15:57 +00:00
|
|
|
GSList *l;
|
2015-05-11 19:19:36 +00:00
|
|
|
int num_empty_same_pid = 0;
|
2015-02-04 23:15:57 +00:00
|
|
|
for (l = systray.list_icons; l; l = l->next) {
|
|
|
|
if (((TrayWindow*)l->data)->tray_id == id)
|
|
|
|
return FALSE;
|
2015-05-11 19:19:36 +00:00
|
|
|
if (pid && ((TrayWindow*)l->data)->pid == pid && ((TrayWindow*)l->data)->empty)
|
|
|
|
num_empty_same_pid++;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int max_num_empty_same_pid = 0;
|
|
|
|
if (num_empty_same_pid > max_num_empty_same_pid) {
|
|
|
|
for (l = systray.list_icons; l; l = l->next) {
|
|
|
|
if (pid && ((TrayWindow*)l->data)->pid == pid && ((TrayWindow*)l->data)->empty) {
|
|
|
|
num_empty_same_pid++;
|
|
|
|
fprintf(stderr, "Removing tray icon %lu from misbehaving application with pid=%d\n", ((TrayWindow*)l->data)->tray_id, pid);
|
|
|
|
remove_icon((TrayWindow*)l->data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-02-04 23:15:57 +00:00
|
|
|
}
|
2015-05-11 19:19:36 +00:00
|
|
|
//printf("add_icon: %d, pid %d, %d\n", id, pid, num_empty_same_pid);
|
2015-02-04 23:15:57 +00:00
|
|
|
|
2009-06-18 20:26:40 +00:00
|
|
|
error = FALSE;
|
2009-12-31 14:20:32 +00:00
|
|
|
XWindowAttributes attr;
|
2010-03-30 18:47:11 +00:00
|
|
|
if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE;
|
2010-01-03 20:17:46 +00:00
|
|
|
unsigned long mask = 0;
|
2010-01-03 00:33:07 +00:00
|
|
|
XSetWindowAttributes set_attr;
|
2010-08-18 12:32:08 +00:00
|
|
|
Visual* visual = server.visual;
|
2010-04-22 15:08:21 +00:00
|
|
|
//printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height);
|
2010-09-17 21:39:17 +00:00
|
|
|
//printf("icon with depth: %d\n", attr.depth);
|
2015-04-13 20:18:28 +00:00
|
|
|
if (attr.depth != server.depth || FORCE_COMPOSITED_RENDERING || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
2010-08-18 12:32:08 +00:00
|
|
|
visual = attr.visual;
|
2010-01-03 20:17:46 +00:00
|
|
|
set_attr.colormap = attr.colormap;
|
|
|
|
set_attr.background_pixel = 0;
|
|
|
|
set_attr.border_pixel = 0;
|
|
|
|
mask = CWColormap|CWBackPixel|CWBorderPixel;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
set_attr.background_pixmap = ParentRelative;
|
|
|
|
mask = CWBackPixmap;
|
|
|
|
}
|
2015-04-13 20:18:28 +00:00
|
|
|
Window parent_window;
|
|
|
|
parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr);
|
2010-01-03 13:14:25 +00:00
|
|
|
old = XSetErrorHandler(window_error_handler);
|
2010-01-03 00:33:07 +00:00
|
|
|
XReparentWindow(server.dsp, id, parent_window, 0, 0);
|
2011-05-22 08:25:40 +00:00
|
|
|
// watch for the icon trying to resize itself / closing again!
|
|
|
|
XSelectInput(server.dsp, id, StructureNotifyMask);
|
2009-06-18 20:26:40 +00:00
|
|
|
XSync(server.dsp, False);
|
|
|
|
XSetErrorHandler(old);
|
2009-06-19 21:08:34 +00:00
|
|
|
if (error != FALSE) {
|
2009-03-01 19:18:35 +00:00
|
|
|
fprintf(stderr, "tint2 : not icon_swallow\n");
|
2015-04-13 20:18:28 +00:00
|
|
|
XDestroyWindow(server.dsp, parent_window);
|
2009-03-01 19:18:35 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-06-29 18:39:44 +00:00
|
|
|
{
|
|
|
|
Atom acttype;
|
|
|
|
int actfmt;
|
|
|
|
unsigned long nbitem, bytes;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = XGetWindowProperty(server.dsp, id, server.atom._XEMBED_INFO, 0, 2, False, server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data);
|
2009-09-27 21:33:44 +00:00
|
|
|
if (ret == Success) {
|
|
|
|
if (data) {
|
|
|
|
if (nbitem == 2) {
|
|
|
|
//hide = ((data[1] & XEMBED_MAPPED) == 0);
|
|
|
|
//printf("hide %d\n", hide);
|
|
|
|
}
|
|
|
|
XFree(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-06-29 18:39:44 +00:00
|
|
|
fprintf(stderr, "tint2 : xembed error\n");
|
2015-04-13 20:18:28 +00:00
|
|
|
XDestroyWindow(server.dsp, parent_window);
|
2009-06-29 18:39:44 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
XEvent e;
|
|
|
|
e.xclient.type = ClientMessage;
|
|
|
|
e.xclient.serial = 0;
|
|
|
|
e.xclient.send_event = True;
|
|
|
|
e.xclient.message_type = server.atom._XEMBED;
|
|
|
|
e.xclient.window = id;
|
|
|
|
e.xclient.format = 32;
|
|
|
|
e.xclient.data.l[0] = CurrentTime;
|
|
|
|
e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY;
|
|
|
|
e.xclient.data.l[2] = 0;
|
2010-01-03 00:33:07 +00:00
|
|
|
e.xclient.data.l[3] = parent_window;
|
2009-06-29 18:39:44 +00:00
|
|
|
e.xclient.data.l[4] = 0;
|
|
|
|
XSendEvent(server.dsp, id, False, 0xFFFFFF, &e);
|
|
|
|
}
|
|
|
|
|
2009-02-25 20:04:43 +00:00
|
|
|
traywin = g_new0(TrayWindow, 1);
|
2015-04-13 20:18:28 +00:00
|
|
|
traywin->id = parent_window;
|
2010-01-03 00:33:07 +00:00
|
|
|
traywin->tray_id = id;
|
2009-09-27 21:33:44 +00:00
|
|
|
traywin->hide = hide;
|
2010-01-03 20:17:46 +00:00
|
|
|
traywin->depth = attr.depth;
|
|
|
|
traywin->damage = 0;
|
2015-05-11 19:19:36 +00:00
|
|
|
traywin->empty = 0;
|
|
|
|
traywin->pid = pid;
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2010-09-18 18:06:29 +00:00
|
|
|
if (systray.area.on_screen == 0)
|
2010-09-22 19:33:10 +00:00
|
|
|
show(&systray.area);
|
2010-09-18 18:06:29 +00:00
|
|
|
|
2009-09-27 20:00:34 +00:00
|
|
|
if (systray.sort == 3)
|
2009-09-27 19:52:25 +00:00
|
|
|
systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
|
|
|
|
else
|
2015-05-13 19:02:40 +00:00
|
|
|
systray.list_icons = g_slist_append(systray.list_icons, traywin);
|
|
|
|
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
2009-06-29 18:39:44 +00:00
|
|
|
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
|
2009-06-19 21:08:34 +00:00
|
|
|
|
2015-04-13 20:18:28 +00:00
|
|
|
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
|
|
|
traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles);
|
|
|
|
XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual);
|
|
|
|
}
|
|
|
|
|
2009-06-19 21:08:34 +00:00
|
|
|
// show the window
|
2010-01-17 20:02:56 +00:00
|
|
|
if (!traywin->hide)
|
2010-01-18 20:16:32 +00:00
|
|
|
XMapWindow(server.dsp, traywin->tray_id);
|
2015-04-13 20:18:28 +00:00
|
|
|
if (!traywin->hide && !panel->is_hidden)
|
|
|
|
XMapRaised(server.dsp, traywin->id);
|
2009-02-27 22:18:30 +00:00
|
|
|
|
2010-09-21 09:54:19 +00:00
|
|
|
// changed in systray
|
|
|
|
systray.area.resize = 1;
|
2009-02-27 22:18:30 +00:00
|
|
|
panel_refresh = 1;
|
2009-02-25 20:04:43 +00:00
|
|
|
return TRUE;
|
2009-02-10 23:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-01 19:18:35 +00:00
|
|
|
void remove_icon(TrayWindow *traywin)
|
2009-02-27 22:18:30 +00:00
|
|
|
{
|
|
|
|
XErrorHandler old;
|
|
|
|
|
2009-06-29 18:39:44 +00:00
|
|
|
// remove from our list
|
|
|
|
systray.list_icons = g_slist_remove(systray.list_icons, traywin);
|
2015-05-11 19:19:36 +00:00
|
|
|
//printf("remove_icon: %d\n", traywin->tray_id);
|
2009-06-29 18:39:44 +00:00
|
|
|
|
2010-01-03 00:33:07 +00:00
|
|
|
XSelectInput(server.dsp, traywin->tray_id, NoEventMask);
|
2010-01-03 20:17:46 +00:00
|
|
|
if (traywin->damage)
|
|
|
|
XDamageDestroy(server.dsp, traywin->damage);
|
2009-02-27 22:18:30 +00:00
|
|
|
|
2009-03-01 19:18:35 +00:00
|
|
|
// reparent to root
|
|
|
|
error = FALSE;
|
|
|
|
old = XSetErrorHandler(window_error_handler);
|
2009-09-27 21:33:44 +00:00
|
|
|
if (!traywin->hide)
|
2010-01-16 15:42:02 +00:00
|
|
|
XUnmapWindow(server.dsp, traywin->tray_id);
|
2010-01-03 00:33:07 +00:00
|
|
|
XReparentWindow(server.dsp, traywin->tray_id, server.root_win, 0, 0);
|
2015-04-13 20:18:28 +00:00
|
|
|
XDestroyWindow(server.dsp, traywin->id);
|
2009-03-01 19:18:35 +00:00
|
|
|
XSync(server.dsp, False);
|
|
|
|
XSetErrorHandler(old);
|
2015-04-17 20:17:25 +00:00
|
|
|
stop_timeout(traywin->render_timeout);
|
2009-10-30 20:54:29 +00:00
|
|
|
g_free(traywin);
|
2009-03-01 19:18:35 +00:00
|
|
|
|
2010-09-18 18:06:29 +00:00
|
|
|
// check empty systray
|
|
|
|
int count = 0;
|
|
|
|
GSList *l;
|
2015-04-11 09:51:10 +00:00
|
|
|
for (l = systray.list_icons; l; l = l->next) {
|
2015-05-11 19:19:36 +00:00
|
|
|
if (((TrayWindow*)l->data)->hide || ((TrayWindow*)l->data)->empty)
|
|
|
|
continue;
|
|
|
|
count++;
|
2010-09-18 18:06:29 +00:00
|
|
|
}
|
2010-09-22 19:33:10 +00:00
|
|
|
if (count == 0)
|
|
|
|
hide(&systray.area);
|
|
|
|
|
2010-09-21 09:54:19 +00:00
|
|
|
// changed in systray
|
|
|
|
systray.area.resize = 1;
|
2009-02-27 22:18:30 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-10 23:16:10 +00:00
|
|
|
void net_message(XClientMessageEvent *e)
|
|
|
|
{
|
2009-02-25 20:04:43 +00:00
|
|
|
unsigned long opcode;
|
|
|
|
Window id;
|
|
|
|
|
|
|
|
opcode = e->data.l[1];
|
|
|
|
switch (opcode) {
|
2009-02-28 23:04:53 +00:00
|
|
|
case SYSTEM_TRAY_REQUEST_DOCK:
|
|
|
|
id = e->data.l[2];
|
2009-03-01 19:18:35 +00:00
|
|
|
if (id) add_icon(id);
|
2009-02-28 23:04:53 +00:00
|
|
|
break;
|
2009-02-25 20:04:43 +00:00
|
|
|
|
2009-02-28 23:04:53 +00:00
|
|
|
case SYSTEM_TRAY_BEGIN_MESSAGE:
|
|
|
|
case SYSTEM_TRAY_CANCEL_MESSAGE:
|
2009-06-13 19:39:41 +00:00
|
|
|
// we don't show baloons messages.
|
2009-02-28 23:04:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-06-29 18:39:44 +00:00
|
|
|
if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA)
|
2009-06-13 19:39:41 +00:00
|
|
|
printf("message from dockapp: %s\n", e->data.b);
|
|
|
|
else
|
2009-06-29 18:39:44 +00:00
|
|
|
fprintf(stderr, "SYSTEM_TRAY : unknown message type\n");
|
2009-02-28 23:04:53 +00:00
|
|
|
break;
|
2009-02-25 20:04:43 +00:00
|
|
|
}
|
2009-02-10 23:16:10 +00:00
|
|
|
}
|
|
|
|
|
2010-01-07 19:51:00 +00:00
|
|
|
void systray_render_icon_now(void* t)
|
2010-01-03 00:33:07 +00:00
|
|
|
{
|
2010-02-20 10:08:56 +00:00
|
|
|
// we end up in this function only in real transparency mode or if systray_task_asb != 100 0 0
|
2010-02-28 07:58:50 +00:00
|
|
|
// we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
|
2010-01-07 19:51:00 +00:00
|
|
|
TrayWindow* traywin = t;
|
2015-05-11 19:19:36 +00:00
|
|
|
|
2010-01-06 19:47:12 +00:00
|
|
|
traywin->render_timeout = 0;
|
2010-10-08 21:45:14 +00:00
|
|
|
if ( traywin->width == 0 || traywin->height == 0 ) {
|
|
|
|
// reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
|
|
|
|
systray_render_icon(traywin);
|
|
|
|
return;
|
|
|
|
}
|
2010-01-06 19:47:12 +00:00
|
|
|
|
2015-05-11 19:19:36 +00:00
|
|
|
XImage *ximage = XGetImage(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, AllPlanes, XYPixmap);
|
|
|
|
XColor color;
|
|
|
|
int x, y, empty = 1;
|
|
|
|
for (x = 0; empty && x < traywin->width; x++) {
|
|
|
|
for (y = 0; empty && y < traywin->height; y++) {
|
|
|
|
color.pixel = XGetPixel(ximage, x, y);
|
|
|
|
if (color.pixel != 0)
|
|
|
|
empty = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XFree(ximage);
|
|
|
|
if (traywin->empty != empty) {
|
|
|
|
traywin->empty = empty;
|
|
|
|
systray.area.resize = 1;
|
|
|
|
panel_refresh = 1;
|
|
|
|
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
|
|
|
}
|
|
|
|
//printf("systray_render_icon_now: %d empty %d\n", traywin->tray_id, empty);
|
|
|
|
if (empty)
|
|
|
|
return;
|
|
|
|
|
2010-01-03 20:17:46 +00:00
|
|
|
// good systray icons support 32 bit depth, but some icons are still 24 bit.
|
2010-01-03 00:33:07 +00:00
|
|
|
// We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
|
|
|
|
// mask out all pixel with the same rgb value
|
|
|
|
Panel* panel = systray.area.panel;
|
2010-01-31 14:04:58 +00:00
|
|
|
|
|
|
|
// Very ugly hack, but somehow imlib2 is not able to get the image from the traywindow itself,
|
|
|
|
// so we first render the tray window onto a pixmap, and then we tell imlib2 to use this pixmap as
|
|
|
|
// drawable. If someone knows why it does not work with the traywindow itself, please tell me ;)
|
2010-02-28 07:58:50 +00:00
|
|
|
Pixmap tmp_pmap = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, 32);
|
2010-01-31 14:04:58 +00:00
|
|
|
XRenderPictFormat* f;
|
|
|
|
if (traywin->depth == 24)
|
2010-01-31 16:56:54 +00:00
|
|
|
f = XRenderFindStandardFormat(server.dsp, PictStandardRGB24);
|
|
|
|
else if (traywin->depth == 32)
|
2010-01-31 15:10:38 +00:00
|
|
|
f = XRenderFindStandardFormat(server.dsp, PictStandardARGB32);
|
2010-01-31 16:56:54 +00:00
|
|
|
else {
|
2010-02-20 10:08:56 +00:00
|
|
|
printf("Strange tray icon found with depth: %d\n", traywin->depth);
|
2010-01-31 16:56:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-04-18 10:35:25 +00:00
|
|
|
Picture pict_image;
|
2010-04-20 15:14:37 +00:00
|
|
|
//if (server.real_transparency)
|
|
|
|
//pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0);
|
|
|
|
// reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr
|
|
|
|
pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0);
|
2010-02-28 07:58:50 +00:00
|
|
|
Picture pict_drawable = XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0);
|
2010-01-31 14:04:58 +00:00
|
|
|
XRenderComposite(server.dsp, PictOpSrc, pict_image, None, pict_drawable, 0, 0, 0, 0, 0, 0, traywin->width, traywin->height);
|
|
|
|
XRenderFreePicture(server.dsp, pict_image);
|
|
|
|
XRenderFreePicture(server.dsp, pict_drawable);
|
|
|
|
// end of the ugly hack and we can continue as before
|
|
|
|
|
2010-02-28 07:58:50 +00:00
|
|
|
imlib_context_set_visual(server.visual32);
|
|
|
|
imlib_context_set_colormap(server.colormap32);
|
2010-01-31 14:04:58 +00:00
|
|
|
imlib_context_set_drawable(tmp_pmap);
|
|
|
|
Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, traywin->width, traywin->height, 1);
|
2010-01-06 19:30:55 +00:00
|
|
|
if (image == 0)
|
|
|
|
return;
|
|
|
|
|
2010-01-03 20:17:46 +00:00
|
|
|
imlib_context_set_image(image);
|
2010-04-22 15:08:21 +00:00
|
|
|
//if (traywin->depth == 24)
|
|
|
|
//imlib_save_image("/home/thil77/test.jpg");
|
2010-01-03 20:17:46 +00:00
|
|
|
imlib_image_set_has_alpha(1);
|
|
|
|
DATA32* data = imlib_image_get_data();
|
2010-02-28 07:58:50 +00:00
|
|
|
if (traywin->depth == 24) {
|
2010-01-03 00:33:07 +00:00
|
|
|
createHeuristicMask(data, traywin->width, traywin->height);
|
|
|
|
}
|
2010-01-03 20:17:46 +00:00
|
|
|
if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)
|
|
|
|
adjust_asb(data, traywin->width, traywin->height, systray.alpha, (float)systray.saturation/100, (float)systray.brightness/100);
|
|
|
|
imlib_image_put_back_data(data);
|
2010-01-09 00:11:01 +00:00
|
|
|
XCopyArea(server.dsp, render_background, systray.area.pix, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x-systray.area.posx, traywin->y-systray.area.posy);
|
2015-05-03 13:36:34 +00:00
|
|
|
render_image(systray.area.pix, traywin->x-systray.area.posx, traywin->y-systray.area.posy);
|
2010-01-09 00:11:01 +00:00
|
|
|
XCopyArea(server.dsp, systray.area.pix, panel->main_win, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y);
|
2010-01-05 11:21:18 +00:00
|
|
|
imlib_free_image_and_decache();
|
2010-01-31 14:04:58 +00:00
|
|
|
XFreePixmap(server.dsp, tmp_pmap);
|
2010-02-28 07:58:50 +00:00
|
|
|
imlib_context_set_visual(server.visual);
|
|
|
|
imlib_context_set_colormap(server.colormap);
|
2010-01-06 19:47:12 +00:00
|
|
|
|
2010-01-26 18:32:00 +00:00
|
|
|
if (traywin->damage)
|
|
|
|
XDamageSubtract(server.dsp, traywin->damage, None, None);
|
2010-01-06 19:47:12 +00:00
|
|
|
XFlush(server.dsp);
|
|
|
|
}
|
|
|
|
|
2010-01-07 21:23:15 +00:00
|
|
|
|
2010-01-06 19:47:12 +00:00
|
|
|
void systray_render_icon(TrayWindow* traywin)
|
|
|
|
{
|
2015-04-13 20:18:28 +00:00
|
|
|
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
2010-01-30 23:06:07 +00:00
|
|
|
// wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms
|
2015-04-17 20:17:25 +00:00
|
|
|
if (!traywin->render_timeout)
|
|
|
|
traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin, &traywin->render_timeout);
|
2010-01-30 23:06:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-04-13 20:18:28 +00:00
|
|
|
// Pixmap pix = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, server.depth);
|
|
|
|
// XCopyArea(server.dsp, panel->temp_pmap, pix, server.gc, traywin->x, traywin->y, traywin->width, traywin->height, 0, 0);
|
|
|
|
// XSetWindowBackgroundPixmap(server.dsp, traywin->id, pix);
|
2010-01-30 23:06:07 +00:00
|
|
|
XClearArea(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, True);
|
|
|
|
}
|
2010-01-03 00:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-20 15:08:33 +00:00
|
|
|
void refresh_systray_icon()
|
2009-06-13 19:39:41 +00:00
|
|
|
{
|
|
|
|
TrayWindow *traywin;
|
|
|
|
GSList *l;
|
|
|
|
for (l = systray.list_icons; l ; l = l->next) {
|
|
|
|
traywin = (TrayWindow*)l->data;
|
2015-05-11 19:19:36 +00:00
|
|
|
if (traywin->hide)
|
|
|
|
continue;
|
2010-01-30 23:06:07 +00:00
|
|
|
systray_render_icon(traywin);
|
2009-06-13 19:39:41 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-31 11:02:35 +00:00
|
|
|
|
|
|
|
int systray_on_monitor(int i_monitor, int nb_panels)
|
|
|
|
{
|
|
|
|
return (i_monitor == systray_monitor) ||
|
|
|
|
(i_monitor == 0 && (systray_monitor >= nb_panels || systray_monitor < 0));
|
|
|
|
}
|