Damjan Jovanovic : winex11: Support the startup notification fd.o spec.

Alexandre Julliard julliard at winehq.org
Wed Jan 7 10:57:16 CST 2009


Module: wine
Branch: master
Commit: 3613b15785c5168cef52efe186f154d08f712ccd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3613b15785c5168cef52efe186f154d08f712ccd

Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date:   Tue Jan  6 20:59:07 2009 +0200

winex11: Support the startup notification fd.o spec.

---

 dlls/winex11.drv/window.c                  |   62 ++++++++++++++++++++++++++++
 dlls/winex11.drv/x11drv.h                  |    2 +
 dlls/winex11.drv/x11drv_main.c             |    2 +
 programs/winemenubuilder/winemenubuilder.c |    2 +-
 tools/wine.desktop                         |    1 +
 5 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 3725352..db34f20 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -82,6 +82,66 @@ 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";
 
+
+/***********************************************************************
+ * http://standards.freedesktop.org/startup-notification-spec
+ */
+static void remove_startup_notification(Display *display, Window window)
+{
+    static LONG startup_notification_removed = 0;
+    char id[1024];
+    char message[1024];
+    int i;
+    int pos;
+    XEvent xevent;
+    const char *src;
+    int srclen;
+
+    if (InterlockedCompareExchange(&startup_notification_removed, 1, 0) != 0)
+        return;
+
+    if (GetEnvironmentVariableA("DESKTOP_STARTUP_ID", id, sizeof(id)) == 0)
+        return;
+    SetEnvironmentVariableA("DESKTOP_STARTUP_ID", NULL);
+
+    pos = snprintf(message, sizeof(message), "remove: ID=");
+    message[pos++] = '"';
+    for (i = 0; id[i] && pos < sizeof(message) - 2; i++)
+    {
+        if (id[i] == '"' || id[i] == '\\')
+            message[pos++] = '\\';
+        message[pos++] = id[i];
+    }
+    message[pos++] = '"';
+    message[pos++] = '\0';
+
+    xevent.xclient.type = ClientMessage;
+    xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO_BEGIN);
+    xevent.xclient.display = display;
+    xevent.xclient.window = window;
+    xevent.xclient.format = 8;
+
+    src = message;
+    srclen = strlen(src) + 1;
+
+    wine_tsx11_lock();
+    while (srclen > 0)
+    {
+        int msglen = srclen;
+        if (msglen > 20)
+            msglen = 20;
+        memset(&xevent.xclient.data.b[0], 0, 20);
+        memcpy(&xevent.xclient.data.b[0], src, msglen);
+        src += msglen;
+        srclen -= msglen;
+
+        XSendEvent( display, DefaultRootWindow( display ), False, PropertyChangeMask, &xevent );
+        xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO);
+    }
+    wine_tsx11_unlock();
+}
+
+
 /***********************************************************************
  *		is_window_managed
  *
@@ -1099,6 +1159,8 @@ static void map_window( Display *display, struct x11drv_win_data *data, DWORD ne
 {
     TRACE( "win %p/%lx\n", data->hwnd, data->whole_window );
 
+    remove_startup_notification( display, data->whole_window );
+
     wait_for_withdrawn_state( display, data, TRUE );
 
     if (!data->embedded)
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 6b29f2a..955a08c 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -595,6 +595,8 @@ enum x11drv_atoms
     XATOM_DndSelection,
     XATOM__ICC_PROFILE,
     XATOM__MOTIF_WM_HINTS,
+    XATOM__NET_STARTUP_INFO_BEGIN,
+    XATOM__NET_STARTUP_INFO,
     XATOM__NET_SUPPORTED,
     XATOM__NET_SYSTEM_TRAY_OPCODE,
     XATOM__NET_SYSTEM_TRAY_S0,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index fd8a415..020d6b5 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -132,6 +132,8 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
     "DndSelection",
     "_ICC_PROFILE",
     "_MOTIF_WM_HINTS",
+    "_NET_STARTUP_INFO_BEGIN",
+    "_NET_STARTUP_INFO",
     "_NET_SUPPORTED",
     "_NET_SYSTEM_TRAY_OPCODE",
     "_NET_SYSTEM_TRAY_S0",
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 56eac5a..f5f7ec0 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -804,7 +804,7 @@ static BOOL write_desktop_entry(const char *location, const char *linkname, cons
     fprintf(file, "Exec=env WINEPREFIX=\"%s\" wine \"%s\" %s\n",
             wine_get_config_dir(), path, args);
     fprintf(file, "Type=Application\n");
-    fprintf(file, "StartupWMClass=Wine\n");
+    fprintf(file, "StartupNotify=true\n");
     if (descr && lstrlenA(descr))
         fprintf(file, "Comment=%s\n", descr);
     if (workdir && lstrlenA(workdir))
diff --git a/tools/wine.desktop b/tools/wine.desktop
index fe8f1e3..0d69cc8 100644
--- a/tools/wine.desktop
+++ b/tools/wine.desktop
@@ -18,3 +18,4 @@ Name[nn]=Wine Programlaster for Windowsapplikasjoner
 Exec=wine start /unix %f
 MimeType=application/x-ms-dos-executable;application/x-msdos-program;application/x-msdownload;application/exe;application/x-exe;application/dos-exe;vms/exe;application/x-winexe;application/msdos-windows;application/x-zip-compressed;application/x-executable;application/x-msi;
 NoDisplay=true
+StartupNotify=true




More information about the wine-cvs mailing list