Commit Graph

1681 Commits

Author SHA1 Message Date
Luca Bacci
8a6d6fe6b1 DirectManipulation: Account for DPI scale 2022-05-24 11:37:06 +02:00
Luca Bacci
288dd406e0 GdkWin32: Plug memory leak 2022-05-19 08:49:05 +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
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Luca Bacci
66a0e0a59e GdkWin32: Send smooth scroll events
Bring back smooth scroll events as the issues mentioned
in [1] do not occur anymore. Also rework code style and
comments.

References:

  [1] GTK4: Scrolling hides mouse on windows
      https://gitlab.gnome.org/GNOME/gtk/-/issues/3581

  [2] Why are mouse wheel messages delivered to the focus window
      instead of the window under the mouse?
      https://devblogs.microsoft.com/oldnewthing/20160420-00/?p=93325
2022-05-06 15:01:59 +02:00
Luca Bacci
cb0c1b3f08 GdkWin32: Generate crossing event after button release
Fixes #4813
2022-04-06 20:27:46 +02:00
Luca Bacci
91f200167e GdkWin32: Correct generation of crossing events when holding an implicit grab
Fixes #4722
2022-04-06 20:27:32 +02:00
Luca Bacci
2b6fb005a8 GdkWin32: Report serial for events 2022-04-06 19:45:50 +02:00
Chun-wei Fan
8519ab56f5 gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote()
The call to gdk_win32_clipboard_request_contentformats() can return NULL even
without an error condition being hit (such as when the system clipboard is
empty), so check whether the returned GdkContentFormat pointer is not NULL
before calling gdk_clipboard_claim_remote(), which expects it to be not NULL,
otherwise we face a warning from that funtion and the subsequent
g_object_unref().

This at least partially fixes issue #4796.
2022-03-31 10:55:39 +08:00
panoplie
fb4927827b gdk: Add enum to indicate the unit of scroll deltas
Add a new GdkScrollUnit enum that represent the
unit of scroll deltas provided by GdkScrollEvent.
The unit is accessible through
gdk_scroll_event_get_unit().
2022-03-19 00:41:26 +01:00
Luca Bacci
d3acfa8c2b Merge branch 'gdk-win32-configure-as-needed-fullscreen' into 'main'
GdkWin32: Configure as needed when fullscreening toplevels

Closes #4631

See merge request GNOME/gtk!4506
2022-02-28 15:11:36 +00:00
Philip Zander
e5a4b91997 gdkkeys-win32: Only perform substitution as last-resort
Instead of performing keyboard layout substitution whenever we find a matching
entry in the registry, first try to load the original layout and only attempt
substitution when that fails.

See #4724
2022-02-27 16:40:58 +01:00
Luca Bacci
828688d5cd Fix last error reporting when calling GetClipboardOwner
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1402
2022-02-25 17:14:39 +01: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
43476c09ed GdkWin32: Remove implicit_grab_surface 2022-02-21 17:38:50 +01:00
Philip Zander
037c0e4005
gdkkeys-win32: Also ignore Ctrl + Shift (etc.)
Some Windows keymaps have bogus mappings for the Ctrl modifier. !4423 attempted
to fix this by ignoring the Ctrl layer, but that was not enough. We also need to
ignore combinations of Ctrl with other modifiers, i.e. Ctrl + Shift. For example,
Ctrl + Shift + 6 is mapped to the character 0x1E on a US keyboard (but it should
be treated as Ctrl + ^). Basically, always ignore Ctrl unless it is used in
conjunction with Alt, i.e. as part of AltGr.

Related issue: #4667
2022-02-09 10:43:07 +01:00
Philip Zander
90ab8b8dd3
gdkkeys-win32: Ignore CTRL bit for key translation
Some keymaps on Windows contain bogus mappings for Ctrl+key for certain
keys, e.g. Ctrl+Backspace = Delete, or Ctrl+[ = 0x1B. These are never
used on Windows, so we should ignore them.

Fixes #4667
2022-02-01 14:12:56 +01:00
Chun-wei Fan
0fe37d1828 gdkdisplay-win32.c: Clean up GL initialization further 2022-01-19 11:56:32 +08:00
Chun-wei Fan
6f2848c311 Cleanup "GDK/Win32: Try to fix initializing GLES contexts"
As per Benjamin's suggestions, cleanup the previous implementation on
initializing the GLES context on Windows, so that we use more items that are
already in GDK proper and integrate two functions into one.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
38c17c1f79 gdkglcontext-win32-wgl.c: Cleanup GL context creation
Instead of first trying to explicitly ask for a WGL 4.1 context, ask for
the WGL context version that matches what is reported via
epoxy_gl_version(), so that we get the maximum WGL version that is
supported by the graphics drivers, and make sure any WGL contexts that
are shared with this (initial) WGL context are created likewise.

We can try to do a default-bog-standard 3.2 core WGL context creation
if the need arises, but let's leave that alone for now.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
598c7d9cf4 GDK/Win32: Try to fix initializing GLES contexts
We are now able to create EGL contexts properly on Windows, but not GLES.  This
tries to fix things by doing the following:

*  Record the GL context type in a more proper fashion, using an Enum.  This
   makes things a bit cleaner.
*  Force GLES-3.0+ contexts, since libANGLE requires this to properly work with
   the shaders-its 2.0 contexts don't work well with our shaders.
2022-01-19 11:56:32 +08:00
Luca Bacci
243bb57a27
GdkWin32: Add translation result w/o CAPS LOCK to key events for accelerator matching 2022-01-17 14:14:55 +01:00
Luca Bacci
4916ebd05e
GdkWin32: Remove _gdk_input_codepage variable
It's unused
2022-01-17 14:14:55 +01:00
Luca Bacci
8bbf48eb64
GdkWin32: Code reorganization for gdk_event_translate 2022-01-17 14:14:47 +01:00
Philip Zander
b9bc7d9166 IMContextSimple/IMContextIME: Fix AltGr not working on Win32
The old code assumed that any key press containing Ctrl or Alt cannot be
regular text input. This is not correct on Win32 as AltGr = Ctrl + Alt.
2022-01-13 17:26:59 +01:00
David Hogan
7d6257cb1e
gdkkeys-win32: Perform keyboard layout substitution
For some users, GetKeyboardLayoutNameA() returns an alias instead of the
fully resolved keyboard layout identifier. In that case, we have to
query the registry to resolve the alias before we can look up the DLL
path.

See comments under https://gitlab.gnome.org/GNOME/gtk/-/issues/4610
2022-01-12 21:44:28 +01:00
Philip Zander
db0234ecb4
gdkkeys-win32: Fix handling of SGCAPS
Contrary to what you can read on the internet, SGCAPS keys don't work
by having capslock toggle the KBDCTRL bit, they actually have two
consecutive table entries, the first of which is for the normal
version and the second of which is for the capslocked version.

Background: SGCAPS is short for Swiss German caps because Swiss German
was the first layout to use this feature. For keys with the SGCAPS flag,
capslock has a different effect than pressing shift. For example:
Shift + ü = è,  CapsLock + ü = Ü,  CapsLock + Shift + ü = È
2022-01-12 21:44:24 +01:00
Philip Zander
438fad803e
gdkkeys-win32: Fix crash when keyboard DLL failed to load
DLL loading failures should not happen under normal circumstances, but
we should at least try not to crash and and print better diagnostic
messages if they do happen.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/4610
2022-01-12 21:44:15 +01:00
Philip Zander
82f8f878bc
gdkkeys-win32: Add keysym mapping for capslock key
Add missing mapping between VK_CAPITAL and GDK_KEY_Caps_Lock, so
applications get a meaningful keyval rather than ffffff.
2022-01-12 21:44:07 +01:00
Philip Zander
b0818f9535
gdkkeys-win32: Fix capslock handling
Previously, we treated CapsLock and KanaLock as part of the global
keyboard state, much like NumLock and ScrollLock, rather than using
the supplied modifier mask. This was because GDK does not have a
modifier mask for KanaLock, only for CapsLock, so it would not have been
possible to properly support it.

However, this approach ended up causing problems, with certain keyboard
shortcuts not registering when capslock was active. This was first
observed in Inkscape [0] and appears to affect shortcuts consisting of a
single key (like 'a') with no additional modifiers (wheareas shortcuts
like 'ctrl+a' work).

So now we are using the supplied GDK_LOCK_MASK instead, and dropped
support for KanaLock, which we probably don't need anyway (since regular
text input should be handled by the IME input module -- the keymap is
mainly for shortcuts and keybindings, where you don't really want
KanaLock).

[0] https://gitlab.com/inkscape/inkscape/-/issues/3082
2022-01-12 21:43:53 +01:00
Philip Zander
ea65abc7e2
Rewrite GdkWin32Keymap (load table directly from layout DLL)
The old code used repeated calls to `ToUnicodeEx` to populate
the translation table, which is slow and buggy. The new code
directly loads the layout driver DLLs from Windows.

See https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4338
2022-01-12 19:01:35 +01:00
Luca Bacci
07b04fbea9
Remove some unneeded files from gdk/win32
bdfcursor.c, cursor.bdf and libwntab32x.la
2022-01-02 18:49:44 +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
7a1004df73
Remove WM_SYNCPAINT message handler
It was added to work around what seemed to be an OS or graphics
driver issue on Windows XP. The issue was not reproducible on
Windows Vista anyway.

References:
* https://bugzilla.gnome.org/show_bug.cgi?id=153567
* https://gitlab.gnome.org/GNOME/gtk/-/commit/c8fef535
* https://devblogs.microsoft.com/oldnewthing/20120723-00/?p=7073
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
41599e5e90 GDK-Win32: Make EGL a runtime opt-in
Use the debug envvar 'GDK_DEBUG=gl-egl' to determine whether we want to try to
initialize EGL first before trying WGL, as a means for people to more easily
enable EGL support on Windows to test EGL there (such as to debug the shaders,
for instance)
2021-11-08 15:40:59 +08:00
Chun-wei Fan
1b2e69f6c0 GDK-Win32: Realize EGL using common realization code
This will clean up the EGL code in GDK-Win32, as well as fixing crashes caused
by using an invalid EGL context in gdk_gl_context_make_current() as we did not
store up the EGL context in the correct place (lost during the transition to
the common EGL initialization code).

On the Windows/libANGLE side, the initialization of EGL has now fully moved to
the common code in GDK, but we will still default on WGL for now.  Help is
really appreciated for fixing the shaders on libANGLE!
2021-11-08 15:40:49 +08: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
Luca Bacci
4c8e703803
GdkWin32: Remove the global screen offset
Removes the _gdk_offset_x / _gdk_offset_y variables,
as today are not needed anymore.
2021-11-07 19:08:30 +01:00
Luca Bacci
8338e55549
GdkWin32: Use a signed integral type for the DPI scale 2021-11-07 19:01:32 +01:00
Matthias Clasen
bddf9f9ca3 docs: Cosmetics
Do a round of "the the" removal.
2021-10-18 08:35:54 -04:00
Benjamin Otte
cf7ee82755 Merge branch 'fix-dnd-coordinates-on-windows' into 'master'
Fix DND coordinates on Windows

See merge request GNOME/gtk!3930
2021-10-16 17:04:26 +00:00