Commit Graph

187 Commits

Author SHA1 Message Date
Luca Bacci
3c94e91e5e GdkWin32: Do not clear surface contents when restoring from minimize
The code does not work anyway since we dropped WS_EX_LAYERED windows.
2024-04-06 10:58:40 +02:00
Luca Bacci
9297439de4 GdkWin32: Remove some work arounds that are not needed anymore
2cc650ce was added to work around some of the regressions
introduced by 79557271, but that commit was finally reverted
in 43476c09.

We can now revert 2cc650ce as well.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6614
2024-04-06 10:44:02 +02:00
Luca Bacci
8ffa681e02 GdkWin32: Always set WS_MINIMIZEBOX on GdkToplevel
Regardless if server-side decorated or not. This way the shell knows
that the window can be minimized.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3749
2024-03-22 16:47:59 +01:00
g.willems
fa3bbed200 GdkWin32: implement surface's icon_list property setter
The 'icon_list' implementation of gtk+3 was somehow dropped
during the early conversion of GdkWindow to GdkSurface for gtk4.
Add it again, with minor tweaks to support GdkSurface.

Share the GdkTexture-to-HICON internal API with GdkCursor.

This allows 'gtk_window_set_icon_name()' to work on win32.
2024-02-10 18:53:39 +01:00
G.Willems
4c46f5a8f7 GdkWin32: ignore invalid client rects
Gdk-Win32 uses GetClientRect() internally to query the surfaces coordinates,
but this API may fail in some transient contexts (observed when iconifying
a maximized window).
Check if the rect area is null, and don't update the surface position in
that case. This will keep the current surface size, until Win32 notifies
the new valid window state later.
This prevents using a nulled next_layout for toplevel size computation,
which would break widgets allocation once notified on gtk side.

Fixes #5724
Closes #5724
2023-09-19 20:29:04 +02:00
Luca Bacci
5b39abd1a4 Merge branch 'fix-server-side-decorations' into 'main'
win32: Fix minimize and maximize buttons missing on ssd

Closes #5142

See merge request GNOME/gtk!6052
2023-08-08 15:17:09 +00:00
Luca Bacci
a9082fa5fa GdkWin32: Remove unused members from GdkWin32Surface 2023-08-02 18:08:31 +02:00
Luca Bacci
5e9daa9728 GdkWin32: Unscaled coordinates in current_root_x, current_root_y
Also modify gdk_win32_surface_do_move_resize_drag() to take
unscaled root coordinates.

Fixes #5877
2023-06-21 16:01:42 +02:00
Luca Bacci
412bc1713a GdkWin32: Keep track of the last cursor position in move / resize contexts
...and avoid doing any work if the position hasn't changed.
2023-06-21 15:31:48 +02:00
Luca Bacci
51265e2367 Merge branch 'center-dialogs' into 'main'
win32: Center newly created transient windows

Closes #5407

See merge request GNOME/gtk!6050
2023-06-12 13:53:00 +00:00
dgsasha
5240d8cdf5 win32: Fix minimize and maximize buttons missing on ssd
Completely fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5142
2023-06-10 23:08:21 -04:00
dgsasha
84840f1f2e win32: Center newly created transient windows
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5407
2023-06-08 16:42:27 -04:00
Luca Bacci
1a058a41c9 Do not keep HINSTANCE variables around
Use &__ImageBase for the GTK DLL and GetModuleHandle (NULL)
for the application module. Then remove DllMain as it's not
necessary anymore.

References:

 [1] Accessing the current module's HINSTANCE from a static library:
     https://devblogs.microsoft.com/oldnewthing/20041025-00/?p=37483
2023-05-30 19:31:54 +02:00
Jason Francis
cf79ad4433
win32: implement fullscreen_on_monitor
Track the HMONITOR so it can be used by the toplevel layout.
2023-05-24 18:48:37 -04:00
Benjamin Otte
9d0448756f display: Remove ::create_surface() vfunc
Instead, have a toplevel_type and popup_type in GdkDisplay and
call g_object_new() with those types.
2023-04-26 21:03:34 +02:00
Benjamin Otte
cb642bec25 gdk: Remove GDK_SURFACE_DRAG enum member
I want to remove the whole enum, but this value was used all over the
place. So removing it first ensures I didn't forget anything.
2023-04-26 21:03:34 +02:00
Benjamin Otte
ab0fa08d8e win32: Create gdk_win32_draw_surface_new()
... and use it.
2023-04-26 21:03:34 +02:00
Benjamin Otte
77fe9116af win32: Set frame clock in constructed()
... instead of passing it as construct argument.
2023-04-26 21:03:34 +02:00
Benjamin Otte
4fa81cf70f win32: Move surface init code into ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte
9ac31fe0a0 win32: Abort on error
Returning NULL from a function that must not return NULL is not a good
idea.
2023-04-26 21:03:34 +02:00
Benjamin Otte
69fabb3ce9 win32: Remove outdated debug messages
They are not needed anymore as they print stuff that's no decided in
that function anymore.
2023-04-26 21:03:34 +02:00
Benjamin Otte
f59c230a96 win32: Move toplevel signal into the toplevel class 2023-04-26 21:03:34 +02:00
Benjamin Otte
7ef5f6ef1a display: Remove x/y/w/h from create_surface() 2023-04-26 21:03:34 +02:00
Matthias Clasen
075bea788b Add gdk_surface_get_scale
Add a scale property to GdkSurface and use the
fractional scale for it on Wayland.
2023-04-01 19:09:16 -04:00
Matthias Clasen
2bab8cca5f gdk: Rename GDK_SURFACE_TEMP
We use this value only for drag surfaces, so call it that.
2022-11-17 22:49:56 -05:00
Marc-André Lureau
cf04a3c99d gdk-win32: implement basic inhibit-system-shortcuts
This is largely adapted from commit 83027c68f1 ("11: Implement
inhibit_system_shortcuts API"), with similar rationale:

    To implement the inhibit_system_shortcuts API on X11, we emulate the
    same behavior using grabs on the keyboard.

    To avoid keeping active grabs on the keyboard that would affect
    other X11 applications even when the surface isn't focused, the X11
    implementation takes care of releasing the grabs as soon as the
    toplevel loses focus.

Note that Windows has low-level keyboard hooks that could help achieve
the expected behaviour. This is implemented by spice-gtk & gtk-vnc for
example, but correctness isn't obvious. I left a TODO comment.

This patch helps implementing remote desktop widgets with GTK4, since
currently on win32 backend Alt-Tab and such are always left to the
system unless there is keyboard grab (which can't be requested by the
client API anymore, afaict).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-11-09 19:29:03 +04:00
Marc-André Lureau
a92aea4c0e gdk-win32: fix unused variable warnings
../gdk/win32/gdksurface-win32.c: In function 'gdk_win32_get_window_size_and_position_from_client_rect':
../gdk/win32/gdksurface-win32.c:3753:20: warning: unused variable 'impl' [-Wunused-variable]
 3753 |   GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
      |                    ^~~~
../gdk/win32/gdksurface-win32.c: In function 'gdk_win32_surface_get_queued_window_rect':
../gdk/win32/gdksurface-win32.c:5129:20: warning: unused variable 'impl' [-Wunused-variable]
 5129 |   GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-11-09 19:19:44 +04:00
Marc-André Lureau
52e3ed13e2 gdk/win32: deprecate gdk_win32_handle_table_lookup
This function is probably not generally useful for a Gtk+/win32 user,
and it's only used internally by gdk-win32. It's time to deprecate it, I
believe.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-24 21:02:57 +04:00
Luca Bacci
ef831235fe Merge branch 'win32-gir' into 'main'
win32: various GI annotations and fixes

See merge request GNOME/gtk!4977
2022-08-24 09:41:11 +00:00
Marc-André Lureau
0d7a0132bb gdk/win32: annotate gdk_win32_surface_lookup_for_display
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 17:20:39 +04:00
Marc-André Lureau
cad32636ce gdk/win32: annotate gdk_win32_surface_set_urgency_hint
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 17:06:48 +04:00
Luca Bacci
d125fcd35a GdkWin32: Position popups on the primary monitor if outside of the visible screen area
Fixes a crash caused by attempting to dereference a NULL GdkMonitor*
in GdkWin32.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/5125
2022-08-23 14:54:01 +02:00
Marc-André Lureau
a6418d5028 gdk/win32: deprecate gdk_win32_surface_get_impl_hwnd
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:35:07 +04:00
Marc-André Lureau
3cbf6c9d6e gdk/win32: annotate gdk_win32_surface_get_handle
And adjust the argument precondition check.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:25:33 +04:00
Marc-André Lureau
a75de5fb90 gdk/win32: correct gdk_win32_surface_get_handle return type
The associated surface window handle is a HWND, not a HGDIOBJ.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:17:19 +04:00
Marc-André Lureau
180dd5fb7f gdk/win32: deprecate gdk_win32_surface_is_win32
The function isn't used by Gtk itself anymore, and does not help much.
It creates extra issues for bindings, as it doesn't fit well with code
doing the same job for other objects.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 15:34:50 +04:00
Luca Bacci
749425808d Fix typo
And reword comment
2022-08-19 19:29:17 +02:00
Luca Bacci
8f19099f1a GdkWin32: Add support for DirectManipulation
Adds support for Precision TouchPads (PTPs) gestures
and scroll events.
2022-05-15 14:37:55 +02:00
Luca Bacci
ab65e8e178 GdkWin32: Configure as needed when going fullscreen
Apply the fixes made by Chun-Wei Fan in [1] also for fullscreening /
unfullscreen. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4631

Also set the SWP_FRAMECHANGED flag as written by Raymond Chen in "How
do I switch a window between normal and fullscreen?" [2]

> An important flag to pass here is SWP_FRAME­CHANGED, which tells
> the window manager to recalculate the window decorations (which we
> need it to do because we just changed them).

References:
[1] - https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3712
[2] - https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353
2022-02-22 09:15:28 +01:00
Luca Bacci
2f685d5d2a
Remove leftover code dealing with input-only windows 2022-01-02 18:42:33 +01:00
Luca Bacci
4f7d18a28f
Do not use GetProcAddress for FlashWindowEx
It's available since Windows XP
2022-01-02 18:42:32 +01:00
Luca Bacci
c77272a7d7
Remove call to ShowOwnedPopups (FALSE) to hide owned windows
This is needed to fully support windows with the property
"destroy-with-parent" set to FALSE.
2022-01-02 18:42:31 +01:00
Luca Bacci
5e090c1fac Merge branch 'fix-3728-3799' into 'main'
GDK-Win32: Force toplevel surfaces to configure as needed (fix issues #3728 and #3799)

Closes #3728 and #3799

See merge request GNOME/gtk!3712
2021-12-16 14:58:03 +00:00
Chun-wei Fan
bdf879427c gdksurface-win32.c: Call gdk_surface_set_egl_native_window()
.. when creating the surface (with the HWND associated with the
newly-created surface) as well as destroying the surface (with NULL,
since the HWND is going to be destroyed), so that we can tie the EGL
calls to the HWND that we want to do the EGL stuff.
2021-12-03 10:39:59 +08:00
Chun-wei Fan
da535164b4 gdksurface-win32.c: Rename window->surface as appropriate
Update the functions that were updated in the previous commit to have all
GdkSurface variables named as 'surface' instead of the GTK-3.x-era window, to
make things more consistent across the board.  Also fix formatting a bit.
2021-12-01 17:32:40 +08:00
Chun-wei Fan
82d9570ed4 GDK-Win32: Make surface ready for updates
Make the toplevel surface respond to size computations unless it is just being
created, or maximized, made fullscreen or underwent an AeroSnap operation.

This will ensure that the surface size is properly computed in time, so that
surfaces can be resized as needed.

This will fix issues 3728 and 3799.
2021-12-01 17:32:40 +08:00
Luca Bacci
48b83d3e97 Merge branch 'win32-egl-cleanup' into 'master'
GDK-Win32: Port EGL code to newer common GDK code

See merge request GNOME/gtk!4040
2021-11-19 08:42:40 +00:00
Chun-wei Fan
b801125797
GDK-Win32: Fix AeroSnap indicator and positioning
Ensure that we take the DPI scaling into account so that surfaces will
be placed at their correct positions upon an AeroSnap operation on HiDPI
displays.

Also, use the X coordinate of the surface as-is during snap up so that
we do not inadvertently move the surface to the very left.  Also fix the
AeroSnap indicator drawing for snap up so that it is drawn at the
correct places.

Since we are updating these functions, make the old GdkWindow-era
variable names to match better the names we use nowadays.
2021-11-18 12:40:57 +01:00
Chun-wei Fan
048fe84888 GDK-Win32: Port to common EGL handling code
This will port the EGL code in GDK-Win32 to use the common GDK code to
initialize EGL.  However, at the current state, although EGL is
correctly initialized, this code is disabled for now since
gdk_gl_context_make_current() fails as the shaders do not work for EGL
via libANGLE on Windows.

We can now clean things up in gdkglcontext-win32-egl.c as a result.
2021-11-08 15:25:24 +08:00
Chun-wei Fan
480031439f GDK-Win32: Drop GDK_WIN32_ENABLE_EGL flag
Instead, use HAVE_EGL check macro instead, which is used by the other
platforms as well.
2021-11-08 15:25:24 +08:00