2000-05-01 22:49:16 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2000-05-01 22:49:16 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
2000-05-01 22:49:16 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2000-05-01 22:49:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* gdkgeometry-win32.c: emulation of 32 bit coordinates within the
|
2005-03-11 23:50:21 +00:00
|
|
|
* limits of Win32 GDI. The idea of big window emulation is more or less
|
|
|
|
* a copy of the X11 version, and the equvalent of guffaw scrolling
|
|
|
|
* is ScrollWindowEx(). While we determine the invalidated region
|
|
|
|
* ourself during scrolling, we do not pass SW_INVALIDATE to
|
|
|
|
* ScrollWindowEx() to avoid a unnecessary WM_PAINT.
|
2000-05-01 22:49:16 +00:00
|
|
|
*
|
2005-03-11 23:50:21 +00:00
|
|
|
* Bits are always scrolled correctly by ScrollWindowEx(), but
|
|
|
|
* some big children may hit the coordinate boundary (i.e.
|
|
|
|
* win32_x/win32_y < -16383) after scrolling. They needed to be moved
|
|
|
|
* back to the real position determined by gdk_window_compute_position().
|
|
|
|
* This is handled in gdk_window_postmove().
|
|
|
|
*
|
2000-05-01 22:49:16 +00:00
|
|
|
* The X11 version by Owen Taylor <otaylor@redhat.com>
|
|
|
|
* Copyright Red Hat, Inc. 2000
|
|
|
|
* Win32 hack by Tor Lillqvist <tml@iki.fi>
|
2001-11-18 15:37:13 +00:00
|
|
|
* and Hans Breuer <hans@breuer.org>
|
2005-03-11 23:50:21 +00:00
|
|
|
* Modified by Ivan, Wong Yat Cheung <email@ivanwong.info>
|
|
|
|
* so that big window emulation finally works.
|
2000-05-01 22:49:16 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2000-05-01 22:49:16 +00:00
|
|
|
#include "gdk.h" /* For gdk_rectangle_intersect */
|
2009-02-14 18:23:54 +00:00
|
|
|
#include "gdkinternals.h"
|
2000-05-01 22:49:16 +00:00
|
|
|
#include "gdkprivate-win32.h"
|
2011-01-02 10:51:25 +00:00
|
|
|
#include "gdkwin32.h"
|
2000-05-01 22:49:16 +00:00
|
|
|
|
2005-03-11 23:50:21 +00:00
|
|
|
#define SIZE_LIMIT 32767
|
2001-09-21 19:58:35 +00:00
|
|
|
|
2000-05-01 22:49:16 +00:00
|
|
|
typedef struct _GdkWindowParentPos GdkWindowParentPos;
|
|
|
|
|
2009-03-01 13:55:50 +00:00
|
|
|
static void tmp_unset_bg (GdkWindow *window);
|
|
|
|
static void tmp_reset_bg (GdkWindow *window);
|
|
|
|
|
2000-05-01 22:49:16 +00:00
|
|
|
void
|
|
|
|
_gdk_window_move_resize_child (GdkWindow *window,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2000-07-25 17:31:05 +00:00
|
|
|
GdkWindowImplWin32 *impl;
|
2009-02-14 18:23:54 +00:00
|
|
|
|
2000-05-01 22:49:16 +00:00
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
|
2009-02-14 18:23:54 +00:00
|
|
|
|
2005-03-16 01:38:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
|
2011-01-02 10:51:25 +00:00
|
|
|
_gdk_win32_window_description (window),
|
|
|
|
window->x, window->y, width, height, x, y));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2009-02-14 18:23:54 +00:00
|
|
|
if (width > 65535 || height > 65535)
|
|
|
|
{
|
2009-02-24 15:52:32 +00:00
|
|
|
g_warning ("Native children wider or taller than 65535 pixels are not supported.");
|
2000-05-01 22:49:16 +00:00
|
|
|
|
2009-02-24 15:52:32 +00:00
|
|
|
if (width > 65535)
|
|
|
|
width = 65535;
|
|
|
|
if (height > 65535)
|
|
|
|
height = 65535;
|
2009-02-14 18:23:54 +00:00
|
|
|
}
|
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to
2002-11-12 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate-win32.h
* gdk/win32/*.c: Rename all global variables and functions to
start with underscore.
Merge from stable:
More work on the Win32 backend. The cause of some scrolling
problems was that SetWindowPos() and ScrollWindowEx() don't blit
those parts of the window they think are invalid. As we didn't
keep Windows's update region in synch with GDK's, Windows thought
those areas that in fact had been updated were invalid. Calling
ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to
be an elegant and efficient solution, removing from Windows's
update region those areas we are about to repaint proactively.
In some cases garbage leftover values were used for the clip
origin in GdkGCWin32. This showed up as odd blank areas around the
pixmaps included in the Text Widget in gtk-demo.
Having the clip region either as a GdkRegion or a HRGN in
GdkGCWin32 was unnecessary, it's better to just use a HRGN.
The translation and antiexpose queue handling in
gdkgeometry-win32.c seems unnecessary (and not implementable in
the same way as on X11 anyway, no serial numbers) on Windows,
ifdeffed out.
Don't (try to) do guffaw scrolling as there is no static window
gravity on Windows. Guffaw scrolling would be unnecessary anyway,
as there is the ScrollWindow() API. This improves the behaviour of
the Text Widget demo in gtk-demo a lot. But I have no idea how the
lack of static win gravity should be handled in other places where
the X11 code uses it. Especially _gdk_window_move_resize_child().
There is still some problem in expose handling. By moving an
obscuring window back and forth over testgtk's main window, for
instance, every now and then you typically get narrow vertical or
horizontal strips of pixels that haven't been properly redrawn
after being exposed. A fencepost error somewhere?
Otherwise, all of testgtk and gtk-demo except "big windows" now
seem to work pretty well.
Bug #79720 should be fixed now.
* gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string,
gdk_win32_print_paletteentries, gdk_win32_print_system_palette,
gdk_win32_print_hpalette)
* gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description)
* gdk/win32/gdkevents-win32.c (gdk_win32_message_name):
Move all debugging helper functions to gdkmain-win32.c.
* gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles):
Rewrite. Make static. Must take tile origin parameters, too.
(gdk_win32_draw_rectangle): Pass the tile/stipple origin to
_gdk_win32_draw_tiles(). Remove #if 0 code.
(blit_inside_window): Don't call ScrollDC(), that didn't work at
all like I thought. A simple call to BitBlt() is enough.
* gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused
latin_locale_loaded variable.
(_gdk_win32_get_next_tick): New function. Used to make sure
timestamps of events are always increasing, both in events
generated from the window procedure and in events gotten via
PeekMessage(). Not sure whether this is actually useful, but it
seemed as a good idea.
(real_window_procedure): Don't use a local GdkEventPrivate
variable. Don't attempt any compression of configure or expose
events here, handled elsewhere.
(erase_background): Accumulate window offsets when traversing up
the parent chain for GDK_PARENT_RELATIVE_BG, in order to get
correct alignment of background pixmaps. Don't fill with
BLACK_BRUSH if GDK_NO_BG.
(gdk_event_get_graphics_expose): A bit more verbose debugging output.
(gdk_event_translate): Use _gdk_win32_get_next_tick(). In the
WM_PAINT handler, don't check for empty update rect. When we get a
WM_PAINT, the update region isn't empty. And if it for some
strange reason is, that will be handled later anyway. Call
GetUpdateRgn() before calling BeginPaint() and EndPaint() (which
empty the update region).
* gdk/win32/gdkdnd-win32.c
* gdk/win32/gdkinput-win32.c:
Use _gdk_win32_get_next_tick().
* gdk/win32/gdkfont-win32.c: Use %p to print HFONTs.
(gdk_text_size): Remove, unused.
* gdk/win32/gdkgc-win32.c: Set clip origins to zero
when appropriate.
(gdk_gc_copy): Increase refcount on colormap if present.
(gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple,
combine it with clip region after selecting into the DC.
(_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region.
(_gdk_win3_gdkregion_to_hrgn): New function, code snippet
extracted from gdk_win32_hdc_get().
* gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue
handling.
(gdk_window_copy_area_scroll): Increase clipRect to avoid
ScrollWindowEx() not scrolling pixels it thinks are invalid.
Scroll also children with the ScrollWindowEx() call. No need to
call gdk_window_move() on the children.
(gdk_window_scroll): Don't do guffaw scrolling.
(gdk_window_compute_position): Fix typo, used win32_y where x was
intended.
(gdk_window_premove, gdk_window_postmove,
gdk_window_clip_changed): Add debugging output.
(_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn()
on the region.
(_gdk_window_process_expose): No use for the serial number
parameter now. Instead of a rectangle, take a region parameter, as
Windows gives us one in WM_PAINT.
* gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string,
_gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string,
_gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string,
_gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string,
_gdk_win32_gdkregion_to_string): New debugging functions.
(static_printf): Helper function for the above. sprintfs into a
static circular buffer, return value should be used "soon".
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory
leak, free list after use.
(gdk_window_gravity_works): Remove, we know that there is no such
thing on Windows.
(gdk_window_set_static_bit_gravity,
gdk_window_set_static_win_gravity): Ditto, remove, they didn't do
anything anyway.
(_gdk_windowing_window_init, gdk_window_foreign_new): Call
_gdk_window_init_position() like in the X11 backend.
(gdk_window_reparent): Don't call the now nonexistent
gdk_window_set_static_win_gravity(). No idea what should be done
instead.
(gdk_window_get_geometry): The returned x and y should be relative
to parent. Used to be always zero..
(gdk_window_set_static_gravities): Return FALSE if trying to set
static gravity.
* gdk/win32/gdkprivate-win32.h: Drop the clip_region field from
GdkGCWin32. Only use the HRGN hcliprgn. Declare new
functions.
* gdk/win32/*.c: Use new debugging functions.
* gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
window->x = x;
|
|
|
|
window->y = y;
|
|
|
|
window->width = width;
|
|
|
|
window->height = height;
|
2009-02-24 15:52:32 +00:00
|
|
|
|
|
|
|
_gdk_win32_window_tmp_unset_parent_bg (window);
|
|
|
|
_gdk_win32_window_tmp_unset_bg (window, TRUE);
|
2009-02-14 18:23:54 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
|
2010-08-26 18:02:00 +00:00
|
|
|
"NOACTIVATE|NOZORDER)\n",
|
2009-02-24 15:52:32 +00:00
|
|
|
GDK_WINDOW_HWND (window),
|
2011-01-02 10:51:25 +00:00
|
|
|
window->x + window->parent->abs_x, window->y + window->parent->abs_y,
|
2010-08-26 18:02:00 +00:00
|
|
|
width, height));
|
2009-02-14 18:23:54 +00:00
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
|
2011-01-02 10:51:25 +00:00
|
|
|
window->x + window->parent->abs_x, window->y + window->parent->abs_y,
|
2009-02-24 15:52:32 +00:00
|
|
|
width, height,
|
2010-08-26 18:02:00 +00:00
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER));
|
2009-02-24 15:52:32 +00:00
|
|
|
|
2009-03-01 13:55:50 +00:00
|
|
|
_gdk_win32_window_tmp_reset_bg (window, TRUE);
|
2000-05-01 22:49:16 +00:00
|
|
|
}
|
|
|
|
|
2009-02-24 15:52:32 +00:00
|
|
|
void
|
|
|
|
_gdk_win32_window_tmp_unset_bg (GdkWindow *window,
|
|
|
|
gboolean recurse)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
if (window->input_only || window->destroyed ||
|
|
|
|
(window->window_type != GDK_WINDOW_ROOT &&
|
2009-02-24 15:52:32 +00:00
|
|
|
!GDK_WINDOW_IS_MAPPED (window)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_gdk_window_has_impl (window) &&
|
|
|
|
GDK_WINDOW_IS_WIN32 (window) &&
|
2011-01-02 10:51:25 +00:00
|
|
|
window->window_type != GDK_WINDOW_ROOT &&
|
|
|
|
window->window_type != GDK_WINDOW_FOREIGN)
|
2009-02-24 15:52:32 +00:00
|
|
|
tmp_unset_bg (window);
|
|
|
|
|
|
|
|
if (recurse)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
for (l = window->children; l != NULL; l = l->next)
|
2009-02-24 15:52:32 +00:00
|
|
|
_gdk_win32_window_tmp_unset_bg (l->data, TRUE);
|
|
|
|
}
|
2000-05-01 22:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-24 15:52:32 +00:00
|
|
|
tmp_unset_bg (GdkWindow *window)
|
2000-05-01 22:49:16 +00:00
|
|
|
{
|
2000-07-25 17:31:05 +00:00
|
|
|
GdkWindowImplWin32 *impl;
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
|
2000-07-25 17:31:05 +00:00
|
|
|
|
2009-02-14 18:23:54 +00:00
|
|
|
impl->no_bg = TRUE;
|
2000-05-01 22:49:16 +00:00
|
|
|
}
|
|
|
|
|
2009-03-01 13:55:50 +00:00
|
|
|
static void
|
|
|
|
tmp_reset_bg (GdkWindow *window)
|
|
|
|
{
|
|
|
|
GdkWindowImplWin32 *impl;
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
|
2009-03-01 13:55:50 +00:00
|
|
|
|
|
|
|
impl->no_bg = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-02-24 15:52:32 +00:00
|
|
|
void
|
|
|
|
_gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window)
|
|
|
|
{
|
2011-01-02 10:51:25 +00:00
|
|
|
if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
|
2009-02-24 15:52:32 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
window = _gdk_window_get_impl_window (window->parent);
|
2009-02-24 15:52:32 +00:00
|
|
|
_gdk_win32_window_tmp_unset_bg (window, FALSE);
|
|
|
|
}
|
|
|
|
|
2009-03-01 13:55:50 +00:00
|
|
|
void
|
|
|
|
_gdk_win32_window_tmp_reset_bg (GdkWindow *window,
|
|
|
|
gboolean recurse)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
if (window->input_only || window->destroyed ||
|
|
|
|
(window->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window)))
|
2009-03-01 13:55:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (_gdk_window_has_impl (window) &&
|
|
|
|
GDK_WINDOW_IS_WIN32 (window) &&
|
2011-01-02 10:51:25 +00:00
|
|
|
window->window_type != GDK_WINDOW_ROOT &&
|
|
|
|
window->window_type != GDK_WINDOW_FOREIGN)
|
2009-03-01 13:55:50 +00:00
|
|
|
{
|
|
|
|
tmp_reset_bg (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (recurse)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
for (l = window->children; l != NULL; l = l->next)
|
2009-03-01 13:55:50 +00:00
|
|
|
_gdk_win32_window_tmp_reset_bg (l->data, TRUE);
|
|
|
|
}
|
|
|
|
}
|