After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733768 - W32: Widgets can't be embedded into foreign windows
W32: Widgets can't be embedded into foreign windows
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
unspecified
Other All
: Normal normal
: ---
Assigned To: Fan, Chun-wei
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-07-25 23:47 UTC by LRN
Modified: 2014-08-06 07:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
When wrapping a foreign W32 window, don't forget to store its HWND (1.04 KB, patch)
2014-07-25 23:47 UTC, LRN
committed Details | Review
gdkwindow-win32.c: Fix build on MSVC by casting old_ptr to HWND (1.01 KB, patch)
2014-08-06 05:08 UTC, Fan, Chun-wei
committed Details | Review

Description LRN 2014-07-25 23:47:37 UTC
When this is attempted (for example, by gedit opening a printing dialogue),
this gets logged:
Gdk-WARNING **: gdkwindow-win32.c:677: CreateWindowExW failed: Cannot create a top-level child window.
Comment 1 LRN 2014-07-25 23:47:41 UTC
Created attachment 281740 [details] [review]
When wrapping a foreign W32 window, don't forget to store its HWND

When that window is later used as a parent for a GDK child, the call to
CreateWindow*() will fail, because its HWND is 0.
Comment 2 Ignacio Casal Quinteiro (nacho) 2014-07-28 07:58:03 UTC
Review of attachment 281740 [details] [review]:

See comment

::: gdk/win32/gdkwindow-win32.c
@@ +744,2 @@
   window->depth = gdk_visual_get_system ()->depth;
+  GDK_WINDOW_HWND (window) = anid;

let's use impl->handle instead ?
Comment 3 LRN 2014-07-28 08:36:42 UTC
Why?

gdkevents-win32.c:1900
>      else if (msg->message == WM_CREATE)
>	{
>	  window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
>	  GDK_WINDOW_HWND (window) = msg->hwnd;
>	}
>      else

although gdkwindow-win32.c:650
>      /* HB: IHMO due to a race condition the handle was increased by
>       * one, which causes much trouble. Because I can't find the 
>       * real bug, try to workaround it ...
>       * To reproduce: compile with MSVC 5, DEBUG=1
>       */
># if 0
>      gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
>      GDK_WINDOW_HWND (window) = hwndNew;
>      gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
># else
>      /* the old behaviour, but with warning */
>      impl->handle = hwndNew;
># endif
Comment 4 Ignacio Casal Quinteiro (nacho) 2014-07-28 10:34:40 UTC
using a macro to assign the new value seems bad practice...
Comment 5 Ignacio Casal Quinteiro (nacho) 2014-08-05 06:23:58 UTC
ok, let's push this with the macro for consistency.
Comment 6 Ignacio Casal Quinteiro (nacho) 2014-08-05 06:24:17 UTC
Review of attachment 281740 [details] [review]:

Please push.
Comment 7 LRN 2014-08-05 06:38:09 UTC
Attachment 281740 [details] pushed as 31d08bd - When wrapping a foreign W32 window, don't forget to store its HWND
Comment 8 Fan, Chun-wei 2014-08-06 05:08:32 UTC
Created attachment 282626 [details] [review]
gdkwindow-win32.c: Fix build on MSVC by casting old_ptr to HWND

Hi,

Unfortunately, I have to reopen this... this broke the build on MSVC as it is more strict on the types when we try to do a value comparison.  Let's cast old_ptr to a HWND...

With blessings, thank you!
Comment 9 Ignacio Casal Quinteiro (nacho) 2014-08-06 06:18:43 UTC
Review of attachment 282626 [details] [review]:

Looks good.
Comment 10 Fan, Chun-wei 2014-08-06 07:15:51 UTC
Review of attachment 282626 [details] [review]:

Hello Nacho,

Thanks for the review.  The patch was pushed to master as 781846e5.  Shall we push the patches here to gtk-3-12, as this issue hits all releases of GTK+-3.x?

With blessings, thank you!
Comment 11 LRN 2014-08-06 07:20:03 UTC
You've reopened the wrong bug, you actually wanted to comment on bug 726224
Comment 12 Fan, Chun-wei 2014-08-06 07:23:08 UTC
Hello LRN,

Yup, sorry...

Thanks though.

Blesings!