Commit Graph

1846 Commits

Author SHA1 Message Date
Chun-wei Fan
0376e4668c GDK/Win32: Fix gdk_display_get_name()
We switched to using the Unicode (UTF-16) versions of the Windows API by
default, so we also obtain the display name in UTF-16 form as well.

This updates the implementation in the Windows backend so that we
properly acquire the names that we need in UTF-16, and then convert the
results to UTF-8, which is what we use in GTK/GLib.
2024-08-30 08:47:01 +08:00
Luca Bacci
f4bd883003 GdkWin32: Try to call _gdk_surface_update_size() only when the size actually changed
Otherwise we adapt Vulkan and OpenGL swap chains a lot and we effectively
disable incremental rendering.

Note that the fix is not complete.
2024-08-26 17:05:19 +02:00
Luca Bacci
0fcdadc531 GdkWin32GLContextWGL: Use the previous frames paint regions kept by GdkGLContext
We do this because:

 a) The parent class (GdkGLContext) already stores the paint regions of
    previous frames, no need to do the same.
 b) The painted region passed to end_frame () includes the backbuffer's
    damage region, so it's not really what we want.

This also fixes a leak of cairo_region_t that I introduced by mistake
in !7418
2024-08-26 17:05:13 +02:00
Chun-wei Fan
cc1c3799b6 Merge branch 'wgl-report-damage' into 'main'
GdkWin32GLContextWGL: Add support for incremental rendering

See merge request GNOME/gtk!7418
2024-08-21 02:37:41 +00:00
Matthias Clasen
39e6301f42 win32: Adapt to default flag changes
I hope this change does the right thing.
2024-08-19 21:37:49 -04:00
Chun-wei Fan
e14670d457 gdksurface-win32.c: Call _gdk_surface_update_size() more
The current resizing implementation in the GDK-Win32 backend is not
telling GDK early enough for Vulkan that a resize in the surface (i.e.
HWND) is done, so that GDK can re-create swapchain in time, which is
apparent on nVidia drivers (and AMD drivers that utilize the mailbox
presentation mode on Windows) when the HWND is being enlarged
interactively.

To work around this, bar a refactor in the Windows resizing/presentation
code, is to call _gdk_surface_update_size() when we really did resize
the HWND when we handle queued resizes via SetWindowsPos().

The existing call in gdksurface-win32.c in
_gdk_win32_surface_compute_size() remains required, otherwise the
surface won't display initially.

Thanks to Benjamin Otte for pointing this possibility out.
2024-08-19 11:25:50 +08:00
Luca Bacci
d3e3ddf897 WGL: Report paint region when presenting (SwapBuffers)
Report the paint region to the OpenGL driver, which in turn may
report it to the system compositor (DWM).
2024-08-12 18:56:45 +02:00
Luca Bacci
fca983e81e WGL: Report backbuffer's damage to GDK
The backbuffer's damage region is the region of the backbuffer
that doesn't contain up-to-date contents. This is determined
by the backbuffer's age and previous frame's paint regions.

This enables incremental rendering
2024-08-12 18:56:34 +02:00
Sergey Bugaev
85830c059e Plug GTask leaks
The error-prone pattern seems to be:

  GTask *task = g_task_new (...);

  if (condition)
    {
      g_task_return_... (task, ...);
      /* need g_object_unref (task) here! */
      return;
    }

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-05 14:38:23 +03:00
Luca Bacci
ccc6f7c24e GdkWin32: Drop unused variable
We still check whether depth buffer bits must be > 0,
we just don't use that variable anymore.
2024-07-24 15:36:25 +02:00
Luca Bacci
41b21b6634 WGL: Search pixel format with defined swap method (opengl32)
We want to get PFD_SWAP flags as that's required to enable incremental
rendering. However, as documented on MSDN, ChoosePixelFormat ignores
PFD_SWAP flags.

We may get PFD_SWAP flags or not depending on the way the OpenGL driver
orders its pixel formats. While PFD_SWAP flags are very important for
GUI toolkits, they are best avoided by games, as most games render the
scene in its entirety on each frame. Drivers optimized for games tend
to order pixel formats with no PFD_SWAP flags first.

Se we implement our own method to select the best pixel format. We check
for usable pixel formats and assign penalties for each one, until we find
a format with 0 penalty or the sequence ends. Then the best pixel format
is selected.
2024-07-24 15:36:25 +02:00
Luca Bacci
b46a900d71 WGL: Search pixel format with defined swap method (arb)
Getting a defined swap method is necessary to enable incremental
rendering. We cannot just add a swap method attribute since
exchange is generally preferred, but is not always available.
Here we try to infer what the driver prefers, then ask for
exchange or copy, in sequence.
2024-07-24 15:35:40 +02:00
Benjamin Otte
ab7d969700 gdk: Add color state arg to gdk_texture_download_surface()
All callers set it to SRGB at the moment.
2024-07-11 14:57:20 +02:00
Benjamin Otte
1b1e7f4296 drawcontext: Make begin_frame() set colorstate + depth
Make begin_frame() set a rendering colorstate and depth, and provide it
to the renderers via gdk_draw_context_get_depth() and
gdk_draw_context_get_color_state().

This allows the draw contexts to define their own values, so that ie the
Cairo and GL renderer can choose different settings for rendering (in
particular, GL can choose GL_SRGB and do the srgb conversion; while
Cairo relies on the renderer).
2024-07-11 14:57:20 +02:00
Matthias Clasen
8841a002ed Merge branch 'build-with-unicode' into 'main'
Windows: Build with UNICODE

