Commit 52246fb9 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Move all the embedded systray window support to winex11.drv.

parent a643337c
......@@ -4,6 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winex11.drv
IMPORTS = user32 gdi32 advapi32 imm32 kernel32 ntdll
DELAYIMPORTS = comctl32
EXTRAINCL = @X_CFLAGS@
EXTRALIBS = @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
......@@ -30,6 +31,7 @@ C_SRCS = \
pen.c \
scroll.c \
settings.c \
systray.c \
text.c \
window.c \
winpos.c \
......
......@@ -64,9 +64,6 @@ static const char gl_drawable_prop[] = "__wine_x11_gl_drawable";
static const char pixmap_prop[] = "__wine_x11_pixmap";
static const char managed_prop[] = "__wine_x11_managed";
/* for XDG systray icons */
#define SYSTEM_TRAY_REQUEST_DOCK 0
extern int usexcomposite;
/***********************************************************************
......@@ -692,93 +689,6 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, HICO
}
}
/***********************************************************************
* wine_make_systray_window (X11DRV.@)
*
* Docks the given X window with the NETWM system tray.
*/
void X11DRV_make_systray_window( HWND hwnd )
{
static Atom systray_atom;
Display *display = thread_display();
struct x11drv_win_data *data;
Window systray_window;
if (root_window != DefaultRootWindow(display)) return;
if (!(data = X11DRV_get_win_data( hwnd )) &&
!(data = X11DRV_create_win_data( hwnd ))) return;
wine_tsx11_lock();
if (!systray_atom)
{
if (DefaultScreen( display ) == 0)
systray_atom = x11drv_atom(_NET_SYSTEM_TRAY_S0);
else
{
char systray_buffer[29]; /* strlen(_NET_SYSTEM_TRAY_S4294967295)+1 */
sprintf( systray_buffer, "_NET_SYSTEM_TRAY_S%u", DefaultScreen( display ) );
systray_atom = XInternAtom( display, systray_buffer, False );
}
}
systray_window = XGetSelectionOwner( display, systray_atom );
wine_tsx11_unlock();
TRACE("Docking tray icon %p\n", data->hwnd);
if (systray_window != None)
{
XEvent ev;
unsigned long info[2];
/* the window _cannot_ be mapped if we intend to dock with an XEMBED tray */
if (data->mapped) FIXME( "trying to dock mapped window %p\n", data->hwnd );
/* set XEMBED protocol data on the window */
info[0] = 0; /* protocol version */
info[1] = 1; /* mapped = true */
wine_tsx11_lock();
XChangeProperty( display, data->whole_window,
x11drv_atom(_XEMBED_INFO),
x11drv_atom(_XEMBED_INFO), 32, PropModeReplace,
(unsigned char*)info, 2 );
/* send the docking request message */
ev.xclient.type = ClientMessage;
ev.xclient.window = systray_window;
ev.xclient.message_type = x11drv_atom( _NET_SYSTEM_TRAY_OPCODE );
ev.xclient.format = 32;
ev.xclient.data.l[0] = CurrentTime;
ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
ev.xclient.data.l[2] = data->whole_window;
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
XSendEvent( display, systray_window, False, NoEventMask, &ev );
wine_tsx11_unlock();
data->mapped = TRUE;
}
else
{
int val = 1;
/* fall back to he KDE hints if the WM doesn't support XEMBED'ed
* systrays */
wine_tsx11_lock();
XChangeProperty( display, data->whole_window,
x11drv_atom(KWM_DOCKWINDOW),
x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace,
(unsigned char*)&val, 1 );
XChangeProperty( display, data->whole_window,
x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
XA_WINDOW, 32, PropModeReplace,
(unsigned char*)&data->whole_window, 1 );
wine_tsx11_unlock();
}
}
/***********************************************************************
* set_size_hints
......
......@@ -129,7 +129,7 @@
@ cdecl wine_create_desktop(long long) X11DRV_create_desktop
# System tray
@ cdecl wine_make_systray_window(long) X11DRV_make_systray_window
@ cdecl wine_notify_icon(long ptr)
# XIM
@ cdecl ForceXIMReset(long) X11DRV_ForceXIMReset
......
......@@ -582,12 +582,10 @@ enum x11drv_atoms
XATOM_WM_DELETE_WINDOW,
XATOM_WM_STATE,
XATOM_WM_TAKE_FOCUS,
XATOM_KWM_DOCKWINDOW,
XATOM_DndProtocol,
XATOM_DndSelection,
XATOM__ICC_PROFILE,
XATOM__MOTIF_WM_HINTS,
XATOM__KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
XATOM__NET_SUPPORTED,
XATOM__NET_SYSTEM_TRAY_OPCODE,
XATOM__NET_SYSTEM_TRAY_S0,
......
......@@ -125,12 +125,10 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"WM_DELETE_WINDOW",
"WM_STATE",
"WM_TAKE_FOCUS",
"KWM_DOCKWINDOW",
"DndProtocol",
"DndSelection",
"_ICC_PROFILE",
"_MOTIF_WM_HINTS",
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
"_NET_SUPPORTED",
"_NET_SYSTEM_TRAY_OPCODE",
"_NET_SYSTEM_TRAY_S0",
......
......@@ -45,6 +45,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(systray);
#define IS_OPTION_FALSE(ch) \
((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
static BOOL (*wine_notify_icon)(DWORD,NOTIFYICONDATAW *);
static const WCHAR adaptor_classname[] = /* Adaptor */ {'A','d','a','p','t','o','r',0};
/* tray state */
......@@ -146,7 +148,6 @@ static void update_tooltip_text(struct icon *icon)
*/
static BOOL display_icon(struct icon *icon, BOOL hide)
{
HMODULE x11drv = GetModuleHandleA("winex11.drv");
RECT rect;
static const WCHAR adaptor_windowname[] = /* Wine System Tray Adaptor */ {'W','i','n','e',' ','S','y','s','t','e','m',' ','T','r','a','y',' ','A','d','a','p','t','o','r',0};
......@@ -182,11 +183,6 @@ static BOOL display_icon(struct icon *icon, BOOL hide)
rect.right - rect.left,
rect.bottom - rect.top,
NULL, NULL, NULL, icon);
if (x11drv)
{
void (*make_systray_window)(HWND) = (void *)GetProcAddress(x11drv, "wine_make_systray_window");
if (make_systray_window) make_systray_window(icon->window);
}
if (!hide_systray)
ShowWindow(icon->window, SW_SHOWNA);
......@@ -355,6 +351,12 @@ static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
buffer, buffer + cbMaskBits);
}
if (wine_notify_icon && wine_notify_icon( cds->dwData, &nid ))
{
if (nid.uFlags & NIF_ICON) DestroyIcon( nid.hIcon );
return TRUE;
}
switch (cds->dwData)
{
case NIM_ADD:
......@@ -484,6 +486,7 @@ static BOOL is_systray_hidden(void)
/* this function creates the listener window */
void initialize_systray(void)
{
HMODULE x11drv;
WNDCLASSEX class;
static const WCHAR classname[] = /* Shell_TrayWnd */ {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
static const WCHAR winname[] = /* Wine Systray Listener */
......@@ -491,6 +494,9 @@ void initialize_systray(void)
WINE_TRACE("initiaizing\n");
if ((x11drv = GetModuleHandleA( "winex11.drv" )))
wine_notify_icon = (void *)GetProcAddress( x11drv, "wine_notify_icon" );
hide_systray = is_systray_hidden();
list_init(&tray.icons);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment