1999-11-11 22:12:27 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
2004-05-08 16:25:15 +00:00
|
|
|
* Copyright (C) 1998-2004 Tor Lillqvist
|
2011-01-02 10:51:25 +00:00
|
|
|
* Copyright (C) 2001-2011 Hans Breuer
|
2009-03-01 13:55:50 +00:00
|
|
|
* Copyright (C) 2007-2009 Cody Russell
|
1999-11-11 22:12:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
1999-11-11 22:12:27 +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.
|
1999-11-11 22:12:27 +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/>.
|
1999-11-11 22:12:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-11-11 22:12:27 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2015-04-29 07:31:08 +00:00
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-11-11 22:12:27 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
1999-11-11 22:12:27 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-11-09 12:35:56 +00:00
|
|
|
#include "gdk.h"
|
1999-11-20 01:22:57 +00:00
|
|
|
#include "gdkprivate-win32.h"
|
2010-05-25 22:38:44 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
|
|
|
#include "gdkdevicemanager-win32.h"
|
2008-10-05 00:00:10 +00:00
|
|
|
#include "gdkenumtypes.h"
|
2011-01-02 10:51:25 +00:00
|
|
|
#include "gdkwin32.h"
|
|
|
|
#include "gdkdisplayprivate.h"
|
2021-09-29 02:40:56 +00:00
|
|
|
#include "gdkdragsurfaceprivate.h"
|
2019-05-21 21:20:15 +00:00
|
|
|
#include "gdkframeclockidleprivate.h"
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
#include "gdkmonitorprivate.h"
|
2021-09-29 02:40:56 +00:00
|
|
|
#include "gdkpopupprivate.h"
|
|
|
|
#include "gdkseatprivate.h"
|
|
|
|
#include "gdksurfaceprivate.h"
|
|
|
|
#include "gdktoplevelprivate.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdkwin32surface.h"
|
2018-03-29 23:40:32 +00:00
|
|
|
#include "gdkwin32cursor.h"
|
2021-07-02 09:13:06 +00:00
|
|
|
#include "gdkinput-winpointer.h"
|
2014-12-17 04:32:04 +00:00
|
|
|
#include "gdkglcontext-win32.h"
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
#include "gdkdisplay-win32.h"
|
2020-09-04 09:24:57 +00:00
|
|
|
#include "gdkdevice-win32.h"
|
2020-08-05 02:36:53 +00:00
|
|
|
#include "gdkcairocontext-win32.h"
|
2011-01-02 10:51:25 +00:00
|
|
|
|
|
|
|
#include <cairo-win32.h>
|
2015-04-22 19:10:55 +00:00
|
|
|
#include <dwmapi.h>
|
2016-03-08 02:33:47 +00:00
|
|
|
#include <math.h>
|
2003-08-06 21:01:00 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
static void gdk_surface_win32_finalize (GObject *object);
|
2020-12-31 08:36:41 +00:00
|
|
|
static void compute_toplevel_size (GdkSurface *surface,
|
|
|
|
gboolean update_geometry,
|
|
|
|
int *width,
|
|
|
|
int *height);
|
2000-07-25 17:31:05 +00:00
|
|
|
|
|
|
|
static gpointer parent_class = NULL;
|
2008-02-05 16:47:24 +00:00
|
|
|
static GSList *modal_window_stack = NULL;
|
2000-07-25 17:31:05 +00:00
|
|
|
|
2011-10-26 10:43:24 +00:00
|
|
|
typedef struct _FullscreenInfo FullscreenInfo;
|
|
|
|
|
|
|
|
struct _FullscreenInfo
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
guint hint_flags;
|
|
|
|
LONG style;
|
|
|
|
};
|
2011-01-02 10:51:25 +00:00
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
struct _AeroSnapEdgeRegion
|
|
|
|
{
|
|
|
|
/* The rectangle along the edge of the desktop
|
|
|
|
* that allows application of the snap transformation.
|
|
|
|
*/
|
|
|
|
GdkRectangle edge;
|
|
|
|
|
|
|
|
/* A subregion of the "edge". When the pointer hits
|
|
|
|
* this region, the transformation is revealed.
|
|
|
|
* Usually it is 1-pixel thick and is located at the
|
|
|
|
* very edge of the screen. When there's a toolbar
|
|
|
|
* at that edge, the "trigger" and the "edge" regions
|
|
|
|
* are extended to cover that toolbar.
|
|
|
|
*/
|
|
|
|
GdkRectangle trigger;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _AeroSnapEdgeRegion AeroSnapEdgeRegion;
|
|
|
|
|
|
|
|
/* Size of the regions at the edges of the desktop where
|
|
|
|
* snapping can take place (in pixels)
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_REGION_THICKNESS (20)
|
|
|
|
/* Size of the subregions that actually trigger the snapping prompt
|
|
|
|
* (in pixels).
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_REGION_TRIGGER_THICKNESS (1)
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
/* The gap between the snap indicator and the edge of the work area
|
|
|
|
* (in pixels).
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_INDICATOR_EDGE_GAP (10)
|
|
|
|
|
|
|
|
/* Width of the outline of the snap indicator
|
|
|
|
* (in pixels).
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_INDICATOR_LINE_WIDTH (3.0)
|
|
|
|
|
|
|
|
/* Corner radius of the snap indicator.
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_INDICATOR_CORNER_RADIUS (3.0)
|
|
|
|
|
|
|
|
/* The time it takes for snap indicator to expand/shrink
|
|
|
|
* from current window size to future position of the
|
|
|
|
* snapped window (in microseconds).
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_INDICATOR_ANIMATION_DURATION (200 * 1000)
|
|
|
|
|
|
|
|
/* Opacity if the snap indicator. */
|
|
|
|
#define AEROSNAP_INDICATOR_OPACITY (0.5)
|
|
|
|
|
|
|
|
/* The interval between snap indicator redraws (in milliseconds).
|
|
|
|
* 16 is ~ 1/60 of a second, for ~60 FPS.
|
|
|
|
*/
|
|
|
|
#define AEROSNAP_INDICATOR_ANIMATION_TICK (16)
|
|
|
|
|
2018-04-09 20:16:23 +00:00
|
|
|
static void gdk_win32_impl_frame_clock_after_paint (GdkFrameClock *clock,
|
|
|
|
GdkSurface *surface);
|
2006-02-09 02:58:45 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
G_DEFINE_TYPE (GdkWin32Surface, gdk_win32_surface, GDK_TYPE_SURFACE)
|
2011-01-02 10:51:25 +00:00
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
GType gdk_win32_toplevel_get_type (void) G_GNUC_CONST;
|
|
|
|
GType gdk_win32_popup_get_type (void) G_GNUC_CONST;
|
|
|
|
GType gdk_win32_drag_surface_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define GDK_TYPE_WIN32_TOPLEVEL (gdk_win32_toplevel_get_type ())
|
|
|
|
#define GDK_TYPE_WIN32_POPUP (gdk_win32_popup_get_type ())
|
|
|
|
#define GDK_TYPE_WIN32_DRAG_SURFACE (gdk_win32_drag_surface_get_type ())
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2019-05-19 03:09:05 +00:00
|
|
|
gdk_win32_surface_init (GdkWin32Surface *impl)
|
2000-07-25 17:31:05 +00:00
|
|
|
{
|
2003-12-14 01:06:56 +00:00
|
|
|
impl->hicon_big = NULL;
|
|
|
|
impl->hicon_small = NULL;
|
2000-07-25 17:31:05 +00:00
|
|
|
impl->hint_flags = 0;
|
2007-07-12 23:38:30 +00:00
|
|
|
impl->transient_owner = NULL;
|
2007-10-18 00:31:22 +00:00
|
|
|
impl->transient_children = NULL;
|
|
|
|
impl->num_transients = 0;
|
|
|
|
impl->changing_state = FALSE;
|
2018-03-20 11:05:26 +00:00
|
|
|
impl->surface_scale = 1;
|
2000-07-25 17:31:05 +00:00
|
|
|
}
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
|
2018-03-29 23:40:32 +00:00
|
|
|
|
|
|
|
static void
|
2019-05-19 03:09:05 +00:00
|
|
|
gdk_surface_win32_dispose (GObject *object)
|
2018-03-29 23:40:32 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *surface;
|
2018-03-29 23:40:32 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_return_if_fail (GDK_IS_WIN32_SURFACE (object));
|
2018-03-29 23:40:32 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
surface = GDK_WIN32_SURFACE (object);
|
2018-03-29 23:40:32 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_clear_object (&surface->cursor);
|
2018-03-29 23:40:32 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
static void
|
2019-05-19 03:09:05 +00:00
|
|
|
gdk_surface_win32_finalize (GObject *object)
|
2000-07-25 17:31:05 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *surface;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_return_if_fail (GDK_IS_WIN32_SURFACE (object));
|
2000-07-25 17:31:05 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
surface = GDK_WIN32_SURFACE (object);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2019-05-21 21:20:15 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (surface))
|
1999-11-20 01:22:57 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
gdk_win32_handle_table_remove (surface->handle);
|
1999-11-20 01:22:57 +00:00
|
|
|
}
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_clear_pointer (&surface->snap_stash, g_free);
|
|
|
|
g_clear_pointer (&surface->snap_stash_int, g_free);
|
2016-03-08 03:17:09 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface->hicon_big != NULL)
|
2003-12-14 01:06:56 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GDI_CALL (DestroyIcon, (surface->hicon_big));
|
|
|
|
surface->hicon_big = NULL;
|
2003-12-14 01:06:56 +00:00
|
|
|
}
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface->hicon_small != NULL)
|
2003-08-05 22:24:35 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GDI_CALL (DestroyIcon, (surface->hicon_small));
|
|
|
|
surface->hicon_small = NULL;
|
2003-08-05 22:24:35 +00:00
|
|
|
}
|
2000-07-04 06:12:54 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface->cache_surface)
|
2017-09-04 14:42:11 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
cairo_surface_destroy (surface->cache_surface);
|
|
|
|
surface->cache_surface = NULL;
|
2017-09-04 14:42:11 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 21:20:15 +00:00
|
|
|
_gdk_win32_surface_unregister_dnd (GDK_SURFACE (surface));
|
GDK W32: Adapt to GdkDrop and GdkDragContext changes
* Remove clipdrop->dnd_target_state, it's not used anymore
* Remove non-functioning _gdk_dropfiles_store(), store dropfiles
list in GdkWin32Drop instead
* Fix multiple comment typos
* Fix _gdk_win32_get_clipboard_format_name_as_interned_mimetype() to
leave names that look like mime/types alone
* Refactor _gdk_win32_add_w32format_to_pairs() to populate
GdkContentFormatsBuilder directly, instead of making a GList
* Rename context -> drag (still using GdkDragContext type,
but [almost?] all variables and comments say "drag" now)
* Rename GdkDropContext -> GdkDrop
* Rename some parameter names for clarity
* Rewrite local protocol to look more like OLE2 protocol
instead of mirroring the structure of the X11 API.
* Add handle_events field to GdkWin32DragContext,
to shut off event handling (temporary fix until GTK is patched up)
* Remove _gdk_win32_drag_context_find() - the drag object is stored
in GdkDrop instead. Use _gdk_win32_find_drag_for_dest_surface()
to get it initially.
* Remove target_ctx_for_window, droptarget context is stored
in the surface instead.
* Call gdk_drag_context_set_cursor() just like wayland backend does
(slightly broken for now)
* Clean up the action choosing code (filter source actions by using
keyboard state, pass that to GTK, get all actions supported by GTK in
response, match them up with filtered source actions, return the
result, falling back to COPY in case of multiple actions)
* Check drag_win32->protocol instead of the use_ole2_dnd variable where
possible
* Remove protocol checks from functions that are only used by the local
protocol
* Use event state to manufacture the keyboard state for WM_MOUSEMOVE
* Change function names printed by GDK_NOTE to name the actual
functions, not their theoretical generic GDK stack ancestors
* Consistently use drag_win32 and drop_win32 variables instead of a mix
of that and win32_drag/win32_drop
* Return FALSE from button handler to ensure that GTK gets the button
event to break implicit grab
* Emit leave event on failed idroptarget_drop() calls
2018-06-05 23:03:51 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_assert (surface->transient_owner == NULL);
|
|
|
|
g_assert (surface->transient_children == NULL);
|
2017-09-04 14:42:11 +00:00
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1999-11-20 01:22:57 +00:00
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2018-04-24 15:14:23 +00:00
|
|
|
void
|
|
|
|
_gdk_win32_get_window_client_area_rect (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int scale,
|
2018-04-24 15:14:23 +00:00
|
|
|
RECT *rect)
|
2017-09-02 15:25:36 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y, width, height;
|
2017-09-02 15:25:36 +00:00
|
|
|
|
2020-08-05 07:14:44 +00:00
|
|
|
gdk_surface_get_geometry (window, &x, &y, NULL, NULL);
|
2018-03-20 10:40:08 +00:00
|
|
|
width = gdk_surface_get_width (window);
|
|
|
|
height = gdk_surface_get_height (window);
|
2017-09-02 15:25:36 +00:00
|
|
|
rect->left = x * scale;
|
|
|
|
rect->top = y * scale;
|
|
|
|
rect->right = rect->left + width * scale;
|
|
|
|
rect->bottom = rect->top + height * scale;
|
|
|
|
}
|
|
|
|
|
2018-04-09 20:16:23 +00:00
|
|
|
static void
|
|
|
|
gdk_win32_impl_frame_clock_after_paint (GdkFrameClock *clock,
|
|
|
|
GdkSurface *surface)
|
|
|
|
{
|
|
|
|
DWM_TIMING_INFO timing_info;
|
|
|
|
LARGE_INTEGER tick_frequency;
|
|
|
|
GdkFrameTimings *timings;
|
|
|
|
|
|
|
|
timings = gdk_frame_clock_get_timings (clock, gdk_frame_clock_get_frame_counter (clock));
|
|
|
|
|
|
|
|
if (timings)
|
|
|
|
{
|
|
|
|
timings->refresh_interval = 16667; /* default to 1/60th of a second */
|
|
|
|
timings->presentation_time = 0;
|
|
|
|
|
|
|
|
if (QueryPerformanceFrequency (&tick_frequency))
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
timing_info.cbSize = sizeof (timing_info);
|
|
|
|
hr = DwmGetCompositionTimingInfo (NULL, &timing_info);
|
|
|
|
|
|
|
|
if (SUCCEEDED (hr))
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
timings->refresh_interval = timing_info.qpcRefreshPeriod * (double)G_USEC_PER_SEC / tick_frequency.QuadPart;
|
|
|
|
timings->presentation_time = timing_info.qpcCompose * (double)G_USEC_PER_SEC / tick_frequency.QuadPart;
|
2018-04-09 20:16:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timings->complete = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
gdk/win32/gdkinput-win32.h Drop the GdkEvent* parameter, it wasn't used.
2003-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput-win32.c (_gdk_input_configure_event,
_gdk_input_enter_event): Drop the GdkEvent* parameter, it wasn't
used.
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Adapt caller
accordingly, in fact an uninitialised variable was dereferenced.
[Win32] Add support for multiple monitors.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New global variables for
multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and
_gdk_offset_x and _gdk_offset_y.
* gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New
functions, enumeration functions passed to EnumDisplayMonitors().
(gdk_display_open): If the EnumDisplayMonitors() and
GetMonitorInfo() API is present (on Win98, Win2000 and newer), use
if to find out monitor info.
Calculate the offset between Win32 coordinates (relative to the
primary monitor's origin (and thus negative on monitors to the
left of or above it), and GDK's (visible coordinates should be
non-negative).
* gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors,
gdk_screen_get_monitor_geometry): Use information collected above.
(gdk_window_move, gdk_window_move_resize_window_get_geometry):
Subtract _gdk_offset_{x,y} from GDK root window coordinates.
(gdk_window_get_geometry, gdk_window_get_origin,
gdk_window_get_frame_extents): For top-level windows, add
_gdk_offset_{x,y} to GDK root window coordinates
Still need to handle multiple monitors in
gdk_window_fullscreen(). Probably should make the window
fullscreen on the monitor where the cursor is?
* gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK
root window coordinates in GdkEvents.
[Win32] Fix geometry hint handling. Add support for resize
increment and base size, and aspect ratio geometry hints. The
"gridded geometry" test in testgtk now works beautifully.
* gdk/win32/gdkwindow-win32.c (gdk_window_set_geometry_hints):
Turns out this function shouldn't actually ever modify the
window's size, just store the hints. (Old code kept for a while
inside #if 0.)
(gdk_window_set_hints): Remove presumably broken code that handles
the position hints, this function is obsolete anyway.
* gdk/win32/gdkevents-win32.c: Drop the current_{x,y}_root
variables, not used.
(adjust_drag): New function, used to implement resize increment
hints.
(gdk_event_translate): Handle WM_SIZING, implement resize
increment and base size, and aspect ratio geometry hints here. The
WM_GETMINMAXINFO handler takes care of the minimum and maximum
size hints as before. Fix the WM_GETMINMAXINFO handler to take
into account window decorations. No need to modify the
ptMaxPosition and ptMaxSize fields in the MINMAXINFO struct,
the defaults are fine.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwindow-win32.c (_gdk_win32_adjust_client_rect,
_gdk_win32_get_adjusted_client_rect): New helper functions.
2003-08-07 22:17:18 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_adjust_client_rect (GdkSurface *window,
|
gdk/win32/gdkinput-win32.h Drop the GdkEvent* parameter, it wasn't used.
2003-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput-win32.c (_gdk_input_configure_event,
_gdk_input_enter_event): Drop the GdkEvent* parameter, it wasn't
used.
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Adapt caller
accordingly, in fact an uninitialised variable was dereferenced.
[Win32] Add support for multiple monitors.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New global variables for
multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and
_gdk_offset_x and _gdk_offset_y.
* gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New
functions, enumeration functions passed to EnumDisplayMonitors().
(gdk_display_open): If the EnumDisplayMonitors() and
GetMonitorInfo() API is present (on Win98, Win2000 and newer), use
if to find out monitor info.
Calculate the offset between Win32 coordinates (relative to the
primary monitor's origin (and thus negative on monitors to the
left of or above it), and GDK's (visible coordinates should be
non-negative).
* gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors,
gdk_screen_get_monitor_geometry): Use information collected above.
(gdk_window_move, gdk_window_move_resize_window_get_geometry):
Subtract _gdk_offset_{x,y} from GDK root window coordinates.
(gdk_window_get_geometry, gdk_window_get_origin,
gdk_window_get_frame_extents): For top-level windows, add
_gdk_offset_{x,y} to GDK root window coordinates
Still need to handle multiple monitors in
gdk_window_fullscreen(). Probably should make the window
fullscreen on the monitor where the cursor is?
* gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK
root window coordinates in GdkEvents.
[Win32] Fix geometry hint handling. Add support for resize
increment and base size, and aspect ratio geometry hints. The
"gridded geometry" test in testgtk now works beautifully.
* gdk/win32/gdkwindow-win32.c (gdk_window_set_geometry_hints):
Turns out this function shouldn't actually ever modify the
window's size, just store the hints. (Old code kept for a while
inside #if 0.)
(gdk_window_set_hints): Remove presumably broken code that handles
the position hints, this function is obsolete anyway.
* gdk/win32/gdkevents-win32.c: Drop the current_{x,y}_root
variables, not used.
(adjust_drag): New function, used to implement resize increment
hints.
(gdk_event_translate): Handle WM_SIZING, implement resize
increment and base size, and aspect ratio geometry hints here. The
WM_GETMINMAXINFO handler takes care of the minimum and maximum
size hints as before. Fix the WM_GETMINMAXINFO handler to take
into account window decorations. No need to modify the
ptMaxPosition and ptMaxSize fields in the MINMAXINFO struct,
the defaults are fine.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwindow-win32.c (_gdk_win32_adjust_client_rect,
_gdk_win32_get_adjusted_client_rect): New helper functions.
2003-08-07 22:17:18 +00:00
|
|
|
RECT *rect)
|
|
|
|
{
|
|
|
|
LONG style, exstyle;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
style = GetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE);
|
|
|
|
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
|
gdk/win32/gdkinput-win32.h Drop the GdkEvent* parameter, it wasn't used.
2003-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput-win32.c (_gdk_input_configure_event,
_gdk_input_enter_event): Drop the GdkEvent* parameter, it wasn't
used.
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Adapt caller
accordingly, in fact an uninitialised variable was dereferenced.
[Win32] Add support for multiple monitors.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New global variables for
multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and
_gdk_offset_x and _gdk_offset_y.
* gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New
functions, enumeration functions passed to EnumDisplayMonitors().
(gdk_display_open): If the EnumDisplayMonitors() and
GetMonitorInfo() API is present (on Win98, Win2000 and newer), use
if to find out monitor info.
Calculate the offset between Win32 coordinates (relative to the
primary monitor's origin (and thus negative on monitors to the
left of or above it), and GDK's (visible coordinates should be
non-negative).
* gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors,
gdk_screen_get_monitor_geometry): Use information collected above.
(gdk_window_move, gdk_window_move_resize_window_get_geometry):
Subtract _gdk_offset_{x,y} from GDK root window coordinates.
(gdk_window_get_geometry, gdk_window_get_origin,
gdk_window_get_frame_extents): For top-level windows, add
_gdk_offset_{x,y} to GDK root window coordinates
Still need to handle multiple monitors in
gdk_window_fullscreen(). Probably should make the window
fullscreen on the monitor where the cursor is?
* gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK
root window coordinates in GdkEvents.
[Win32] Fix geometry hint handling. Add support for resize
increment and base size, and aspect ratio geometry hints. The
"gridded geometry" test in testgtk now works beautifully.
* gdk/win32/gdkwindow-win32.c (gdk_window_set_geometry_hints):
Turns out this function shouldn't actually ever modify the
window's size, just store the hints. (Old code kept for a while
inside #if 0.)
(gdk_window_set_hints): Remove presumably broken code that handles
the position hints, this function is obsolete anyway.
* gdk/win32/gdkevents-win32.c: Drop the current_{x,y}_root
variables, not used.
(adjust_drag): New function, used to implement resize increment
hints.
(gdk_event_translate): Handle WM_SIZING, implement resize
increment and base size, and aspect ratio geometry hints here. The
WM_GETMINMAXINFO handler takes care of the minimum and maximum
size hints as before. Fix the WM_GETMINMAXINFO handler to take
into account window decorations. No need to modify the
ptMaxPosition and ptMaxSize fields in the MINMAXINFO struct,
the defaults are fine.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwindow-win32.c (_gdk_win32_adjust_client_rect,
_gdk_win32_get_adjusted_client_rect): New helper functions.
2003-08-07 22:17:18 +00:00
|
|
|
API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:10:55 +00:00
|
|
|
gboolean
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_enable_transparency (GdkSurface *window)
|
2015-04-22 19:10:55 +00:00
|
|
|
{
|
|
|
|
DWM_BLURBEHIND blur_behind;
|
|
|
|
HRGN empty_region;
|
|
|
|
HRESULT call_result;
|
2019-05-28 16:37:28 +00:00
|
|
|
HWND thiswindow;
|
2015-04-22 19:10:55 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (window == NULL || GDK_SURFACE_HWND (window) == NULL)
|
2015-04-22 19:10:55 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!gdk_display_is_composited (gdk_surface_get_display (window)))
|
2015-04-22 19:10:55 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
thiswindow = GDK_SURFACE_HWND (window);
|
2015-04-22 19:10:55 +00:00
|
|
|
|
|
|
|
empty_region = CreateRectRgn (0, 0, -1, -1);
|
|
|
|
|
|
|
|
if (empty_region == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memset (&blur_behind, 0, sizeof (blur_behind));
|
|
|
|
blur_behind.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
|
|
|
|
blur_behind.hRgnBlur = empty_region;
|
|
|
|
blur_behind.fEnable = TRUE;
|
|
|
|
call_result = DwmEnableBlurBehindWindow (thiswindow, &blur_behind);
|
|
|
|
|
|
|
|
if (!SUCCEEDED (call_result))
|
|
|
|
g_warning ("%s: %s (%p) failed: %" G_GINT32_MODIFIER "x",
|
|
|
|
G_STRLOC, "DwmEnableBlurBehindWindow", thiswindow, (guint32) call_result);
|
|
|
|
|
|
|
|
DeleteObject (empty_region);
|
|
|
|
|
|
|
|
return SUCCEEDED (call_result);
|
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static const char *
|
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
|
|
|
get_default_title (void)
|
|
|
|
{
|
|
|
|
const char *title;
|
|
|
|
title = g_get_application_name ();
|
|
|
|
if (!title)
|
|
|
|
title = g_get_prgname ();
|
|
|
|
|
|
|
|
return title;
|
2000-07-25 17:31:05 +00:00
|
|
|
}
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
/* RegisterGdkClass
|
|
|
|
* is a wrapper function for RegisterWindowClassEx.
|
2015-04-29 07:31:08 +00:00
|
|
|
* It creates at least one unique class for every
|
2018-03-20 10:40:08 +00:00
|
|
|
* GdkSurfaceType. If support for single window-specific icons
|
1999-11-11 22:12:27 +00:00
|
|
|
* is ever needed (e.g Dialog specific), every such window should
|
|
|
|
* get its own class
|
|
|
|
*/
|
2001-10-28 21:28:51 +00:00
|
|
|
static ATOM
|
2020-08-14 01:36:44 +00:00
|
|
|
RegisterGdkClass (GdkSurfaceType wtype)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2020-10-27 17:26:45 +00:00
|
|
|
static ATOM klassTOPLEVEL = 0;
|
|
|
|
static ATOM klassTEMP = 0;
|
1999-11-11 22:12:27 +00:00
|
|
|
static HICON hAppIcon = NULL;
|
2006-10-28 23:58:30 +00:00
|
|
|
static HICON hAppIconSm = NULL;
|
2015-04-29 07:31:08 +00:00
|
|
|
static WNDCLASSEXW wcl;
|
1999-11-11 22:12:27 +00:00
|
|
|
ATOM klass = 0;
|
|
|
|
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
wcl.cbSize = sizeof (WNDCLASSEX);
|
1999-11-11 22:12:27 +00:00
|
|
|
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
|
|
|
|
* on WM_SIZE and WM_MOVE. Flicker, Performance!
|
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
|
1999-11-11 22:12:27 +00:00
|
|
|
wcl.cbClsExtra = 0;
|
|
|
|
wcl.cbWndExtra = 0;
|
2018-06-16 18:24:56 +00:00
|
|
|
wcl.hInstance = _gdk_dll_hinstance;
|
1999-11-11 22:12:27 +00:00
|
|
|
wcl.hIcon = 0;
|
2006-10-28 23:58:30 +00:00
|
|
|
wcl.hIconSm = 0;
|
2008-02-05 16:47:24 +00:00
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
/* initialize once! */
|
2006-10-28 23:58:30 +00:00
|
|
|
if (0 == hAppIcon && 0 == hAppIconSm)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char sLoc [MAX_PATH+1];
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2021-03-21 14:24:28 +00:00
|
|
|
// try to load first icon of executable program
|
|
|
|
if (0 != GetModuleFileName (NULL, sLoc, MAX_PATH))
|
2006-10-28 23:58:30 +00:00
|
|
|
{
|
|
|
|
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2006-10-28 23:58:30 +00:00
|
|
|
if (0 == hAppIcon && 0 == hAppIconSm)
|
|
|
|
{
|
2021-03-21 14:24:28 +00:00
|
|
|
// fallback : load icon from GTK DLL
|
2006-10-28 23:58:30 +00:00
|
|
|
if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
|
2008-02-05 16:47:24 +00:00
|
|
|
{
|
|
|
|
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
|
|
|
|
}
|
2006-10-28 23:58:30 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2006-10-28 23:58:30 +00:00
|
|
|
if (0 == hAppIcon && 0 == hAppIconSm)
|
|
|
|
{
|
|
|
|
hAppIcon = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
|
|
|
|
GetSystemMetrics (SM_CXICON),
|
|
|
|
GetSystemMetrics (SM_CYICON), 0);
|
|
|
|
hAppIconSm = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
|
|
|
|
GetSystemMetrics (SM_CXSMICON),
|
|
|
|
GetSystemMetrics (SM_CYSMICON), 0);
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2006-10-28 23:58:30 +00:00
|
|
|
if (0 == hAppIcon)
|
|
|
|
hAppIcon = hAppIconSm;
|
|
|
|
else if (0 == hAppIconSm)
|
|
|
|
hAppIconSm = hAppIcon;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
wcl.lpszMenuName = NULL;
|
|
|
|
|
|
|
|
/* initialize once per class */
|
2001-03-10 18:13:03 +00:00
|
|
|
/*
|
|
|
|
* HB: Setting the background brush leads to flicker, because we
|
|
|
|
* don't get asked how to clear the background. This is not what
|
|
|
|
* we want, at least not for input_only windows ...
|
|
|
|
*/
|
1999-11-11 22:12:27 +00:00
|
|
|
#define ONCE_PER_CLASS() \
|
|
|
|
wcl.hIcon = CopyIcon (hAppIcon); \
|
2006-10-28 23:58:30 +00:00
|
|
|
wcl.hIconSm = CopyIcon (hAppIconSm); \
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
wcl.hbrBackground = NULL; \
|
2015-04-29 07:31:08 +00:00
|
|
|
wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
|
|
|
2021-07-19 02:44:48 +00:00
|
|
|
/* MSDN: CS_OWNDC is needed for OpenGL contexts */
|
|
|
|
wcl.style |= CS_OWNDC;
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
switch (wtype)
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TOPLEVEL:
|
2019-05-26 15:36:03 +00:00
|
|
|
case GDK_SURFACE_POPUP:
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
if (0 == klassTOPLEVEL)
|
2014-12-17 04:32:04 +00:00
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
wcl.lpszClassName = L"gdkSurfaceToplevel";
|
2014-12-17 04:32:04 +00:00
|
|
|
|
|
|
|
ONCE_PER_CLASS ();
|
|
|
|
klassTOPLEVEL = RegisterClassExW (&wcl);
|
|
|
|
}
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
klass = klassTOPLEVEL;
|
|
|
|
break;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TEMP:
|
2020-10-27 17:26:45 +00:00
|
|
|
if (klassTEMP == 0)
|
2007-04-25 23:44:54 +00:00
|
|
|
{
|
2020-10-27 17:26:45 +00:00
|
|
|
wcl.lpszClassName = L"gdkSurfaceTemp";
|
|
|
|
wcl.style |= CS_SAVEBITS;
|
|
|
|
ONCE_PER_CLASS ();
|
|
|
|
klassTEMP = RegisterClassExW (&wcl);
|
2007-04-25 23:44:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:26:45 +00:00
|
|
|
klass = klassTEMP;
|
|
|
|
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
break;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2000-02-13 14:52:47 +00:00
|
|
|
if (klass == 0)
|
|
|
|
{
|
2006-09-03 22:50:00 +00:00
|
|
|
WIN32_API_FAILED ("RegisterClassExW");
|
2000-02-13 14:52:47 +00:00
|
|
|
g_error ("That is a fatal error");
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
return klass;
|
1999-11-20 01:22:57 +00:00
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
/*
|
|
|
|
* Create native windows.
|
|
|
|
*
|
|
|
|
* With the default Gdk the created windows are mostly toplevel windows.
|
|
|
|
*
|
|
|
|
* Placement of the window is derived from the passed in window,
|
|
|
|
* except for toplevel window where OS/Window Manager placement
|
|
|
|
* is used.
|
|
|
|
*
|
|
|
|
* [1] http://mail.gnome.org/archives/gtk-devel-list/2010-August/msg00214.html
|
|
|
|
*/
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkSurface *
|
|
|
|
_gdk_win32_display_create_surface (GdkDisplay *display,
|
|
|
|
GdkSurfaceType surface_type,
|
|
|
|
GdkSurface *parent,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2005-03-16 01:38:57 +00:00
|
|
|
HWND hwndNew;
|
2019-05-28 16:39:58 +00:00
|
|
|
HANDLE owner;
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
ATOM klass = 0;
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
DWORD dwStyle = 0, dwExStyle;
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
RECT rect;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GdkWin32Display *display_win32;
|
2019-05-21 23:41:00 +00:00
|
|
|
GdkSurface *surface;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *title;
|
2006-09-03 22:50:00 +00:00
|
|
|
wchar_t *wtitle;
|
2020-07-24 13:54:49 +00:00
|
|
|
int window_width, window_height;
|
|
|
|
int window_x, window_y;
|
|
|
|
int real_x = 0, real_y = 0;
|
2018-04-09 20:16:23 +00:00
|
|
|
GdkFrameClock *frame_clock;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_return_val_if_fail (display == _gdk_display, NULL);
|
2016-02-22 16:55:16 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
GDK_NOTE (MISC,
|
2019-05-19 03:09:05 +00:00
|
|
|
g_print ("_gdk_surface_new: %s\n", (surface_type == GDK_SURFACE_TOPLEVEL ? "TOPLEVEL" :
|
2019-05-28 17:21:42 +00:00
|
|
|
(surface_type == GDK_SURFACE_TEMP ? "TEMP" :
|
|
|
|
(surface_type == GDK_SURFACE_TEMP ? "POPUP" : "???")))));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2019-05-21 21:20:15 +00:00
|
|
|
display_win32 = GDK_WIN32_DISPLAY (display);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
|
|
|
|
else
|
|
|
|
frame_clock = _gdk_frame_clock_idle_new ();
|
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
switch (surface_type)
|
|
|
|
{
|
|
|
|
case GDK_SURFACE_TOPLEVEL:
|
|
|
|
impl = g_object_new (GDK_TYPE_WIN32_TOPLEVEL,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case GDK_SURFACE_POPUP:
|
|
|
|
impl = g_object_new (GDK_TYPE_WIN32_POPUP,
|
|
|
|
"parent", parent,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case GDK_SURFACE_TEMP:
|
|
|
|
impl = g_object_new (GDK_TYPE_WIN32_DRAG_SURFACE,
|
|
|
|
"display", display,
|
|
|
|
"frame-clock", frame_clock,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
2003-12-10 23:58:23 +00:00
|
|
|
|
2019-05-21 23:41:00 +00:00
|
|
|
surface = GDK_SURFACE (impl);
|
|
|
|
surface->x = x;
|
|
|
|
surface->y = y;
|
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
|
|
|
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
impl->surface_scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2019-04-21 16:06:11 +00:00
|
|
|
dwExStyle = 0;
|
2019-05-28 16:39:58 +00:00
|
|
|
owner = NULL;
|
|
|
|
|
|
|
|
/* MSDN: We need WS_CLIPCHILDREN and WS_CLIPSIBLINGS for GL Context Creation */
|
|
|
|
dwStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
switch (surface_type)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TOPLEVEL:
|
2019-05-28 16:39:58 +00:00
|
|
|
dwStyle |= WS_OVERLAPPEDWINDOW;
|
2019-05-26 15:36:03 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TEMP:
|
2011-11-25 10:21:26 +00:00
|
|
|
dwExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
2019-05-28 16:39:58 +00:00
|
|
|
/* fall through */
|
|
|
|
case GDK_SURFACE_POPUP:
|
|
|
|
dwStyle |= WS_POPUP;
|
|
|
|
|
|
|
|
/* Only popup and temp windows are fit to use the Owner Window mechanism */
|
|
|
|
if (parent != NULL)
|
|
|
|
owner = GDK_SURFACE_HWND (parent);
|
1999-11-11 22:12:27 +00:00
|
|
|
break;
|
2000-07-25 17:31:05 +00:00
|
|
|
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
rect.left = x * impl->surface_scale;
|
|
|
|
rect.top = y * impl->surface_scale;
|
|
|
|
rect.right = rect.left + width * impl->surface_scale;
|
|
|
|
rect.bottom = rect.top + height * impl->surface_scale;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2016-12-19 09:09:49 +00:00
|
|
|
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2021-10-29 16:39:52 +00:00
|
|
|
real_x = x * impl->surface_scale;
|
|
|
|
real_y = y * impl->surface_scale;
|
2011-01-02 10:51:25 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface_type == GDK_SURFACE_TOPLEVEL)
|
2016-12-19 09:09:49 +00:00
|
|
|
{
|
|
|
|
/* We initially place it at default so that we can get the
|
|
|
|
default window positioning if we want */
|
2019-05-19 03:09:05 +00:00
|
|
|
window_x = window_y = CW_USEDEFAULT;
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
}
|
|
|
|
else
|
2018-06-25 22:47:40 +00:00
|
|
|
{
|
|
|
|
/* TEMP: Put these where requested */
|
2019-05-19 03:09:05 +00:00
|
|
|
window_x = real_x;
|
|
|
|
window_y = real_y;
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
|
2016-12-19 09:09:49 +00:00
|
|
|
window_width = rect.right - rect.left;
|
|
|
|
window_height = rect.bottom - rect.top;
|
|
|
|
|
2016-11-04 03:08:50 +00:00
|
|
|
title = get_default_title ();
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
if (!title || !*title)
|
2005-03-15 02:07:08 +00:00
|
|
|
title = "";
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
|
2020-08-14 01:36:44 +00:00
|
|
|
klass = RegisterGdkClass (surface_type);
|
Move the code that sets the window style and extended window style, and
2002-12-21 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_new): Move the code that
sets the window style and extended window style, and adjusts the
width and height to take the window decorations into account
earlier. The adjusted width and height used to be ignored. Remove
the local x, y, width and height variables, no need to further
confuse the code by having local copies. (Partial fix, I hope, for
#101588)
(gdk_window_move): When moving top-level windows, take title bar
and border width into account, offsetting the coordinates before
calling SetWindowPos().
(gdk_window_set_decorations, gdk_window_set_functions):
Reimplement, taking into account the peculiar semantics of
GDK_DECOR_ALL and GDK_FUNC_ALL. (#79036)
(gdk_window_get_decorations): Implement. (#98981)
(gdk_window_set_type_hint): When setting
GDK_WINDOW_TYPE_HINT_MENU, call gdk_window_set_decorations().
(#79036)
* gdk/gdk.def: Add gdk_window_get_decorations. (#98981)
2002-12-21 23:32:20 +00:00
|
|
|
|
2006-09-03 22:50:00 +00:00
|
|
|
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2006-09-03 22:50:00 +00:00
|
|
|
hwndNew = CreateWindowExW (dwExStyle,
|
2009-07-18 14:24:02 +00:00
|
|
|
MAKEINTRESOURCEW (klass),
|
|
|
|
wtitle,
|
|
|
|
dwStyle,
|
2019-05-19 03:09:05 +00:00
|
|
|
window_x, window_y,
|
2009-07-18 14:24:02 +00:00
|
|
|
window_width, window_height,
|
2019-05-28 16:39:58 +00:00
|
|
|
owner,
|
2009-07-18 14:24:02 +00:00
|
|
|
NULL,
|
2018-06-16 18:24:56 +00:00
|
|
|
_gdk_dll_hinstance,
|
2019-05-21 23:41:00 +00:00
|
|
|
surface);
|
2019-05-19 03:09:05 +00:00
|
|
|
impl->handle = hwndNew;
|
2011-11-02 11:15:53 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
GetWindowRect (hwndNew, &rect);
|
2016-12-19 09:09:49 +00:00
|
|
|
impl->initial_x = rect.left;
|
|
|
|
impl->initial_y = rect.top;
|
2011-11-02 11:15:53 +00:00
|
|
|
|
2016-12-19 09:09:49 +00:00
|
|
|
/* Now we know the initial position, move to actually specified position */
|
2019-05-19 03:09:05 +00:00
|
|
|
if (real_x != window_x || real_y != window_y)
|
2016-12-19 09:09:49 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
API_CALL (SetWindowPos, (hwndNew,
|
2016-12-19 09:09:49 +00:00
|
|
|
SWP_NOZORDER_SPECIFIED,
|
|
|
|
real_x, real_y, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
|
2011-11-02 11:15:53 +00:00
|
|
|
}
|
2005-03-16 01:38:57 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_object_ref (impl);
|
2019-05-21 21:20:15 +00:00
|
|
|
/* Take note: we're inserting a pointer into a heap-allocated
|
|
|
|
* object (impl). Inserting a pointer to a stack variable
|
|
|
|
* will break the logic, since stack variables are short-lived.
|
|
|
|
* We insert a pointer to the handle instead of the handle itself
|
|
|
|
* probably because we need to hash them differently depending
|
|
|
|
* on the bitness of the OS. That pointer is still unique,
|
|
|
|
* so this works out in the end.
|
|
|
|
*/
|
|
|
|
gdk_win32_handle_table_insert (&GDK_SURFACE_HWND (impl), impl);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2005-03-16 01:38:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
|
2006-09-03 22:50:00 +00:00
|
|
|
title,
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
window_width, window_height,
|
2021-10-29 16:39:52 +00:00
|
|
|
surface->x,
|
|
|
|
surface->y,
|
2019-05-28 16:39:58 +00:00
|
|
|
owner,
|
2019-05-19 03:09:05 +00:00
|
|
|
hwndNew));
|
2008-10-05 00:00:10 +00:00
|
|
|
|
2006-09-03 22:50:00 +00:00
|
|
|
g_free (wtitle);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
if (impl->handle == NULL)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2006-09-03 22:50:00 +00:00
|
|
|
WIN32_API_FAILED ("CreateWindowExW");
|
2019-05-19 03:09:05 +00:00
|
|
|
g_object_unref (impl);
|
|
|
|
return NULL;
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 14:29:45 +00:00
|
|
|
if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
|
2021-07-02 09:13:06 +00:00
|
|
|
gdk_winpointer_initialize_surface (surface);
|
|
|
|
|
2019-05-21 23:41:00 +00:00
|
|
|
_gdk_win32_surface_enable_transparency (surface);
|
2020-02-22 14:56:36 +00:00
|
|
|
_gdk_win32_surface_register_dnd (surface);
|
2021-09-04 12:12:54 +00:00
|
|
|
_gdk_win32_surface_update_style_bits (surface);
|
2018-04-09 20:16:23 +00:00
|
|
|
|
|
|
|
g_signal_connect (frame_clock,
|
|
|
|
"after-paint",
|
|
|
|
G_CALLBACK (gdk_win32_impl_frame_clock_after_paint),
|
2019-05-19 03:09:05 +00:00
|
|
|
impl);
|
|
|
|
|
2019-05-21 21:20:15 +00:00
|
|
|
g_object_unref (frame_clock);
|
2021-07-19 02:32:28 +00:00
|
|
|
impl->hdc = GetDC (impl->handle);
|
2019-05-21 21:20:15 +00:00
|
|
|
|
2019-05-21 23:41:00 +00:00
|
|
|
return surface;
|
2004-08-22 19:16:22 +00:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
static void
|
|
|
|
gdk_win32_surface_set_transient_for (GdkSurface *window,
|
|
|
|
GdkSurface *parent);
|
|
|
|
|
2010-12-10 19:06:13 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_destroy (GdkSurface *window,
|
2019-05-19 03:09:05 +00:00
|
|
|
gboolean foreign_destroy)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *surface = GDK_WIN32_SURFACE (window);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_destroy: %p\n",
|
|
|
|
GDK_SURFACE_HWND (window)));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2008-02-05 16:47:24 +00:00
|
|
|
/* Remove ourself from the modal stack */
|
|
|
|
_gdk_remove_modal_window (window);
|
|
|
|
|
2019-05-24 10:55:06 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (gdk_surface_get_frame_clock (window),
|
|
|
|
gdk_win32_impl_frame_clock_after_paint,
|
|
|
|
window);
|
|
|
|
|
2007-10-18 00:31:22 +00:00
|
|
|
/* Remove all our transient children */
|
2019-05-19 03:09:05 +00:00
|
|
|
while (surface->transient_children != NULL)
|
2007-10-18 00:31:22 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkSurface *child = surface->transient_children->data;
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_set_transient_for (child, NULL);
|
2007-10-18 00:31:22 +00:00
|
|
|
}
|
|
|
|
|
2007-07-12 23:38:30 +00:00
|
|
|
/* Remove ourself from our transient owner */
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface->transient_owner != NULL)
|
2007-07-12 23:38:30 +00:00
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_set_transient_for (window, NULL);
|
2007-07-12 23:38:30 +00:00
|
|
|
}
|
2004-03-13 18:27:56 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (!foreign_destroy)
|
2001-07-28 23:02:02 +00:00
|
|
|
{
|
2011-01-02 10:51:25 +00:00
|
|
|
window->destroyed = TRUE;
|
2018-03-20 10:40:08 +00:00
|
|
|
DestroyWindow (GDK_SURFACE_HWND (window));
|
2001-07-28 23:02:02 +00:00
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2000-05-16 21:27:10 +00:00
|
|
|
/* This function is called when the window really gone.
|
|
|
|
*/
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_destroy_notify (GdkSurface *window)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
2018-03-20 10:40:08 +00:00
|
|
|
g_print ("gdk_surface_destroy_notify: %p%s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
(GDK_SURFACE_DESTROYED (window) ? " (destroyed)" : "")));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (window))
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-06-25 22:47:40 +00:00
|
|
|
g_warning ("window %p unexpectedly destroyed",
|
|
|
|
GDK_SURFACE_HWND (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_surface_destroy (window, TRUE);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_handle_table_remove (GDK_SURFACE_HWND (window));
|
2003-06-30 21:58:24 +00:00
|
|
|
g_object_unref (window);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2003-08-02 02:05:12 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
get_outer_rect (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int width,
|
|
|
|
int height,
|
2003-08-02 02:05:12 +00:00
|
|
|
RECT *rect)
|
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2003-08-02 02:05:12 +00:00
|
|
|
rect->left = rect->top = 0;
|
2018-03-20 11:05:26 +00:00
|
|
|
rect->right = width * impl->surface_scale;
|
|
|
|
rect->bottom = height * impl->surface_scale;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2005-11-09 12:35:56 +00:00
|
|
|
_gdk_win32_adjust_client_rect (window, rect);
|
2003-08-02 02:05:12 +00:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
static void
|
|
|
|
gdk_win32_surface_fullscreen (GdkSurface *window);
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
show_window_internal (GdkSurface *window,
|
2019-11-16 19:50:57 +00:00
|
|
|
gboolean already_mapped,
|
|
|
|
gboolean unminimize)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *surface;
|
2008-10-21 20:31:05 +00:00
|
|
|
DWORD exstyle;
|
2004-05-08 16:25:15 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
if (window->destroyed)
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
return;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2011-10-25 12:26:22 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s\n",
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state),
|
2019-11-16 19:50:57 +00:00
|
|
|
(unminimize ? " unminimize" : "")));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2019-11-16 19:50:57 +00:00
|
|
|
/* If asked to show (not unminimize) a withdrawn and iconified
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
* window, do that.
|
|
|
|
*/
|
2019-11-16 19:50:57 +00:00
|
|
|
if (!unminimize &&
|
2011-10-25 12:26:22 +00:00
|
|
|
!already_mapped &&
|
2020-09-10 04:39:03 +00:00
|
|
|
(window->state & GDK_TOPLEVEL_STATE_MINIMIZED))
|
2015-04-29 07:31:08 +00:00
|
|
|
{
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWMINNOACTIVE);
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
return;
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
/* If asked to just show an iconified window, do nothing. */
|
2020-09-10 04:39:03 +00:00
|
|
|
if (!unminimize && (window->state & GDK_TOPLEVEL_STATE_MINIMIZED))
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
return;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2019-11-16 19:50:57 +00:00
|
|
|
/* If asked to unminimize an already noniconified window, do
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
* nothing. (Especially, don't cause the window to rise and
|
|
|
|
* activate. There are different calls for that.)
|
|
|
|
*/
|
2020-09-10 04:39:03 +00:00
|
|
|
if (unminimize && !(window->state & GDK_TOPLEVEL_STATE_MINIMIZED))
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
return;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
/* If asked to show (but not raise) a window that is already
|
|
|
|
* visible, do nothing.
|
|
|
|
*/
|
2019-11-16 19:50:57 +00:00
|
|
|
if (!unminimize && !already_mapped && IsWindowVisible (GDK_SURFACE_HWND (window)))
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Other cases */
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
|
2008-10-21 20:31:05 +00:00
|
|
|
|
2004-03-10 22:20:36 +00:00
|
|
|
/* Use SetWindowPos to show transparent windows so automatic redraws
|
|
|
|
* in other windows can be suppressed.
|
|
|
|
*/
|
2008-10-21 20:31:05 +00:00
|
|
|
if (exstyle & WS_EX_TRANSPARENT)
|
2004-03-10 22:20:36 +00:00
|
|
|
{
|
2011-10-25 12:26:22 +00:00
|
|
|
UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
|
2008-10-21 20:31:05 +00:00
|
|
|
|
2020-03-14 14:06:57 +00:00
|
|
|
if (GDK_IS_DRAG_SURFACE (window))
|
2009-07-18 14:24:02 +00:00
|
|
|
flags |= SWP_NOACTIVATE;
|
2004-03-10 22:20:36 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowPos (GDK_SURFACE_HWND (window),
|
2015-11-21 03:58:22 +00:00
|
|
|
SWP_NOZORDER_SPECIFIED, 0, 0, 0, 0, flags);
|
2008-10-21 20:31:05 +00:00
|
|
|
|
2004-03-10 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-27 14:09:42 +00:00
|
|
|
/* For initial map of "normal" windows we want to emulate WM window
|
2015-04-29 07:31:08 +00:00
|
|
|
* positioning behaviour, which means:
|
2011-10-27 14:09:42 +00:00
|
|
|
* + default to the initial CW_USEDEFAULT placement,
|
|
|
|
* no matter if the user moved the window before showing it.
|
|
|
|
* + Certain window types and hints have more elaborate positioning
|
|
|
|
* schemes.
|
|
|
|
*/
|
2019-05-19 03:09:05 +00:00
|
|
|
surface = GDK_WIN32_SURFACE (window);
|
2011-10-27 14:09:42 +00:00
|
|
|
if (!already_mapped &&
|
2020-07-30 15:05:23 +00:00
|
|
|
GDK_IS_TOPLEVEL (window))
|
2011-10-27 14:09:42 +00:00
|
|
|
{
|
|
|
|
gboolean center = FALSE;
|
|
|
|
RECT window_rect, center_on_rect;
|
|
|
|
int x, y;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
x = surface->initial_x;
|
|
|
|
y = surface->initial_y;
|
2011-10-27 14:09:42 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (FALSE)
|
2011-10-27 14:09:42 +00:00
|
|
|
{
|
|
|
|
HMONITOR monitor;
|
|
|
|
MONITORINFO mi;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
2011-10-27 14:09:42 +00:00
|
|
|
mi.cbSize = sizeof (mi);
|
|
|
|
if (monitor && GetMonitorInfo (monitor, &mi))
|
|
|
|
center_on_rect = mi.rcMonitor;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
center_on_rect.left = 0;
|
2016-03-14 16:14:22 +00:00
|
|
|
center_on_rect.top = 0;
|
2011-10-27 14:09:42 +00:00
|
|
|
center_on_rect.right = GetSystemMetrics (SM_CXSCREEN);
|
|
|
|
center_on_rect.bottom = GetSystemMetrics (SM_CYSCREEN);
|
|
|
|
}
|
|
|
|
center = TRUE;
|
|
|
|
}
|
2019-05-19 03:09:05 +00:00
|
|
|
else if (surface->transient_owner != NULL &&
|
|
|
|
GDK_SURFACE_IS_MAPPED (surface->transient_owner))
|
2011-10-27 14:09:42 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkSurface *owner = surface->transient_owner;
|
2011-10-27 14:09:42 +00:00
|
|
|
/* Center on transient parent */
|
2021-10-29 16:39:52 +00:00
|
|
|
center_on_rect.left = owner->x * surface->surface_scale;
|
|
|
|
center_on_rect.top = owner->y * surface->surface_scale;
|
2019-05-19 03:09:05 +00:00
|
|
|
center_on_rect.right = center_on_rect.left + owner->width * surface->surface_scale;
|
|
|
|
center_on_rect.bottom = center_on_rect.top + owner->height * surface->surface_scale;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_adjust_client_rect (GDK_SURFACE (owner), ¢er_on_rect);
|
2011-10-27 14:09:42 +00:00
|
|
|
center = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (center)
|
|
|
|
{
|
|
|
|
window_rect.left = 0;
|
|
|
|
window_rect.top = 0;
|
2019-05-19 03:09:05 +00:00
|
|
|
window_rect.right = window->width * surface->surface_scale;
|
|
|
|
window_rect.bottom = window->height * surface->surface_scale;
|
2011-10-27 14:09:42 +00:00
|
|
|
_gdk_win32_adjust_client_rect (window, &window_rect);
|
|
|
|
|
|
|
|
x = center_on_rect.left + ((center_on_rect.right - center_on_rect.left) - (window_rect.right - window_rect.left)) / 2;
|
|
|
|
y = center_on_rect.top + ((center_on_rect.bottom - center_on_rect.top) - (window_rect.bottom - window_rect.top)) / 2;
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
2015-11-21 03:58:22 +00:00
|
|
|
SWP_NOZORDER_SPECIFIED,
|
2011-10-27 14:09:42 +00:00
|
|
|
x, y, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
|
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (!already_mapped && GDK_IS_TOPLEVEL (window))
|
2011-11-02 13:30:23 +00:00
|
|
|
{
|
|
|
|
/* Ensure new windows are fully onscreen */
|
|
|
|
RECT window_rect;
|
|
|
|
HMONITOR monitor;
|
|
|
|
MONITORINFO mi;
|
|
|
|
int x, y;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GetWindowRect (GDK_SURFACE_HWND (window), &window_rect);
|
2011-11-02 13:30:23 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
2011-11-02 13:30:23 +00:00
|
|
|
mi.cbSize = sizeof (mi);
|
|
|
|
if (monitor && GetMonitorInfo (monitor, &mi))
|
|
|
|
{
|
|
|
|
x = window_rect.left;
|
|
|
|
y = window_rect.top;
|
|
|
|
|
|
|
|
if (window_rect.right > mi.rcWork.right)
|
|
|
|
{
|
|
|
|
window_rect.left -= (window_rect.right - mi.rcWork.right);
|
|
|
|
window_rect.right -= (window_rect.right - mi.rcWork.right);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window_rect.bottom > mi.rcWork.bottom)
|
|
|
|
{
|
|
|
|
window_rect.top -= (window_rect.bottom - mi.rcWork.bottom);
|
|
|
|
window_rect.bottom -= (window_rect.bottom - mi.rcWork.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window_rect.left < mi.rcWork.left)
|
|
|
|
{
|
|
|
|
window_rect.right += (mi.rcWork.left - window_rect.left);
|
|
|
|
window_rect.left += (mi.rcWork.left - window_rect.left);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window_rect.top < mi.rcWork.top)
|
|
|
|
{
|
|
|
|
window_rect.bottom += (mi.rcWork.top - window_rect.top);
|
|
|
|
window_rect.top += (mi.rcWork.top - window_rect.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x != window_rect.left || y != window_rect.top)
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
2015-11-21 03:58:22 +00:00
|
|
|
SWP_NOZORDER_SPECIFIED,
|
2011-11-02 13:30:23 +00:00
|
|
|
window_rect.left, window_rect.top, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2008-08-28 02:42:23 +00:00
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_fullscreen (window);
|
2008-08-28 02:42:23 +00:00
|
|
|
}
|
2020-09-10 04:39:03 +00:00
|
|
|
else if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
2008-08-28 02:42:23 +00:00
|
|
|
{
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_MAXIMIZE);
|
2008-08-28 02:42:23 +00:00
|
|
|
}
|
2020-09-10 04:39:03 +00:00
|
|
|
else if (window->state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
2008-08-28 02:42:23 +00:00
|
|
|
{
|
2020-03-14 14:06:57 +00:00
|
|
|
GtkShowWindow (window, SW_RESTORE);
|
2008-08-28 02:42:23 +00:00
|
|
|
}
|
2020-03-14 14:06:57 +00:00
|
|
|
else if (GDK_IS_DRAG_SURFACE (window))
|
2008-08-28 02:42:23 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!IsWindowVisible (GDK_SURFACE_HWND (window)))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWNOACTIVATE);
|
2016-02-08 12:20:02 +00:00
|
|
|
else
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWNA);
|
2008-08-28 02:42:23 +00:00
|
|
|
}
|
2018-03-20 10:40:08 +00:00
|
|
|
else if (!IsWindowVisible (GDK_SURFACE_HWND (window)))
|
2008-08-28 02:42:23 +00:00
|
|
|
{
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWNORMAL);
|
2008-08-28 02:42:23 +00:00
|
|
|
}
|
2016-02-08 12:20:02 +00:00
|
|
|
else
|
|
|
|
{
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOW);
|
2016-02-08 12:20:02 +00:00
|
|
|
}
|
2011-10-26 09:08:33 +00:00
|
|
|
|
|
|
|
/* Sync STATE_ABOVE to TOPMOST */
|
2020-03-12 11:01:30 +00:00
|
|
|
if (!GDK_IS_DRAG_SURFACE (window) &&
|
2020-09-10 04:39:03 +00:00
|
|
|
(((window->state & GDK_TOPLEVEL_STATE_ABOVE) &&
|
2011-11-25 10:21:26 +00:00
|
|
|
!(exstyle & WS_EX_TOPMOST)) ||
|
2020-09-10 04:39:03 +00:00
|
|
|
(!(window->state & GDK_TOPLEVEL_STATE_ABOVE) &&
|
2011-11-25 10:21:26 +00:00
|
|
|
(exstyle & WS_EX_TOPMOST))))
|
2011-10-26 09:08:33 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
2020-09-10 04:39:03 +00:00
|
|
|
(window->state & GDK_TOPLEVEL_STATE_ABOVE)?HWND_TOPMOST:HWND_NOTOPMOST,
|
2011-10-26 09:08:33 +00:00
|
|
|
0, 0, 0, 0,
|
2020-10-08 04:46:06 +00:00
|
|
|
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
|
2011-10-26 09:08:33 +00:00
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2020-03-09 17:25:06 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_show (GdkSurface *window,
|
2009-07-01 08:26:37 +00:00
|
|
|
gboolean already_mapped)
|
2001-08-19 18:34:59 +00:00
|
|
|
{
|
2009-02-14 18:23:54 +00:00
|
|
|
show_window_internal (window, FALSE, FALSE);
|
2001-08-19 18:34:59 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 13:58:28 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_hide (GdkSurface *window)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2011-01-02 10:51:25 +00:00
|
|
|
if (window->destroyed)
|
gdk/win32/gdkprivate-win32.h New flags _gdk_input_locale_is_ime and
2003-07-25 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New flags _gdk_input_locale_is_ime
and _gdk_keyboard_has_altgr.
* gdk/win32/gdkevents-win32.c: Lots of changes. Most important
ones detailled here.
Code that has been ifdeffed out for a long time removed. Remove
some really old doc comments that were left behind for some public
functions, the official ones are in the X11 backend anyway. Change
GDK_WINDOW_OBJECT() calls to GdkWindowObject casts. Reformat
multi-line boolean expressions to have the operators at ends of
lines.
As mouse capture with SetCapture() indeed seems to work OK, no
need to have the correspoinding macro USE_SETCAPTURE and ifdefs.
Ifdef out the gdk-ping-msg stuff. I don't remember why it was
needed at some time, and things seem to work fine now without
(knock on wood).
Ifdef out the search for some Latin locale keyboard layout being
loaded. Not used currently, but might be needed after all, if we
decide that we want to be able to generate ASCII control character
events with a non-Latin keyboard.
(assign_object): New helper function, handles the g_object_ref()
and unref() calls when assigning GObject pointers.
(generate_crossing_events): Also generate the GDK_NOTIFY_INTERIOR
enter event when the pointer has moved to an ancestor window. Was
left out by mistake.
(gdk_window_is_ancestor): Renamed from gdk_window_is_child().
(gdk_pointer_grab, gdk_pointer_ungrab): Implement the confine_to
functionality, using ClipCursor().
(find_window_for_mouse_event): Splice part of code into new
function find_real_window_for_grabbed_mouse_event().
(fixup_event, append_event, apply_filters): New functions, code
refactored out from elsewhere.
(synthesize_enter_or_leave_event, synthesize_leave_event,
synthesize_enter_event,
synthesize_leave_events,synthesize_enter_events): Also take a
GdkCrossingMode parameter, in preparation to generating
GDK_CROSSING_GRAB and GDK_CROSSING_UNGRAB events.
(fixup_event, append_event, fill_key_event_string): New functions,
code refactoring.
(vk_from_char, build_keypress_event, build_keyrelease_event):
Removed as part of dropping WM_CHAR handling.
(build_key_event_state,gdk_event_translate): Call
GetKeyboardState(), once, for each keyboard message, instead of
several calls to GetKeyState() here and there.
(gdk_event_translate): Fix bugs #104516, #104662, #115902. While
at it, do some major refactoring, and some fixes for potential
problems noticed while going through the code.
Don't handle WM_CHAR at all. Only handle WM_KEYDOWN and
WM_KEYUP. Don't need the state variables related to whether to
wait for WM_CHAR or not, and whether the current key is
AltGr. Remove lots of complexity. Thus don't need the
use_ime_composition flag.
Not handling WM_CHAR means dead key handling will have to be taken
care of by GTK, but that seems to work fine, so no worry.
Another side-effect is that Alt+keypad digits don't work any
longer, but it's better to learn to use GTK's ISO14755 support is
anyway.
Be more careful in checking whether AltGr is involved. Only
attempt to handle it if the keyboard actually has it. And
explicitly check for *left* Control plus *right* Alt being
pressed. Still, allow (left) Alt and/or (right) Control with AltGr
chars.
Handle keys using similar code as in the X11 backend. As we have
built a keymap in gdkkeys-win32.c anyway, use it by calling
gdk_keymap_translate_keyboard_state() to look up the keysym from
the virtual key code and keyboard state. Build the key event
string in exactly the same way as the X11 backend.
If an IME is being used, don't generate GDK events for keys
between receiving WM_IME_STARTCOMPOSITION and
WM_IME_ENDCOMPOSITION, as those keys are for the IME.
For WM_IME_COMPOSITION, handle all the Unicode chars returned from
the IME, not just the first one.
gdk_event_translate() is still quite complex, could split the
message handler cases out into separate functions.
On mouse events, when the mouse is grabbed, use
find_real_window_for_grabbed_mouse_event() in order to be able to
generate correct crossing events.
No longer take a pre-allocated GdkEvent as parameter. Instead,
allocate events as needed and append them to the queue. (This is
different from how gdk_event_translate() in the X11 backend
works.) This change made the code much clearer, especially in the
cases where we have to generate several GDK events for one Windows
message. Return FALSE if DefWindowProc() should be called, TRUE
if not. If DefWindowProc() should not be called, also return the
value to be returned from the window procedure.
(Previously, the interaction with gdk_event_translate()'s caller
was much more complex, when we had to indicate whether the
already-queued event should be left in the queue or removed, and
in addition also had to indicate whether to call DefWindowProc()
or not, and what value to return from the window procedure if
not.)
Don't use a separate "private" variable required to be pointing to
the GdkWindowObject of the "window" variable at all times. Just
use casts, even if looks a bit uglier.
Notice destroyed windows as early as possible, and break out of
the messsage switch.
Use _gdk_pointer_root as current_window when the pointer is
outside GDK's top-level windows.
On WM_INPUTLANGCHANGE, set _gdk_input_locale_is_ime as
appropriate, based on ImmIsIME().
(gdk_event_translate, gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Implement client messages.
Use a registered Windows message to pass GDK client messages. Note
that the amount of user data is restricted to four bytes, as it is
carried in the LPARAM. (The WPARAM is used for the message type
"atom".)
(real_window_procedure): Adapt for new gdk_event_translate()
interface.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_init): Set
_gdk_input_locale_is_ime initially.
* gdk/win32/gdkwindow-win32.c: Use g_object_ref()/unref() instead
of g_colormap_ref()/unref().
(gdk_window_new): Made code a bit more like the X11 one, pretend
to handle screens (although we just have one for now).
* gdk/x11/gdkevents-x11.c
(gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Document the user data
limitation on Win32.
* gdk/win32/gdkevents-win32.c (print_event): More complete enter
and leave notify detail output.
* gdk/win32/gdkkeys-win32.c (update_keymap): Make dead keys
visible to GDK and GTK. Store the corresponding GDK_dead_* keysym
for those, so that the GtkIMContextCimple compose tables will
work. Deduce if the keyboard layout has the AltGr key, and set the
above flag accordingly.
2003-07-26 01:54:59 +00:00
|
|
|
return;
|
2000-07-25 17:31:05 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_hide: %p: %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state)));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (window))
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
gdk_surface_set_is_mapped (window, FALSE);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_surface_clear_update_area (window);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (GDK_IS_TOPLEVEL (window))
|
2018-03-20 10:40:08 +00:00
|
|
|
ShowOwnedPopups (GDK_SURFACE_HWND (window), FALSE);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2015-11-21 04:00:33 +00:00
|
|
|
/* Use SetWindowPos to hide transparent windows so automatic redraws
|
|
|
|
* in other windows can be suppressed.
|
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
|
gdk/win32/gdkprivate-win32.h New flags _gdk_input_locale_is_ime and
2003-07-25 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New flags _gdk_input_locale_is_ime
and _gdk_keyboard_has_altgr.
* gdk/win32/gdkevents-win32.c: Lots of changes. Most important
ones detailled here.
Code that has been ifdeffed out for a long time removed. Remove
some really old doc comments that were left behind for some public
functions, the official ones are in the X11 backend anyway. Change
GDK_WINDOW_OBJECT() calls to GdkWindowObject casts. Reformat
multi-line boolean expressions to have the operators at ends of
lines.
As mouse capture with SetCapture() indeed seems to work OK, no
need to have the correspoinding macro USE_SETCAPTURE and ifdefs.
Ifdef out the gdk-ping-msg stuff. I don't remember why it was
needed at some time, and things seem to work fine now without
(knock on wood).
Ifdef out the search for some Latin locale keyboard layout being
loaded. Not used currently, but might be needed after all, if we
decide that we want to be able to generate ASCII control character
events with a non-Latin keyboard.
(assign_object): New helper function, handles the g_object_ref()
and unref() calls when assigning GObject pointers.
(generate_crossing_events): Also generate the GDK_NOTIFY_INTERIOR
enter event when the pointer has moved to an ancestor window. Was
left out by mistake.
(gdk_window_is_ancestor): Renamed from gdk_window_is_child().
(gdk_pointer_grab, gdk_pointer_ungrab): Implement the confine_to
functionality, using ClipCursor().
(find_window_for_mouse_event): Splice part of code into new
function find_real_window_for_grabbed_mouse_event().
(fixup_event, append_event, apply_filters): New functions, code
refactored out from elsewhere.
(synthesize_enter_or_leave_event, synthesize_leave_event,
synthesize_enter_event,
synthesize_leave_events,synthesize_enter_events): Also take a
GdkCrossingMode parameter, in preparation to generating
GDK_CROSSING_GRAB and GDK_CROSSING_UNGRAB events.
(fixup_event, append_event, fill_key_event_string): New functions,
code refactoring.
(vk_from_char, build_keypress_event, build_keyrelease_event):
Removed as part of dropping WM_CHAR handling.
(build_key_event_state,gdk_event_translate): Call
GetKeyboardState(), once, for each keyboard message, instead of
several calls to GetKeyState() here and there.
(gdk_event_translate): Fix bugs #104516, #104662, #115902. While
at it, do some major refactoring, and some fixes for potential
problems noticed while going through the code.
Don't handle WM_CHAR at all. Only handle WM_KEYDOWN and
WM_KEYUP. Don't need the state variables related to whether to
wait for WM_CHAR or not, and whether the current key is
AltGr. Remove lots of complexity. Thus don't need the
use_ime_composition flag.
Not handling WM_CHAR means dead key handling will have to be taken
care of by GTK, but that seems to work fine, so no worry.
Another side-effect is that Alt+keypad digits don't work any
longer, but it's better to learn to use GTK's ISO14755 support is
anyway.
Be more careful in checking whether AltGr is involved. Only
attempt to handle it if the keyboard actually has it. And
explicitly check for *left* Control plus *right* Alt being
pressed. Still, allow (left) Alt and/or (right) Control with AltGr
chars.
Handle keys using similar code as in the X11 backend. As we have
built a keymap in gdkkeys-win32.c anyway, use it by calling
gdk_keymap_translate_keyboard_state() to look up the keysym from
the virtual key code and keyboard state. Build the key event
string in exactly the same way as the X11 backend.
If an IME is being used, don't generate GDK events for keys
between receiving WM_IME_STARTCOMPOSITION and
WM_IME_ENDCOMPOSITION, as those keys are for the IME.
For WM_IME_COMPOSITION, handle all the Unicode chars returned from
the IME, not just the first one.
gdk_event_translate() is still quite complex, could split the
message handler cases out into separate functions.
On mouse events, when the mouse is grabbed, use
find_real_window_for_grabbed_mouse_event() in order to be able to
generate correct crossing events.
No longer take a pre-allocated GdkEvent as parameter. Instead,
allocate events as needed and append them to the queue. (This is
different from how gdk_event_translate() in the X11 backend
works.) This change made the code much clearer, especially in the
cases where we have to generate several GDK events for one Windows
message. Return FALSE if DefWindowProc() should be called, TRUE
if not. If DefWindowProc() should not be called, also return the
value to be returned from the window procedure.
(Previously, the interaction with gdk_event_translate()'s caller
was much more complex, when we had to indicate whether the
already-queued event should be left in the queue or removed, and
in addition also had to indicate whether to call DefWindowProc()
or not, and what value to return from the window procedure if
not.)
Don't use a separate "private" variable required to be pointing to
the GdkWindowObject of the "window" variable at all times. Just
use casts, even if looks a bit uglier.
Notice destroyed windows as early as possible, and break out of
the messsage switch.
Use _gdk_pointer_root as current_window when the pointer is
outside GDK's top-level windows.
On WM_INPUTLANGCHANGE, set _gdk_input_locale_is_ime as
appropriate, based on ImmIsIME().
(gdk_event_translate, gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Implement client messages.
Use a registered Windows message to pass GDK client messages. Note
that the amount of user data is restricted to four bytes, as it is
carried in the LPARAM. (The WPARAM is used for the message type
"atom".)
(real_window_procedure): Adapt for new gdk_event_translate()
interface.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_init): Set
_gdk_input_locale_is_ime initially.
* gdk/win32/gdkwindow-win32.c: Use g_object_ref()/unref() instead
of g_colormap_ref()/unref().
(gdk_window_new): Made code a bit more like the X11 one, pretend
to handle screens (although we just have one for now).
* gdk/x11/gdkevents-x11.c
(gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Document the user data
limitation on Win32.
* gdk/win32/gdkevents-win32.c (print_event): More complete enter
and leave notify detail output.
* gdk/win32/gdkkeys-win32.c (update_keymap): Make dead keys
visible to GDK and GTK. Store the corresponding GDK_dead_* keysym
for those, so that the GtkIMContextCimple compose tables will
work. Deduce if the keyboard layout has the AltGr key, and set the
above flag accordingly.
2003-07-26 01:54:59 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowPos (GDK_SURFACE_HWND (window), SWP_NOZORDER_SPECIFIED,
|
2005-03-16 01:38:57 +00:00
|
|
|
0, 0, 0, 0,
|
2004-03-10 22:20:36 +00:00
|
|
|
SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
|
gdk/win32/gdkprivate-win32.h New flags _gdk_input_locale_is_ime and
2003-07-25 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New flags _gdk_input_locale_is_ime
and _gdk_keyboard_has_altgr.
* gdk/win32/gdkevents-win32.c: Lots of changes. Most important
ones detailled here.
Code that has been ifdeffed out for a long time removed. Remove
some really old doc comments that were left behind for some public
functions, the official ones are in the X11 backend anyway. Change
GDK_WINDOW_OBJECT() calls to GdkWindowObject casts. Reformat
multi-line boolean expressions to have the operators at ends of
lines.
As mouse capture with SetCapture() indeed seems to work OK, no
need to have the correspoinding macro USE_SETCAPTURE and ifdefs.
Ifdef out the gdk-ping-msg stuff. I don't remember why it was
needed at some time, and things seem to work fine now without
(knock on wood).
Ifdef out the search for some Latin locale keyboard layout being
loaded. Not used currently, but might be needed after all, if we
decide that we want to be able to generate ASCII control character
events with a non-Latin keyboard.
(assign_object): New helper function, handles the g_object_ref()
and unref() calls when assigning GObject pointers.
(generate_crossing_events): Also generate the GDK_NOTIFY_INTERIOR
enter event when the pointer has moved to an ancestor window. Was
left out by mistake.
(gdk_window_is_ancestor): Renamed from gdk_window_is_child().
(gdk_pointer_grab, gdk_pointer_ungrab): Implement the confine_to
functionality, using ClipCursor().
(find_window_for_mouse_event): Splice part of code into new
function find_real_window_for_grabbed_mouse_event().
(fixup_event, append_event, apply_filters): New functions, code
refactored out from elsewhere.
(synthesize_enter_or_leave_event, synthesize_leave_event,
synthesize_enter_event,
synthesize_leave_events,synthesize_enter_events): Also take a
GdkCrossingMode parameter, in preparation to generating
GDK_CROSSING_GRAB and GDK_CROSSING_UNGRAB events.
(fixup_event, append_event, fill_key_event_string): New functions,
code refactoring.
(vk_from_char, build_keypress_event, build_keyrelease_event):
Removed as part of dropping WM_CHAR handling.
(build_key_event_state,gdk_event_translate): Call
GetKeyboardState(), once, for each keyboard message, instead of
several calls to GetKeyState() here and there.
(gdk_event_translate): Fix bugs #104516, #104662, #115902. While
at it, do some major refactoring, and some fixes for potential
problems noticed while going through the code.
Don't handle WM_CHAR at all. Only handle WM_KEYDOWN and
WM_KEYUP. Don't need the state variables related to whether to
wait for WM_CHAR or not, and whether the current key is
AltGr. Remove lots of complexity. Thus don't need the
use_ime_composition flag.
Not handling WM_CHAR means dead key handling will have to be taken
care of by GTK, but that seems to work fine, so no worry.
Another side-effect is that Alt+keypad digits don't work any
longer, but it's better to learn to use GTK's ISO14755 support is
anyway.
Be more careful in checking whether AltGr is involved. Only
attempt to handle it if the keyboard actually has it. And
explicitly check for *left* Control plus *right* Alt being
pressed. Still, allow (left) Alt and/or (right) Control with AltGr
chars.
Handle keys using similar code as in the X11 backend. As we have
built a keymap in gdkkeys-win32.c anyway, use it by calling
gdk_keymap_translate_keyboard_state() to look up the keysym from
the virtual key code and keyboard state. Build the key event
string in exactly the same way as the X11 backend.
If an IME is being used, don't generate GDK events for keys
between receiving WM_IME_STARTCOMPOSITION and
WM_IME_ENDCOMPOSITION, as those keys are for the IME.
For WM_IME_COMPOSITION, handle all the Unicode chars returned from
the IME, not just the first one.
gdk_event_translate() is still quite complex, could split the
message handler cases out into separate functions.
On mouse events, when the mouse is grabbed, use
find_real_window_for_grabbed_mouse_event() in order to be able to
generate correct crossing events.
No longer take a pre-allocated GdkEvent as parameter. Instead,
allocate events as needed and append them to the queue. (This is
different from how gdk_event_translate() in the X11 backend
works.) This change made the code much clearer, especially in the
cases where we have to generate several GDK events for one Windows
message. Return FALSE if DefWindowProc() should be called, TRUE
if not. If DefWindowProc() should not be called, also return the
value to be returned from the window procedure.
(Previously, the interaction with gdk_event_translate()'s caller
was much more complex, when we had to indicate whether the
already-queued event should be left in the queue or removed, and
in addition also had to indicate whether to call DefWindowProc()
or not, and what value to return from the window procedure if
not.)
Don't use a separate "private" variable required to be pointing to
the GdkWindowObject of the "window" variable at all times. Just
use casts, even if looks a bit uglier.
Notice destroyed windows as early as possible, and break out of
the messsage switch.
Use _gdk_pointer_root as current_window when the pointer is
outside GDK's top-level windows.
On WM_INPUTLANGCHANGE, set _gdk_input_locale_is_ime as
appropriate, based on ImmIsIME().
(gdk_event_translate, gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Implement client messages.
Use a registered Windows message to pass GDK client messages. Note
that the amount of user data is restricted to four bytes, as it is
carried in the LPARAM. (The WPARAM is used for the message type
"atom".)
(real_window_procedure): Adapt for new gdk_event_translate()
interface.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_init): Set
_gdk_input_locale_is_ime initially.
* gdk/win32/gdkwindow-win32.c: Use g_object_ref()/unref() instead
of g_colormap_ref()/unref().
(gdk_window_new): Made code a bit more like the X11 one, pretend
to handle screens (although we just have one for now).
* gdk/x11/gdkevents-x11.c
(gdk_event_send_client_message_for_display,
gdk_screen_broadcast_client_message): Document the user data
limitation on Win32.
* gdk/win32/gdkevents-win32.c (print_event): More complete enter
and leave notify detail output.
* gdk/win32/gdkkeys-win32.c (update_keymap): Make dead keys
visible to GDK and GTK. Store the corresponding GDK_dead_* keysym
for those, so that the GtkIMContextCimple compose tables will
work. Deduce if the keyboard layout has the AltGr key, and set the
above flag accordingly.
2003-07-26 01:54:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_HIDE);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 13:58:28 +00:00
|
|
|
static void
|
2019-07-15 09:32:35 +00:00
|
|
|
gdk_win32_surface_do_move (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, int y)
|
2008-07-02 20:22:30 +00:00
|
|
|
{
|
2019-05-28 17:25:45 +00:00
|
|
|
RECT outer_rect;
|
|
|
|
GdkWin32Surface *impl;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2008-07-02 20:22:30 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_move: %p: %+d%+d\n",
|
|
|
|
GDK_SURFACE_HWND (window), x, y));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2011-10-27 08:42:07 +00:00
|
|
|
return;
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
|
|
|
get_outer_rect (window, window->width, window->height, &outer_rect);
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
|
|
|
|
"NOACTIVATE|NOSIZE|NOZORDER)\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
2021-10-29 16:39:52 +00:00
|
|
|
x * impl->surface_scale,
|
|
|
|
y * impl->surface_scale));
|
2019-05-28 17:25:45 +00:00
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
2021-10-29 16:39:52 +00:00
|
|
|
x * impl->surface_scale,
|
|
|
|
y * impl->surface_scale,
|
2019-05-28 17:25:45 +00:00
|
|
|
0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
|
2008-07-02 20:22:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_resize (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int width, int height)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2019-05-28 17:25:45 +00:00
|
|
|
RECT outer_rect;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2008-07-02 20:22:30 +00:00
|
|
|
return;
|
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
if (width < 1)
|
1999-11-11 22:12:27 +00:00
|
|
|
width = 1;
|
2000-07-25 17:31:05 +00:00
|
|
|
if (height < 1)
|
1999-11-11 22:12:27 +00:00
|
|
|
height = 1;
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_resize: %p: %dx%d\n",
|
|
|
|
GDK_SURFACE_HWND (window), width, height));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2011-10-27 08:42:07 +00:00
|
|
|
return;
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
get_outer_rect (window, width, height, &outer_rect);
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
|
|
|
|
"NOACTIVATE|NOMOVE|NOZORDER)\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
outer_rect.right - outer_rect.left,
|
|
|
|
outer_rect.bottom - outer_rect.top));
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
|
|
|
0, 0,
|
|
|
|
outer_rect.right - outer_rect.left,
|
|
|
|
outer_rect.bottom - outer_rect.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
|
|
|
|
window->resize_count += 1;
|
2020-12-31 08:36:41 +00:00
|
|
|
|
|
|
|
gdk_surface_request_layout (window);
|
2008-07-02 20:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_do_move_resize (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2008-07-02 20:22:30 +00:00
|
|
|
{
|
2019-05-28 17:25:45 +00:00
|
|
|
RECT outer_rect;
|
|
|
|
GdkWin32Surface *impl;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2008-07-02 20:22:30 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2008-07-02 20:22:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (width < 1)
|
|
|
|
width = 1;
|
|
|
|
if (height < 1)
|
|
|
|
height = 1;
|
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2011-10-27 08:42:07 +00:00
|
|
|
return;
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_move_resize: %p: %dx%d@%+d%+d\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
2008-07-02 20:22:30 +00:00
|
|
|
width, height, x, y));
|
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
get_outer_rect (window, width, height, &outer_rect);
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
|
2019-05-28 17:25:45 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
|
|
|
|
"NOACTIVATE|NOZORDER)\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
2021-10-29 16:39:52 +00:00
|
|
|
x * impl->surface_scale,
|
|
|
|
y * impl->surface_scale,
|
2019-05-28 17:25:45 +00:00
|
|
|
outer_rect.right - outer_rect.left,
|
|
|
|
outer_rect.bottom - outer_rect.top));
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
2021-10-29 16:39:52 +00:00
|
|
|
x * impl->surface_scale,
|
|
|
|
y * impl->surface_scale,
|
2019-05-28 17:25:45 +00:00
|
|
|
outer_rect.right - outer_rect.left,
|
|
|
|
outer_rect.bottom - outer_rect.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER));
|
2008-07-02 20:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_move_resize_internal (GdkSurface *window,
|
|
|
|
gboolean with_move,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2008-07-02 20:22:30 +00:00
|
|
|
{
|
2015-04-29 07:31:08 +00:00
|
|
|
/* We ignore changes to the window being moved or resized by the
|
2011-10-25 14:13:47 +00:00
|
|
|
user, as we don't want to fight the user */
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_HWND (window) == _modal_move_resize_window)
|
2011-10-27 08:42:07 +00:00
|
|
|
goto out;
|
2011-10-25 14:13:47 +00:00
|
|
|
|
2008-07-02 20:22:30 +00:00
|
|
|
if (with_move && (width < 0 && height < 0))
|
|
|
|
{
|
2019-07-15 09:32:35 +00:00
|
|
|
gdk_win32_surface_do_move (window, x, y);
|
2008-07-02 20:22:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-31 10:11:26 +00:00
|
|
|
_gdk_win32_surface_invalidate_egl_framebuffer (window);
|
|
|
|
|
2008-07-02 20:22:30 +00:00
|
|
|
if (with_move)
|
2018-07-31 10:11:26 +00:00
|
|
|
{
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_do_move_resize (window, x, y, width, height);
|
2018-07-31 10:11:26 +00:00
|
|
|
}
|
2008-07-02 20:22:30 +00:00
|
|
|
else
|
2018-07-31 10:11:26 +00:00
|
|
|
{
|
|
|
|
gdk_win32_surface_resize (window, width, height);
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2011-10-27 08:42:07 +00:00
|
|
|
|
|
|
|
out:
|
2020-12-02 14:29:54 +00:00
|
|
|
gdk_surface_request_layout (window);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
void
|
|
|
|
gdk_win32_surface_move_resize (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2019-07-15 13:47:12 +00:00
|
|
|
{
|
|
|
|
gdk_win32_surface_move_resize_internal (window, TRUE, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2019-07-15 09:32:35 +00:00
|
|
|
void
|
|
|
|
gdk_win32_surface_move (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y)
|
2019-07-15 09:32:35 +00:00
|
|
|
{
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_move_resize_internal (surface, TRUE, x, y, -1, -1);
|
2019-07-15 09:32:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-14 02:10:52 +00:00
|
|
|
static void gdk_win32_surface_set_shadow_width (GdkSurface *window,
|
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom);
|
|
|
|
|
2019-07-15 09:35:24 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_win32_surface_layout_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2019-07-15 09:35:24 +00:00
|
|
|
{
|
2020-07-29 13:47:48 +00:00
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkRectangle bounds;
|
2020-02-16 11:59:24 +00:00
|
|
|
GdkRectangle final_rect;
|
2019-07-15 09:35:24 +00:00
|
|
|
int x, y;
|
2021-02-14 02:10:52 +00:00
|
|
|
int shadow_left, shadow_right, shadow_top, shadow_bottom;
|
2019-07-15 09:35:24 +00:00
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
monitor = gdk_surface_get_layout_monitor (surface, layout,
|
|
|
|
gdk_win32_monitor_get_workarea);
|
|
|
|
gdk_win32_monitor_get_workarea (monitor, &bounds);
|
|
|
|
|
2021-02-14 02:10:52 +00:00
|
|
|
gdk_popup_layout_get_shadow_width (layout,
|
|
|
|
&shadow_left,
|
|
|
|
&shadow_right,
|
|
|
|
&shadow_top,
|
|
|
|
&shadow_bottom);
|
2021-06-16 04:24:47 +00:00
|
|
|
|
2021-02-14 02:10:52 +00:00
|
|
|
gdk_win32_surface_set_shadow_width (surface,
|
|
|
|
shadow_left,
|
|
|
|
shadow_right,
|
|
|
|
shadow_top,
|
|
|
|
shadow_bottom);
|
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_surface_layout_popup_helper (surface,
|
|
|
|
width,
|
|
|
|
height,
|
2021-06-16 04:24:47 +00:00
|
|
|
shadow_left,
|
|
|
|
shadow_right,
|
|
|
|
shadow_top,
|
|
|
|
shadow_bottom,
|
2020-07-29 13:47:48 +00:00
|
|
|
monitor,
|
|
|
|
&bounds,
|
2020-02-16 11:59:24 +00:00
|
|
|
layout,
|
|
|
|
&final_rect);
|
2019-07-15 09:35:24 +00:00
|
|
|
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_surface_get_origin (surface->parent, &x, &y);
|
2019-07-15 09:35:24 +00:00
|
|
|
x += final_rect.x;
|
|
|
|
y += final_rect.y;
|
|
|
|
|
|
|
|
if (final_rect.width != surface->width ||
|
|
|
|
final_rect.height != surface->height)
|
|
|
|
{
|
|
|
|
gdk_win32_surface_move_resize (surface,
|
2020-02-16 11:59:24 +00:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
final_rect.width,
|
|
|
|
final_rect.height);
|
2019-07-15 09:35:24 +00:00
|
|
|
}
|
|
|
|
else
|
2021-06-16 04:24:47 +00:00
|
|
|
gdk_win32_surface_move (surface, x, y);
|
2019-07-15 09:35:24 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 02:29:28 +00:00
|
|
|
static void
|
|
|
|
maybe_notify_mapped (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
if (surface->destroyed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!GDK_SURFACE_IS_MAPPED (surface))
|
|
|
|
{
|
|
|
|
gdk_surface_set_is_mapped (surface, TRUE);
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 09:35:24 +00:00
|
|
|
static void
|
2020-02-16 11:59:24 +00:00
|
|
|
show_popup (GdkSurface *surface)
|
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_raise (surface);
|
2020-12-11 02:29:28 +00:00
|
|
|
maybe_notify_mapped (surface);
|
2020-02-16 11:59:24 +00:00
|
|
|
show_window_internal (surface, FALSE, FALSE);
|
|
|
|
gdk_surface_invalidate_rect (surface, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_grabbing_popup (GdkSeat *seat,
|
|
|
|
GdkSurface *surface,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
show_popup (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_surface_present_popup (GdkSurface *surface,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2019-07-15 09:35:24 +00:00
|
|
|
{
|
2020-02-16 11:59:24 +00:00
|
|
|
gdk_win32_surface_layout_popup (surface, width, height, layout);
|
|
|
|
|
|
|
|
if (GDK_SURFACE_IS_MAPPED (surface))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (surface->autohide)
|
|
|
|
{
|
|
|
|
gdk_seat_grab (gdk_display_get_default_seat (surface->display),
|
|
|
|
surface,
|
|
|
|
GDK_SEAT_CAPABILITY_ALL,
|
|
|
|
TRUE,
|
|
|
|
NULL, NULL,
|
|
|
|
show_grabbing_popup, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
show_popup (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GDK_SURFACE_IS_MAPPED (surface);
|
2019-07-15 09:35:24 +00:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_raise (GdkSurface *window)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (window))
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_raise: %p\n",
|
|
|
|
GDK_SURFACE_HWND (window)));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (GDK_IS_DRAG_SURFACE (window))
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_TOPMOST,
|
2006-02-09 03:20:56 +00:00
|
|
|
0, 0, 0, 0,
|
2017-09-20 17:21:44 +00:00
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER));
|
2020-10-06 09:37:35 +00:00
|
|
|
|
|
|
|
else if (GDK_IS_POPUP (window))
|
|
|
|
ShowWindow (GDK_SURFACE_HWND (window), SW_SHOWNOACTIVATE);
|
2020-03-14 14:06:57 +00:00
|
|
|
else
|
2012-01-25 12:02:21 +00:00
|
|
|
/* Do not wrap this in an API_CALL macro as SetForegroundWindow might
|
|
|
|
* fail when for example dragging a window belonging to a different
|
|
|
|
* application at the time of a gtk_window_present() call due to focus
|
|
|
|
* stealing prevention. */
|
2018-03-20 10:40:08 +00:00
|
|
|
SetForegroundWindow (GDK_SURFACE_HWND (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-20 01:13:41 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_set_urgency_hint (GdkSurface *window,
|
2019-04-20 01:13:41 +00:00
|
|
|
gboolean urgent)
|
2005-07-03 15:47:42 +00:00
|
|
|
{
|
2005-08-01 07:19:15 +00:00
|
|
|
FLASHWINFO flashwinfo;
|
2012-11-23 20:38:34 +00:00
|
|
|
typedef BOOL (WINAPI *PFN_FlashWindowEx) (FLASHWINFO*);
|
2005-09-18 12:28:42 +00:00
|
|
|
PFN_FlashWindowEx flashWindowEx = NULL;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2005-09-18 12:28:42 +00:00
|
|
|
return;
|
|
|
|
|
2005-11-28 08:40:56 +00:00
|
|
|
flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
|
|
|
|
|
|
|
|
if (flashWindowEx)
|
2005-09-18 12:28:42 +00:00
|
|
|
{
|
2005-11-28 08:40:56 +00:00
|
|
|
flashwinfo.cbSize = sizeof (flashwinfo);
|
2018-03-20 10:40:08 +00:00
|
|
|
flashwinfo.hwnd = GDK_SURFACE_HWND (window);
|
2005-11-28 08:40:56 +00:00
|
|
|
if (urgent)
|
|
|
|
flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
|
|
|
|
else
|
|
|
|
flashwinfo.dwFlags = FLASHW_STOP;
|
|
|
|
flashwinfo.uCount = 0;
|
|
|
|
flashwinfo.dwTimeout = 0;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2005-11-28 08:40:56 +00:00
|
|
|
flashWindowEx (&flashwinfo);
|
2005-09-18 12:28:42 +00:00
|
|
|
}
|
|
|
|
else
|
2005-11-28 08:40:56 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
FlashWindow (GDK_SURFACE_HWND (window), urgent);
|
2005-11-28 08:40:56 +00:00
|
|
|
}
|
2005-07-03 15:47:42 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 02:58:45 +00:00
|
|
|
static gboolean
|
2018-03-20 10:40:08 +00:00
|
|
|
get_effective_window_decorations (GdkSurface *window,
|
2006-02-09 02:58:45 +00:00
|
|
|
GdkWMDecoration *decoration)
|
2005-11-27 02:58:09 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2005-11-27 02:58:09 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
*decoration = 0;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (!GDK_IS_TOPLEVEL (window))
|
2020-09-15 07:37:32 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* we want to apply the "no decorations", if decorations are disabled */
|
|
|
|
if (!GDK_WIN32_SURFACE (window)->decorate_all)
|
|
|
|
return TRUE;
|
2005-11-27 02:58:09 +00:00
|
|
|
|
|
|
|
if ((impl->hint_flags & GDK_HINT_MIN_SIZE) &&
|
|
|
|
(impl->hint_flags & GDK_HINT_MAX_SIZE) &&
|
|
|
|
impl->hints.min_width == impl->hints.max_width &&
|
|
|
|
impl->hints.min_height == impl->hints.max_height)
|
|
|
|
{
|
2006-02-09 02:58:45 +00:00
|
|
|
*decoration = GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MAXIMIZE;
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
*decoration |= GDK_DECOR_MINIMIZE;
|
2005-11-27 02:58:09 +00:00
|
|
|
|
2006-02-09 02:58:45 +00:00
|
|
|
return TRUE;
|
2005-11-27 02:58:09 +00:00
|
|
|
}
|
|
|
|
else if (impl->hint_flags & GDK_HINT_MAX_SIZE)
|
|
|
|
{
|
2006-02-09 02:58:45 +00:00
|
|
|
*decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE;
|
2020-03-12 11:01:30 +00:00
|
|
|
*decoration |= GDK_DECOR_MINIMIZE;
|
2008-02-05 16:47:24 +00:00
|
|
|
|
2006-02-09 02:58:45 +00:00
|
|
|
return TRUE;
|
2005-11-27 02:58:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
*decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
|
|
|
|
return TRUE;
|
2005-11-27 02:58:09 +00:00
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2006-02-09 02:58:45 +00:00
|
|
|
return FALSE;
|
2005-11-27 02:58:09 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_set_geometry_hints (GdkSurface *window,
|
2008-01-15 15:32:37 +00:00
|
|
|
const GdkGeometry *geometry,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceHints geom_mask)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2011-10-26 10:43:24 +00:00
|
|
|
FullscreenInfo *fi;
|
gdk/win32/gdkinput-win32.h Drop the GdkEvent* parameter, it wasn't used.
2003-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput-win32.c (_gdk_input_configure_event,
_gdk_input_enter_event): Drop the GdkEvent* parameter, it wasn't
used.
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Adapt caller
accordingly, in fact an uninitialised variable was dereferenced.
[Win32] Add support for multiple monitors.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New global variables for
multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and
_gdk_offset_x and _gdk_offset_y.
* gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New
functions, enumeration functions passed to EnumDisplayMonitors().
(gdk_display_open): If the EnumDisplayMonitors() and
GetMonitorInfo() API is present (on Win98, Win2000 and newer), use
if to find out monitor info.
Calculate the offset between Win32 coordinates (relative to the
primary monitor's origin (and thus negative on monitors to the
left of or above it), and GDK's (visible coordinates should be
non-negative).
* gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors,
gdk_screen_get_monitor_geometry): Use information collected above.
(gdk_window_move, gdk_window_move_resize_window_get_geometry):
Subtract _gdk_offset_{x,y} from GDK root window coordinates.
(gdk_window_get_geometry, gdk_window_get_origin,
gdk_window_get_frame_extents): For top-level windows, add
_gdk_offset_{x,y} to GDK root window coordinates
Still need to handle multiple monitors in
gdk_window_fullscreen(). Probably should make the window
fullscreen on the monitor where the cursor is?
* gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK
root window coordinates in GdkEvents.
[Win32] Fix geometry hint handling. Add support for resize
increment and base size, and aspect ratio geometry hints. The
"gridded geometry" test in testgtk now works beautifully.
* gdk/win32/gdkwindow-win32.c (gdk_window_set_geometry_hints):
Turns out this function shouldn't actually ever modify the
window's size, just store the hints. (Old code kept for a while
inside #if 0.)
(gdk_window_set_hints): Remove presumably broken code that handles
the position hints, this function is obsolete anyway.
* gdk/win32/gdkevents-win32.c: Drop the current_{x,y}_root
variables, not used.
(adjust_drag): New function, used to implement resize increment
hints.
(gdk_event_translate): Handle WM_SIZING, implement resize
increment and base size, and aspect ratio geometry hints here. The
WM_GETMINMAXINFO handler takes care of the minimum and maximum
size hints as before. Fix the WM_GETMINMAXINFO handler to take
into account window decorations. No need to modify the
ptMaxPosition and ptMaxSize fields in the MINMAXINFO struct,
the defaults are fine.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwindow-win32.c (_gdk_win32_adjust_client_rect,
_gdk_win32_get_adjusted_client_rect): New helper functions.
2003-08-07 22:17:18 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
1999-11-11 22:12:27 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_set_geometry_hints: %p\n",
|
|
|
|
GDK_SURFACE_HWND (window)));
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
|
2011-10-26 10:43:24 +00:00
|
|
|
fi = g_object_get_data (G_OBJECT (window), "fullscreen-info");
|
|
|
|
if (fi)
|
|
|
|
fi->hint_flags = geom_mask;
|
|
|
|
else
|
|
|
|
impl->hint_flags = geom_mask;
|
2003-08-02 02:05:12 +00:00
|
|
|
impl->hints = *geometry;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
if (geom_mask & GDK_HINT_MIN_SIZE)
|
|
|
|
{
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... MIN_SIZE: %dx%d\n",
|
|
|
|
geometry->min_width, geometry->min_height));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
if (geom_mask & GDK_HINT_MAX_SIZE)
|
|
|
|
{
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... MAX_SIZE: %dx%d\n",
|
|
|
|
geometry->max_width, geometry->max_height));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
2001-11-09 21:52:52 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_update_style_bits (window);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_set_title (GdkSurface *window,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *title)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2006-08-30 00:39:01 +00:00
|
|
|
wchar_t *wtitle;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
g_return_if_fail (title != NULL);
|
2000-10-22 17:16:42 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2005-07-21 07:29:36 +00:00
|
|
|
return;
|
|
|
|
|
2000-10-22 17:16:42 +00:00
|
|
|
/* Empty window titles not allowed, so set it to just a period. */
|
|
|
|
if (!title[0])
|
|
|
|
title = ".";
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_set_title: %p: %s\n",
|
|
|
|
GDK_SURFACE_HWND (window), title));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC_OR_EVENTS, title = g_strdup_printf ("%p %s", GDK_SURFACE_HWND (window), title));
|
2008-10-05 00:00:10 +00:00
|
|
|
|
2006-08-30 00:39:01 +00:00
|
|
|
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowTextW, (GDK_SURFACE_HWND (window), wtitle));
|
2006-08-30 00:39:01 +00:00
|
|
|
g_free (wtitle);
|
2008-10-05 00:00:10 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC_OR_EVENTS, g_free ((char *) title));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_set_transient_for (GdkSurface *window,
|
|
|
|
GdkSurface *parent)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2001-08-04 13:17:33 +00:00
|
|
|
HWND window_id, parent_id;
|
2014-08-02 15:48:03 +00:00
|
|
|
LONG_PTR old_ptr;
|
|
|
|
DWORD w32_error;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *surface = GDK_WIN32_SURFACE (window);
|
|
|
|
GdkWin32Surface *parent_impl = NULL;
|
2007-10-18 00:31:22 +00:00
|
|
|
GSList *item;
|
2001-08-04 13:17:33 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2001-08-04 13:17:33 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
window_id = GDK_SURFACE_HWND (window);
|
|
|
|
parent_id = parent != NULL ? GDK_SURFACE_HWND (parent) : NULL;
|
2007-07-12 23:38:30 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_set_transient_for: %p: %p\n", window_id, parent_id));
|
2008-10-05 00:00:10 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window) || (parent && GDK_SURFACE_DESTROYED (parent)))
|
2007-07-12 23:38:30 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2007-07-12 23:38:30 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... destroyed!\n"));
|
|
|
|
else
|
|
|
|
GDK_NOTE (MISC, g_print ("... owner destroyed!\n"));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2001-08-04 13:17:33 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (surface->transient_owner == parent)
|
2018-07-31 08:50:06 +00:00
|
|
|
return;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
if (GDK_IS_SURFACE (surface->transient_owner))
|
2007-10-18 00:31:22 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *trans_impl = GDK_WIN32_SURFACE (surface->transient_owner);
|
2018-07-31 08:50:06 +00:00
|
|
|
item = g_slist_find (trans_impl->transient_children, window);
|
|
|
|
item->data = NULL;
|
|
|
|
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
|
|
|
|
trans_impl->num_transients--;
|
2007-10-18 00:31:22 +00:00
|
|
|
|
2018-07-31 08:50:06 +00:00
|
|
|
if (!trans_impl->num_transients)
|
|
|
|
{
|
|
|
|
trans_impl->transient_children = NULL;
|
2007-10-18 00:31:22 +00:00
|
|
|
}
|
2018-07-31 08:50:06 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
g_object_unref (G_OBJECT (surface->transient_owner));
|
2008-01-10 20:58:40 +00:00
|
|
|
g_object_unref (G_OBJECT (window));
|
2007-10-18 00:31:22 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
surface->transient_owner = NULL;
|
2007-10-18 00:31:22 +00:00
|
|
|
}
|
2018-07-31 08:50:06 +00:00
|
|
|
|
|
|
|
if (parent)
|
2007-10-18 00:31:22 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
parent_impl = GDK_WIN32_SURFACE (parent);
|
2007-10-18 00:31:22 +00:00
|
|
|
|
|
|
|
parent_impl->transient_children = g_slist_append (parent_impl->transient_children, window);
|
2008-01-10 20:58:40 +00:00
|
|
|
g_object_ref (G_OBJECT (window));
|
2007-10-18 00:31:22 +00:00
|
|
|
parent_impl->num_transients++;
|
2019-05-19 03:09:05 +00:00
|
|
|
surface->transient_owner = parent;
|
2008-01-10 20:58:40 +00:00
|
|
|
g_object_ref (G_OBJECT (parent));
|
2007-10-18 00:31:22 +00:00
|
|
|
}
|
2001-08-04 13:17:33 +00:00
|
|
|
|
2014-08-02 15:48:03 +00:00
|
|
|
SetLastError (0);
|
|
|
|
old_ptr = GetWindowLongPtr (window_id, GWLP_HWNDPARENT);
|
|
|
|
w32_error = GetLastError ();
|
|
|
|
|
|
|
|
/* Don't re-set GWLP_HWNDPARENT to the same value */
|
2014-08-06 05:06:35 +00:00
|
|
|
if ((HWND) old_ptr == parent_id && w32_error == NO_ERROR)
|
2014-08-02 15:48:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't return if it failed, try SetWindowLongPtr() anyway */
|
|
|
|
if (old_ptr == 0 && w32_error != NO_ERROR)
|
|
|
|
WIN32_API_FAILED ("GetWindowLongPtr");
|
|
|
|
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
/* This changes the *owner* of the window, despite the misleading
|
|
|
|
* name. (Owner and parent are unrelated concepts.) At least that's
|
|
|
|
* what people who seem to know what they talk about say on
|
|
|
|
* USENET. Search on Google.
|
|
|
|
*/
|
|
|
|
SetLastError (0);
|
2014-08-02 15:48:03 +00:00
|
|
|
old_ptr = SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id);
|
|
|
|
w32_error = GetLastError ();
|
|
|
|
|
|
|
|
if (old_ptr == 0 && w32_error != NO_ERROR)
|
2008-08-04 23:21:36 +00:00
|
|
|
WIN32_API_FAILED ("SetWindowLongPtr");
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2008-02-05 16:47:24 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_push_modal_window (GdkSurface *window)
|
2008-02-05 16:47:24 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
modal_window_stack = g_slist_prepend (modal_window_stack, window);
|
2008-02-05 16:47:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_remove_modal_window (GdkSurface *window)
|
2008-02-05 16:47:24 +00:00
|
|
|
{
|
2008-02-07 19:25:07 +00:00
|
|
|
GSList *tmp;
|
|
|
|
|
2008-02-05 16:47:24 +00:00
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
|
|
|
|
/* It's possible to be NULL here if someone sets the modal hint of the window
|
|
|
|
* to FALSE before a modal window stack has ever been created. */
|
|
|
|
if (modal_window_stack == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Find the requested window in the stack and remove it. Yeah, I realize this
|
|
|
|
* means we're not a 'real stack', strictly speaking. Sue me. :) */
|
2008-02-07 19:25:07 +00:00
|
|
|
tmp = g_slist_find (modal_window_stack, window);
|
2008-02-05 16:47:24 +00:00
|
|
|
if (tmp != NULL)
|
|
|
|
{
|
|
|
|
modal_window_stack = g_slist_delete_link (modal_window_stack, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-27 20:13:54 +00:00
|
|
|
gboolean
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_modal_blocked (GdkSurface *window)
|
2008-02-05 16:47:24 +00:00
|
|
|
{
|
2011-10-27 20:13:54 +00:00
|
|
|
GSList *l;
|
|
|
|
gboolean found_any = FALSE;
|
|
|
|
|
|
|
|
for (l = modal_window_stack; l != NULL; l = l->next)
|
2008-02-05 23:46:35 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *modal = l->data;
|
2008-02-05 23:46:35 +00:00
|
|
|
|
2011-10-27 20:13:54 +00:00
|
|
|
if (modal == window)
|
|
|
|
return FALSE;
|
2008-02-05 23:46:35 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (modal))
|
2011-10-27 20:13:54 +00:00
|
|
|
found_any = TRUE;
|
2008-02-05 23:46:35 +00:00
|
|
|
}
|
2011-10-27 20:13:54 +00:00
|
|
|
|
|
|
|
return found_any;
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *
|
2011-10-27 20:13:54 +00:00
|
|
|
_gdk_modal_current (void)
|
|
|
|
{
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
for (l = modal_window_stack; l != NULL; l = l->next)
|
2008-02-05 23:46:35 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *modal = l->data;
|
2011-10-27 20:13:54 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (modal))
|
2011-10-27 20:13:54 +00:00
|
|
|
return modal;
|
2008-02-05 23:46:35 +00:00
|
|
|
}
|
2011-10-27 20:13:54 +00:00
|
|
|
|
|
|
|
return NULL;
|
2008-02-05 16:47:24 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 13:58:28 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_get_geometry (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_SURFACE_DESTROYED (window))
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
|
|
|
RECT rect;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2021-02-02 09:30:55 +00:00
|
|
|
if (GDK_IS_TOPLEVEL (window) && impl->drag_move_resize_context.native_move_resize_pending)
|
|
|
|
rect = impl->next_layout.configured_rect;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
POINT pt;
|
2020-03-12 11:01:30 +00:00
|
|
|
GdkSurface *parent;
|
2021-02-02 09:30:55 +00:00
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (GDK_IS_TOPLEVEL (window))
|
|
|
|
parent = NULL;
|
|
|
|
else if (GDK_IS_POPUP (window))
|
|
|
|
parent = gdk_popup_get_parent (GDK_POPUP (window));
|
|
|
|
else
|
|
|
|
parent = NULL;
|
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
|
|
|
|
2021-02-02 09:30:55 +00:00
|
|
|
API_CALL (GetClientRect, (GDK_SURFACE_HWND (window), &rect));
|
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
|
|
|
|
2021-02-02 09:30:55 +00:00
|
|
|
pt.x = rect.left;
|
|
|
|
pt.y = rect.top;
|
|
|
|
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
2017-11-06 02:00:04 +00:00
|
|
|
if (parent)
|
2021-02-02 09:30:55 +00:00
|
|
|
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
gdk/win32/gdkinput-win32.h Drop the GdkEvent* parameter, it wasn't used.
2003-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput-win32.c (_gdk_input_configure_event,
_gdk_input_enter_event): Drop the GdkEvent* parameter, it wasn't
used.
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Adapt caller
accordingly, in fact an uninitialised variable was dereferenced.
[Win32] Add support for multiple monitors.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New global variables for
multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and
_gdk_offset_x and _gdk_offset_y.
* gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New
functions, enumeration functions passed to EnumDisplayMonitors().
(gdk_display_open): If the EnumDisplayMonitors() and
GetMonitorInfo() API is present (on Win98, Win2000 and newer), use
if to find out monitor info.
Calculate the offset between Win32 coordinates (relative to the
primary monitor's origin (and thus negative on monitors to the
left of or above it), and GDK's (visible coordinates should be
non-negative).
* gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors,
gdk_screen_get_monitor_geometry): Use information collected above.
(gdk_window_move, gdk_window_move_resize_window_get_geometry):
Subtract _gdk_offset_{x,y} from GDK root window coordinates.
(gdk_window_get_geometry, gdk_window_get_origin,
gdk_window_get_frame_extents): For top-level windows, add
_gdk_offset_{x,y} to GDK root window coordinates
Still need to handle multiple monitors in
gdk_window_fullscreen(). Probably should make the window
fullscreen on the monitor where the cursor is?
* gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK
root window coordinates in GdkEvents.
[Win32] Fix geometry hint handling. Add support for resize
increment and base size, and aspect ratio geometry hints. The
"gridded geometry" test in testgtk now works beautifully.
* gdk/win32/gdkwindow-win32.c (gdk_window_set_geometry_hints):
Turns out this function shouldn't actually ever modify the
window's size, just store the hints. (Old code kept for a while
inside #if 0.)
(gdk_window_set_hints): Remove presumably broken code that handles
the position hints, this function is obsolete anyway.
* gdk/win32/gdkevents-win32.c: Drop the current_{x,y}_root
variables, not used.
(adjust_drag): New function, used to implement resize increment
hints.
(gdk_event_translate): Handle WM_SIZING, implement resize
increment and base size, and aspect ratio geometry hints here. The
WM_GETMINMAXINFO handler takes care of the minimum and maximum
size hints as before. Fix the WM_GETMINMAXINFO handler to take
into account window decorations. No need to modify the
ptMaxPosition and ptMaxSize fields in the MINMAXINFO struct,
the defaults are fine.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwindow-win32.c (_gdk_win32_adjust_client_rect,
_gdk_win32_get_adjusted_client_rect): New helper functions.
2003-08-07 22:17:18 +00:00
|
|
|
|
2021-02-02 09:30:55 +00:00
|
|
|
rect.left = pt.x;
|
|
|
|
rect.top = pt.y;
|
|
|
|
|
|
|
|
pt.x = rect.right;
|
|
|
|
pt.y = rect.bottom;
|
|
|
|
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
|
|
|
if (parent)
|
|
|
|
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
|
|
|
|
|
|
|
rect.right = pt.x;
|
|
|
|
rect.bottom = pt.y;
|
|
|
|
}
|
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
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
if (x)
|
2018-03-20 11:05:26 +00:00
|
|
|
*x = rect.left / impl->surface_scale;
|
1999-11-11 22:12:27 +00:00
|
|
|
if (y)
|
2018-03-20 11:05:26 +00:00
|
|
|
*y = rect.top / impl->surface_scale;
|
1999-11-11 22:12:27 +00:00
|
|
|
if (width)
|
2018-03-20 11:05:26 +00:00
|
|
|
*width = (rect.right - rect.left) / impl->surface_scale;
|
1999-11-11 22:12:27 +00:00
|
|
|
if (height)
|
2018-03-20 11:05:26 +00:00
|
|
|
*height = (rect.bottom - rect.top) / impl->surface_scale;
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
|
2018-06-10 20:49:47 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_get_geometry: %p: %ldx%ld@%+ld%+ld\n",
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_HWND (window),
|
2018-03-20 11:05:26 +00:00
|
|
|
(rect.right - rect.left) / impl->surface_scale,
|
|
|
|
(rect.bottom - rect.top) / impl->surface_scale,
|
Fix for #108007, #112402, #117042: There was confusion in gdk/win32 at
2003-07-29 Tor Lillqvist <tml@iki.fi>
Fix for #108007, #112402, #117042: There was confusion in
gdk/win32 at various places whether a window position refers to
the decoration position or the client area position. Also whether
window size includes decorations or not.
The correct interpretation apparently is that in GDK (like in
X11), a top-level window position means the decoration's position,
but size means the window's inner size (client area size). In the
Win32 API, the window size usually includes the decorations,
though.
* gdk/win32/gdkevents-win32.c (decode_key_lparam): Move inside
#ifdef G_ENABLE_DEBUG.
(handle_configure_event): New function, generates GDK_CONFIGURE
events from WM_SIZE and WM_MOVE messages. Even if no event is
generated because of the event mask, still set the private
position and size fields. Calculate position and size correctly.
(gdk_event_translate): Call handle_configure_event().
* gdk/win32/gdkgeometry-win32.c: Cosmetics.
* gdk/win32/gdkwindow-win32.c: Use GDI_CALL() and API_CALL()
macros. Cosmetic debugging output changes.
(SafeAdjustWindowRectEx): Remove. If an application wants to
locate a window outside of the screen, it's not GDK's business to
prevent it. And anyway, with multiple monitors, negative
coordinates are perfectly normal.
(gdk_window_new): Adjust the window size for decorations after
_gdk_window_init_position() has done its job. (But the big window
code currently is presumably broken on Win32 anyway.)
(gdk_window_move): The position passed in is supposed to be that
of the window border, so don't need to adjust for decorations.
(gdk_window_resize, gdk_window_move_resize): Simplify somewhat.
2003-07-29 23:35:40 +00:00
|
|
|
rect.left, rect.top));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 01:58:13 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_get_root_coords (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *root_x,
|
|
|
|
int *root_y)
|
2009-07-01 08:26:37 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int tx;
|
|
|
|
int ty;
|
2009-07-01 08:26:37 +00:00
|
|
|
POINT pt;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2009-07-01 08:26:37 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
pt.x = x * impl->surface_scale;
|
|
|
|
pt.y = y * impl->surface_scale;
|
2018-03-20 10:40:08 +00:00
|
|
|
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
2009-07-01 08:26:37 +00:00
|
|
|
tx = pt.x;
|
|
|
|
ty = pt.y;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2009-07-04 10:10:57 +00:00
|
|
|
if (root_x)
|
2021-10-29 16:39:52 +00:00
|
|
|
*root_x = tx / impl->surface_scale;
|
2009-07-04 10:10:57 +00:00
|
|
|
if (root_y)
|
2021-10-29 16:39:52 +00:00
|
|
|
*root_y = ty / impl->surface_scale;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_get_root_coords: %p: %+d%+d %+d%+d\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
2018-03-20 11:05:26 +00:00
|
|
|
x * impl->surface_scale,
|
|
|
|
y * impl->surface_scale,
|
2021-10-29 16:39:52 +00:00
|
|
|
tx / impl->surface_scale,
|
|
|
|
ty / impl->surface_scale));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 08:26:37 +00:00
|
|
|
static gboolean
|
2020-08-26 20:35:28 +00:00
|
|
|
gdk_surface_win32_get_device_state (GdkSurface *window,
|
|
|
|
GdkDevice *device,
|
|
|
|
double *x,
|
|
|
|
double *y,
|
|
|
|
GdkModifierType *mask)
|
2009-07-01 08:26:37 +00:00
|
|
|
{
|
2020-08-26 20:35:28 +00:00
|
|
|
_gdk_device_win32_query_state (device, window, NULL, x, y, mask);
|
2009-07-01 08:26:37 +00:00
|
|
|
|
2020-08-26 20:35:28 +00:00
|
|
|
return *x >= 0 && *y >= 0 && *x < window->width && *y < window->height;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-09 12:35:56 +00:00
|
|
|
static void
|
2008-03-10 15:48:06 +00:00
|
|
|
update_single_bit (LONG *style,
|
|
|
|
gboolean all,
|
|
|
|
int gdk_bit,
|
|
|
|
int style_bit)
|
|
|
|
{
|
|
|
|
/* all controls the interpretation of gdk_bit -- if all is TRUE,
|
|
|
|
* gdk_bit indicates whether style_bit is off; if all is FALSE, gdk
|
|
|
|
* bit indicate whether style_bit is on
|
|
|
|
*/
|
2006-02-09 02:58:45 +00:00
|
|
|
if ((!all && gdk_bit) || (all && !gdk_bit))
|
|
|
|
*style |= style_bit;
|
|
|
|
else
|
|
|
|
*style &= ~style_bit;
|
|
|
|
}
|
|
|
|
|
2016-02-23 09:20:55 +00:00
|
|
|
/*
|
|
|
|
* Returns TRUE if window has no decorations.
|
|
|
|
* Usually it means CSD windows, because GTK
|
2018-03-20 10:40:08 +00:00
|
|
|
* calls gdk_surface_set_decorations (window, 0);
|
2016-02-23 09:20:55 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_lacks_wm_decorations (GdkSurface *window)
|
2016-02-23 09:20:55 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-02-23 09:20:55 +00:00
|
|
|
LONG style;
|
|
|
|
gboolean has_any_decorations;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2016-02-23 09:20:55 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-02-23 09:20:55 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
/* This is because GTK calls gdk_surface_set_decorations (window, 0),
|
2016-02-23 09:20:55 +00:00
|
|
|
* even though GdkWMDecoration docs indicate that 0 does NOT mean
|
|
|
|
* "no decorations".
|
|
|
|
*/
|
2020-09-15 07:37:32 +00:00
|
|
|
if (!impl->decorate_all)
|
2016-02-23 09:20:55 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_HWND (window) == 0)
|
2016-02-23 09:20:55 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
style = GetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE);
|
2016-02-23 09:20:55 +00:00
|
|
|
|
|
|
|
if (style == 0)
|
|
|
|
{
|
|
|
|
DWORD w32_error = GetLastError ();
|
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Failed to get style of window %p (handle %p): %lu\n",
|
2018-03-20 10:40:08 +00:00
|
|
|
window, GDK_SURFACE_HWND (window), w32_error));
|
2016-02-23 09:20:55 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
/* Keep this in sync with _gdk_win32_surface_update_style_bits() */
|
2016-02-23 09:20:55 +00:00
|
|
|
/* We don't check what get_effective_window_decorations()
|
|
|
|
* has to say, because it gives suggestions based on
|
|
|
|
* various hints, while we want *actual* decorations,
|
|
|
|
* or their absence.
|
|
|
|
*/
|
|
|
|
has_any_decorations = FALSE;
|
|
|
|
|
|
|
|
if (style & (WS_BORDER | WS_THICKFRAME | WS_CAPTION |
|
|
|
|
WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX))
|
|
|
|
has_any_decorations = TRUE;
|
|
|
|
else
|
|
|
|
GDK_NOTE (MISC, g_print ("Window %p (handle %p): has no decorations (style %lx)\n",
|
2018-03-20 10:40:08 +00:00
|
|
|
window, GDK_SURFACE_HWND (window), style));
|
2016-02-23 09:20:55 +00:00
|
|
|
|
|
|
|
return !has_any_decorations;
|
|
|
|
}
|
|
|
|
|
2016-03-08 05:00:49 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_update_style_bits (GdkSurface *window)
|
2005-11-09 12:35:56 +00:00
|
|
|
{
|
2006-02-09 02:58:45 +00:00
|
|
|
GdkWMDecoration decorations;
|
2008-10-05 00:00:10 +00:00
|
|
|
LONG old_style, new_style, old_exstyle, new_exstyle;
|
2008-03-10 15:48:06 +00:00
|
|
|
gboolean all;
|
2005-11-09 12:35:56 +00:00
|
|
|
RECT rect, before, after;
|
2015-11-21 03:48:55 +00:00
|
|
|
gboolean was_topmost;
|
|
|
|
gboolean will_be_topmost;
|
2021-09-04 12:12:54 +00:00
|
|
|
gboolean was_layered;
|
|
|
|
gboolean will_be_layered;
|
2015-11-21 03:48:55 +00:00
|
|
|
HWND insert_after;
|
|
|
|
UINT flags;
|
2005-11-09 12:35:56 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
2011-10-26 10:43:24 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
old_style = GetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE);
|
|
|
|
old_exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
|
2005-11-09 12:35:56 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GetClientRect (GDK_SURFACE_HWND (window), &before);
|
2005-11-09 12:35:56 +00:00
|
|
|
after = before;
|
2008-10-05 00:00:10 +00:00
|
|
|
AdjustWindowRectEx (&before, old_style, FALSE, old_exstyle);
|
2008-03-10 15:48:06 +00:00
|
|
|
|
2015-11-21 03:48:55 +00:00
|
|
|
was_topmost = (old_exstyle & WS_EX_TOPMOST) ? TRUE : FALSE;
|
2021-09-04 12:12:54 +00:00
|
|
|
was_layered = (old_exstyle & WS_EX_LAYERED) ? TRUE : FALSE;
|
2015-11-21 03:48:55 +00:00
|
|
|
will_be_topmost = was_topmost;
|
2021-09-04 12:12:54 +00:00
|
|
|
will_be_layered = was_layered;
|
2015-11-21 03:48:55 +00:00
|
|
|
|
|
|
|
old_exstyle &= ~WS_EX_TOPMOST;
|
|
|
|
|
2008-05-23 18:25:12 +00:00
|
|
|
new_style = old_style;
|
2008-10-05 00:00:10 +00:00
|
|
|
new_exstyle = old_exstyle;
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
if (GDK_IS_DRAG_SURFACE (window))
|
2015-11-21 03:48:55 +00:00
|
|
|
{
|
|
|
|
new_exstyle |= WS_EX_TOOLWINDOW;
|
2021-09-04 12:12:54 +00:00
|
|
|
|
|
|
|
/* WS_EX_LAYERED | WS_EX_TRANSPARENT makes the drag surface behave
|
|
|
|
* in pointer input passthrough mode, so it doesn't interfere with
|
|
|
|
* the drag and drop operation.
|
|
|
|
*/
|
|
|
|
new_exstyle |= WS_EX_LAYERED | WS_EX_TRANSPARENT;
|
2015-11-21 03:48:55 +00:00
|
|
|
will_be_topmost = TRUE;
|
2021-09-04 12:12:54 +00:00
|
|
|
will_be_layered = TRUE;
|
2015-11-21 03:48:55 +00:00
|
|
|
}
|
2008-10-05 00:00:10 +00:00
|
|
|
else
|
2015-11-21 03:48:55 +00:00
|
|
|
{
|
|
|
|
new_exstyle &= ~WS_EX_TOOLWINDOW;
|
|
|
|
}
|
2008-10-05 00:00:10 +00:00
|
|
|
|
2006-02-09 02:58:45 +00:00
|
|
|
if (get_effective_window_decorations (window, &decorations))
|
|
|
|
{
|
|
|
|
all = (decorations & GDK_DECOR_ALL);
|
2020-09-15 07:37:32 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
/* Keep this in sync with the test in _gdk_win32_surface_lacks_wm_decorations() */
|
2008-05-23 18:25:12 +00:00
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER);
|
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME);
|
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_TITLE, WS_CAPTION);
|
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_MENU, WS_SYSMENU);
|
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_MINIMIZE, WS_MINIMIZEBOX);
|
|
|
|
update_single_bit (&new_style, all, decorations & GDK_DECOR_MAXIMIZE, WS_MAXIMIZEBOX);
|
2006-02-09 02:58:45 +00:00
|
|
|
}
|
2005-11-09 12:35:56 +00:00
|
|
|
|
2008-10-05 00:00:10 +00:00
|
|
|
if (old_style == new_style && old_exstyle == new_exstyle )
|
2008-05-23 18:25:12 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("_gdk_win32_surface_update_style_bits: %p: no change\n",
|
|
|
|
GDK_SURFACE_HWND (window)));
|
2008-05-23 18:25:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-05 00:00:10 +00:00
|
|
|
if (old_style != new_style)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("_gdk_win32_surface_update_style_bits: %p: STYLE: %s => %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_style_to_string (old_style),
|
|
|
|
_gdk_win32_surface_style_to_string (new_style)));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE, new_style);
|
2008-10-05 00:00:10 +00:00
|
|
|
}
|
2008-03-10 15:48:06 +00:00
|
|
|
|
2008-10-05 00:00:10 +00:00
|
|
|
if (old_exstyle != new_exstyle)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("_gdk_win32_surface_update_style_bits: %p: EXSTYLE: %s => %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_exstyle_to_string (old_exstyle),
|
|
|
|
_gdk_win32_surface_exstyle_to_string (new_exstyle)));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE, new_exstyle);
|
2021-09-04 12:12:54 +00:00
|
|
|
|
|
|
|
if (!was_layered && will_be_layered)
|
|
|
|
{
|
|
|
|
/* We have to call SetLayeredWindowAttributes when setting the
|
|
|
|
* WS_EX_LAYERED style anew, otherwise the window won't show up
|
|
|
|
*/
|
|
|
|
API_CALL (SetLayeredWindowAttributes, (GDK_SURFACE_HWND (window), 0, 255, LWA_ALPHA));
|
|
|
|
}
|
2008-10-05 00:00:10 +00:00
|
|
|
}
|
2005-11-09 12:35:56 +00:00
|
|
|
|
2008-10-05 00:00:10 +00:00
|
|
|
AdjustWindowRectEx (&after, new_style, FALSE, new_exstyle);
|
2005-11-09 12:35:56 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GetWindowRect (GDK_SURFACE_HWND (window), &rect);
|
2005-11-09 12:35:56 +00:00
|
|
|
rect.left += after.left - before.left;
|
|
|
|
rect.top += after.top - before.top;
|
|
|
|
rect.right += after.right - before.right;
|
|
|
|
rect.bottom += after.bottom - before.bottom;
|
|
|
|
|
2020-10-08 04:46:06 +00:00
|
|
|
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION;
|
2008-03-10 15:48:06 +00:00
|
|
|
|
2015-11-21 03:48:55 +00:00
|
|
|
if (will_be_topmost && !was_topmost)
|
|
|
|
{
|
|
|
|
insert_after = HWND_TOPMOST;
|
|
|
|
}
|
|
|
|
else if (was_topmost && !will_be_topmost)
|
|
|
|
{
|
|
|
|
insert_after = HWND_NOTOPMOST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= SWP_NOZORDER;
|
2015-11-21 03:58:22 +00:00
|
|
|
insert_after = SWP_NOZORDER_SPECIFIED;
|
2015-11-21 03:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowPos (GDK_SURFACE_HWND (window), insert_after,
|
2016-04-06 10:22:15 +00:00
|
|
|
rect.left, rect.top,
|
2015-11-21 03:48:55 +00:00
|
|
|
rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
flags);
|
2008-03-10 15:48:06 +00:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
2016-03-08 05:03:29 +00:00
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
log_region (char *prefix, AeroSnapEdgeRegion *region)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
|
|
|
GDK_NOTE (MISC, g_print ("Region %s:\n"
|
|
|
|
"edge %d x %d @ %d x %d\n"
|
|
|
|
"trig %d x %d @ %d x %d\n",
|
|
|
|
prefix,
|
|
|
|
region->edge.width,
|
|
|
|
region->edge.height,
|
|
|
|
region->edge.x,
|
|
|
|
region->edge.y,
|
|
|
|
region->trigger.width,
|
|
|
|
region->trigger.height,
|
|
|
|
region->trigger.x,
|
|
|
|
region->trigger.y));
|
|
|
|
}
|
2016-03-12 16:26:19 +00:00
|
|
|
#endif
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
2020-05-17 03:58:20 +00:00
|
|
|
GListModel *monitors;
|
2020-07-24 13:54:49 +00:00
|
|
|
int monitor_idx, other_monitor_idx;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (context->window);
|
2016-03-12 16:26:19 +00:00
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2016-03-12 16:26:19 +00:00
|
|
|
#endif
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2020-08-03 08:01:40 +00:00
|
|
|
display = gdk_surface_get_display (context->window);
|
2020-05-17 03:58:20 +00:00
|
|
|
monitors = gdk_display_get_monitors (display);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
#define _M_UP 0
|
|
|
|
#define _M_DOWN 1
|
|
|
|
#define _M_LEFT 2
|
|
|
|
#define _M_RIGHT 3
|
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
for (monitor_idx = 0; monitor_idx < g_list_model_get_n_items (monitors); monitor_idx++)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
|
|
|
GdkRectangle wa;
|
|
|
|
GdkRectangle geometry;
|
|
|
|
AeroSnapEdgeRegion snap_region;
|
|
|
|
gboolean move_edge[4] = { TRUE, FALSE, TRUE, TRUE };
|
|
|
|
gboolean resize_edge[2] = { TRUE, TRUE };
|
2020-07-24 13:54:49 +00:00
|
|
|
int diff;
|
|
|
|
int thickness, trigger_thickness;
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
monitor = g_list_model_get_item (monitors, monitor_idx);
|
2020-11-10 14:06:37 +00:00
|
|
|
g_object_unref (monitor);
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (monitor, &wa);
|
2016-10-21 05:40:49 +00:00
|
|
|
gdk_monitor_get_geometry (monitor, &geometry);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2016-10-21 05:40:49 +00:00
|
|
|
for (other_monitor_idx = 0;
|
2020-05-17 03:58:20 +00:00
|
|
|
other_monitor_idx < g_list_model_get_n_items (monitors) &&
|
2016-03-08 05:03:29 +00:00
|
|
|
(move_edge[_M_UP] || move_edge[_M_LEFT] ||
|
|
|
|
move_edge[_M_RIGHT] || resize_edge[_M_DOWN]);
|
2016-10-21 05:40:49 +00:00
|
|
|
other_monitor_idx++)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
|
|
|
GdkRectangle other_wa;
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *other_monitor;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2016-10-21 05:40:49 +00:00
|
|
|
if (other_monitor_idx == monitor_idx)
|
2016-03-08 05:03:29 +00:00
|
|
|
continue;
|
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
other_monitor = g_list_model_get_item (monitors, other_monitor_idx);
|
|
|
|
g_object_unref (other_monitor);
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (other_monitor, &other_wa);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
/* An edge triggers AeroSnap only if there are no
|
|
|
|
* monitors beyond that edge.
|
|
|
|
* Even if there's another monitor, but it does not cover
|
|
|
|
* the whole edge (it's smaller or is not aligned to
|
|
|
|
* the corner of current monitor), that edge is still
|
|
|
|
* removed from the trigger list.
|
|
|
|
*/
|
|
|
|
if (other_wa.x >= wa.x + wa.width)
|
|
|
|
move_edge[_M_RIGHT] = FALSE;
|
|
|
|
|
|
|
|
if (other_wa.x + other_wa.width <= wa.x)
|
|
|
|
move_edge[_M_LEFT] = FALSE;
|
|
|
|
|
|
|
|
if (other_wa.y + other_wa.height <= wa.y)
|
|
|
|
{
|
|
|
|
move_edge[_M_UP] = FALSE;
|
|
|
|
resize_edge[_M_UP] = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (other_wa.y >= wa.y + wa.height)
|
|
|
|
{
|
|
|
|
/* no move_edge for the bottom edge, just resize_edge */
|
|
|
|
resize_edge[_M_DOWN] = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
thickness = AEROSNAP_REGION_THICKNESS * impl->surface_scale;
|
|
|
|
trigger_thickness = AEROSNAP_REGION_TRIGGER_THICKNESS * impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
snap_region.edge = wa;
|
|
|
|
snap_region.trigger = wa;
|
|
|
|
snap_region.edge.height = thickness;
|
|
|
|
snap_region.trigger.height = trigger_thickness;
|
|
|
|
|
|
|
|
/* Extend both regions into toolbar space.
|
|
|
|
* When there's no toolbar, diff == 0.
|
|
|
|
*/
|
|
|
|
diff = wa.y - geometry.y;
|
|
|
|
snap_region.edge.height += diff;
|
|
|
|
snap_region.edge.y -= diff;
|
|
|
|
snap_region.trigger.height += diff;
|
|
|
|
snap_region.trigger.y -= diff;
|
|
|
|
|
|
|
|
if (move_edge[_M_UP])
|
|
|
|
g_array_append_val (context->maximize_regions, snap_region);
|
|
|
|
|
|
|
|
if (resize_edge[_M_UP])
|
|
|
|
g_array_append_val (context->fullup_regions, snap_region);
|
|
|
|
|
|
|
|
snap_region.edge = wa;
|
|
|
|
snap_region.trigger = wa;
|
|
|
|
snap_region.edge.width = thickness;
|
|
|
|
snap_region.trigger.width = trigger_thickness;
|
|
|
|
|
|
|
|
diff = wa.x - geometry.x;
|
|
|
|
snap_region.edge.width += diff;
|
|
|
|
snap_region.edge.x -= diff;
|
|
|
|
snap_region.trigger.width += diff;
|
|
|
|
snap_region.trigger.x -= diff;
|
|
|
|
|
|
|
|
if (move_edge[_M_LEFT])
|
|
|
|
g_array_append_val (context->halfleft_regions, snap_region);
|
|
|
|
|
|
|
|
snap_region.edge = wa;
|
|
|
|
snap_region.trigger = wa;
|
|
|
|
snap_region.edge.x += wa.width - thickness;
|
|
|
|
snap_region.edge.width = thickness;
|
|
|
|
snap_region.trigger.x += wa.width - trigger_thickness;
|
|
|
|
snap_region.trigger.width = trigger_thickness;
|
|
|
|
|
|
|
|
diff = (geometry.x + geometry.width) - (wa.x + wa.width);
|
|
|
|
snap_region.edge.width += diff;
|
|
|
|
snap_region.trigger.width += diff;
|
|
|
|
|
|
|
|
if (move_edge[_M_RIGHT])
|
|
|
|
g_array_append_val (context->halfright_regions, snap_region);
|
|
|
|
|
|
|
|
snap_region.edge = wa;
|
|
|
|
snap_region.trigger = wa;
|
|
|
|
snap_region.edge.y += wa.height - thickness;
|
|
|
|
snap_region.edge.height = thickness;
|
|
|
|
snap_region.trigger.y += wa.height - trigger_thickness;
|
|
|
|
snap_region.trigger.height = trigger_thickness;
|
|
|
|
|
|
|
|
diff = (geometry.y + geometry.height) - (wa.y + wa.height);
|
|
|
|
snap_region.edge.height += diff;
|
|
|
|
snap_region.trigger.height += diff;
|
|
|
|
|
|
|
|
if (resize_edge[_M_DOWN])
|
|
|
|
g_array_append_val (context->fullup_regions, snap_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef _M_UP
|
|
|
|
#undef _M_DOWN
|
|
|
|
#undef _M_LEFT
|
|
|
|
#undef _M_RIGHT
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
2016-03-08 05:03:29 +00:00
|
|
|
for (i = 0; i < context->maximize_regions->len; i++)
|
|
|
|
log_region ("maximize", &g_array_index (context->maximize_regions, AeroSnapEdgeRegion, i));
|
|
|
|
|
|
|
|
for (i = 0; i < context->halfleft_regions->len; i++)
|
|
|
|
log_region ("halfleft", &g_array_index (context->halfleft_regions, AeroSnapEdgeRegion, i));
|
|
|
|
|
|
|
|
for (i = 0; i < context->halfright_regions->len; i++)
|
|
|
|
log_region ("halfright", &g_array_index (context->halfright_regions, AeroSnapEdgeRegion, i));
|
|
|
|
|
|
|
|
for (i = 0; i < context->fullup_regions->len; i++)
|
|
|
|
log_region ("fullup", &g_array_index (context->fullup_regions, AeroSnapEdgeRegion, i));
|
2016-03-12 16:26:19 +00:00
|
|
|
#endif
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
discard_snapinfo (GdkSurface *window)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
|
|
|
|
if (impl->snap_stash == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_pointer (&impl->snap_stash, g_free);
|
|
|
|
g_clear_pointer (&impl->snap_stash_int, g_free);
|
|
|
|
}
|
|
|
|
|
2016-03-08 02:33:47 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
unsnap (GdkSurface *window,
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor)
|
2016-03-08 02:33:47 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 02:33:47 +00:00
|
|
|
GdkRectangle rect;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
|
|
|
|
if (impl->snap_stash == NULL)
|
|
|
|
return;
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (monitor, &rect);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Monitor work area %d x %d @ %d : %d\n", rect.width, rect.height, rect.x, rect.y));
|
|
|
|
|
2016-03-08 03:17:09 +00:00
|
|
|
if (rect.width >= impl->snap_stash_int->width &&
|
|
|
|
rect.height >= impl->snap_stash_int->height)
|
|
|
|
{
|
|
|
|
/* If the window fits into new work area without resizing it,
|
|
|
|
* place it into new work area without resizing it.
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
double left, right, up, down, hratio, vratio;
|
|
|
|
double hscale, vscale;
|
|
|
|
double new_left, new_up;
|
2016-03-08 03:17:09 +00:00
|
|
|
|
|
|
|
left = impl->snap_stash->x;
|
|
|
|
right = 1.0 - (impl->snap_stash->x + impl->snap_stash->width);
|
|
|
|
up = impl->snap_stash->y;
|
|
|
|
down = 1.0 - (impl->snap_stash->y + impl->snap_stash->height);
|
|
|
|
hscale = 1.0;
|
|
|
|
|
|
|
|
if (right > 0.001)
|
|
|
|
{
|
|
|
|
hratio = left / right;
|
|
|
|
hscale = hratio / (1.0 + hratio);
|
|
|
|
}
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
new_left = (double) (rect.width - impl->snap_stash_int->width) * hscale;
|
2016-03-08 03:17:09 +00:00
|
|
|
|
|
|
|
vscale = 1.0;
|
|
|
|
|
|
|
|
if (down > 0.001)
|
|
|
|
{
|
|
|
|
vratio = up / down;
|
|
|
|
vscale = vratio / (1.0 + vratio);
|
|
|
|
}
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
new_up = (double) (rect.height - impl->snap_stash_int->height) * vscale;
|
2016-03-08 03:17:09 +00:00
|
|
|
|
|
|
|
rect.x = round (rect.x + new_left);
|
|
|
|
rect.y = round (rect.y + new_up);
|
|
|
|
rect.width = impl->snap_stash_int->width;
|
|
|
|
rect.height = impl->snap_stash_int->height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Calculate actual unsnapped window size based on its
|
|
|
|
* old relative size. Same for position.
|
|
|
|
*/
|
|
|
|
rect.x += round (rect.width * impl->snap_stash->x);
|
|
|
|
rect.y += round (rect.height * impl->snap_stash->y);
|
|
|
|
rect.width = round (rect.width * impl->snap_stash->width);
|
|
|
|
rect.height = round (rect.height * impl->snap_stash->height);
|
|
|
|
}
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Unsnapped window size %d x %d @ %d : %d\n", rect.width, rect.height, rect.x, rect.y));
|
|
|
|
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_move_resize (window, rect.x, rect.y,
|
|
|
|
rect.width, rect.height);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
g_clear_pointer (&impl->snap_stash, g_free);
|
2016-03-08 03:17:09 +00:00
|
|
|
g_clear_pointer (&impl->snap_stash_int, g_free);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
stash_window (GdkSurface *window,
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl)
|
2016-03-08 02:33:47 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y;
|
|
|
|
int width, wwidth;
|
|
|
|
int height, wheight;
|
2016-03-08 02:33:47 +00:00
|
|
|
WINDOWPLACEMENT placement;
|
|
|
|
HMONITOR hmonitor;
|
|
|
|
MONITORINFO hmonitor_info;
|
|
|
|
|
|
|
|
placement.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
|
|
|
|
/* Use W32 API to get unmaximized window size, which GDK doesn't remember */
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GetWindowPlacement (GDK_SURFACE_HWND (window), &placement))
|
2016-03-08 02:33:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* MSDN is very vague, but in practice rcNormalPosition is the same as GetWindowRect(),
|
2020-05-28 08:00:03 +00:00
|
|
|
* only with adjustments for toolbars (which creates rather weird coordinate space issues).
|
2016-03-08 02:33:47 +00:00
|
|
|
* We need to get monitor info and apply workarea vs monitorarea diff to turn
|
|
|
|
* these into screen coordinates proper.
|
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
2016-03-08 02:33:47 +00:00
|
|
|
hmonitor_info.cbSize = sizeof (hmonitor_info);
|
|
|
|
|
|
|
|
if (!GetMonitorInfoA (hmonitor, &hmonitor_info))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (impl->snap_stash == NULL)
|
|
|
|
impl->snap_stash = g_new0 (GdkRectangleDouble, 1);
|
|
|
|
|
2016-03-08 03:17:09 +00:00
|
|
|
if (impl->snap_stash_int == NULL)
|
|
|
|
impl->snap_stash_int = g_new0 (GdkRectangle, 1);
|
|
|
|
|
2016-03-08 02:33:47 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("monitor work area %ld x %ld @ %ld : %ld\n",
|
2018-03-20 11:05:26 +00:00
|
|
|
(hmonitor_info.rcWork.right - hmonitor_info.rcWork.left) / impl->surface_scale,
|
|
|
|
(hmonitor_info.rcWork.bottom - hmonitor_info.rcWork.top) / impl->surface_scale,
|
2016-03-08 02:33:47 +00:00
|
|
|
hmonitor_info.rcWork.left,
|
|
|
|
hmonitor_info.rcWork.top));
|
|
|
|
GDK_NOTE (MISC, g_print ("monitor area %ld x %ld @ %ld : %ld\n",
|
2018-03-20 11:05:26 +00:00
|
|
|
(hmonitor_info.rcMonitor.right - hmonitor_info.rcMonitor.left) / impl->surface_scale,
|
|
|
|
(hmonitor_info.rcMonitor.bottom - hmonitor_info.rcMonitor.top) / impl->surface_scale,
|
2016-03-08 02:33:47 +00:00
|
|
|
hmonitor_info.rcMonitor.left,
|
|
|
|
hmonitor_info.rcMonitor.top));
|
|
|
|
GDK_NOTE (MISC, g_print ("window work place %ld x %ld @ %ld : %ld\n",
|
2018-03-20 11:05:26 +00:00
|
|
|
(placement.rcNormalPosition.right - placement.rcNormalPosition.left) / impl->surface_scale,
|
|
|
|
(placement.rcNormalPosition.bottom - placement.rcNormalPosition.top) / impl->surface_scale,
|
2016-03-08 02:33:47 +00:00
|
|
|
placement.rcNormalPosition.left,
|
|
|
|
placement.rcNormalPosition.top));
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
width = (placement.rcNormalPosition.right - placement.rcNormalPosition.left) / impl->surface_scale;
|
|
|
|
height = (placement.rcNormalPosition.bottom - placement.rcNormalPosition.top) / impl->surface_scale;
|
|
|
|
x = (placement.rcNormalPosition.left - hmonitor_info.rcMonitor.left) / impl->surface_scale;
|
|
|
|
y = (placement.rcNormalPosition.top - hmonitor_info.rcMonitor.top) / impl->surface_scale;
|
2017-08-08 14:19:45 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
wwidth = (hmonitor_info.rcWork.right - hmonitor_info.rcWork.left) / impl->surface_scale;
|
|
|
|
wheight = (hmonitor_info.rcWork.bottom - hmonitor_info.rcWork.top) / impl->surface_scale;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
impl->snap_stash->x = (double) (x) / (double) (wwidth);
|
|
|
|
impl->snap_stash->y = (double) (y) / (double) (wheight);
|
|
|
|
impl->snap_stash->width = (double) width / (double) (wwidth);
|
|
|
|
impl->snap_stash->height = (double) height / (double) (wheight);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2017-08-08 14:19:45 +00:00
|
|
|
impl->snap_stash_int->x = x;
|
|
|
|
impl->snap_stash_int->y = y;
|
|
|
|
impl->snap_stash_int->width = width;
|
|
|
|
impl->snap_stash_int->height = height;
|
2016-03-08 03:17:09 +00:00
|
|
|
|
2016-03-08 02:33:47 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("Stashed window %d x %d @ %d : %d as %f x %f @ %f : %f\n",
|
|
|
|
width, height, x, y,
|
|
|
|
impl->snap_stash->width, impl->snap_stash->height, impl->snap_stash->x, impl->snap_stash->y));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-07-06 09:15:39 +00:00
|
|
|
snap_up (GdkSurface *surface)
|
2016-03-08 02:33:47 +00:00
|
|
|
{
|
|
|
|
SHORT maxysize;
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y;
|
|
|
|
int width, height;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (surface);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_FULLUP;
|
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
stash_window (surface, impl);
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale;
|
2020-03-12 11:01:30 +00:00
|
|
|
x = y = 0;
|
2021-07-06 09:15:39 +00:00
|
|
|
width = gdk_surface_get_width (surface);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2016-03-15 10:17:45 +00:00
|
|
|
y = 0;
|
|
|
|
height = maxysize;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
x = surface->x - impl->shadow.left / impl->surface_scale;
|
|
|
|
y = y - impl->shadow.top / impl->surface_scale;
|
2020-12-31 09:27:40 +00:00
|
|
|
width += impl->shadow_x;
|
|
|
|
height += impl->shadow_y;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
gdk_win32_surface_move_resize (surface, x, y, width, height);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-07-06 09:15:39 +00:00
|
|
|
snap_left (GdkSurface *surface,
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor,
|
|
|
|
GdkMonitor *snap_monitor)
|
2016-03-08 02:33:47 +00:00
|
|
|
{
|
|
|
|
GdkRectangle rect;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (surface);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
stash_window (surface, impl);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2017-08-08 14:19:45 +00:00
|
|
|
rect.width = rect.width / 2;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
|
|
|
|
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
|
2020-12-31 09:27:40 +00:00
|
|
|
rect.width = rect.width + impl->shadow_x;
|
|
|
|
rect.height = rect.height + impl->shadow_y;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
gdk_win32_surface_move_resize (surface,
|
2019-07-15 13:47:12 +00:00
|
|
|
rect.x, rect.y,
|
|
|
|
rect.width, rect.height);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-07-06 09:15:39 +00:00
|
|
|
snap_right (GdkSurface *surface,
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor,
|
|
|
|
GdkMonitor *snap_monitor)
|
2016-03-08 02:33:47 +00:00
|
|
|
{
|
|
|
|
GdkRectangle rect;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (surface);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
|
|
|
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
stash_window (surface, impl);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2017-08-08 14:19:45 +00:00
|
|
|
rect.width = rect.width / 2;
|
2016-03-08 02:33:47 +00:00
|
|
|
rect.x += rect.width;
|
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
|
|
|
|
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
|
2020-12-31 09:27:40 +00:00
|
|
|
rect.width = rect.width + impl->shadow_x;
|
|
|
|
rect.height = rect.height + impl->shadow_y;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2021-07-06 09:15:39 +00:00
|
|
|
gdk_win32_surface_move_resize (surface,
|
2019-07-15 13:47:12 +00:00
|
|
|
rect.x, rect.y,
|
|
|
|
rect.width, rect.height);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:01:30 +00:00
|
|
|
static void
|
|
|
|
gdk_win32_surface_maximize (GdkSurface *window);
|
|
|
|
static void
|
|
|
|
gdk_win32_surface_unmaximize (GdkSurface *window);
|
|
|
|
static void
|
|
|
|
gdk_win32_surface_minimize (GdkSurface *window);
|
|
|
|
|
2016-03-08 02:33:47 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
2016-03-08 02:33:47 +00:00
|
|
|
GdkWin32AeroSnapCombo combo)
|
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 02:33:47 +00:00
|
|
|
GdkDisplay *display;
|
2020-05-17 03:58:20 +00:00
|
|
|
GListModel *monitors;
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_monitors;
|
2020-09-10 04:39:03 +00:00
|
|
|
GdkToplevelState surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (window));
|
|
|
|
gboolean minimized = surface_state & GDK_TOPLEVEL_STATE_MINIMIZED;
|
|
|
|
gboolean maximized = surface_state & GDK_TOPLEVEL_STATE_MAXIMIZED;
|
2016-03-08 02:33:47 +00:00
|
|
|
gboolean halfsnapped;
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor;
|
2016-03-08 02:33:47 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2018-03-20 10:40:08 +00:00
|
|
|
display = gdk_surface_get_display (window);
|
2020-05-17 03:58:20 +00:00
|
|
|
monitors = gdk_display_get_monitors (display);
|
|
|
|
n_monitors = g_list_model_get_n_items (monitors);
|
2018-03-20 11:05:26 +00:00
|
|
|
monitor = gdk_display_get_monitor_at_surface (display, window);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
if (minimized && maximized)
|
|
|
|
minimized = FALSE;
|
|
|
|
|
|
|
|
halfsnapped = (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP);
|
|
|
|
|
|
|
|
switch (combo)
|
|
|
|
{
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_NOTHING:
|
|
|
|
/* Do nothing */
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_UP:
|
|
|
|
if (!maximized)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_maximize (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_DOWN:
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_SHIFTDOWN:
|
|
|
|
if (maximized)
|
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_unmaximize (window);
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
else if (halfsnapped)
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
else if (!minimized)
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_minimize (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_LEFT:
|
|
|
|
if (maximized)
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_unmaximize (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_UNDETERMINED ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
|
|
|
snap_left (window, monitor, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT)
|
|
|
|
{
|
2020-05-17 03:58:20 +00:00
|
|
|
GdkMonitor *other;
|
|
|
|
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2020-05-17 03:58:20 +00:00
|
|
|
if (gdk_win32_display_get_primary_monitor (monitor->display) == monitor)
|
|
|
|
other = g_object_ref (monitor);
|
|
|
|
else
|
|
|
|
other = g_list_model_get_item (monitors, n_monitors - 1);
|
|
|
|
snap_right (window, monitor, other);
|
|
|
|
g_object_unref (other);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_RIGHT:
|
|
|
|
if (maximized)
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_unmaximize (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
|
|
|
|
if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_UNDETERMINED ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
|
|
|
snap_right (window, monitor, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT)
|
|
|
|
{
|
2020-05-17 03:58:20 +00:00
|
|
|
GdkMonitor *other;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2016-10-21 05:40:49 +00:00
|
|
|
|
|
|
|
unsnap (window, monitor);
|
2020-05-17 03:58:20 +00:00
|
|
|
for (i = 0; i < n_monitors; i++)
|
|
|
|
{
|
|
|
|
other = g_list_model_get_item (monitors, i);
|
|
|
|
g_object_unref (other);
|
|
|
|
if (monitor == other)
|
|
|
|
break;
|
|
|
|
}
|
2016-10-21 05:40:49 +00:00
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
other = g_list_model_get_item (monitors, (i + 1) % n_monitors);
|
|
|
|
snap_left (window, monitor, other);
|
|
|
|
g_object_unref (other);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_SHIFTUP:
|
|
|
|
if (!maximized &&
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_UNDETERMINED)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
snap_up (window);
|
2016-03-08 02:33:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT:
|
|
|
|
case GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT:
|
|
|
|
/* No implementation needed at the moment */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
apply_snap (GdkSurface *window,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkWin32AeroSnapState snap)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkDisplay *display;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
display = gdk_surface_get_display (window);
|
2018-03-20 11:05:26 +00:00
|
|
|
monitor = gdk_display_get_monitor_at_surface (display, window);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
switch (snap)
|
|
|
|
{
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_UNDETERMINED:
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_MAXIMIZE:
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_maximize (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFLEFT:
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
|
|
|
snap_left (window, monitor, monitor);
|
2016-03-08 05:03:29 +00:00
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFRIGHT:
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
|
|
|
snap_right (window, monitor, monitor);
|
2016-03-08 05:03:29 +00:00
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
|
2016-10-21 05:40:49 +00:00
|
|
|
snap_up (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-15 16:10:34 +00:00
|
|
|
/* Registers a dumb window class. This window
|
|
|
|
* has DefWindowProc() for a window procedure and
|
2018-03-20 10:40:08 +00:00
|
|
|
* does not do anything that GdkSurface-bound HWNDs do.
|
2016-03-15 16:10:34 +00:00
|
|
|
*/
|
|
|
|
static ATOM
|
|
|
|
RegisterGdkDumbClass ()
|
|
|
|
{
|
|
|
|
static ATOM klassDUMB = 0;
|
|
|
|
static WNDCLASSEXW wcl;
|
|
|
|
ATOM klass = 0;
|
|
|
|
|
|
|
|
wcl.cbSize = sizeof (WNDCLASSEX);
|
|
|
|
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
|
|
|
|
* on WM_SIZE and WM_MOVE. Flicker, Performance!
|
|
|
|
*/
|
|
|
|
wcl.lpfnWndProc = DefWindowProcW;
|
|
|
|
wcl.cbClsExtra = 0;
|
|
|
|
wcl.cbWndExtra = 0;
|
2018-06-16 18:24:56 +00:00
|
|
|
wcl.hInstance = _gdk_dll_hinstance;
|
2016-03-15 16:10:34 +00:00
|
|
|
wcl.hIcon = 0;
|
|
|
|
wcl.hIconSm = 0;
|
|
|
|
wcl.lpszMenuName = NULL;
|
|
|
|
wcl.hbrBackground = NULL;
|
|
|
|
wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
|
|
wcl.style |= CS_OWNDC;
|
2018-03-21 10:49:14 +00:00
|
|
|
wcl.lpszClassName = L"gdkSurfaceDumb";
|
2016-03-15 16:10:34 +00:00
|
|
|
|
|
|
|
if (klassDUMB == 0)
|
|
|
|
klassDUMB = RegisterClassExW (&wcl);
|
|
|
|
|
|
|
|
klass = klassDUMB;
|
|
|
|
|
|
|
|
if (klass == 0)
|
|
|
|
{
|
|
|
|
WIN32_API_FAILED ("RegisterClassExW");
|
|
|
|
g_error ("That is a fatal error");
|
|
|
|
}
|
|
|
|
|
|
|
|
return klass;
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
static gboolean
|
|
|
|
ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
|
|
|
|
{
|
|
|
|
if (context->shape_indicator == NULL)
|
|
|
|
{
|
|
|
|
HWND handle;
|
|
|
|
ATOM klass;
|
2016-03-15 16:10:34 +00:00
|
|
|
klass = RegisterGdkDumbClass ();
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
handle = CreateWindowExW (WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE,
|
|
|
|
MAKEINTRESOURCEW (klass),
|
|
|
|
L"",
|
|
|
|
WS_POPUP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0, 0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2018-06-16 18:24:56 +00:00
|
|
|
_gdk_dll_hinstance,
|
2016-03-12 16:26:19 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
context->shape_indicator = handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
return context->shape_indicator != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ensure_snap_indicator_surface (GdkW32DragMoveResizeContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
int width,
|
|
|
|
int height,
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
guint scale)
|
2016-03-12 16:26:19 +00:00
|
|
|
{
|
|
|
|
if (context->indicator_surface != NULL &&
|
|
|
|
(context->indicator_surface_width < width ||
|
|
|
|
context->indicator_surface_height < height))
|
|
|
|
{
|
|
|
|
cairo_surface_destroy (context->indicator_surface);
|
|
|
|
context->indicator_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->indicator_surface == NULL)
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
context->indicator_surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32,
|
|
|
|
width * scale,
|
|
|
|
height * scale);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
if (cairo_surface_status (context->indicator_surface) != CAIRO_STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
cairo_surface_destroy (context->indicator_surface);
|
|
|
|
context->indicator_surface = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Indicator is drawn with some inward offset, so that it does
|
|
|
|
* not hug screen edges.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
adjust_indicator_rectangle (GdkRectangle *rect,
|
2017-08-08 14:19:45 +00:00
|
|
|
gboolean inward)
|
2016-03-12 16:26:19 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double inverter;
|
2020-07-24 13:54:49 +00:00
|
|
|
const int gap = AEROSNAP_INDICATOR_EDGE_GAP;
|
2016-03-12 16:26:19 +00:00
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
|
|
|
GdkRectangle cache = *rect;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (inward)
|
|
|
|
inverter = 1.0;
|
|
|
|
else
|
|
|
|
inverter = -1.0;
|
|
|
|
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
rect->x += (gap * inverter);
|
|
|
|
rect->y += (gap * inverter);
|
2017-08-08 14:19:45 +00:00
|
|
|
rect->width -= (gap * 2 * inverter);
|
|
|
|
rect->height -= (gap * 2 * inverter);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
|
|
|
GDK_NOTE (MISC, g_print ("Adjusted %d x %d @ %d : %d -> %d x %d @ %d : %d\n",
|
|
|
|
cache.width, cache.height, cache.x, cache.y,
|
|
|
|
rect->width, rect->height, rect->x, rect->y));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rounded_rectangle (cairo_t *cr,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height,
|
2020-07-24 20:32:16 +00:00
|
|
|
double radius,
|
|
|
|
double line_width,
|
2016-03-12 16:26:19 +00:00
|
|
|
GdkRGBA *fill,
|
2017-08-08 14:19:45 +00:00
|
|
|
GdkRGBA *outline)
|
2016-03-12 16:26:19 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double degrees = M_PI / 180.0;
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
if (fill == NULL && outline == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_new_sub_path (cr);
|
2017-08-08 14:19:45 +00:00
|
|
|
cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
|
|
|
|
cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
|
|
|
|
cairo_arc (cr, (x + radius), y + height - radius, radius, 90 * degrees, 180 * degrees);
|
|
|
|
cairo_arc (cr, (x + radius), (y + radius), radius, 180 * degrees, 270 * degrees);
|
2016-03-12 16:26:19 +00:00
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
if (fill)
|
|
|
|
{
|
|
|
|
cairo_set_source_rgba (cr, fill->red, fill->green, fill->blue, fill->alpha);
|
|
|
|
|
|
|
|
if (outline)
|
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
else
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outline)
|
|
|
|
{
|
|
|
|
cairo_set_source_rgba (cr, outline->red, outline->green, outline->blue, outline->alpha);
|
|
|
|
cairo_set_line_width (cr, line_width);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translates linear animation scale into some kind of curve */
|
2020-07-24 20:32:16 +00:00
|
|
|
static double
|
|
|
|
curve (double val)
|
2016-03-12 16:26:19 +00:00
|
|
|
{
|
|
|
|
/* TODO: try different curves. For now it's just linear */
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
draw_indicator (GdkW32DragMoveResizeContext *context,
|
|
|
|
gint64 timestamp)
|
|
|
|
{
|
|
|
|
cairo_t *cr;
|
|
|
|
GdkRGBA outline = {0, 0, 1.0, 1.0};
|
|
|
|
GdkRGBA fill = {0, 0, 1.0, 0.8};
|
|
|
|
GdkRectangle current_rect;
|
|
|
|
gint64 current_time = g_get_monotonic_time ();
|
2020-07-24 20:32:16 +00:00
|
|
|
double animation_progress;
|
2016-03-12 16:26:19 +00:00
|
|
|
gboolean last_draw;
|
2020-07-24 20:32:16 +00:00
|
|
|
double line_width;
|
|
|
|
double corner_radius;
|
2016-03-12 16:26:19 +00:00
|
|
|
gint64 animation_duration;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (context->window);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
line_width = AEROSNAP_INDICATOR_LINE_WIDTH * impl->surface_scale;
|
2016-03-12 16:26:19 +00:00
|
|
|
corner_radius = AEROSNAP_INDICATOR_CORNER_RADIUS;
|
|
|
|
animation_duration = AEROSNAP_INDICATOR_ANIMATION_DURATION;
|
|
|
|
last_draw = FALSE;
|
|
|
|
|
|
|
|
if (timestamp == 0 &&
|
|
|
|
current_time - context->indicator_start_time > animation_duration)
|
|
|
|
{
|
|
|
|
timestamp = context->indicator_start_time + animation_duration;
|
|
|
|
last_draw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timestamp != 0)
|
|
|
|
current_time = timestamp;
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
animation_progress = (double) (current_time - context->indicator_start_time) / animation_duration;
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
if (animation_progress > 1.0)
|
|
|
|
animation_progress = 1.0;
|
|
|
|
|
|
|
|
if (animation_progress < 0)
|
|
|
|
animation_progress = 0;
|
|
|
|
|
|
|
|
animation_progress = curve (animation_progress);
|
|
|
|
|
|
|
|
current_rect = context->indicator_start;
|
|
|
|
current_rect.x += (context->indicator_target.x - context->indicator_start.x) * animation_progress;
|
|
|
|
current_rect.y += (context->indicator_target.y - context->indicator_start.y) * animation_progress;
|
|
|
|
current_rect.width += (context->indicator_target.width - context->indicator_start.width) * animation_progress;
|
|
|
|
current_rect.height += (context->indicator_target.height - context->indicator_start.height) * animation_progress;
|
|
|
|
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE && last_draw)
|
|
|
|
{
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x + (context->indicator_target.width - current_rect.width);
|
|
|
|
current_rect.y = context->indicator_target.y + (context->indicator_target.height - current_rect.height);
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.y = context->indicator_target.y + (context->indicator_target.height - current_rect.height);
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x + (context->indicator_target.width - current_rect.width);
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x + (context->indicator_target.width - current_rect.width);
|
|
|
|
current_rect.y = context->indicator_target.y;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x;
|
|
|
|
current_rect.y = context->indicator_target.y + (context->indicator_target.height - current_rect.height);
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x;
|
|
|
|
current_rect.y = context->indicator_target.y;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.y = context->indicator_target.y;
|
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
2016-03-12 16:26:19 +00:00
|
|
|
current_rect.x = context->indicator_target.x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cr = cairo_create (context->indicator_surface);
|
|
|
|
rounded_rectangle (cr,
|
2018-03-20 11:05:26 +00:00
|
|
|
(current_rect.x - context->indicator_window_rect.x) * impl->surface_scale,
|
|
|
|
(current_rect.y - context->indicator_window_rect.y) * impl->surface_scale,
|
|
|
|
current_rect.width * impl->surface_scale,
|
|
|
|
current_rect.height * impl->surface_scale,
|
2016-03-12 16:26:19 +00:00
|
|
|
corner_radius,
|
|
|
|
line_width,
|
2017-08-08 14:19:45 +00:00
|
|
|
&fill, &outline);
|
2016-03-12 16:26:19 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
|
|
|
GDK_NOTE (MISC, g_print ("Indicator is %d x %d @ %d : %d; current time is %" G_GINT64_FORMAT "\n",
|
|
|
|
current_rect.width, current_rect.height,
|
|
|
|
current_rect.x - context->indicator_window_rect.x,
|
|
|
|
current_rect.y - context->indicator_window_rect.y,
|
|
|
|
current_time));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return last_draw;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
redraw_indicator (gpointer user_data)
|
|
|
|
{
|
|
|
|
GdkW32DragMoveResizeContext *context = user_data;
|
|
|
|
POINT window_position;
|
|
|
|
SIZE window_size;
|
|
|
|
BLENDFUNCTION blender;
|
|
|
|
HDC hdc;
|
|
|
|
POINT source_point = { 0, 0 };
|
|
|
|
gboolean last_draw;
|
2020-07-24 20:32:16 +00:00
|
|
|
double indicator_opacity;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
gboolean do_source_remove = FALSE;
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
indicator_opacity = AEROSNAP_INDICATOR_OPACITY;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (context->window) ||
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
!ensure_snap_indicator_exists (context))
|
|
|
|
{
|
|
|
|
do_source_remove = TRUE;
|
|
|
|
}
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (context->window);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
|
|
|
if (!ensure_snap_indicator_surface (context,
|
|
|
|
context->indicator_window_rect.width,
|
|
|
|
context->indicator_window_rect.height,
|
2018-03-20 11:05:26 +00:00
|
|
|
impl->surface_scale))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
{
|
|
|
|
do_source_remove = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_source_remove)
|
2016-03-12 16:26:19 +00:00
|
|
|
{
|
|
|
|
context->timer = 0;
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_draw = draw_indicator (context, context->draw_timestamp);
|
|
|
|
|
2021-10-29 16:39:52 +00:00
|
|
|
window_position.x = context->indicator_window_rect.x * impl->surface_scale;
|
|
|
|
window_position.y = context->indicator_window_rect.y * impl->surface_scale;
|
2018-03-20 11:05:26 +00:00
|
|
|
window_size.cx = context->indicator_window_rect.width * impl->surface_scale;
|
|
|
|
window_size.cy = context->indicator_window_rect.height * impl->surface_scale;
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
blender.BlendOp = AC_SRC_OVER;
|
|
|
|
blender.BlendFlags = 0;
|
|
|
|
blender.AlphaFormat = AC_SRC_ALPHA;
|
|
|
|
blender.SourceConstantAlpha = 255 * indicator_opacity;
|
|
|
|
|
|
|
|
hdc = cairo_win32_surface_get_dc (context->indicator_surface);
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (context->shape_indicator,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_HWND (context->window),
|
2016-03-12 16:26:19 +00:00
|
|
|
0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_SHOWWINDOW | SWP_NOACTIVATE));
|
|
|
|
|
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
|
|
|
GDK_NOTE (MISC, g_print ("Indicator window position is %ld x %ld @ %ld : %ld\n",
|
|
|
|
window_size.cx, window_size.cy,
|
|
|
|
window_position.x, window_position.y));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
API_CALL (UpdateLayeredWindow, (context->shape_indicator, NULL,
|
|
|
|
&window_position, &window_size,
|
|
|
|
hdc, &source_point,
|
|
|
|
0, &blender, ULW_ALPHA));
|
|
|
|
|
|
|
|
if (last_draw)
|
|
|
|
context->timer = 0;
|
|
|
|
|
|
|
|
return last_draw ? G_SOURCE_REMOVE : G_SOURCE_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkRectangle
|
|
|
|
unity_of_rects (GdkRectangle a,
|
|
|
|
GdkRectangle b)
|
|
|
|
{
|
|
|
|
GdkRectangle u = b;
|
|
|
|
|
|
|
|
if (a.x < u.x)
|
|
|
|
{
|
|
|
|
u.width += u.x - a.x;
|
|
|
|
u.x = a.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a.y < u.y)
|
|
|
|
{
|
|
|
|
u.height += (u.y - a.y);
|
|
|
|
u.y = a.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a.x + a.width > u.x + u.width)
|
|
|
|
u.width += (a.x + a.width) - (u.x + u.width);
|
|
|
|
|
|
|
|
if (a.y + a.height > u.y + u.height)
|
|
|
|
u.height += (a.y + a.height) - (u.y + u.height);
|
|
|
|
|
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
|
|
|
GDK_NOTE (MISC, g_print ("Unified 2 rects into %d x %d @ %d : %d\n",
|
|
|
|
u.width, u.height, u.x, u.y));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return u;
|
|
|
|
}
|
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
static void
|
|
|
|
start_indicator_drawing (GdkW32DragMoveResizeContext *context,
|
|
|
|
GdkRectangle from,
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GdkRectangle to,
|
|
|
|
guint scale)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2016-03-12 16:26:19 +00:00
|
|
|
GdkRectangle to_adjusted, from_adjusted, from_or_to;
|
|
|
|
gint64 indicator_animation_tick = AEROSNAP_INDICATOR_ANIMATION_TICK;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Start drawing snap indicator %d x %d @ %d : %d -> %d x %d @ %d : %d\n",
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
from.width * scale, from.height * scale, from.x, from.y, to.width * scale, to.height * scale, to.x, to.y));
|
2016-03-12 16:26:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (context->window))
|
2016-03-12 16:26:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!ensure_snap_indicator_exists (context))
|
|
|
|
return;
|
|
|
|
|
|
|
|
from_or_to = unity_of_rects (from, to);
|
|
|
|
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
if (!ensure_snap_indicator_surface (context, from_or_to.width, from_or_to.height, scale))
|
2016-03-12 16:26:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
to_adjusted = to;
|
2017-08-08 14:19:45 +00:00
|
|
|
adjust_indicator_rectangle (&to_adjusted, TRUE);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
from_adjusted = from;
|
2017-08-08 14:19:45 +00:00
|
|
|
adjust_indicator_rectangle (&from_adjusted, TRUE);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
context->draw_timestamp = 0;
|
|
|
|
context->indicator_start = from_adjusted;
|
|
|
|
context->indicator_target = to_adjusted;
|
|
|
|
context->indicator_window_rect = from_or_to;
|
|
|
|
context->indicator_start_time = g_get_monotonic_time ();
|
|
|
|
|
|
|
|
if (context->timer)
|
|
|
|
{
|
|
|
|
g_source_remove (context->timer);
|
|
|
|
context->timer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->timer = g_timeout_add_full (G_PRIORITY_DEFAULT,
|
|
|
|
indicator_animation_tick,
|
|
|
|
redraw_indicator,
|
|
|
|
context,
|
|
|
|
NULL);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
update_fullup_indicator (GdkSurface *window,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkW32DragMoveResizeContext *context)
|
|
|
|
{
|
2016-03-12 16:26:19 +00:00
|
|
|
SHORT maxysize;
|
|
|
|
GdkRectangle from, to;
|
|
|
|
GdkRectangle to_adjusted, from_adjusted, from_or_to;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Update fullup indicator\n"));
|
2016-03-12 16:26:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (context->window))
|
2016-03-12 16:26:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->shape_indicator == NULL)
|
|
|
|
return;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-03-12 16:26:19 +00:00
|
|
|
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN);
|
2020-03-12 11:01:30 +00:00
|
|
|
to.x = to.y = 0;
|
2018-03-20 10:40:08 +00:00
|
|
|
to.width = gdk_surface_get_width (window);
|
|
|
|
to.height = gdk_surface_get_height (window);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
to.y = 0;
|
2021-07-06 09:15:39 +00:00
|
|
|
to.x = window->x;
|
2016-03-12 16:26:19 +00:00
|
|
|
to.height = maxysize;
|
|
|
|
from = context->indicator_target;
|
|
|
|
|
|
|
|
if (context->timer == 0)
|
|
|
|
{
|
|
|
|
from_adjusted = from;
|
2017-08-08 14:19:45 +00:00
|
|
|
adjust_indicator_rectangle (&from_adjusted, FALSE);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Restart fullup animation from %d x %d @ %d : %d -> %d x %d @ %d x %d\n",
|
|
|
|
context->indicator_target.width, context->indicator_target.height,
|
|
|
|
context->indicator_target.x, context->indicator_target.y,
|
|
|
|
to.width, to.height, to.x, to.y));
|
2018-03-20 11:05:26 +00:00
|
|
|
start_indicator_drawing (context, from_adjusted, to, impl->surface_scale);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
from_or_to = unity_of_rects (from, to);
|
|
|
|
|
|
|
|
to_adjusted = to;
|
2017-08-08 14:19:45 +00:00
|
|
|
adjust_indicator_rectangle (&to_adjusted, TRUE);
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Retarget fullup animation %d x %d @ %d : %d -> %d x %d @ %d x %d\n",
|
|
|
|
context->indicator_target.width, context->indicator_target.height,
|
|
|
|
context->indicator_target.x, context->indicator_target.y,
|
|
|
|
to_adjusted.width, to_adjusted.height, to_adjusted.x, to_adjusted.y));
|
|
|
|
|
|
|
|
context->indicator_target = to_adjusted;
|
|
|
|
context->indicator_window_rect = from_or_to;
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
ensure_snap_indicator_surface (context, from_or_to.width, from_or_to.height, impl->surface_scale);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
2019-05-29 17:31:37 +00:00
|
|
|
static GdkMonitor *
|
|
|
|
get_monitor_at_point (GdkDisplay *display,
|
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2020-05-17 03:58:20 +00:00
|
|
|
GListModel *monitors;
|
2019-05-29 17:31:37 +00:00
|
|
|
GdkMonitor *nearest = NULL;
|
|
|
|
int nearest_dist = G_MAXINT;
|
2020-05-17 03:58:20 +00:00
|
|
|
guint i;
|
2019-05-29 17:31:37 +00:00
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
monitors = gdk_display_get_monitors (display);
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
2019-05-29 17:31:37 +00:00
|
|
|
{
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkRectangle geometry;
|
|
|
|
int dist_x, dist_y, dist;
|
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
monitor = g_list_model_get_item (monitors, i);
|
2019-05-29 17:31:37 +00:00
|
|
|
gdk_monitor_get_geometry (monitor, &geometry);
|
|
|
|
|
|
|
|
if (x < geometry.x)
|
|
|
|
dist_x = geometry.x - x;
|
|
|
|
else if (geometry.x + geometry.width <= x)
|
|
|
|
dist_x = x - (geometry.x + geometry.width) + 1;
|
|
|
|
else
|
|
|
|
dist_x = 0;
|
|
|
|
|
|
|
|
if (y < geometry.y)
|
|
|
|
dist_y = geometry.y - y;
|
|
|
|
else if (geometry.y + geometry.height <= y)
|
|
|
|
dist_y = y - (geometry.y + geometry.height) + 1;
|
|
|
|
else
|
|
|
|
dist_y = 0;
|
|
|
|
|
|
|
|
dist = dist_x + dist_y;
|
|
|
|
if (dist < nearest_dist)
|
|
|
|
{
|
|
|
|
nearest_dist = dist;
|
|
|
|
nearest = monitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x < geometry.x)
|
|
|
|
dist_x = geometry.x - x;
|
|
|
|
else if (geometry.x + geometry.width <= x)
|
|
|
|
dist_x = x - (geometry.x + geometry.width) + 1;
|
|
|
|
else
|
|
|
|
dist_x = 0;
|
|
|
|
|
|
|
|
if (y < geometry.y)
|
|
|
|
dist_y = geometry.y - y;
|
|
|
|
else if (geometry.y + geometry.height <= y)
|
|
|
|
dist_y = y - (geometry.y + geometry.height) + 1;
|
|
|
|
else
|
|
|
|
dist_y = 0;
|
|
|
|
|
|
|
|
dist = dist_x + dist_y;
|
|
|
|
if (dist < nearest_dist)
|
|
|
|
{
|
|
|
|
nearest_dist = dist;
|
|
|
|
nearest = monitor;
|
|
|
|
}
|
|
|
|
|
2020-05-17 03:58:20 +00:00
|
|
|
g_object_unref (monitor);
|
|
|
|
|
2019-05-29 17:31:37 +00:00
|
|
|
if (nearest_dist == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nearest;
|
|
|
|
}
|
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
start_indicator (GdkSurface *window,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkW32DragMoveResizeContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkWin32AeroSnapState state)
|
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor;
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkRectangle workarea;
|
|
|
|
SHORT maxysize;
|
|
|
|
GdkRectangle start_size, end_size;
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkDisplay *display;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
display = gdk_surface_get_display (window);
|
2019-05-29 17:31:37 +00:00
|
|
|
monitor = get_monitor_at_point (display, x, y);
|
2020-07-29 13:47:48 +00:00
|
|
|
gdk_win32_monitor_get_workarea (monitor, &workarea);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale;
|
2020-03-12 11:01:30 +00:00
|
|
|
start_size.x = start_size.y = 0;
|
2018-03-20 10:40:08 +00:00
|
|
|
start_size.width = gdk_surface_get_width (window);
|
|
|
|
start_size.height = gdk_surface_get_height (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
end_size = start_size;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_UNDETERMINED:
|
|
|
|
return;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_MAXIMIZE:
|
|
|
|
end_size.x = workarea.x;
|
|
|
|
end_size.y = workarea.y;
|
|
|
|
end_size.width = workarea.width;
|
|
|
|
end_size.height = workarea.height;
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFLEFT:
|
|
|
|
end_size.x = workarea.x;
|
|
|
|
end_size.y = workarea.y;
|
|
|
|
end_size.width = workarea.width / 2;
|
|
|
|
end_size.height = workarea.height;
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFRIGHT:
|
2017-08-08 14:19:45 +00:00
|
|
|
end_size.x = (workarea.x + workarea.width / 2);
|
2016-03-08 05:03:29 +00:00
|
|
|
end_size.y = workarea.y;
|
|
|
|
end_size.width = workarea.width / 2;
|
|
|
|
end_size.height = workarea.height;
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
|
2021-07-06 09:15:39 +00:00
|
|
|
start_size.x = end_size.x = window->x;
|
2016-03-12 16:26:19 +00:00
|
|
|
end_size.y = 0;
|
2016-03-08 05:03:29 +00:00
|
|
|
end_size.height = maxysize;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
start_indicator_drawing (context, start_size, end_size, impl->surface_scale);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
stop_indicator (GdkSurface *window,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkW32DragMoveResizeContext *context)
|
|
|
|
{
|
|
|
|
GDK_NOTE (MISC, g_print ("Stop drawing snap indicator\n"));
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
if (context->timer)
|
|
|
|
{
|
|
|
|
g_source_remove (context->timer);
|
|
|
|
context->timer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (context->shape_indicator,
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
SWP_NOZORDER | SWP_NOMOVE |
|
|
|
|
SWP_NOSIZE | SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_NOACTIVATE));
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
|
|
|
point_in_aerosnap_region (int x,
|
|
|
|
int y,
|
2017-08-08 14:19:45 +00:00
|
|
|
AeroSnapEdgeRegion *region)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int edge, trigger;
|
2017-08-08 14:19:45 +00:00
|
|
|
|
|
|
|
edge = (x >= region->edge.x &&
|
|
|
|
y >= region->edge.y &&
|
|
|
|
x <= region->edge.x + region->edge.width &&
|
|
|
|
y <= region->edge.y + region->edge.height) ? 1 : 0;
|
|
|
|
trigger = (x >= region->trigger.x &&
|
|
|
|
y >= region->trigger.y &&
|
|
|
|
x <= region->trigger.x + region->trigger.width &&
|
|
|
|
y <= region->trigger.y + region->trigger.height) ? 1 : 0;
|
2016-03-08 05:03:29 +00:00
|
|
|
return edge + trigger;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
handle_aerosnap_move_resize (GdkSurface *window,
|
2016-03-08 05:03:29 +00:00
|
|
|
GdkW32DragMoveResizeContext *context,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2016-03-08 05:03:29 +00:00
|
|
|
AeroSnapEdgeRegion *reg;
|
2020-07-24 13:54:49 +00:00
|
|
|
int maximize = 0;
|
|
|
|
int halfleft = 0;
|
|
|
|
int halfright = 0;
|
|
|
|
int fullup = 0;
|
2016-03-12 16:26:19 +00:00
|
|
|
gboolean fullup_edge = FALSE;
|
|
|
|
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE)
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-03-12 16:26:19 +00:00
|
|
|
break;
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2016-03-12 16:26:19 +00:00
|
|
|
fullup_edge = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
for (i = 0; i < context->maximize_regions->len && maximize == 0; i++)
|
|
|
|
{
|
|
|
|
reg = &g_array_index (context->maximize_regions, AeroSnapEdgeRegion, i);
|
2017-08-08 14:19:45 +00:00
|
|
|
maximize = point_in_aerosnap_region (x, y, reg);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < context->halfleft_regions->len && halfleft == 0; i++)
|
|
|
|
{
|
|
|
|
reg = &g_array_index (context->halfleft_regions, AeroSnapEdgeRegion, i);
|
2017-08-08 14:19:45 +00:00
|
|
|
halfleft = point_in_aerosnap_region (x, y, reg);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < context->halfright_regions->len && halfright == 0; i++)
|
|
|
|
{
|
|
|
|
reg = &g_array_index (context->halfright_regions, AeroSnapEdgeRegion, i);
|
2017-08-08 14:19:45 +00:00
|
|
|
halfright = point_in_aerosnap_region (x, y, reg);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < context->fullup_regions->len && fullup == 0; i++)
|
|
|
|
{
|
|
|
|
reg = &g_array_index (context->fullup_regions, AeroSnapEdgeRegion, i);
|
2017-08-08 14:19:45 +00:00
|
|
|
fullup = point_in_aerosnap_region (x, y, reg);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
#if defined(MORE_AEROSNAP_DEBUGGING)
|
2016-03-08 05:03:29 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("AeroSnap: point %d : %d - max: %d, left %d, right %d, up %d\n",
|
|
|
|
x, y, maximize, halfleft, halfright, fullup));
|
2016-03-12 16:26:19 +00:00
|
|
|
#endif
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
if (!context->revealed)
|
|
|
|
{
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && maximize == 2)
|
|
|
|
{
|
|
|
|
context->revealed = TRUE;
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_MAXIMIZE;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE && halfleft == 2)
|
|
|
|
{
|
|
|
|
context->revealed = TRUE;
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE && halfright == 2)
|
|
|
|
{
|
|
|
|
context->revealed = TRUE;
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
2016-03-12 16:26:19 +00:00
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_RESIZE && fullup == 2 && fullup_edge)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
|
|
|
context->revealed = TRUE;
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_FULLUP;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (context->current_snap)
|
|
|
|
{
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_UNDETERMINED:
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE && fullup > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_FULLUP;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_MAXIMIZE:
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && maximize > 0)
|
|
|
|
break;
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && halfleft > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE && halfright > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
stop_indicator (window, context);
|
|
|
|
context->revealed = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFLEFT:
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && halfleft > 0)
|
|
|
|
break;
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && maximize > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_MAXIMIZE;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE && halfright > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
stop_indicator (window, context);
|
|
|
|
context->revealed = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_HALFRIGHT:
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && halfright > 0)
|
|
|
|
break;
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_MOVE && maximize > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_MAXIMIZE;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE && halfleft > 0)
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
|
|
|
start_indicator (window, context, x, y, context->current_snap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
stop_indicator (window, context);
|
|
|
|
context->revealed = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
|
2016-03-12 16:26:19 +00:00
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE && fullup > 0 && fullup_edge)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
|
|
|
update_fullup_indicator (window, context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
|
|
|
stop_indicator (window, context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static const char *
|
2016-02-27 00:10:12 +00:00
|
|
|
get_cursor_name_from_op (GdkW32WindowDragOp op,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceEdge edge)
|
2016-02-27 00:10:12 +00:00
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case GDK_WIN32_DRAGOP_MOVE:
|
|
|
|
return "move";
|
|
|
|
case GDK_WIN32_DRAGOP_RESIZE:
|
|
|
|
switch (edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "nw-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "n-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "ne-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "w-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "e-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "sw-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
2016-02-27 00:10:12 +00:00
|
|
|
return "s-resize";
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-03-12 12:14:04 +00:00
|
|
|
return "se-resize";
|
2016-02-27 00:10:12 +00:00
|
|
|
}
|
|
|
|
/* default: warn about unhandled enum values,
|
|
|
|
* fallthrough to GDK_WIN32_DRAGOP_NONE case
|
|
|
|
*/
|
|
|
|
case GDK_WIN32_DRAGOP_COUNT:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
case GDK_WIN32_DRAGOP_NONE:
|
|
|
|
return "default";
|
|
|
|
/* default: warn about unhandled enum values */
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
setup_drag_move_resize_context (GdkSurface *window,
|
2016-02-06 12:06:41 +00:00
|
|
|
GdkW32DragMoveResizeContext *context,
|
|
|
|
GdkW32WindowDragOp op,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceEdge edge,
|
2016-02-06 12:06:41 +00:00
|
|
|
GdkDevice *device,
|
2020-07-24 13:54:49 +00:00
|
|
|
int button,
|
2020-08-03 08:01:40 +00:00
|
|
|
double x,
|
|
|
|
double y,
|
2016-02-06 12:06:41 +00:00
|
|
|
guint32 timestamp)
|
2004-08-06 19:20:42 +00:00
|
|
|
{
|
2016-02-06 12:06:41 +00:00
|
|
|
RECT rect;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *cursor_name;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *pointer_window;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2020-09-10 04:39:03 +00:00
|
|
|
gboolean maximized = gdk_toplevel_get_state (GDK_TOPLEVEL (window)) & GDK_TOPLEVEL_STATE_MAXIMIZED;
|
2020-07-24 13:54:49 +00:00
|
|
|
int root_x, root_y;
|
2019-04-01 06:18:30 +00:00
|
|
|
|
|
|
|
gdk_win32_surface_get_root_coords (window, x, y, &root_x, &root_y);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
/* Before we drag, we need to undo any maximization or snapping.
|
2016-03-15 10:17:45 +00:00
|
|
|
* AeroSnap behaviour:
|
|
|
|
* If snapped halfleft/halfright:
|
|
|
|
* horizontal resize:
|
|
|
|
* resize
|
|
|
|
* don't unsnap
|
|
|
|
* keep stashed unsnapped size intact
|
|
|
|
* vertical resize:
|
|
|
|
* resize
|
|
|
|
* unsnap to new size (merge cached unsnapped state with current
|
|
|
|
* snapped state in such a way that the gripped edge
|
|
|
|
* does not move)
|
|
|
|
* diagonal resize:
|
|
|
|
* difficult to test (first move is usually either purely
|
|
|
|
* horizontal or purely vertical, in which
|
|
|
|
* case the above behaviour applies)
|
|
|
|
* If snapped up:
|
|
|
|
* horizontal resize:
|
|
|
|
* resize
|
|
|
|
* don't unsnap
|
|
|
|
* apply new width and x position to unsnapped cache,
|
|
|
|
* so that unsnapped window only regains its height
|
|
|
|
* and y position, but inherits x and width from
|
|
|
|
* the fullup snapped state
|
|
|
|
* vertical resize:
|
|
|
|
* unsnap to new size (merge cached unsnapped state with current
|
|
|
|
* snapped state in such a way that the gripped edge
|
|
|
|
* does not move)
|
|
|
|
*
|
|
|
|
* This implementation behaviour:
|
|
|
|
* If snapped halfleft/halfright/fullup:
|
|
|
|
* any resize:
|
|
|
|
* unsnap to current size, discard cached pre-snap state
|
|
|
|
*
|
|
|
|
* TODO: make this implementation behave as AeroSnap on resizes?
|
|
|
|
* There's also the case where
|
2016-03-08 05:03:29 +00:00
|
|
|
* a halfleft/halfright window isn't unsnapped when it's
|
|
|
|
* being moved horizontally, but it's more difficult to implement.
|
|
|
|
*/
|
2016-03-15 10:17:45 +00:00
|
|
|
if (op == GDK_WIN32_DRAGOP_RESIZE &&
|
2016-03-08 05:03:29 +00:00
|
|
|
(impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP))
|
2016-03-15 10:17:45 +00:00
|
|
|
{
|
|
|
|
discard_snapinfo (window);
|
|
|
|
}
|
|
|
|
else if (maximized ||
|
|
|
|
(impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT ||
|
|
|
|
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP))
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkMonitor *monitor;
|
2020-07-24 13:54:49 +00:00
|
|
|
int wx, wy, wwidth, wheight;
|
|
|
|
int swx, swy, swwidth, swheight;
|
2016-03-08 05:03:29 +00:00
|
|
|
gboolean pointer_outside_of_window;
|
2020-07-24 13:54:49 +00:00
|
|
|
int offsetx, offsety;
|
2016-03-08 05:03:29 +00:00
|
|
|
gboolean left_half;
|
2016-10-21 05:40:49 +00:00
|
|
|
GdkDisplay *display;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
display = gdk_surface_get_display (window);
|
2018-03-20 11:05:26 +00:00
|
|
|
monitor = gdk_display_get_monitor_at_surface (display, window);
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_get_geometry (window, &wx, &wy, &wwidth, &wheight);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2016-03-15 10:17:45 +00:00
|
|
|
swx = wx;
|
|
|
|
swy = wy;
|
|
|
|
swwidth = wwidth;
|
|
|
|
swheight = wheight;
|
|
|
|
|
|
|
|
/* Subtract window shadow. We don't want pointer to go outside of
|
|
|
|
* the visible window during drag-move. For drag-resize it's OK.
|
|
|
|
* Don't take shadow into account if the window is maximized -
|
|
|
|
* maximized windows don't have shadows.
|
|
|
|
*/
|
|
|
|
if (op == GDK_WIN32_DRAGOP_MOVE && !maximized)
|
|
|
|
{
|
2020-12-31 09:27:40 +00:00
|
|
|
swx += impl->shadow.left / impl->surface_scale;
|
|
|
|
swy += impl->shadow.top / impl->surface_scale;
|
|
|
|
swwidth -= impl->shadow_x;
|
|
|
|
swheight -= impl->shadow_y;
|
2016-03-15 10:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pointer_outside_of_window = root_x < swx || root_x > swx + swwidth ||
|
|
|
|
root_y < swy || root_y > swy + swheight;
|
2016-03-08 05:03:29 +00:00
|
|
|
/* Calculate the offset of the pointer relative to the window */
|
2016-03-15 10:17:45 +00:00
|
|
|
offsetx = root_x - swx;
|
|
|
|
offsety = root_y - swy;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
/* Figure out in which half of the window the pointer is.
|
|
|
|
* The code currently only concerns itself with horizontal
|
|
|
|
* dimension (left/right halves).
|
|
|
|
* There's no upper/lower half, because usually window
|
|
|
|
* is dragged by its upper half anyway. If that changes, adjust
|
|
|
|
* accordingly.
|
|
|
|
*/
|
2016-03-15 10:17:45 +00:00
|
|
|
left_half = (offsetx < swwidth / 2);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
/* Inverse the offset for it to be from the right edge */
|
|
|
|
if (!left_half)
|
2016-03-15 10:17:45 +00:00
|
|
|
offsetx = swwidth - offsetx;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Pointer at %d : %d, this is %d : %d relative to the window's %s\n",
|
|
|
|
root_x, root_y, offsetx, offsety,
|
|
|
|
left_half ? "left half" : "right half"));
|
|
|
|
|
|
|
|
/* Move window in such a way that on unmaximization/unsnapping the pointer
|
|
|
|
* is still pointing at the appropriate half of the window,
|
|
|
|
* with the same offset from the left or right edge. If the new
|
|
|
|
* window size is too small, and adding that offset puts the pointer
|
|
|
|
* into the other half or even beyond, move the pointer to the middle.
|
|
|
|
*/
|
|
|
|
if (!pointer_outside_of_window && maximized)
|
|
|
|
{
|
|
|
|
WINDOWPLACEMENT placement;
|
2020-07-24 13:54:49 +00:00
|
|
|
int unmax_width, unmax_height;
|
|
|
|
int shadow_unmax_width, shadow_unmax_height;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
placement.length = sizeof (placement);
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (GetWindowPlacement, (GDK_SURFACE_HWND (window), &placement));
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("W32 WM unmaximized window placement is %ld x %ld @ %ld : %ld\n",
|
|
|
|
placement.rcNormalPosition.right - placement.rcNormalPosition.left,
|
|
|
|
placement.rcNormalPosition.bottom - placement.rcNormalPosition.top,
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.left,
|
|
|
|
placement.rcNormalPosition.top));
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
unmax_width = placement.rcNormalPosition.right - placement.rcNormalPosition.left;
|
|
|
|
unmax_height = placement.rcNormalPosition.bottom - placement.rcNormalPosition.top;
|
|
|
|
|
2020-12-31 09:27:40 +00:00
|
|
|
shadow_unmax_width = unmax_width - impl->shadow_x * impl->surface_scale;
|
|
|
|
shadow_unmax_height = unmax_height - impl->shadow_y * impl->surface_scale;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
if (offsetx * impl->surface_scale < (shadow_unmax_width / 2) &&
|
|
|
|
offsety * impl->surface_scale < (shadow_unmax_height / 2))
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top) * impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
placement.rcNormalPosition.bottom = placement.rcNormalPosition.top + unmax_height;
|
|
|
|
|
|
|
|
if (left_half)
|
|
|
|
{
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.left = (root_x - offsetx + impl->shadow.left) * impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
placement.rcNormalPosition.right = placement.rcNormalPosition.left + unmax_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.right = (root_x + offsetx + impl->shadow.right) * impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
placement.rcNormalPosition.left = placement.rcNormalPosition.right - unmax_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.left = root_x * impl->surface_scale - unmax_width / 2;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
if (offsety * impl->surface_scale < shadow_unmax_height / 2)
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top) * impl->surface_scale;
|
2016-03-15 10:17:45 +00:00
|
|
|
else
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.top = root_y * impl->surface_scale - unmax_height / 2;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
placement.rcNormalPosition.right = placement.rcNormalPosition.left + unmax_width;
|
|
|
|
placement.rcNormalPosition.bottom = placement.rcNormalPosition.top + unmax_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Unmaximized window will be at %ld : %ld\n",
|
2021-10-29 16:39:52 +00:00
|
|
|
placement.rcNormalPosition.left,
|
|
|
|
placement.rcNormalPosition.top));
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPlacement, (GDK_SURFACE_HWND (window), &placement));
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
else if (!pointer_outside_of_window && impl->snap_stash_int)
|
|
|
|
{
|
|
|
|
GdkRectangle new_pos;
|
2016-03-15 10:17:45 +00:00
|
|
|
GdkRectangle snew_pos;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
new_pos.width = impl->snap_stash_int->width;
|
|
|
|
new_pos.height = impl->snap_stash_int->height;
|
2016-03-15 10:17:45 +00:00
|
|
|
snew_pos = new_pos;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
2016-03-15 10:17:45 +00:00
|
|
|
if (op == GDK_WIN32_DRAGOP_MOVE)
|
2016-03-08 05:03:29 +00:00
|
|
|
{
|
2020-12-31 09:27:40 +00:00
|
|
|
snew_pos.width -= impl->shadow_x;
|
|
|
|
snew_pos.height -= impl->shadow_y;
|
2016-03-15 10:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (offsetx < snew_pos.width / 2 && offsety < snew_pos.height / 2)
|
|
|
|
{
|
2020-12-31 09:27:40 +00:00
|
|
|
new_pos.y = root_y - offsety + impl->shadow.top / impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
if (left_half)
|
2020-12-31 09:27:40 +00:00
|
|
|
new_pos.x = root_x - offsetx + impl->shadow.left / impl->surface_scale;
|
2016-03-08 05:03:29 +00:00
|
|
|
else
|
2020-12-31 09:27:40 +00:00
|
|
|
new_pos.x = root_x + offsetx + impl->shadow.left / impl->surface_scale - new_pos.width;
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_pos.x = root_x - new_pos.width / 2;
|
|
|
|
new_pos.y = root_y - new_pos.height / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("Unsnapped window to %d : %d\n",
|
|
|
|
new_pos.x, new_pos.y));
|
|
|
|
discard_snapinfo (window);
|
2019-07-15 13:47:12 +00:00
|
|
|
gdk_win32_surface_move_resize (window, new_pos.x, new_pos.y,
|
|
|
|
new_pos.width, new_pos.height);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (maximized)
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_unmaximize (window);
|
2016-03-08 05:03:29 +00:00
|
|
|
else
|
2016-10-21 05:40:49 +00:00
|
|
|
unsnap (window, monitor);
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
if (pointer_outside_of_window)
|
|
|
|
{
|
|
|
|
/* Pointer outside of the window, move pointer into window */
|
|
|
|
GDK_NOTE (MISC, g_print ("Pointer at %d : %d is outside of %d x %d @ %d : %d, move it to %d : %d\n",
|
|
|
|
root_x, root_y, wwidth, wheight, wx, wy, wx + wwidth / 2, wy + wheight / 2));
|
|
|
|
root_x = wx + wwidth / 2;
|
|
|
|
/* This is Gnome behaviour. Windows WM would put the pointer
|
|
|
|
* in the middle of the titlebar, but GDK doesn't know where
|
|
|
|
* the titlebar is, if any.
|
|
|
|
*/
|
|
|
|
root_y = wy + wheight / 2;
|
2021-10-29 16:39:52 +00:00
|
|
|
SetCursorPos (root_x, root_y);
|
2016-03-08 05:03:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
_gdk_win32_get_window_rect (window, &rect);
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2016-02-27 00:10:12 +00:00
|
|
|
cursor_name = get_cursor_name_from_op (op, edge);
|
|
|
|
|
2017-11-07 07:39:48 +00:00
|
|
|
context->cursor = gdk_cursor_new_from_name (cursor_name, NULL);
|
2016-02-27 00:10:12 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
pointer_window = window;
|
2016-02-27 00:10:12 +00:00
|
|
|
|
|
|
|
/* Note: This triggers a WM_CAPTURECHANGED, which will trigger
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_win32_surface_end_move_resize_drag(), which will end
|
2016-02-27 00:10:12 +00:00
|
|
|
* our op before it even begins, but only if context->op is not NONE.
|
|
|
|
* This is why we first do the grab, *then* set the op.
|
|
|
|
*/
|
|
|
|
gdk_device_grab (device, pointer_window,
|
2020-06-22 21:54:46 +00:00
|
|
|
FALSE,
|
2016-02-27 00:10:12 +00:00
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
context->cursor,
|
|
|
|
timestamp);
|
|
|
|
|
2016-03-12 16:26:19 +00:00
|
|
|
context->window = g_object_ref (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
context->op = op;
|
|
|
|
context->edge = edge;
|
|
|
|
context->device = device;
|
|
|
|
context->button = button;
|
|
|
|
context->start_root_x = root_x;
|
|
|
|
context->start_root_y = root_y;
|
|
|
|
context->timestamp = timestamp;
|
|
|
|
context->start_rect = rect;
|
2004-08-06 19:20:42 +00:00
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
context->shape_indicator = NULL;
|
|
|
|
context->revealed = FALSE;
|
|
|
|
context->halfleft_regions = g_array_new (FALSE, FALSE, sizeof (AeroSnapEdgeRegion));
|
|
|
|
context->halfright_regions = g_array_new (FALSE, FALSE, sizeof (AeroSnapEdgeRegion));
|
|
|
|
context->maximize_regions = g_array_new (FALSE, FALSE, sizeof (AeroSnapEdgeRegion));
|
|
|
|
context->fullup_regions = g_array_new (FALSE, FALSE, sizeof (AeroSnapEdgeRegion));
|
|
|
|
|
|
|
|
calculate_aerosnap_regions (context);
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
2016-02-27 00:10:12 +00:00
|
|
|
g_print ("begin drag moveresize: window %p, toplevel %p, "
|
2016-02-06 12:06:41 +00:00
|
|
|
"op %u, edge %d, device %p, "
|
|
|
|
"button %d, coord %d:%d, time %u\n",
|
2019-05-19 03:09:05 +00:00
|
|
|
pointer_window, window,
|
2016-02-06 12:06:41 +00:00
|
|
|
context->op, context->edge, context->device,
|
|
|
|
context->button, context->start_root_x,
|
|
|
|
context->start_root_y, context->timestamp));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_end_move_resize_drag (GdkSurface *window)
|
2016-02-06 12:06:41 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
GdkW32DragMoveResizeContext *context = &impl->drag_move_resize_context;
|
2018-07-31 10:11:26 +00:00
|
|
|
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE)
|
|
|
|
_gdk_win32_surface_invalidate_egl_framebuffer (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
|
|
|
|
context->op = GDK_WIN32_DRAGOP_NONE;
|
2016-02-27 00:10:12 +00:00
|
|
|
|
|
|
|
gdk_device_ungrab (context->device, GDK_CURRENT_TIME);
|
|
|
|
|
|
|
|
g_clear_object (&context->cursor);
|
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
context->revealed = FALSE;
|
2016-03-12 16:26:19 +00:00
|
|
|
|
|
|
|
if (context->timer)
|
|
|
|
{
|
|
|
|
g_source_remove (context->timer);
|
|
|
|
context->timer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_object (&context->window);
|
|
|
|
|
|
|
|
if (context->indicator_surface)
|
|
|
|
{
|
|
|
|
cairo_surface_destroy (context->indicator_surface);
|
|
|
|
context->indicator_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->shape_indicator)
|
|
|
|
{
|
|
|
|
stop_indicator (window, context);
|
|
|
|
DestroyWindow (context->shape_indicator);
|
|
|
|
context->shape_indicator = NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-08 05:03:29 +00:00
|
|
|
g_clear_pointer (&context->halfleft_regions, g_array_unref);
|
|
|
|
g_clear_pointer (&context->halfright_regions, g_array_unref);
|
|
|
|
g_clear_pointer (&context->maximize_regions, g_array_unref);
|
|
|
|
g_clear_pointer (&context->fullup_regions, g_array_unref);
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
2016-02-27 00:10:12 +00:00
|
|
|
g_print ("end drag moveresize: window %p, toplevel %p,"
|
2016-02-06 12:06:41 +00:00
|
|
|
"op %u, edge %d, device %p, "
|
|
|
|
"button %d, coord %d:%d, time %u\n",
|
2019-05-19 03:09:05 +00:00
|
|
|
window, window,
|
2016-02-06 12:06:41 +00:00
|
|
|
context->op, context->edge, context->device,
|
|
|
|
context->button, context->start_root_x,
|
|
|
|
context->start_root_y, context->timestamp));
|
2016-06-05 07:37:02 +00:00
|
|
|
|
|
|
|
if (context->current_snap != GDK_WIN32_AEROSNAP_STATE_UNDETERMINED)
|
|
|
|
apply_snap (window, context->current_snap);
|
|
|
|
|
|
|
|
context->current_snap = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
|
2016-02-06 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-02 15:25:36 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_get_window_size_and_position_from_client_rect (GdkSurface *window,
|
2017-09-02 15:25:36 +00:00
|
|
|
RECT *window_rect,
|
|
|
|
SIZE *window_size,
|
|
|
|
POINT *window_position)
|
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2017-09-02 15:25:36 +00:00
|
|
|
|
|
|
|
/* Turn client area into window area */
|
|
|
|
_gdk_win32_adjust_client_rect (window, window_rect);
|
|
|
|
|
|
|
|
window_position->x = window_rect->left;
|
|
|
|
window_position->y = window_rect->top;
|
|
|
|
window_size->cx = window_rect->right - window_rect->left;
|
|
|
|
window_size->cy = window_rect->bottom - window_rect->top;
|
|
|
|
}
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int x,
|
|
|
|
int y)
|
2016-02-06 12:06:41 +00:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
RECT new_rect;
|
2020-07-24 13:54:49 +00:00
|
|
|
int diffy, diffx;
|
2016-02-06 12:06:41 +00:00
|
|
|
MINMAXINFO mmi;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-02-06 12:06:41 +00:00
|
|
|
GdkW32DragMoveResizeContext *context;
|
2020-07-24 13:54:49 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2016-02-06 12:06:41 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
context = &impl->drag_move_resize_context;
|
|
|
|
|
|
|
|
if (!_gdk_win32_get_window_rect (window, &rect))
|
2004-10-30 18:04:49 +00:00
|
|
|
return;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect = context->start_rect;
|
2018-03-20 11:05:26 +00:00
|
|
|
diffx = (x - context->start_root_x) * impl->surface_scale;
|
|
|
|
diffy = (y - context->start_root_y) * impl->surface_scale;
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
switch (context->op)
|
2004-10-30 18:04:49 +00:00
|
|
|
{
|
2016-02-06 12:06:41 +00:00
|
|
|
case GDK_WIN32_DRAGOP_RESIZE:
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.left += diffx;
|
|
|
|
new_rect.top += diffy;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.top += diffy;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.right += diffx;
|
|
|
|
new_rect.top += diffy;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.left += diffx;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.right += diffx;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.left += diffx;
|
|
|
|
new_rect.bottom += diffy;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.bottom += diffy;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
default:
|
|
|
|
new_rect.right += diffx;
|
|
|
|
new_rect.bottom += diffy;
|
|
|
|
break;
|
|
|
|
}
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
/* When handling WM_GETMINMAXINFO, mmi is already populated
|
|
|
|
* by W32 WM and we apply our stuff on top of that.
|
|
|
|
* Here it isn't, so we should at least clear it.
|
|
|
|
*/
|
|
|
|
memset (&mmi, 0, sizeof (mmi));
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!_gdk_win32_surface_fill_min_max_info (window, &mmi))
|
2016-02-06 12:06:41 +00:00
|
|
|
break;
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
width = new_rect.right - new_rect.left;
|
|
|
|
height = new_rect.bottom - new_rect.top;
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
if (width > mmi.ptMaxTrackSize.x)
|
|
|
|
{
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.left = new_rect.right - mmi.ptMaxTrackSize.x;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
default:
|
|
|
|
new_rect.right = new_rect.left + mmi.ptMaxTrackSize.x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (width < mmi.ptMinTrackSize.x)
|
|
|
|
{
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.left = new_rect.right - mmi.ptMinTrackSize.x;
|
|
|
|
break;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_EAST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
default:
|
|
|
|
new_rect.right = new_rect.left + mmi.ptMinTrackSize.x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
if (height > mmi.ptMaxTrackSize.y)
|
|
|
|
{
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.top = new_rect.bottom - mmi.ptMaxTrackSize.y;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
default:
|
|
|
|
new_rect.bottom = new_rect.top + mmi.ptMaxTrackSize.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (height < mmi.ptMinTrackSize.y)
|
|
|
|
{
|
|
|
|
switch (context->edge)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_NORTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH:
|
|
|
|
case GDK_SURFACE_EDGE_NORTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
new_rect.top = new_rect.bottom - mmi.ptMinTrackSize.y;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_EDGE_SOUTH_WEST:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH:
|
|
|
|
case GDK_SURFACE_EDGE_SOUTH_EAST:
|
2016-02-06 12:06:41 +00:00
|
|
|
default:
|
|
|
|
new_rect.bottom = new_rect.top + mmi.ptMinTrackSize.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-10-30 18:04:49 +00:00
|
|
|
|
|
|
|
break;
|
2016-02-06 12:06:41 +00:00
|
|
|
case GDK_WIN32_DRAGOP_MOVE:
|
|
|
|
new_rect.left += diffx;
|
|
|
|
new_rect.top += diffy;
|
|
|
|
new_rect.right += diffx;
|
|
|
|
new_rect.bottom += diffy;
|
|
|
|
break;
|
2004-10-30 18:04:49 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE &&
|
|
|
|
(rect.left != new_rect.left ||
|
|
|
|
rect.right != new_rect.right ||
|
|
|
|
rect.top != new_rect.top ||
|
|
|
|
rect.bottom != new_rect.bottom))
|
|
|
|
{
|
2020-12-31 08:36:41 +00:00
|
|
|
if (GDK_IS_TOPLEVEL (window))
|
|
|
|
{
|
|
|
|
int scale = impl->surface_scale;
|
|
|
|
|
2021-02-02 09:30:55 +00:00
|
|
|
impl->next_layout.configured_rect = new_rect;
|
2021-03-15 01:56:28 +00:00
|
|
|
impl->next_layout.configured_width = (new_rect.right - new_rect.left + scale - 1) / scale;
|
|
|
|
impl->next_layout.configured_height = (new_rect.bottom - new_rect.top + scale - 1) / scale;
|
2020-12-31 08:36:41 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
context->native_move_resize_pending = TRUE;
|
|
|
|
}
|
|
|
|
else if (context->op == GDK_WIN32_DRAGOP_MOVE &&
|
|
|
|
(rect.left != new_rect.left ||
|
|
|
|
rect.top != new_rect.top))
|
|
|
|
{
|
2020-11-05 08:24:40 +00:00
|
|
|
SIZE window_size;
|
|
|
|
POINT window_position;
|
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
context->native_move_resize_pending = FALSE;
|
|
|
|
|
2020-12-02 14:29:54 +00:00
|
|
|
gdk_surface_request_layout (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
|
2020-11-05 08:24:40 +00:00
|
|
|
gdk_win32_get_window_size_and_position_from_client_rect (window,
|
|
|
|
&new_rect,
|
|
|
|
&window_size,
|
|
|
|
&window_position);
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
|
|
|
window_position.x, window_position.y,
|
|
|
|
0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE));
|
2016-02-06 12:06:41 +00:00
|
|
|
}
|
2016-03-08 05:03:29 +00:00
|
|
|
|
|
|
|
if (context->op == GDK_WIN32_DRAGOP_RESIZE ||
|
|
|
|
context->op == GDK_WIN32_DRAGOP_MOVE)
|
|
|
|
handle_aerosnap_move_resize (window, context, x, y);
|
2020-12-31 08:36:41 +00:00
|
|
|
|
|
|
|
gdk_surface_request_layout (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_win32_toplevel_begin_resize (GdkToplevel *toplevel,
|
|
|
|
GdkSurfaceEdge edge,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2016-02-06 12:06:41 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *window = GDK_SURFACE (toplevel);
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-02-06 12:06:41 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window) ||
|
|
|
|
IsIconic (GDK_SURFACE_HWND (window)))
|
2016-02-06 12:06:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Tell Windows to start interactively resizing the window by pretending that
|
|
|
|
* the left pointer button was clicked in the suitable edge or corner. This
|
|
|
|
* will only work if the button is down when this function is called, and
|
|
|
|
* will only work with button 1 (left), since Windows only allows window
|
|
|
|
* dragging using the left mouse button.
|
|
|
|
*/
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
|
|
|
|
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_end_move_resize_drag (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
|
|
|
|
setup_drag_move_resize_context (window, &impl->drag_move_resize_context,
|
|
|
|
GDK_WIN32_DRAGOP_RESIZE, edge, device,
|
2019-04-01 06:18:30 +00:00
|
|
|
button, x, y, timestamp);
|
2004-08-06 19:20:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2020-05-17 16:35:45 +00:00
|
|
|
gdk_win32_toplevel_begin_move (GdkToplevel *toplevel,
|
|
|
|
GdkDevice *device,
|
|
|
|
int button,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
guint32 timestamp)
|
2004-08-06 19:20:42 +00:00
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
GdkSurface *window = GDK_SURFACE (toplevel);
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
2016-02-06 12:06:41 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window) ||
|
|
|
|
IsIconic (GDK_SURFACE_HWND (window)))
|
2004-08-06 19:20:42 +00:00
|
|
|
return;
|
|
|
|
|
2004-10-30 18:04:49 +00:00
|
|
|
/* Tell Windows to start interactively moving the window by pretending that
|
|
|
|
* the left pointer button was clicked in the titlebar. This will only work
|
|
|
|
* if the button is down when this function is called, and will only work
|
|
|
|
* with button 1 (left), since Windows only allows window dragging using the
|
2005-11-02 13:33:27 +00:00
|
|
|
* left mouse button.
|
|
|
|
*/
|
2004-10-30 18:04:49 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
impl = GDK_WIN32_SURFACE (window);
|
2016-02-06 12:06:41 +00:00
|
|
|
|
|
|
|
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_end_move_resize_drag (window);
|
2004-10-30 18:04:49 +00:00
|
|
|
|
2016-02-06 12:06:41 +00:00
|
|
|
setup_drag_move_resize_context (window, &impl->drag_move_resize_context,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_WIN32_DRAGOP_MOVE, GDK_SURFACE_EDGE_NORTH_WEST,
|
2019-04-01 06:18:30 +00:00
|
|
|
device, button, x, y, timestamp);
|
2004-08-06 19:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-09 16:43:19 +00:00
|
|
|
/*
|
|
|
|
* Setting window states
|
|
|
|
*/
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_win32_surface_minimize (GdkSurface *window)
|
2001-03-09 16:43:19 +00:00
|
|
|
{
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
HWND old_active_window;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2001-03-09 16:43:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2001-03-09 16:43:19 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-16 19:50:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_minimize: %p: %s\n",
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state)));
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (window))
|
2001-03-09 16:43:19 +00:00
|
|
|
{
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
old_active_window = GetActiveWindow ();
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_MINIMIZE);
|
2018-03-20 10:40:08 +00:00
|
|
|
if (old_active_window != GDK_SURFACE_HWND (window))
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
SetActiveWindow (old_active_window);
|
2001-03-09 16:43:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2019-11-16 19:50:57 +00:00
|
|
|
0,
|
2020-09-10 04:39:03 +00:00
|
|
|
GDK_TOPLEVEL_STATE_MINIMIZED);
|
2001-03-09 16:43:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_maximize (GdkSurface *window)
|
2001-03-09 16:43:19 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2001-03-09 16:43:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2001-03-09 16:43:19 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_maximize: %p: %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state)));
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (window))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_MAXIMIZE);
|
2001-03-09 16:43:19 +00:00
|
|
|
else
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2001-03-09 16:43:19 +00:00
|
|
|
0,
|
2020-09-10 04:39:03 +00:00
|
|
|
GDK_TOPLEVEL_STATE_MAXIMIZED);
|
2001-03-09 16:43:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_unmaximize (GdkSurface *window)
|
2001-03-09 16:43:19 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2001-03-09 16:43:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2001-03-09 16:43:19 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_unmaximize: %p: %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state)));
|
Merge from stable:
2002-12-09 Tor Lillqvist <tml@iki.fi>
Merge from stable:
* gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak
stipple_gc. More checks for errors. Use correct ternary ROP when
blitting the foreground into the tile pixmap onto those pixels
where the stipple is set. (I didn't notice that I had used the
wrong one, as it didn't matter on Win2k, where DIB sections
apparently are zeroed upon creation. But on Win98 they have random
initial contents. Thanks to Hans Breuer for reporting this.)
(gdk_win32_draw_rectangle, gdk_win32_draw_arc,
gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to
generic_draw() if drawing a filled figure.
* gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics.
(_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty.
(_gdk_win32_window_state_to_string): New debugging output helper
function.
* gdk/win32/gdkevents-win32.c: Minor debugging output changes.
(gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or
SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for
WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to
unmapping on X11. Set window state correctly for all three of
SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified
("minimized" in Windows terminology) window still has the
"maximized" property, i.e. when deiconified, it will reappear as
maximized. (#10557)
* gdk/win32/gdkprivate-win32.h: Declare new function.
(WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use
__PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message.
* gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more
situations. Add parameter to tell whether deiconifying. Code
reorg: Return early when appropriate instead of using nested if
statements. If just deiconifying without raising, restore active
window. (#10557)
(gdk_window_hide, gdk_window_withdraw, gdk_window_iconify,
gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize,
gdk_window_focus): Use _gdk_win32_window_state_to_string() in
debugging output.
(gdk_window_iconify): Restore active window after calling
ShowWindow(). Otherwise the "next" window gets activated.
(gdk_window_stick, gdk_window_unstick): Don't output any warnings.
(gdk_window_set_transient_for): Rewrite. Just call SetWindowLong()
with GWL_HWNDPARENT, which despite its name sets the *owner*
window, which should be exactly what we want. The PSDK
documentation is said to be misleading. testgtk's modal window
test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
|
|
|
|
2018-07-31 10:11:26 +00:00
|
|
|
_gdk_win32_surface_invalidate_egl_framebuffer (window);
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_IS_MAPPED (window))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_RESTORE);
|
2001-03-09 16:43:19 +00:00
|
|
|
else
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2020-09-10 04:39:03 +00:00
|
|
|
GDK_TOPLEVEL_STATE_MAXIMIZED,
|
2001-03-09 16:43:19 +00:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_fullscreen (GdkSurface *window)
|
2002-11-16 21:51:47 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y, width, height;
|
2003-08-05 22:24:35 +00:00
|
|
|
FullscreenInfo *fi;
|
2007-11-25 22:59:50 +00:00
|
|
|
HMONITOR monitor;
|
|
|
|
MONITORINFO mi;
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2002-11-16 21:51:47 +00:00
|
|
|
|
2003-08-05 22:24:35 +00:00
|
|
|
fi = g_new (FullscreenInfo, 1);
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GetWindowRect (GDK_SURFACE_HWND (window), &(fi->r)))
|
2003-08-05 22:24:35 +00:00
|
|
|
g_free (fi);
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
2007-11-25 22:59:50 +00:00
|
|
|
mi.cbSize = sizeof (mi);
|
|
|
|
if (monitor && GetMonitorInfo (monitor, &mi))
|
|
|
|
{
|
|
|
|
x = mi.rcMonitor.left;
|
|
|
|
y = mi.rcMonitor.top;
|
|
|
|
width = mi.rcMonitor.right - x;
|
|
|
|
height = mi.rcMonitor.bottom - y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = y = 0;
|
|
|
|
width = GetSystemMetrics (SM_CXSCREEN);
|
|
|
|
height = GetSystemMetrics (SM_CYSCREEN);
|
|
|
|
}
|
|
|
|
|
2003-08-05 22:24:35 +00:00
|
|
|
/* remember for restoring */
|
|
|
|
fi->hint_flags = impl->hint_flags;
|
|
|
|
impl->hint_flags &= ~GDK_HINT_MAX_SIZE;
|
|
|
|
g_object_set_data (G_OBJECT (window), "fullscreen-info", fi);
|
2018-03-20 10:40:08 +00:00
|
|
|
fi->style = GetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE);
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2011-10-26 08:21:10 +00:00
|
|
|
/* Send state change before configure event */
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FULLSCREEN);
|
2011-10-26 08:21:10 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE,
|
2003-08-05 22:24:35 +00:00
|
|
|
(fi->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
|
2005-03-16 01:38:57 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_TOP,
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
x, y, width, height,
|
2020-10-08 04:46:06 +00:00
|
|
|
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
|
2003-08-05 22:24:35 +00:00
|
|
|
}
|
2002-11-16 21:51:47 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_unfullscreen (GdkSurface *window)
|
2002-11-16 21:51:47 +00:00
|
|
|
{
|
2003-08-05 22:24:35 +00:00
|
|
|
FullscreenInfo *fi;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2005-11-02 13:33:27 +00:00
|
|
|
fi = g_object_get_data (G_OBJECT (window), "fullscreen-info");
|
2003-08-05 22:24:35 +00:00
|
|
|
if (fi)
|
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2003-08-05 22:24:35 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
gdk_synthesize_surface_state (window, GDK_TOPLEVEL_STATE_FULLSCREEN, 0);
|
2011-10-26 08:21:10 +00:00
|
|
|
|
2003-08-05 22:24:35 +00:00
|
|
|
impl->hint_flags = fi->hint_flags;
|
2018-03-20 10:40:08 +00:00
|
|
|
SetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE, fi->style);
|
2018-07-31 10:11:26 +00:00
|
|
|
_gdk_win32_surface_invalidate_egl_framebuffer (window);
|
2018-03-20 10:40:08 +00:00
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_NOTOPMOST,
|
2005-03-16 01:38:57 +00:00
|
|
|
fi->r.left, fi->r.top,
|
|
|
|
fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
|
2020-10-08 04:46:06 +00:00
|
|
|
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2003-08-05 22:24:35 +00:00
|
|
|
g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
|
|
|
|
g_free (fi);
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_win32_surface_update_style_bits (window);
|
2003-08-05 22:24:35 +00:00
|
|
|
}
|
2002-11-16 21:51:47 +00:00
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_focus (GdkSurface *window,
|
2011-01-02 10:51:25 +00:00
|
|
|
guint32 timestamp)
|
2001-03-09 16:43:19 +00:00
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
g_return_if_fail (GDK_IS_SURFACE (window));
|
2001-03-09 16:43:19 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2001-03-09 16:43:19 +00:00
|
|
|
return;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_surface_focus: %p: %s\n",
|
|
|
|
GDK_SURFACE_HWND (window),
|
|
|
|
_gdk_win32_surface_state_to_string (window->state)));
|
2002-03-06 00:36:08 +00:00
|
|
|
|
2020-09-10 04:39:03 +00:00
|
|
|
if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWMAXIMIZED);
|
2020-09-10 04:39:03 +00:00
|
|
|
else if (window->state & GDK_TOPLEVEL_STATE_MINIMIZED)
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_RESTORE);
|
2018-03-20 10:40:08 +00:00
|
|
|
else if (!IsWindowVisible (GDK_SURFACE_HWND (window)))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOWNORMAL);
|
2016-02-08 12:20:02 +00:00
|
|
|
else
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GtkShowWindow (window, SW_SHOW);
|
2016-02-08 08:24:12 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
SetFocus (GDK_SURFACE_HWND (window));
|
2001-03-09 16:43:19 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *
|
|
|
|
gdk_win32_surface_lookup_for_display (GdkDisplay *display,
|
2011-02-06 14:03:32 +00:00
|
|
|
HWND anid)
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
{
|
2016-02-22 16:55:16 +00:00
|
|
|
g_return_val_if_fail (display == gdk_display_get_default (), NULL);
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
return (GdkSurface*) gdk_win32_handle_table_lookup (anid);
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
}
|
2004-07-11 13:26:57 +00:00
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
gboolean
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_is_win32 (GdkSurface *window)
|
2009-02-14 18:23:54 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
return GDK_IS_WIN32_SURFACE (window);
|
2009-02-14 18:23:54 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 04:51:52 +00:00
|
|
|
static gboolean
|
2021-03-12 10:39:04 +00:00
|
|
|
gdk_win32_surface_show_window_menu (GdkSurface *surface,
|
|
|
|
GdkEvent *event)
|
2016-03-18 04:51:52 +00:00
|
|
|
{
|
|
|
|
double event_x, event_y;
|
2020-07-24 13:54:49 +00:00
|
|
|
int x, y;
|
2021-03-12 10:39:04 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
GdkEventType event_type = gdk_event_get_event_type (event);
|
2016-03-18 04:51:52 +00:00
|
|
|
|
2021-03-12 10:39:04 +00:00
|
|
|
switch ((int) event_type)
|
2016-03-18 04:51:52 +00:00
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_position (event, &event_x, &event_y);
|
2021-03-12 10:39:04 +00:00
|
|
|
gdk_win32_surface_get_root_coords (surface, event_x, event_y, &x, &y);
|
2016-03-18 04:51:52 +00:00
|
|
|
|
2021-03-12 10:39:04 +00:00
|
|
|
SendMessage (GDK_SURFACE_HWND (surface),
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
WM_SYSMENU,
|
|
|
|
0,
|
2018-03-20 11:05:26 +00:00
|
|
|
MAKELPARAM (x * impl->surface_scale, y * impl->surface_scale));
|
2016-03-18 04:51:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-10-28 09:05:53 +00:00
|
|
|
HWND
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_get_impl_hwnd (GdkSurface *window)
|
2011-10-28 09:05:53 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
if (GDK_IS_WIN32_SURFACE (window))
|
2018-03-20 10:40:08 +00:00
|
|
|
return GDK_SURFACE_HWND (window);
|
2011-10-28 09:05:53 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-16 18:16:33 +00:00
|
|
|
BOOL WINAPI
|
2018-03-20 10:40:08 +00:00
|
|
|
GtkShowWindow (GdkSurface *window,
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
int cmd_show)
|
2016-03-16 18:16:33 +00:00
|
|
|
{
|
|
|
|
cairo_t *cr;
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
RECT window_rect;
|
|
|
|
HDC hdc;
|
|
|
|
POINT window_position;
|
|
|
|
SIZE window_size;
|
|
|
|
POINT source_point;
|
|
|
|
BLENDFUNCTION blender;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
HWND hwnd = GDK_SURFACE_HWND (window);
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2016-03-16 18:16:33 +00:00
|
|
|
switch (cmd_show)
|
|
|
|
{
|
|
|
|
case SW_FORCEMINIMIZE:
|
|
|
|
case SW_HIDE:
|
|
|
|
case SW_MINIMIZE:
|
|
|
|
break;
|
|
|
|
case SW_MAXIMIZE:
|
|
|
|
case SW_RESTORE:
|
|
|
|
case SW_SHOW:
|
|
|
|
case SW_SHOWDEFAULT:
|
|
|
|
case SW_SHOWMINIMIZED:
|
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
case SW_SHOWNA:
|
|
|
|
case SW_SHOWNOACTIVATE:
|
|
|
|
case SW_SHOWNORMAL:
|
|
|
|
if (IsWindowVisible (hwnd))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Window was hidden, will be shown. Erase it, GDK will repaint soon,
|
|
|
|
* but not soon enough, so it's possible to see old content before
|
|
|
|
* the next redraw, unless we erase the window first.
|
|
|
|
*/
|
|
|
|
GetWindowRect (hwnd, &window_rect);
|
|
|
|
source_point.x = source_point.y = 0;
|
|
|
|
|
|
|
|
window_position.x = window_rect.left;
|
|
|
|
window_position.y = window_rect.top;
|
|
|
|
window_size.cx = window_rect.right - window_rect.left;
|
|
|
|
window_size.cy = window_rect.bottom - window_rect.top;
|
|
|
|
|
|
|
|
blender.BlendOp = AC_SRC_OVER;
|
|
|
|
blender.BlendFlags = 0;
|
|
|
|
blender.AlphaFormat = AC_SRC_ALPHA;
|
|
|
|
blender.SourceConstantAlpha = 255;
|
|
|
|
|
|
|
|
/* Create a surface of appropriate size and clear it */
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32,
|
|
|
|
window_size.cx,
|
|
|
|
window_size.cy);
|
2018-03-20 11:05:26 +00:00
|
|
|
cairo_surface_set_device_scale (surface, impl->surface_scale, impl->surface_scale);
|
2016-03-16 18:16:33 +00:00
|
|
|
cr = cairo_create (surface);
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
|
|
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
|
|
|
|
cairo_paint (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cairo_surface_flush (surface);
|
|
|
|
hdc = cairo_win32_surface_get_dc (surface);
|
|
|
|
|
|
|
|
/* No API_CALL() wrapper, don't check for errors */
|
|
|
|
UpdateLayeredWindow (hwnd, NULL,
|
|
|
|
&window_position, &window_size,
|
|
|
|
hdc, &source_point,
|
|
|
|
0, &blender, ULW_ALPHA);
|
|
|
|
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-12-11 16:26:34 +00:00
|
|
|
/* Ensure that maximized window size is corrected later on */
|
|
|
|
if (cmd_show == SW_MAXIMIZE)
|
|
|
|
impl->maximizing = TRUE;
|
|
|
|
|
2016-03-16 18:16:33 +00:00
|
|
|
return ShowWindow (hwnd, cmd_show);
|
|
|
|
}
|
|
|
|
|
2016-03-15 10:15:14 +00:00
|
|
|
static void
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_set_shadow_width (GdkSurface *window,
|
2020-07-24 13:54:49 +00:00
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom)
|
2016-03-15 10:15:14 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
2016-03-15 10:15:14 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (window))
|
2016-03-15 10:15:14 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_win32_surface_set_shadow_width: window %p, "
|
2016-03-15 10:17:45 +00:00
|
|
|
"left %d, top %d, right %d, bottom %d\n",
|
|
|
|
window, left, top, right, bottom));
|
|
|
|
|
2020-12-31 09:27:40 +00:00
|
|
|
impl->zero_shadow = left == 0 && right == 0 && top == 0 && bottom == 0;
|
2016-03-15 10:17:45 +00:00
|
|
|
|
2020-12-31 09:27:40 +00:00
|
|
|
if (impl->zero_shadow)
|
2016-03-15 10:17:45 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-16 04:24:47 +00:00
|
|
|
impl->shadow.left = left * impl->surface_scale;;
|
2020-12-31 09:27:40 +00:00
|
|
|
impl->shadow.right = right * impl->surface_scale;
|
2021-06-16 04:24:47 +00:00
|
|
|
impl->shadow.top = top * impl->surface_scale;;
|
2020-12-31 09:27:40 +00:00
|
|
|
impl->shadow.bottom = bottom * impl->surface_scale;
|
|
|
|
impl->shadow_x = left + right;
|
|
|
|
impl->shadow_y = top + bottom;
|
2016-03-15 10:15:14 +00:00
|
|
|
}
|
|
|
|
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
int
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
_gdk_win32_surface_get_scale_factor (GdkSurface *surface)
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkWin32Surface *impl;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
GdkWin32Display *win32_display;
|
|
|
|
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
if (GDK_SURFACE_DESTROYED (surface))
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
return 1;
|
|
|
|
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
g_return_val_if_fail (surface != NULL, 1);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
display = gdk_surface_get_display (surface);
|
|
|
|
impl = GDK_WIN32_SURFACE (surface);
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
|
|
|
|
win32_display = GDK_WIN32_DISPLAY (display);
|
|
|
|
|
|
|
|
if (win32_display->dpi_aware_type != PROCESS_DPI_UNAWARE)
|
|
|
|
{
|
|
|
|
if (win32_display->has_fixed_scale)
|
2018-03-20 11:05:26 +00:00
|
|
|
impl->surface_scale = win32_display->surface_scale;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
else
|
GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:
* Drop the preceding underscore.
* Dropping an unused parameter.
* Using a GdkSurface instead of a HWND, as the HWND that we pass into
this function might have been taken from a GdkSurface, which are now
always created with CS_OWNDC. This means if a GdkSurface was passed
in, we ensure that we only acquire the DC from the HWND once, and do
not attempt to call ReleaseDC() on it.
* Store the HDC that we acquire from the GdkSurface's HWND into the
surface, and use that as the HDC we need for our GdkGLContext.
* Drop the gl_hwnd from GdkWin32Display, as that is really should be
stored in the GdkSurface.
* For functions that were updated, name GdkWin32Display variables as
display_win32 and GdkSurface variables as surface, to unify things.
* Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
they were acquired from HWND's created with CS_OWNDC.
2021-07-19 10:20:09 +00:00
|
|
|
impl->surface_scale = gdk_win32_display_get_monitor_scale_factor (win32_display,
|
|
|
|
surface,
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
NULL);
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
return impl->surface_scale;
|
GDK-Win32/4.0: Enable HiDPI support for Windows
This enables HiDPI support for GTK+ on Windows, so that the
fonts and window look better on HiDPI displays. Notes for the current
work:
-The DPI awareness enabling can be disabled if and only if an application
manifest is not embedded in the app to enable DPI awareness AND a user
compatibility setting is not set to limit DPI awareness for the app, via
the envvar GDK_WIN32_DISABLE_HIDPI. The app manifest/user setting for
DPI awareness will always win against the envvar, and so the HiDPI items
will be always setup in such scenarios, unless DPI awareness is disabled.
-Both automatic detection for the scaling factor and setting the scale
factor using the GDK_SCALE envvar are supported, where the envvar takes
precedence, which will therefore disable automatic scaling when
resolution changes.
-We now default to a per-system DPI awareness model, which means that we
do not handle WM_DPICHANGED, unless one sets the
GDK_WIN32_PER_MONITOR_HIDPI envvar, where notes for it are in the
following point.
-Automatic scaling during WM_DISPLAYCHANGE is handled (DPI setting change of
current monitor) is now supported. WM_DPICHANGED is handled as well,
except that the window positioning during the change of scaling still
needs to be refined, a change in GDK itself may be required for this.
-I am unable to test the wintab items because I don't have such devices
around.
https://bugzilla.gnome.org/show_bug.cgi?id=768081
2016-06-27 05:16:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (win32_display->has_fixed_scale)
|
|
|
|
{
|
|
|
|
static gsize hidpi_msg_displayed = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&hidpi_msg_displayed))
|
|
|
|
{
|
|
|
|
g_message ("Note: GDK_SCALE is ignored as HiDPI awareness is disabled.");
|
|
|
|
g_once_init_leave (&hidpi_msg_displayed, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Application is not DPI aware, don't bother */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 09:09:49 +00:00
|
|
|
static void
|
2020-03-01 19:29:06 +00:00
|
|
|
gdk_win32_surface_set_input_region (GdkSurface *window,
|
|
|
|
cairo_region_t *input_region)
|
2016-12-19 09:09:49 +00:00
|
|
|
{
|
|
|
|
/* Partial input shape support is implemented by handling the
|
|
|
|
* NC_NCHITTEST message
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2020-12-31 08:36:41 +00:00
|
|
|
static void
|
|
|
|
compute_toplevel_size (GdkSurface *surface,
|
|
|
|
gboolean update_geometry,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
GdkToplevelSize size;
|
|
|
|
int bounds_width, bounds_height;
|
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
|
|
|
|
monitor = gdk_display_get_monitor_at_surface (display, surface);
|
|
|
|
if (monitor)
|
|
|
|
{
|
|
|
|
GdkRectangle workarea;
|
|
|
|
|
|
|
|
gdk_win32_monitor_get_workarea (monitor, &workarea);
|
|
|
|
bounds_width = workarea.width;
|
|
|
|
bounds_height = workarea.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bounds_width = G_MAXINT;
|
|
|
|
bounds_height = G_MAXINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
|
|
|
|
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
|
|
|
|
g_warn_if_fail (size.width > 0);
|
|
|
|
g_warn_if_fail (size.height > 0);
|
|
|
|
*width = size.width;
|
|
|
|
*height = size.height;
|
|
|
|
|
|
|
|
if (size.shadow.is_valid)
|
|
|
|
{
|
|
|
|
gdk_win32_surface_set_shadow_width (surface,
|
|
|
|
size.shadow.left,
|
|
|
|
size.shadow.right,
|
|
|
|
size.shadow.top,
|
|
|
|
size.shadow.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update_geometry)
|
|
|
|
{
|
|
|
|
GdkGeometry geometry;
|
|
|
|
GdkSurfaceHints mask;
|
|
|
|
GdkToplevelLayout *layout = impl->toplevel_layout;
|
|
|
|
|
|
|
|
if (gdk_toplevel_layout_get_resizable (layout))
|
|
|
|
{
|
|
|
|
geometry.min_width = size.min_width;
|
|
|
|
geometry.min_height = size.min_height;
|
|
|
|
mask = GDK_HINT_MIN_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geometry.max_width = geometry.min_width = *width;
|
|
|
|
geometry.max_height = geometry.min_height = *height;
|
|
|
|
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
|
|
|
|
}
|
|
|
|
gdk_win32_surface_set_geometry_hints (surface, &geometry, mask);
|
|
|
|
gdk_surface_constrain_size (&geometry, mask, *width, *height, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gdk_win32_surface_request_layout (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
int scale = impl->surface_scale;
|
|
|
|
RECT rect;
|
|
|
|
|
2021-06-16 04:24:47 +00:00
|
|
|
if (impl->drag_move_resize_context.native_move_resize_pending)
|
2020-12-31 08:36:41 +00:00
|
|
|
{
|
|
|
|
surface->width = impl->next_layout.configured_width;
|
|
|
|
surface->height = impl->next_layout.configured_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_gdk_win32_get_window_rect (surface, &rect);
|
|
|
|
|
2021-03-15 01:56:28 +00:00
|
|
|
impl->next_layout.configured_width = (rect.right - rect.left + scale - 1) / scale;
|
|
|
|
impl->next_layout.configured_height = (rect.bottom - rect.top + scale - 1) / scale;
|
2021-06-16 04:24:47 +00:00
|
|
|
|
|
|
|
if (GDK_IS_TOPLEVEL (surface))
|
|
|
|
{
|
|
|
|
surface->x = rect.left / scale;
|
|
|
|
surface->y = rect.top / scale;
|
|
|
|
}
|
|
|
|
else if (GDK_IS_POPUP (surface))
|
|
|
|
{
|
|
|
|
gdk_win32_surface_get_geometry (surface,
|
|
|
|
&surface->x, &surface->y,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
2020-12-31 08:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_gdk_win32_surface_compute_size (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
if (GDK_IS_TOPLEVEL (surface))
|
|
|
|
compute_toplevel_size (surface, TRUE, &width, &height);
|
|
|
|
|
2021-02-02 08:45:45 +00:00
|
|
|
if (!impl->drag_move_resize_context.native_move_resize_pending)
|
2020-12-31 08:36:41 +00:00
|
|
|
{
|
|
|
|
surface->width = impl->next_layout.configured_width;
|
|
|
|
surface->height = impl->next_layout.configured_height;
|
|
|
|
|
|
|
|
_gdk_surface_update_size (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
static void
|
2019-05-19 03:09:05 +00:00
|
|
|
gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
|
2011-01-02 10:51:25 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-05-19 03:09:05 +00:00
|
|
|
GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
|
2011-01-02 10:51:25 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2019-05-19 03:09:05 +00:00
|
|
|
object_class->dispose = gdk_surface_win32_dispose;
|
|
|
|
object_class->finalize = gdk_surface_win32_finalize;
|
2015-04-29 07:31:08 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
impl_class->hide = gdk_win32_surface_hide;
|
|
|
|
impl_class->get_geometry = gdk_win32_surface_get_geometry;
|
|
|
|
impl_class->get_device_state = gdk_surface_win32_get_device_state;
|
|
|
|
impl_class->get_root_coords = gdk_win32_surface_get_root_coords;
|
|
|
|
|
2020-03-01 19:29:06 +00:00
|
|
|
impl_class->set_input_region = gdk_win32_surface_set_input_region;
|
2018-03-20 10:40:08 +00:00
|
|
|
impl_class->destroy = gdk_win32_surface_destroy;
|
|
|
|
|
|
|
|
//impl_class->beep = gdk_x11_surface_beep;
|
|
|
|
|
|
|
|
impl_class->destroy_notify = gdk_win32_surface_destroy_notify;
|
|
|
|
impl_class->drag_begin = _gdk_win32_surface_drag_begin;
|
|
|
|
impl_class->get_scale_factor = _gdk_win32_surface_get_scale_factor;
|
2020-12-31 08:36:41 +00:00
|
|
|
impl_class->request_layout = _gdk_win32_surface_request_layout;
|
|
|
|
impl_class->compute_size = _gdk_win32_surface_compute_size;
|
2011-01-02 10:51:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HGDIOBJ
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_win32_surface_get_handle (GdkSurface *window)
|
2011-01-02 10:51:25 +00:00
|
|
|
{
|
2019-05-19 03:09:05 +00:00
|
|
|
if (!GDK_IS_WIN32_SURFACE (window))
|
2011-09-09 14:17:29 +00:00
|
|
|
{
|
|
|
|
g_warning (G_STRLOC " window is not a native Win32 window");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
return GDK_SURFACE_HWND (window);
|
2011-01-02 10:51:25 +00:00
|
|
|
}
|
2020-03-12 04:34:45 +00:00
|
|
|
|
|
|
|
#define LAST_PROP 1
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32Surface parent_instance;
|
|
|
|
} GdkWin32Popup;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32SurfaceClass parent_class;
|
|
|
|
} GdkWin32PopupClass;
|
|
|
|
|
|
|
|
static void gdk_win32_popup_iface_init (GdkPopupInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWin32Popup, gdk_win32_popup, GDK_TYPE_WIN32_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
|
|
|
gdk_win32_popup_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_popup_init (GdkWin32Popup *popup)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_popup_get_property (GObject *object,
|
2021-06-15 08:01:09 +00:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2020-03-12 04:34:45 +00:00
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
g_value_set_object (value, surface->parent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
g_value_set_boolean (value, surface->autohide);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_popup_set_property (GObject *object,
|
2021-06-15 08:01:09 +00:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2020-03-12 04:34:45 +00:00
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_PARENT:
|
|
|
|
surface->parent = g_value_dup_object (value);
|
|
|
|
if (surface->parent != NULL)
|
|
|
|
surface->parent->children = g_list_prepend (surface->parent->children, surface);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_POPUP_PROP_AUTOHIDE:
|
|
|
|
surface->autohide = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_popup_class_init (GdkWin32PopupClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_win32_popup_get_property;
|
|
|
|
object_class->set_property = gdk_win32_popup_set_property;
|
|
|
|
|
|
|
|
gdk_popup_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_popup_present (GdkPopup *popup,
|
2021-06-15 08:01:09 +00:00
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GdkPopupLayout *layout)
|
2020-03-12 04:34:45 +00:00
|
|
|
{
|
|
|
|
return gdk_win32_surface_present_popup (GDK_SURFACE (popup), width, height, layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_win32_popup_get_surface_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.surface_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGravity
|
|
|
|
gdk_win32_popup_get_rect_anchor (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->popup.rect_anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_win32_popup_get_position_x (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gdk_win32_popup_get_position_y (GdkPopup *popup)
|
|
|
|
{
|
|
|
|
return GDK_SURFACE (popup)->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_popup_iface_init (GdkPopupInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_win32_popup_present;
|
|
|
|
iface->get_surface_anchor = gdk_win32_popup_get_surface_anchor;
|
|
|
|
iface->get_rect_anchor = gdk_win32_popup_get_rect_anchor;
|
|
|
|
iface->get_position_x = gdk_win32_popup_get_position_x;
|
|
|
|
iface->get_position_y = gdk_win32_popup_get_position_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32Surface parent_instance;
|
|
|
|
} GdkWin32Toplevel;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32SurfaceClass parent_class;
|
|
|
|
} GdkWin32ToplevelClass;
|
|
|
|
|
|
|
|
static void gdk_win32_toplevel_iface_init (GdkToplevelInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWin32Toplevel, gdk_win32_toplevel, GDK_TYPE_WIN32_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
|
|
|
gdk_win32_toplevel_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_init (GdkWin32Toplevel *toplevel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
gdk_win32_surface_set_title (surface, g_value_get_string (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
|
|
|
gdk_win32_surface_set_transient_for (surface, g_value_get_object (value));
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
2020-07-27 08:59:05 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
2020-10-06 07:06:47 +00:00
|
|
|
GDK_SURFACE (surface)->modal_hint = g_value_get_boolean (value);
|
|
|
|
|
|
|
|
if (GDK_SURFACE (surface)->modal_hint)
|
2020-10-08 07:55:29 +00:00
|
|
|
{
|
|
|
|
SetCapture (GDK_SURFACE_HWND (surface));
|
|
|
|
_gdk_push_modal_window (surface);
|
|
|
|
}
|
2020-10-06 07:06:47 +00:00
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
2020-07-27 08:59:05 +00:00
|
|
|
break;
|
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
2020-09-15 07:37:32 +00:00
|
|
|
GDK_WIN32_SURFACE (surface)->decorate_all = g_value_get_boolean (value);
|
2020-07-27 08:59:05 +00:00
|
|
|
_gdk_win32_surface_update_style_bits (surface);
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
2020-03-12 04:34:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE:
|
|
|
|
surface->fullscreen_mode = g_value_get_enum (value);
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
|
|
|
|
break;
|
|
|
|
|
2020-03-27 16:14:52 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
break;
|
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STATE:
|
|
|
|
g_value_set_flags (value, surface->state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TITLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_STARTUP_ID:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
|
2020-03-12 11:01:30 +00:00
|
|
|
g_value_set_object (value, surface->transient_for);
|
2020-03-12 04:34:45 +00:00
|
|
|
break;
|
|
|
|
|
2020-07-27 08:59:05 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
|
2020-10-06 07:06:47 +00:00
|
|
|
g_value_set_boolean (value, GDK_SURFACE (surface)->modal_hint);
|
2020-07-27 08:59:05 +00:00
|
|
|
break;
|
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
|
|
|
|
g_value_set_pointer (value, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
|
2020-09-15 07:37:32 +00:00
|
|
|
g_value_set_boolean (value, GDK_WIN32_SURFACE (surface)->decorate_all);
|
2020-03-12 04:34:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE:
|
|
|
|
g_value_set_enum (value, surface->fullscreen_mode);
|
|
|
|
break;
|
|
|
|
|
2020-03-27 16:14:52 +00:00
|
|
|
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
|
|
|
|
g_value_set_boolean (value, surface->shortcuts_inhibited);
|
|
|
|
break;
|
|
|
|
|
2020-03-12 04:34:45 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_class_init (GdkWin32ToplevelClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->get_property = gdk_win32_toplevel_get_property;
|
|
|
|
object_class->set_property = gdk_win32_toplevel_set_property;
|
|
|
|
|
|
|
|
gdk_toplevel_install_properties (object_class, 1);
|
|
|
|
}
|
|
|
|
|
2020-12-11 02:37:43 +00:00
|
|
|
static void
|
2020-03-12 04:34:45 +00:00
|
|
|
gdk_win32_toplevel_present (GdkToplevel *toplevel,
|
2020-07-30 21:06:59 +00:00
|
|
|
GdkToplevelLayout *layout)
|
2020-03-12 04:34:45 +00:00
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (toplevel);
|
2020-12-31 08:36:41 +00:00
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
2020-07-30 21:06:59 +00:00
|
|
|
int width, height;
|
2020-12-16 10:53:19 +00:00
|
|
|
gboolean maximize;
|
|
|
|
gboolean fullscreen;
|
2020-03-12 04:34:45 +00:00
|
|
|
|
2020-12-31 08:36:41 +00:00
|
|
|
g_clear_pointer (&impl->toplevel_layout, gdk_toplevel_layout_unref);
|
|
|
|
impl->toplevel_layout = gdk_toplevel_layout_copy (layout);
|
|
|
|
compute_toplevel_size (surface, FALSE, &width, &height);
|
2020-03-12 11:01:30 +00:00
|
|
|
gdk_win32_surface_resize (surface, width, height);
|
2020-03-12 04:34:45 +00:00
|
|
|
|
2020-12-16 10:53:19 +00:00
|
|
|
if (gdk_toplevel_layout_get_maximized (layout, &maximize))
|
|
|
|
{
|
|
|
|
if (maximize)
|
|
|
|
gdk_win32_surface_maximize (surface);
|
|
|
|
else
|
|
|
|
gdk_win32_surface_unmaximize (surface);
|
|
|
|
}
|
2020-03-12 04:34:45 +00:00
|
|
|
|
2020-12-16 10:53:19 +00:00
|
|
|
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
|
|
|
|
{
|
|
|
|
if (fullscreen)
|
|
|
|
gdk_win32_surface_fullscreen (surface);
|
|
|
|
else
|
|
|
|
gdk_win32_surface_unfullscreen (surface);
|
|
|
|
}
|
2020-03-12 04:34:45 +00:00
|
|
|
|
2020-12-11 02:29:28 +00:00
|
|
|
gdk_win32_surface_show (surface, FALSE);
|
|
|
|
maybe_notify_mapped (surface);
|
2020-03-12 04:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_toplevel_minimize (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
gdk_win32_surface_minimize (GDK_SURFACE (toplevel));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_toplevel_lower (GdkToplevel *toplevel)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_focus (GdkToplevel *toplevel,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
gdk_win32_surface_focus (GDK_SURFACE (toplevel), timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_toplevel_show_window_menu (GdkToplevel *toplevel,
|
|
|
|
GdkEvent *event)
|
|
|
|
{
|
|
|
|
return gdk_win32_surface_show_window_menu (GDK_SURFACE (toplevel), event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
|
|
|
|
{
|
2020-03-12 11:01:30 +00:00
|
|
|
return FALSE;
|
2020-03-12 04:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_toplevel_iface_init (GdkToplevelInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_win32_toplevel_present;
|
|
|
|
iface->minimize = gdk_win32_toplevel_minimize;
|
|
|
|
iface->lower = gdk_win32_toplevel_lower;
|
|
|
|
iface->focus = gdk_win32_toplevel_focus;
|
|
|
|
iface->show_window_menu = gdk_win32_toplevel_show_window_menu;
|
|
|
|
iface->supports_edge_constraints = gdk_win32_toplevel_supports_edge_constraints;
|
2020-05-17 16:35:45 +00:00
|
|
|
iface->begin_resize = gdk_win32_toplevel_begin_resize;
|
|
|
|
iface->begin_move = gdk_win32_toplevel_begin_move;
|
2020-03-12 04:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32Surface parent_instance;
|
|
|
|
} GdkWin32DragSurface;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GdkWin32SurfaceClass parent_class;
|
|
|
|
} GdkWin32DragSurfaceClass;
|
|
|
|
|
|
|
|
static void gdk_win32_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWin32DragSurface, gdk_win32_drag_surface, GDK_TYPE_WIN32_SURFACE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
|
|
|
gdk_win32_drag_surface_iface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_drag_surface_init (GdkWin32DragSurface *surface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_drag_surface_class_init (GdkWin32DragSurfaceClass *class)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_win32_drag_surface_present (GdkDragSurface *drag_surface,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
GdkSurface *surface = GDK_SURFACE (drag_surface);
|
|
|
|
|
2020-12-11 02:29:28 +00:00
|
|
|
gdk_win32_surface_resize (surface, width, height);
|
|
|
|
gdk_win32_surface_show (surface, FALSE);
|
|
|
|
maybe_notify_mapped (surface);
|
2020-03-12 04:34:45 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_win32_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
|
|
|
|
{
|
|
|
|
iface->present = gdk_win32_drag_surface_present;
|
|
|
|
}
|
2018-07-31 10:11:26 +00:00
|
|
|
|
2020-08-03 10:22:51 +00:00
|
|
|
|
2020-08-05 02:43:11 +00:00
|
|
|
static void
|
2020-08-03 10:22:51 +00:00
|
|
|
gdk_win32_surface_get_queued_window_rect (GdkSurface *surface,
|
|
|
|
int scale,
|
|
|
|
RECT *return_window_rect)
|
|
|
|
{
|
|
|
|
RECT window_rect;
|
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
|
|
|
|
_gdk_win32_get_window_client_area_rect (surface, scale, &window_rect);
|
|
|
|
|
|
|
|
/* Turn client area into window area */
|
|
|
|
_gdk_win32_adjust_client_rect (surface, &window_rect);
|
|
|
|
|
|
|
|
*return_window_rect = window_rect;
|
|
|
|
}
|
|
|
|
|
2020-08-05 02:43:11 +00:00
|
|
|
static void
|
2020-08-03 10:22:51 +00:00
|
|
|
gdk_win32_surface_apply_queued_move_resize (GdkSurface *surface,
|
|
|
|
RECT window_rect)
|
|
|
|
{
|
|
|
|
if (!IsIconic (GDK_SURFACE_HWND (surface)))
|
|
|
|
{
|
|
|
|
GDK_NOTE (EVENTS, g_print ("Setting window position ... "));
|
|
|
|
|
|
|
|
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (surface),
|
|
|
|
SWP_NOZORDER_SPECIFIED,
|
|
|
|
window_rect.left, window_rect.top,
|
|
|
|
window_rect.right - window_rect.left,
|
|
|
|
window_rect.bottom - window_rect.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW));
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS, g_print (" ... set window position\n"));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't move iconic windows */
|
|
|
|
/* TODO: use SetWindowPlacement() to change non-minimized window position */
|
|
|
|
}
|
2020-08-05 02:36:53 +00:00
|
|
|
|
|
|
|
RECT
|
|
|
|
gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context)
|
|
|
|
{
|
|
|
|
GdkSurface *surface;
|
|
|
|
GdkWin32Surface *impl;
|
|
|
|
int scale;
|
|
|
|
RECT queued_window_rect;
|
|
|
|
|
|
|
|
surface = gdk_draw_context_get_surface (draw_context);
|
|
|
|
impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
scale = gdk_surface_get_scale_factor (surface);
|
|
|
|
|
|
|
|
gdk_win32_surface_get_queued_window_rect (surface, scale, &queued_window_rect);
|
|
|
|
|
2020-11-05 08:24:40 +00:00
|
|
|
/* Apply queued resizes for non-double-buffered windows
|
2020-08-05 02:36:53 +00:00
|
|
|
* before painting them (we paint on the window DC directly,
|
|
|
|
* it must have the right size).
|
|
|
|
* Due to some poorly-undetstood issue delayed
|
|
|
|
* resizing of double-buffered windows can produce weird
|
|
|
|
* artefacts, so these are also resized before we paint.
|
|
|
|
*/
|
2020-11-05 08:24:40 +00:00
|
|
|
if (impl->drag_move_resize_context.native_move_resize_pending)
|
2020-08-05 02:36:53 +00:00
|
|
|
{
|
|
|
|
impl->drag_move_resize_context.native_move_resize_pending = FALSE;
|
|
|
|
gdk_win32_surface_apply_queued_move_resize (surface, queued_window_rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
return queued_window_rect;
|
|
|
|
}
|
2021-07-14 04:19:52 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface)
|
|
|
|
{
|
|
|
|
/* If we are using ANGLE, we need to force redraw of the whole Window and its child windows
|
|
|
|
* as we need to re-acquire the EGL surfaces that we rendered to upload to Cairo explicitly,
|
|
|
|
* using gdk_window_invalidate_rect (), when we maximize or restore or use aerosnap
|
|
|
|
*/
|
2021-10-07 07:26:49 +00:00
|
|
|
#ifdef HAVE_EGL
|
2021-07-14 04:19:52 +00:00
|
|
|
if (surface->gl_paint_context != NULL && gdk_gl_context_get_use_es (surface->gl_paint_context))
|
|
|
|
{
|
|
|
|
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
|
|
|
|
|
|
|
impl->egl_force_redraw_all = TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|