24
24
<a name="gtk-migrating-ClientSideWindows"></a>Migrating to client-side windows</h2></div></div></div>
26
26
In version 2.18, GDK has been changed to use client-side windows. This
27
means that there is no longer a 1-1 correspondence between <a href="http://library.gnome.org/devel/gdk3/gdk-Windows.html#GdkWindow"><span class="type">GdkWindows</span></a>
27
means that there is no longer a 1-1 correspondence between <a href="../gdk/gdk-Windows.html#GdkWindow"><span class="type">GdkWindows</span></a>
28
28
and windows in the underlying window system. In particular, it is no
29
29
longer correct to assume that each window has an associated XID.
30
30
Code that makes this assumption can sometimes be fixed by calling
31
<a href="http://library.gnome.org/devel/gdk3/gdk-Windows.html#gdk-window-ensure-native"><code class="function">gdk_window_ensure_native()</code></a> on the windows in question.
32
Calling <a href="http://library.gnome.org/devel/gdk3/gdk-X-Window-System-Interaction.html#gdk-x11-drawable-get-xid"><code class="function">gdk_x11_drawable_get_xid()</code></a> (or <a href="http://library.gnome.org/devel/gdk3/gdk-X-Window-System-Interaction.html#GDK-WINDOW-XID:CAPS"><code class="function">GDK_WINDOW_XID()</code></a>) from the
31
<a href="../gdk/gdk-Windows.html#gdk-window-ensure-native"><code class="function">gdk_window_ensure_native()</code></a> on the windows in question.
32
Calling <a href="../gdk/gdk-X-Window-System-Interaction.html#gdk-x11-drawable-get-xid"><code class="function">gdk_x11_drawable_get_xid()</code></a> (or <a href="../gdk/gdk-X-Window-System-Interaction.html#GDK-WINDOW-XID:CAPS"><code class="function">GDK_WINDOW_XID()</code></a>) from the
33
33
X11-specific API on a non-native window will explicitly call
34
<a href="http://library.gnome.org/devel/gdk3/gdk-Windows.html#gdk-window-ensure-native"><code class="function">gdk_window_ensure_native()</code></a>, so old code using this will continue to
35
work. A small gotcha is that the <a href="http://library.gnome.org/devel/gdk3/gdk-X-Window-System-Interaction.html#GDK-WINDOW-XID:CAPS"><code class="function">GDK_WINDOW_XID()</code></a> call is no longer a
34
<a href="../gdk/gdk-Windows.html#gdk-window-ensure-native"><code class="function">gdk_window_ensure_native()</code></a>, so old code using this will continue to
35
work. A small gotcha is that the <a href="../gdk/gdk-X-Window-System-Interaction.html#GDK-WINDOW-XID:CAPS"><code class="function">GDK_WINDOW_XID()</code></a> call is no longer a
36
36
trivial accessor for the XID of the window, and thus must not be called
37
37
from another thread without taking locking precautions.
48
48
using <code class="function">XRestackWindows()</code>. Fixing this properly requires to fix the code
49
49
to use GDK functions to achieve whatever it is trying to achieve.
50
50
To make this easier in the case of stacking order changes, we've added
51
a <a href="http://library.gnome.org/devel/gdk3/gdk-Windows.html#gdk-window-restack"><code class="function">gdk_window_restack()</code></a> function.
51
a <a href="../gdk/gdk-Windows.html#gdk-window-restack"><code class="function">gdk_window_restack()</code></a> function.
54
54
One change that can cause problems for some applications is that GDK
60
60
Problems can also occur when using cairo for drawing. One thing that can
61
61
go wrong is clip handling. If you ever need to reset the clip region on
62
a cairo_t (i.e. use <a href="/home/mclasen/gnome-3.0/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-reset-clip"><code class="function">cairo_reset_clip()</code></a>), you have to to use
63
<a href="http://library.gnome.org/devel/gdk3/gdk-Cairo-Interaction.html#gdk-cairo-reset-clip"><code class="function">gdk_cairo_reset_clip()</code></a> instead. The reason for this is that the <a href="/home/mclasen/gnome-3.0/install/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-reset-clip"><code class="function">cairo_reset_clip()</code></a> call will remove the initial clip region that limits your drawing to
62
a cairo_t (i.e. use <a href="/usr/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-reset-clip"><code class="function">cairo_reset_clip()</code></a>), you have to to use
63
<a href="../gdk/gdk-Cairo-Interaction.html#gdk-cairo-reset-clip"><code class="function">gdk_cairo_reset_clip()</code></a> instead. The reason for this is that the <a href="/usr/share/gtk-doc/html/cairo/cairo-cairo-t.html#cairo-reset-clip"><code class="function">cairo_reset_clip()</code></a> call will remove the initial clip region that limits your drawing to
64
64
the client-side window at hand, so you will end up drawing over stuff
65
outside the window. You also need to use <a href="http://library.gnome.org/devel/gdk3/gdk-Cairo-Interaction.html#gdk-cairo-reset-clip"><code class="function">gdk_cairo_reset_clip()</code></a> if you
65
outside the window. You also need to use <a href="../gdk/gdk-Cairo-Interaction.html#gdk-cairo-reset-clip"><code class="function">gdk_cairo_reset_clip()</code></a> if you
66
66
use a cairo_t that was not allocated in a double-buffered expose handler
67
67
and keep it in use after window hierarchy changes (resizing, moving,
68
68
stacking order changes). The easiest fix for this kind of problem is to
69
69
simply create a new cairo context for each expose event.
72
Due to a weird API in XClearArea the <a href="http://library.gnome.org/devel/gdk3/gdk-Windows.html#gdk-window-clear-area"><code class="function">gdk_window_clear_area()</code></a> call handled
72
Due to a weird API in XClearArea the <a href="../gdk/gdk-Windows.html#gdk-window-clear-area"><code class="function">gdk_window_clear_area()</code></a> call handled
73
73
a specified width or height of zero to mean "to end of window" for
74
74
non-double-buffered drawing. This has been changed to be consistent with
75
75
the docs and what happens in the double-buffered case. All code in GTK+
76
76
that relied on this has been fixed, but it is possible (although unlikely)
77
77
that third party applications rely on this. If you need to do this, just
78
implement it yourself using <a href="http://library.gnome.org/devel/gdk3/gdk-Drawing-Primitives.html#gdk-drawable-get-size"><code class="function">gdk_drawable_get_size()</code></a>.
78
implement it yourself using <a href="../gdk/gdk-Drawing-Primitives.html#gdk-drawable-get-size"><code class="function">gdk_drawable_get_size()</code></a>.
81
81
<div class="footer">