Commit Graph

1920 Commits

Author SHA1 Message Date
Chun-wei Fan
45b19724c8 GDK/Win32: Drop AeroSnap emulation
It turns out that this AeroSnap emulation can really get in the way
as we try to modernize and clean up the codebase, so drop the support,
and so clean up the GDK/Win32 code a bit as a result.

We really want to clean up the event handling and resizing handling a
bit here.
2024-11-27 11:17:00 +08:00
Luca Bacci
1ef7ca800b GdkWin32: Call epoxy_handle_external_wglMakeCurrent
...where we call wglMakeCurrent directly, to inform libepoxy
that the current GL context changed (and thus the current DC
and pixel format may have changed). Skipping the call is not
an issue in practice, since most drivers return the same
pointers regardless of the pixel format (as long as it's an
ICD pixel format instead of the GDI software implementation),
but it's the correct thing to do.
2024-11-18 12:09:38 +01:00
Luca Bacci
8e15dcd5ab GdkWin32: Fix paste of color-indexed bitmaps when biClrUsed is zero
Patch proposed by user @Dwedit in #6685

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6685
2024-11-18 12:09:31 +01:00
Luca Bacci
281f8bb967 GdkWin32: Don't check if modal operation is in progress
...within modal_timer_proc. If the timer is active, it means
that the modal operation is in progress, no need to check.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7147
2024-11-18 11:45:52 +01:00
Chun-wei Fan
be70ff1772 Merge branch 'lb90/for-main' into 'main'
For main

Closes #7075

See merge request GNOME/gtk!7898
2024-11-06 09:39:15 +00:00
Luca Bacci
12b0613b34 GdkWin32: Pass the right arguments when calling modal_timer_proc directly
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7075
2024-11-05 11:16:08 +01:00
Benjamin Otte
3d578e8db5 win32: Use gdk_win32_com_clear() where appropriate 2024-11-05 02:45:37 +01:00
Benjamin Otte
2ed6867084 win32: Define COBJMACROS via project argument
We use it everywhere, so it makes sense to enable it everywhere.

For anyone not in the know, defining COBJMACROS makes Micrsoft headers
for COM objects provide C macros so that instead of having to call
  foo->lpVtbl->Release();
to unref a COM object, one can call
  IFoo_Release (foo);

Note that thes macros are implemented with inheritance as Release()
is defined on the IUnknown base interface (MS' equivalent to GObject)
and would otherwise require
  IUnknown_Release ((IUnknown *) foo);
That line works, too - but it is not necessary.
2024-11-05 02:45:37 +01:00
Benjamin Otte
ef839e6505 win32: Add gdk_win32_com_clear()
Like g_clear_object(), but for COM objects.
2024-11-05 02:45:37 +01:00
Benjamin Otte
70c327993b win32: Remove unused macro 2024-11-04 21:50:26 +01:00
Luca Bacci
e75308ad11 GdkWin32: Rework display's beep vfunc to only use MessageBeep
Beep is synchronous, let's just move away from it.

Also add an explicit cast for signed to unsigned conversion.
2024-11-04 10:11:33 +01:00
Luca Bacci
ccecf5916f GdkWin32: Stub out the display's flush and sync vfuncs
There's nothing relevant to do
2024-11-04 10:05:45 +01:00
Benjamin Otte
13aa4f5fe8 win32: Don't return existing display from gdk_display_open()
Existing code assumes displays are new connections and calls
gdk_display_close() on the display when done with whatever it was
doing.

If we return an existing display, that display gets closed...

It's also what the other backends do, including MacOS.

Fixes gsk/misc test.
2024-10-31 15:27:43 +01:00
Benjamin Otte
06d61c5d39 win32: Stop sending clipboard_hwnd to main thread
With the switch to using the glib main context in the clipboard thread,
the clipboard hwnd is no longer used for sending messages.

This means it's not necessary to know it in the main thread.

And that means there's no small window where the clipboard thread spins
up and the window doesn't exist and any copy operation fails.
The main context can be created before spinning up the thread so
that is avoided.

Fixes the gtk/textbuffer test in the testsuite.
2024-10-31 15:27:43 +01:00
Benjamin Otte
4b4e7276f6 win32: Do async clipboard thread via main loop
Instead of sending windows messages, use the main loop.
This is closer to the expectations of GTK developers and has better
thread safety handling as no HWND is needed as a messaging queue token.
2024-10-31 15:27:43 +01:00
Benjamin Otte
a4323259e5 win32: Split out a function 2024-10-31 15:27:43 +01:00
Benjamin Otte
ae5f581e47 win32: Remove useless code
The function is checking and early-exiting in this situation anyway.
2024-10-31 15:27:43 +01:00
Benjamin Otte
17f391b4e7 win32: "unpop" items from clipboard queue
We can indeed "unpop" items from the clipboard queue, the function is
called g_async_queue_push_front().

So do that instead of tracking a GList.
2024-10-31 15:27:43 +01:00
Benjamin Otte
a7670bfcc5 gdk: Add GDK_DISABLE=aerosnap
Disables the Aerosnap hook for Windows which is particularly useful
when debugging because the aerosnap hook slows down keyboard input.
2024-10-31 15:27:43 +01:00
Benjamin Otte
4b32ac3341 win32: Use the builder argument
We can straight build content formats these days, no need for a detour.
2024-10-31 15:27:43 +01:00
Benjamin Otte
6af853c7a0 win32: Some trivial cleanups
* Make a function static

* Don't lookup function that exists since Windows XP
2024-10-31 15:27:43 +01:00
Benjamin Otte
741b369b2a win32: Remove unused variable
The variable was last used in GTK3.
2024-10-31 15:27:42 +01:00
Benjamin Otte
0b62165bf2 clipboard: Run a GMainLoop in the clipboard thread
Use the new message source to do the task of processing messages.
2024-10-31 15:27:42 +01:00
Benjamin Otte
517ec1112c win32: Add GdkWin32MessageSource
The source does nothing but run PeekMessage() + DispatchMessage().
But we need it in every thread where we want to use a main loop.

No users yet.
2024-10-31 15:27:42 +01:00
Benjamin Otte
4dec70e1a6 gdk: Remove unused display vfunc
But it's nice that everyone still implements it.
2024-10-24 17:24:43 +02:00
Benjamin Otte
a74457697e build: Fix MSVC warning due to Pango bug
Pango unconditionally defines STRICT, which we use, see
https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict

And that causes a duplicate definition, so we undefined it before
including the offending Pango header.

See also https://gitlab.gnome.org/GNOME/pango/-/merge_requests/749
2024-10-21 07:35:42 +02:00
Benjamin Otte
2646785e4c build: Fix MSVC warning about non-matching types 2024-10-21 07:35:41 +02:00
Benjamin Otte
591bc5edc0 build: Work around duplicated define of APIENTRY
epoxy defines it if windows.h hasn't been included.
So include windows.h before epoxy.

See also https://github.com/anholt/libepoxy/issues/299
2024-10-21 07:35:41 +02:00
Benjamin Otte
f907d8a17a win32: Don't crash when threads start too slow
Passing on-stack items to a thread in a function that exits right
after spawning the threads is a bad idea:
By the time the thread starts up and reads the values, the stack might
be in use for other stuff.

So instead of putting the items on the stack, just read them out of the
clipdrop struct.
2024-10-19 22:33:54 +02:00
Benjamin Otte
fddd5f33ab win32: Avoid g_warning() when layout doesn't exist
If the registry key doesn't exist, it doesn't warrant a warning.

We hit that case in CI and it aborts every test during startup.
2024-10-19 20:22:03 +02:00
Benjamin Otte
b28b2ea768 win32: Embed quirks struct in display struct
No need to manually allocate it (and then not freeing it in dispose ;)).
2024-10-18 11:59:04 +02:00
Benjamin Otte
d96f2bcde6 win32: Always try WGL_SUPPORT_GDI_ARB
We can avoid a quirk here by always trying WGL_SUPPORT_GDI_ARB
first and falling back when it's not supported.
2024-10-18 11:59:04 +02:00
Luca Bacci
834f20e2a7 Merge branch 'gdk-win32-cleanup' into 'main'
GdkWin32 Cleanup

See merge request GNOME/gtk!7810
2024-10-10 19:26:54 +00:00
Luca Bacci
a0c823e11d Meson: Define _WIN32_WINNT in the toplevel meson.build file 2024-10-10 14:34:28 +02:00
Luca Bacci
419758576f Win32: Do not define STRICT
STRICT is defined automatically by Windows SDK and mingw-w64 headers
2024-10-10 10:58:35 +02:00
Luca Bacci
0ee985bd5b Remove unneeded defines 2024-10-10 10:58:26 +02:00
Luca Bacci
0113fdc8d5 Merge branch 'gdk-win32-purge-globals' into 'main'
GDK/Win32: Drop most of the global variables

See merge request GNOME/gtk!7804
2024-10-10 08:26:30 +00:00
Luca Bacci
20bdb0d7d5 Merge branch 'wgl-updates' into 'main'
WGL: Avoid using swap exchange on NVidia drivers

Closes #7019

See merge request GNOME/gtk!7776
2024-10-08 10:24:02 +00:00
Luca Bacci
f840ae1337 WGL: Avoid using swap method exchange on NVidia drivers
It seems that NVidia sets PFD_SWAP_EXCHANGE / WGL_SWAP_EXCHANGE_ARB
on pixel formats but doesn't guarantee that the backbuffer age is
constantly 2. My guess is that they use swap exchange only to signal
usage of a flip present method.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7019
2024-10-08 11:27:05 +02:00
Chun-wei Fan
b6269a3234 gdkevents-win32.c: Drop AeroSnap global variables
Put them into our GdkWin32Display under an appropriate sub-struct.
2024-10-07 14:37:40 +08:00
Chun-wei Fan
2879f6a99b gdkevents-win32.c: Drop event debug indent global variable
Tuck it as appropriate into our GdkWin32Display.
2024-10-07 14:37:40 +08:00
Chun-wei Fan
03a86b4667 GDK/Win32: Drop global variable on both shifts pressed 2024-10-07 14:37:39 +08:00
Chun-wei Fan
7eb96c39c5 GDK/Win32: Drop global variable tracking IME state
Tuck it into our GdkDisplay structure under an appropriate sub-struct.
2024-10-07 14:37:38 +08:00
Chun-wei Fan
b4c5a7af69 GDK/Win32: Fold pen input global vars into GdkDeviceManagerWin32
This way, we just grab and set the values from there.
2024-10-07 14:37:38 +08:00
Chun-wei Fan
d120aaf6ee GDK/Win32: Drop global variables from GdkKeys implementation
We get to create our GdkKey with a display as a property for free, so
just stuff the default keymap and keymap serial (to track IME state
changes and so) into our GdkWin32Display under an existing sub-struct
that is for holding these items.
2024-10-07 14:37:23 +08:00
Chun-wei Fan
004d787cb2 Gdk/Win32: Drop _gdk_display global variable
On Windows, we really only support a single GdkDisplay, so we can just
make the GdkDisplay that we obtain a property of our GdkDeviceManagerWin32
and GdkWin32Screen objects, and so we can just do away with the global
_gdk_display global variable.

This way, we can also drop the venerable gdkglobals-win32.c source file.
Yay!
2024-10-07 12:07:05 +08:00
Chun-wei Fan
7b554240f3 GDK/Win32: Drop modal surface-related global variables
Tuck them into GdkWin32Display as we track these operations.
2024-10-07 12:01:08 +08:00
Chun-wei Fan
7837f342e9 GdkDeviceManagerWin32: Drop global variables
Tuck the wintab global variables into the GdkDeviceManagerWin32
structure, and initialize and utilize items accordingly.
2024-10-07 12:01:07 +08:00
Chun-wei Fan
236139c78a gdkdisplay-win32.c: Drop debug_indent global variable
Instead, use [Set|Get]WindowLongPtr(), to store and retrieve that
value from the notification window HWND that we are using, as it
is where we are using that value.
2024-10-07 12:01:06 +08:00
Chun-wei Fan
789bb83b5a GDK/Win32: Drop surface tracking global variables
...including the list of modal surfaces and hashes of opened HWNDs for
various surfaces, and tuck them into GdkWin32Display.
2024-10-07 12:00:59 +08:00