Re: Taskbar grouping in Windows 7

2011-07-25 Thread Tobias Häußler

On 19.07.2011 17:17, Jon TURNEY wrote:

On 01/07/2011 21:38, Tobias Häußler wrote:

On 29/06/2011 15:25, Jon TURNEY wrote:

On 25/06/2011 13:48, Tobias Häußler wrote:

I created a small patch for XWin that adds correct grouping of taskbar
icons when 'Always combine, hide labels' is set in the taskbar
properties. It uses the new taskbar APIs introduced in Windows 7 to set
an application id for each window. The id is based on the X11 class hints.
Maybe it is useful for someone...


Firstly, thanks very much for this patch.

Getting Windows to correctly group XWin windows on the taskbar is something
that has needed fixing for a while, so it's great to have it done :-)


Thanks for your suggestions! I changed the code you mentioned.


Thanks.  I've included this patch into the 1.10.3-1 package.

I noticed that there are a couple of warnings issued when building


   CC winmultiwindowwm.o
In file included from winmultiwindowwm.c:69:0:
taskbar.h:59:19: warning: ‘IID_IPropertyStore’ initialized and declared ‘extern’
taskbar.h:67:53: warning: ‘PKEY_AppUserModel_ID’ initialized and declared 
‘extern’


This seems to be related to the nonsense that is INITGUID.  I'm not sure how
to fix this warning.  Would moving all the GUIDs we use (including the DirectX
ones we use) to a separate file and compiling that with INITGUID defined be
the correct solution?


I don't know the right way to deal with that, but it seems to work if 
taskbar.h is included in a separate .c-file with INITGUID defined, and 
in winmultiwindowwm.c without:


--- taskbar.c:
#define INITGUID
#include basetyps.h
#include shlguid.h

#include taskbar.h

--- winmultiwindowwm.c:
#include taskbar.h

The current solution produces this warning because of the declaration of 
DEFINE_GUID in basetyps.h and initguid.h:


DEFINE_GUID with INITGUID in basetyps.h resolves to:
  const GUID IID_IPropertyStore = {a,b,c,...}

DEFINE_GUID without INITGUID in basetyps.h resolves to:
  extern const GUID IID_IPropertyStore;

DEFINE_GUID with INITGUID in initguid.h resolves to:
  (extern) const GUID IID_IPropertyStore = {a,b,c,...}
Whether extern is appended or not depends on basetyps.h, which is 
included before initguid.h.


Including initguid.h (with INITGUID defined) after basetyps.h appends = 
{a,b,c}, but does not remove extern. In winmultiwindowwm.c this is 
the case, as basetyps.h is included by objbase.h before initguid.h.


The DirectX-GUIDs are initialized in the lib*.a-files of w32api, 
therefore INITGUID is not necessary and the warnings are not present. As 
soon as w32api contains the GUID for IID_IPropertyStore, taskbar.c with 
INITGUID can be removed.





The other thing I noticed is that PropVariantClear() has been provided by
ole32.dll since at least NT4, so there's no need to dynamically link with it.
  So I'm confused as to why you are using GetProcAddress for that?



PropVariantClear() is not declared in the header files of w32api, so I 
had to link it dynamically.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Taskbar grouping in Windows 7

2011-07-19 Thread Jon TURNEY
On 01/07/2011 21:38, Tobias Häußler wrote:
 On 29/06/2011 15:25, Jon TURNEY wrote:
 On 25/06/2011 13:48, Tobias Häußler wrote:
 I created a small patch for XWin that adds correct grouping of taskbar
 icons when 'Always combine, hide labels' is set in the taskbar
 properties. It uses the new taskbar APIs introduced in Windows 7 to set
 an application id for each window. The id is based on the X11 class hints.
 Maybe it is useful for someone...

 Firstly, thanks very much for this patch.

 Getting Windows to correctly group XWin windows on the taskbar is something
 that has needed fixing for a while, so it's great to have it done :-)
 
 Thanks for your suggestions! I changed the code you mentioned.

Thanks.  I've included this patch into the 1.10.3-1 package.

I noticed that there are a couple of warnings issued when building

   CC winmultiwindowwm.o
 In file included from winmultiwindowwm.c:69:0:
 taskbar.h:59:19: warning: ‘IID_IPropertyStore’ initialized and declared 
 ‘extern’
 taskbar.h:67:53: warning: ‘PKEY_AppUserModel_ID’ initialized and declared 
 ‘extern’

This seems to be related to the nonsense that is INITGUID.  I'm not sure how
to fix this warning.  Would moving all the GUIDs we use (including the DirectX
ones we use) to a separate file and compiling that with INITGUID defined be
the correct solution?

The other thing I noticed is that PropVariantClear() has been provided by
ole32.dll since at least NT4, so there's no need to dynamically link with it.
 So I'm confused as to why you are using GetProcAddress for that?

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Taskbar grouping in Windows 7

