Commit Graph

12196 Commits

Author SHA1 Message Date
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
566c484317 cicpparams: Guard with BEGIN/END_DECLS
I want to include this header from DirectX C++ code.
2024-11-04 21:50:26 +01:00
Benjamin Otte
5822989e82 gdk: Add missing G_END_DECLS 2024-11-04 21:50:26 +01:00
Benjamin Otte
70c327993b win32: Remove unused macro 2024-11-04 21:50:26 +01:00
Luca Bacci
7d45beb830 Gdk: Remove unused files 2024-11-04 10:13:53 +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
20b50c80d3 Merge branch 'for-main' into 'main'
docs: Fix a few copy-paste errors

See merge request GNOME/gtk!7884
2024-10-30 14:39:35 +00:00
Benjamin Otte
8b9ab19f15 docs: Fix various issues in texture builder docs 2024-10-30 09:37:06 -04:00
Matthias Clasen
926e969abb docs: Fix a few copy-paste errors 2024-10-30 09:18:17 -04:00
Matthias Clasen
c8cc8c4842 Merge branch 'amolenaar/color-picker-min-version' into 'main'
macos: Check for minimal macOS SDK version (>= 10.15)

See merge request GNOME/gtk!7881
2024-10-30 11:26:35 +00:00
Arjan Molenaar
5b78ee2227 macos: Remove obsolete version check blocks.
All code works on macOS 10.15+.
2024-10-30 11:04:15 +01:00
Matthias Clasen
64d56746e8 Tweak init requirement for displays
gdk_display_get_default is nullable, so it is less painful
and more practical to simply return NULL if GDK hasn't been
initialized yet.
2024-10-28 23:45:55 -04:00
Benjamin Otte
f4bcb80ab8 Merge branch 'wip/otte/most-important-source-ever' into 'main'
Rework the Wayland source again

Closes #7091

See merge request GNOME/gtk!7865
2024-10-28 21:54:26 +00:00
Benjamin Otte
239f45ce8e wayland: Split event source into two
We need to guarantee that we call wayland_display_read_events() after a
poll() and before any other source runs, including any source with
higher priority.

As GSourceFuncs doesn't have a after_poll() vfunc and check() is not
guaranteed to be called for anything but the highest priority, we only
have once chance:
Run with the highest priority

But because we don't want event delivery with ultrahigh priority, we
split the source into two:
 * a poll source that polls while blocking wayland reading and
   then immediately calls read_events() with priority G_MININT
 * our old trusty event source with PRIORITY_EVENTS that dispatches
   events

Fixes !7859
Fixes #7091
2024-10-28 13:34:09 +01:00
Emmanuele Bassi
5a2d55c4d3 docs: Add some markup
Use <kbd> for keys, to improve the consistency of our docs.
2024-10-25 16:49:58 +00:00
Matthias Clasen
c1e5609565 docs: Drop mention of X from general docs
Our docs should not allude to specifics of X11, unless they are
about the X11 backend.
2024-10-25 12:45:33 -04:00
Matthias Clasen
aef6b1b932 Merge branch 'inspector/extensions' into 'main'
inspector: List all extensions

See merge request GNOME/gtk!7866
2024-10-25 11:40:12 +00:00
Matthias Clasen
06ef33271f gdk: Export feature keys privately
Export these. They will be used in the inspector in later commits.
2024-10-24 23:04:37 -04:00
Matthias Clasen
bee6e3acc5 Merge branch 'android_misc' into 'main'
Non directly android-backend related changes for the android backend

See merge request GNOME/gtk!7817
2024-10-25 00:05:24 +00:00
Benjamin Otte
4eba4ad640 wayland: Move all GSource handling into gdkeventsource.c 2024-10-24 17:29:33 +02:00
Benjamin Otte
0722ede806 wayland: Remove unused variable 2024-10-24 17:29:33 +02:00
Benjamin Otte
6b0e1ed7dc wayland: Rename source functions
It's a GdkWaylandEventSource, name the function accordingly.
2024-10-24 17:29:33 +02:00
Benjamin Otte
8454ec7181 Revert "wayland: Don't block the event queue"
This reverts commit a9723fc96b.