See merge request GNOME/gtk!7230
2024-05-29 23:20:01 +00:00
Matthias Clasen
6da606aaad Merge branch 'issue-6401-legacy' into 'main'
Win32 GL: Also force not to use depth/stencil/accum bits on legacy contexts (for issue #6401)

See merge request GNOME/gtk!7176
2024-05-29 23:18:04 +00:00
Luca Bacci
7f9363d471 Windows: Build with UNICODE
Build with UNICODE (and _UNICODE) defined when targeting Windows.
2024-05-28 16:37:48 +02:00
g.willems
aa057da1ca win32: Guarantee dnd-move as a cursor name
gdk currently falls back to the default cursor, which may not be
approriate for rendering a DnD move.
2024-05-22 20:55:21 +02:00
Georges Basile Stavracas Neto
7d2ad604d2 win32/vulkancontext: Remove unused variable
Silences a compiler warning.
2024-05-03 09:52:57 -03:00
Georges Basile Stavracas Neto
45e64b915c win32/wgl: Initialize hwnd to NULL
Otherwise there's a valid code path that may return it uninitialized.
2024-05-03 09:51:46 -03:00
Georges Basile Stavracas Neto
ebaef9f18b win32/cursor: Ignore GdkPixbuf deprecation warning
Seems harmless to ignore this for now, other bits of code also ignore
this.
2024-05-03 09:49:46 -03:00
Chun-wei Fan
54a86a2a7e Win32 GL: Also force not to use depth/stencil/accum bits on legacy contexts
For completeness' sake, also specifiy in the PIXELFORMATDESCRIPTOR to use no
depth, stencil and accum bits to initializing WGL when we can't (yet) use
wglChoosePixelFormatARB(), as we must always fist have a base legacy WGL
context using ChoosePixelFormat() before we can use that to use
wglChoosePixelFormatARB(), or if wglChoosePixelFormatARB() is somehow not
available for us.

Some drivers, however, enforces enabling depth buffers, so if we can't
acquire a pixel format that disables depth buffers, retry acquiring one
with that, which sadly is not optimal but we must make do.

Attempts to complete fix for issue #6401.
2024-04-24 16:23:17 +08:00
Matthias Clasen
d1bb1d091c Merge branch 'gdk-build-dep-fix' into 'main'
build: Add a missing dependency

Closes #6618

See merge request GNOME/gtk!7127
2024-04-11 20:57:34 +00:00
Matthias Clasen
6510b876d1 build: Add a missing dependency
Add the generated gdk headers to the sources for all the backends,
to guarantee that they are generated before the library is used.

Fixes: #6618
2024-04-11 15:47:38 -04:00
Luca Bacci
2e15225446 Merge branch 'remove-work-arounds' into 'main'
GdkWin32: Remove some work arounds that are not needed anymore

Closes #6614

See merge request GNOME/gtk!7114
2024-04-11 17:03:08 +00:00
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
8a1bee1d79 GdkWin32: Don't explicitly set the transient owner as active
...when a transient child is hidden.

The system does that automatically
2024-04-06 10:58:25 +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
Matthias Clasen
b1a3ac8330 win32: Handle callback cursors
This implementation matches the X11 one closely.
2024-04-04 01:07:28 +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
Matthias Clasen
02a7a30978 Merge branch 'disable-depth-test' into 'main'
GL, NGL: Disable depth test

Closes #6401

See merge request GNOME/gtk!6917
2024-02-19 19:14:36 +00:00
Luca Bacci
73e8b39bc6 WGL: Initialize PIXELFORMATDESCRIPTOR structure 2024-02-19 18:16:35 +01:00
Luca Bacci
72b2938e43 WGL: Request that no depth, stencil and accum buffers be created
Unspecified attributes are not interpreted as "leave this feature out",
rather as "pick a default value". For depth, stencil and accum bits the
defaults may be different than 0. For example, with AMD drivers we get:

 * WGL_DEPTH_BITS_ARB:   32
 * WGL_STENCIL_BITS_ARB: 8
 * WGL_ACCUM_BITS_ARB:   0

Set the attributes to 0 as a hint that depth, stencil and accum buffers
should not be created.

The driver may still create them (matching criteria is "minimum" [1]),
but that's outside of our control (and unlikely to happen).

References:

 [1] - WGL_ARB_pixel_format specification
       https://registry.khronos.org/OpenGL/extensions/ARB/WGL_ARB_pixel_format.txt

See #6401
2024-02-19 18:15:52 +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
Luca Bacci
57dde7e877 GdkWin32: Implement GdkDrawContext::empty_frame() vfunc 2024-01-30 16:23:28 +01:00
Arjan Molenaar
6e7893d527 Let GdkDisplay decide if shadows should be drawn
Replace the `#ifdef` blocks by a backend call.
2024-01-25 12:09:10 +01:00
Matthias Clasen
59578c6d18 Fix typos throughout
These were pointed out by codespell.
2024-01-07 20:44:05 -05:00
Luca Bacci
4e5456c8c3 GdkWin32: Do not create multiple WGL contexts for the dummy window
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6285
2023-12-27 16:26:06 +01:00
g.willems
dfe7afdb04 gdk/win32: support default-settings debug flag 2023-12-09 17:59:24 +01:00
Matthias Clasen
f04c819439 Drop the gl-legacy debug value
The consensus is that we can do without this.
2023-11-20 08:02:02 -05:00
Matthias Clasen
025b846fce Add a debug value to prefer desktop GL
This will be used in the next commit, when we change the default
preference to be GLES.
2023-11-19 08:07:02 -05:00
Luca Bacci
0b853f62ed Merge branch '6203_gdk_win32_precalculate_keymap' into 'main'
GdkWin32: precalculate keymap at display opening

Closes #6203

See merge request GNOME/gtk!6566
2023-11-18 13:24:21 +00:00
g.willems
ad08c1444a win32: precalculate keymap at display opening
The default keymap and keymap layouts are calculated on request.
If done once a surface is setup and listening at win32 events,
we may then enter in a recursive loop.
To avoid this, precalculate the keymap as soon as displays are open.

Fixes #6203
Closes #6203
2023-11-14 20:26:05 +01:00
g.willems
a58424588f win32: switch to new clipboard API
This is a backport of !1143 to gtk4.

SetClipboardViewer() API is obsolete is prone to clipboard chain breaks
from other applications.
Use recommended AddClipboardFormatListener() instead.

Fixes #442
2023-11-13 21:29:48 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Luca Bacci
822425072b Merge branch '5724_gdk_win32_ignore_invalid_client_rect' into 'main'
Gdk4 Win32: ignore invalid client rects

Closes #5724

See merge request GNOME/gtk!6414
2023-10-04 07:58:55 +00: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
17c59d6da6 GdkWin32: Unref GdkMonitor after calling gdk_monitor_invalidate ()
Ensure that we have a reference when calling gdk_monitor_invalidate ()

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6080
2023-09-19 18:46:41 +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