2011-07-01 Thread Tobias Häußler
On 29/06/2011 15:25, Jon TURNEY wrote:
 On 25/06/2011 13:48, Tobias Häußler wrote:
 I created a small patch for XWin that adds correct grouping of taskbar
 icons when 'Always combine, hide labels' is set in the taskbar
 properties. It uses the new taskbar APIs introduced in Windows 7 to set
 an application id for each window. The id is based on the X11 class hints.
 Maybe it is useful for someone...
 
 Firstly, thanks very much for this patch.
 
 Getting Windows to correctly group XWin windows on the taskbar is something
 that has needed fixing for a while, so it's great to have it done :-)
 

Thanks for your suggestions! I changed the code you mentioned.

 A few minor comments included inline:
 [...]
 Can you start this file with the license information, like all other files.
 
 This should also serve to confirm that you are happy for me to forward this
 upstream to be distributed under the MIT/X11 license [1]
 

Done. I copied the license text from another file...

 [...]
 
 Looks like this function can be made static?
 

Yes, however for proper cleanup this function is now also called from
the WM_DESTROY handler and I left it non-static.

 [...]
 
 Since the results of LoadLibrary/GetProcAddress are invariant at run-time, I'd
 rather these calls were done once, rather than every time we want to use those
 results.
 
 It would also be useful to include a comment mentioning which version of
 Windows these interfaces were added in (so future generations will know when
 they can directly link to those functions :-))
 
 I assume that there is no way to achieve this functionality prior for Windows
 7, rather than an alternative interface which you chose not to use?
 

The initialization/deinitialization is now done only once when XWin is
started/stopped. I am not sure if there is an API to control the taskbar
grouping on older versions of Windows, therefore I have choosen this one...


 [...]
 
 Should be PropVariantInit() ?
 

I cannot use PropVariantInit() for the initialization of the PROPVARIANT
structure because it is not supported bei the w32api of cygwin (or at
least I cannot find it). According to the Microsoft SDK, PropVariantInit
only calls memset.


 [...]
 
 The MSDN description of SHGetPropertyStoreForWindow() says:
 A window's properties must be removed before the window is closed. If this is
 not done, the resources used by those properties are not returned to the 
 system.
 
 Does this not apply in this case, or is some cleanup needed?
 

You are right about that, I added code for cleanup.

 [...]
 
 [1] http://cgit.freedesktop.org/xorg/xserver/tree/COPYING
 

  Tobias
diff -uNr src/xserver-cygwin-1.10.1-1/hw/xwin/InitOutput.c 
src/xserver-cygwin-1.10.1-1/hw/xwin/InitOutput.c
--- src/xserver-cygwin-1.10.1-1/hw/xwin/InitOutput.c2011-04-22 
18:03:27.0 +0200
+++ src/xserver-cygwin-1.10.1-1/hw/xwin/InitOutput.c2011-07-01 
20:11:55.028448200 +0200
@@ -219,6 +219,9 @@
 }
 
 #ifdef XWIN_MULTIWINDOW
+  /* Unload libraries for taskbar grouping */
+  winTaskbarDestroy ();
+
   /* Notify the worker threads we're exiting */
   winDeinitMultiWindowWM ();
 #endif
@@ -984,6 +987,11 @@
   /* Detect supported engines */
   winDetectSupportedEngines ();
 
+#ifdef XWIN_MULTIWINDOW
+  /* Load libraries for taskbar grouping */
+  winTaskbarInit ();
+#endif
+
   /* Store the instance handle */
   g_hInstance = GetModuleHandle (NULL);
 
diff -uNr src/xserver-cygwin-1.10.1-1/hw/xwin/Makefile.am 
src/xserver-cygwin-1.10.1-1/hw/xwin/Makefile.am
--- src/xserver-cygwin-1.10.1-1/hw/xwin/Makefile.am 2011-04-22 
18:03:27.0 +0200
+++ src/xserver-cygwin-1.10.1-1/hw/xwin/Makefile.am 2011-07-01 
21:27:18.840399400 +0200
@@ -26,6 +26,7 @@
winmultiwindowwm.c \
winmultiwindowwndproc.c
 DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW
+MULTIWINDOW_LIBS = -lshlwapi
 endif
 
 if XWIN_MULTIWINDOWEXTWM
@@ -149,7 +150,7 @@
 INCLUDES = -I$(top_srcdir)/miext/rootless
 
 XWin_DEPENDENCIES = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_LIBS) 
$(MAIN_LIB) $(XSERVER_LIBS)
-XWin_LDADD = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_GLX_LINK_FLAGS) 
$(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
+XWin_LDADD = $(MULTIWINDOW_LIBS) $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) 
$(XWIN_GLX_LINK_FLAGS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) 
$(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
 XWin_LDFLAGS = -mwindows -static
 
 .rc.o:
diff -uNr src/xserver-cygwin-1.10.1-1/hw/xwin/taskbar.h 
src/xserver-cygwin-1.10.1-1/hw/xwin/taskbar.h
--- src/xserver-cygwin-1.10.1-1/hw/xwin/taskbar.h   1970-01-01 
01:00:00.0 +0100
+++ src/xserver-cygwin-1.10.1-1/hw/xwin/taskbar.h   2011-07-01 
21:10:40.698151400 +0200
@@ -0,0 +1,72 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *Software), to deal in the