This approach was wrong as it can lead to deadlocks when multiple
threads call poll() at almost the same time and the slower thread only
starts poll()ing when the faster thread has already read the fd.

See further comments for a (hopefully) correct fix.

Reverts !7859
2024-10-24 17:29:33 +02: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
Matthias Clasen
71b065cf07 Merge branch 'bugfix/compile-32-bit' into 'main'
gdk/loaders/gdkjpeg.c: fix compilation on 32-bit systems

See merge request GNOME/gtk!7721
2024-10-24 03:04:18 +00:00
Matthias Clasen
b1a82942ee Merge branch 'wip/otte/block-the-clock' into 'main'
wayland: Don't block the event queue

Closes #7091

See merge request GNOME/gtk!7859
2024-10-23 03:06:42 +00:00
Benjamin Otte
a9723fc96b wayland: Don't block the event queue
The Wayland source was blocking the Wayland display queue between its
check() and prepare() callbacks.

This is a rare event to cause problems because it requires
1. Another source with
2. a higher priority that
3. triggers at the same time as the Wayland source and
4. triggers a roundtrip or other operation that requires reading events
   from the display.

Introduced in commit 2893526a48 during GTK 3.21, so this should
probably be fixed in GTK3, too.

Fixes #7091
2024-10-22 23:38:13 +02:00
Thomas Devoogdt
45680ffc8f gdk/loaders/gdkjpeg.c: fix compilation on 32-bit systems
../gdk/loaders/gdkjpeg.c: In function ‘gdk_save_jpeg’:
../gdk/loaders/gdkjpeg.c:291:32: error: passing argument 3 of ‘jpeg_mem_dest’ from incompatible pointer type [-Wincompatible-pointer-types]
  291 |   jpeg_mem_dest (&info, &data, &size);
      |                                ^~~~~
      |                                |
      |                                gulong * {aka long unsigned int *}
In file included from ../gdk/loaders/gdkjpeg.c:30:
/home/thomas/br-test-pkg/bootlin-armv7-glibc/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/jpeglib.h:979:28: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘gulong *’ {aka ‘long unsigned int *’}

See multiple versions:

https://www.ijg.org/files/jpegsrc.v9c.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  3
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       unsigned long * outsize));

https://www.ijg.org/files/jpegsrc.v9d.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  4
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       size_t * outsize));

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jpeglib.h
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jconfig.h.in
- #define LIBJPEG_TURBO_VERSION  @VERSION@
- EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
                           unsigned long *outsize);

The jpegsrc changed the method signature with the v9d release,
libjpeg-turbo did not changed it's signature (yet).

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-10-22 17:16:35 +02:00
Emmanuele Bassi
3fac7762d7 docs: Fix typo in Gdk.ContentProvider.new_union
It's GDK_TYPE_TEXTURE, not G_TYPE_TEXTURE.

Fixes: #7106
2024-10-22 14:04:01 +01:00
Matthias Clasen
a1d9b3e47d Merge branch 'display-init' into 'main'
gdk: No displays before init

See merge request GNOME/gtk!7836
2024-10-21 22:53:50 +00:00
Benjamin Otte
a84cbe22d1 Merge branch 'wip/otte/win32-fixes' into 'main'
win32: Various fixes

See merge request GNOME/gtk!7848
2024-10-21 21:39:30 +00:00
Matthias Clasen
1f20d0c9ed gdk: Spread the errors
Call gdk_ensure_initialized() directly in gdk_display_open_default(),
gdk_display_open(), gdk_x11_display_open() and gdk_display_get_default(),
so we get the right function name in the error message. These functions
are likely candidates that people might call without ensuring that GDK is
initialized.
2024-10-21 13:30:19 -04:00
Matthias Clasen
c239788a34 gdk: No displays before init
Don't allow to create displays before gdk has been initialized.

Note that this error triggers in nautilus 47.0, but we consider
what it is doing unsupported and broken.

Related: #7035
2024-10-21 13:30:19 -04:00