Commit Graph

9435 Commits

Author SHA1 Message Date
Matthias Clasen
d7c4f93c76 Merge branch 'wip/compute-size' into 'master'
Compute size via signal

See merge request GNOME/gtk!2325
2020-08-05 16:19:19 +00:00
Jonas Ådahl
2ff74eb667 gdk/toplevel: Negotiate surface size via a compute-size signal
GTK will not up front know how to correctly calculate a size, since it
will not be able to reliably predict the constraints that may exist
where it will be mapped.

Thus, to handle this, calculate the size of the toplevel by having GDK
emitting a signal called 'compute-size' that will contain information
needed for computing a toplevel window size.

This signal may be emitted at any time, e.g. during
gdk_toplevel_present(), or spontaneously if constraints change.

This also drops the max size from the toplevel layout, while moving the
min size from the toplevel layout struct to the struct passed via the
signal,

This needs changes to a test case where we make sure we process
GDK_CONFIGURE etc, which means we also needs to show the window and
process all pending events in the test-focus-chain test case.
2020-08-05 15:49:00 +02:00
Matthias Clasen
8870ec5e7b Merge branch 'hex-color-parse' into 'master'
Hex color parse

Closes #2931

See merge request GNOME/gtk!2356
2020-08-05 11:46:55 +00:00
Chun-wei Fan
edc1c28236 GdkGLContext: Drop gdk_gl_context_has_[framebuffer_blit|frame_terminator]()
gdk_gl_context_has_framebuffer_blit() and gdk_gl_context_has_frame_terminator()
were only used by by GDK/Win32, and they do not provide performance advantages
in GTK master, so clean up the code a bit by dropping them.
2020-08-05 18:56:57 +08:00
Chun-wei Fan
d2291abe2a gdksurface-win32.c: Fix resizing
Use gdk_surface_get_geometry() to get the correct x and y coordinates of the
window that we are resizing, so that the window does not reposition itself
automatically at the top-left corner at resizing as we to used hard-code the x
and y coordinates to 0.
2020-08-05 16:23:14 +08:00
Chun-wei Fan
5ce0098adc gdkvulkancontext-win32.c: Implement ->begin_frame()
By doing so, we ensure that resizes of windows will work on Vulkan renderer, by
first calling gdk_win32_surface_handle_queued_move_resize() before we proceed
as usual
2020-08-05 16:23:14 +08:00
Chun-wei Fan
46a8a3fe31 gdk[cairo|gl]context-win32.c: Use gdk_win32_surface_handle_queued_move_resize()
Use the shared function that was added in the previous commit, to simplify
things.

Also make gdk_win32_surface_get_queued_window_rect() and
gdk_win32_surface_apply_queued_move_resize() back into static functions, since
they are now used only by the code in gdksurface-win32.c
2020-08-05 16:23:14 +08:00
Chun-wei Fan
c6ada2a329 gdksurface-win32.c: Add function to handle queued moves/resizes
Since we need to deal with queued moves and resizes in the Cairo, GL and Vulkan
draw contexts, and the logic involved in all three of these are largely
similar, add a function gdk_win32_surface_handle_queued_move_resize() that will
handle this, which will be shared between these three types of draw contexts.
2020-08-05 16:23:12 +08:00
Chun-wei Fan
69bb4f8beb GDK-Win32: Move some functions around
Move gdk_win32_surface_get_queued_window_rect() and
gdk_win32_surface_apply_queued_move_resize() to gdksurface-win32.c, since these
functions are not only used for Cairo draw contexts, but is also used for GL
draw contexts, and will be used for Vulkan draw contexts.
2020-08-05 15:38:08 +08:00
Chun-wei Fan
06f28af80f gdksurface-win32.c: Fix Aerosnap computation
Don't get the default display when we compute the Aerosnap region, but instead
get it from the underlying GdkSurface that we are using for the computation.

Also, don't unref the monitors that we obtain from the display in the wrong
place, which was why we had crashes whenever we triggered AeroSnap code (and we
are actually not supposed to do that as they are owned by the GdkDisplay that
is owned by the GdkSurface we are using), and this will eliminate lots of
criticals that are spewed as a result.
2020-08-05 15:38:08 +08:00
Jonas Ådahl
4ee82e8175 gdk/toplevel: Fix typo in documentation 2020-08-04 16:53:10 +02:00
Matthias Clasen
9659d3f78a Merge branch 'applaunch-warning' into 'master'
x11: Ignore stray DestroyNotify events

Closes #3006

See merge request GNOME/gtk!2355
2020-08-03 03:30:59 +00:00
Matthias Clasen
1f3327d326 rgba: Use pango_color_parse_with_alpha
Use this newly exported pango function, so we
can support hex colors with alpha like #rrggbbaa.

Fixes: #2931
2020-08-02 23:30:33 -04:00
Matthias Clasen
4152e90e7e x11: Ignore stray DestroyNotify events
There's no use in making a delete event with a
NULL surface. Just ignore such events.

Fixes: #3006
2020-08-02 22:45:28 -04:00
Matthias Clasen
5a55f6ff7b gdk: Fix gdk_surface_get_layout_monitor
We are determining the monitor by maximizing the
intersection; that only works if our rectangle
is not empty.

Fixes: #3003
2020-08-02 21:29:18 -04:00
Rico Tzschichholz
371cdf3250 gdk/x11: Add annotations to improve GIR API 2020-07-31 20:56:36 +02:00
Matthias Clasen
1087ff48f0 Merge branch 'glib-build-fix' into 'master'
widget: Drop unnecessary includes

See merge request GNOME/gtk!2328
2020-07-31 18:52:50 +00:00
Matthias Clasen
358f66482d Merge branch 'master.win32' into 'master'
Some improvements for GDK/Win32

See merge request GNOME/gtk!2327
2020-07-31 17:10:47 +00:00
Carlos Garnacho
9564cba492 gdk: Fix toplevel calculation on pointer grab switch
This check used to read if (grab || device_type != GDK_DEVICE_TYPE_PHYSICAL),
the grab check was only reserved to physical devices, which the current
pointer device definitely doesn't act like. So the condition was "fixed" the
wrong way around, and the latter check is now moot, so the condition should
really go away. We always want to check the new toplevel under the pointer
here.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2970
2020-07-31 18:53:01 +02:00
Chun-wei Fan
20388f83f5 GDK-Win32: Use SetProcessDpiAwarenessContext() where available
This allows us to use DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 for the
DPI awareness mode, which will help us to better support use cases with
multiple monitors.  This is actualy a more advaned version of the
current PROCESS_PER_MONITOR_DPI_AWARE via using SetProcessDpiAwareness().

Note that this is not enabled by default, but also enabled via using
GDK_WIN32_PER_MONITOR_HIDPI, as in the PROCESS_PER_MONITOR_DPI_AWARE
case.

Note also, that appliation compatibility settings and DPI-awareness
manifests takes precedence over this API call, as before.
2020-07-31 23:20:25 +08:00
Chun-wei Fan
85706dc39d gdkglcontext-win32.c: Create a global shared GL context
Like the other backends, we ought to create our WGL/EGL GL contexts like
the following:

"Create a global GL context that connects all GL contexts on a display
and lets us share textures between them."
2020-07-31 23:19:28 +08:00
Chun-wei Fan
07166a55ee gdksurface-win32.c: Deal with modal and decoration props
Handle these cases, especially the modal case, which we did not handle
previously after the conversion to surface subtypes.
2020-07-31 23:19:28 +08:00
Matthias Clasen
2dfa5ac804 x11: Stop using GTimeVal
It has been deprecated, and that is breaking our
ci builds with -Werror.
2020-07-31 10:58:53 -04:00
Carlos Garnacho
96452a2e46 gdk: Rename gdk_seat_get_physical_devices() to gdk_seat_get_devices()
We don't want to tell what they are, and the distinction is now less
clear. Remove the adjective from the function name.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
46eb054337 gdk: Drop gdk_device_get_device_type()
There is no longer a hierarchy of devices, or none that is seen
on the outside.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
4a2050e220 gdk/x11: Make device type a X11 detail
The only legit uses of device types are here in gdk/x11, move the
concept of device type to X11, so we can drop it from public API.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
3c68db8e47 gdk: Make gdk_device_list_physical_devices() private
Physical devices should probably be accounted internally in gdk/x11,
make this out of private API so at least the implementation details
don't leak.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
9912c80d70 gdk: Drop gdk_device_get_associated_device()
Devices are no longer associated like this, the seat should be used
to resolve queries on other devices.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
7991032aeb gdk/x11: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:19:44 +02:00
Carlos Garnacho
0cbc857ea4 gdk/win32: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Carlos Garnacho
398c1d1ad7 gdk/macos: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Carlos Garnacho
94982dbab7 gdk: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Benjamin Otte
4dc2ab61c9 Merge branch 'wip/otte/geometry' into 'master'
Some GdkGeometry cleanups

See merge request GNOME/gtk!2322
2020-07-30 15:31:27 +00:00
Benjamin Otte
13d3afa56e Remove unused GDK_HINT_POS 2020-07-30 17:06:15 +02:00
Benjamin Otte
3dd0e6d0b1 Remove gravity from GdkGeometry
It's always northwest
2020-07-30 17:06:15 +02:00
Benjamin Otte
11db6ad574 Remove aspect ratio from GdkGeometry
It's unused.
2020-07-30 17:06:15 +02:00
Benjamin Otte
ebcef256ab gdk: Remove unused flags 2020-07-30 17:06:15 +02:00
Benjamin Otte
b12b06e917 gdk: Remove base_size and increment from GdkGeometry
It's unused.
2020-07-30 16:55:45 +02:00
Chun-wei Fan
a481733b40 GDK/Win32: Force GLES if running on ARM64
If GLES support is enabled on Windows, force GLES mode if we are running
on a ARM64 version of Windows (i.e. Windows 10 for ARM).

This is required as ARM64 versions of Windows only provide a software
implementation of OpenGL 1.1/1.2, which is not enough for our purposes.
Thus, we could make instead use the GLES support provided via Google's
libANGLE (which emulates OpenGL/ES 3 with Direct3D 9/11), so that we
can run GtkGLArea programs under OpenGL/ES in ARM64 versions of Windows.

Note that eventually we could update the libepoxy build files for Windows
to not check nor enable WGL when building for ARM64 Windows, as the WGL
items do not work, although they do build.
2020-07-30 14:30:13 +08:00
Chun-wei Fan
cf0175ffce OpenGL/ES: Fix 'R' and 'B' bits inverted on Windows
We need to use GL_BGRA instead of GL_RGBA when doing glReadPixels() on
EGL on Windows (ANGLE) so that the red and blue bits won't be displayed
inverted.

Also fix the logic where we determine whether to bit blit or redraw
everything.
2020-07-30 14:30:13 +08:00
Chun-wei Fan
257fd990d1 Add a EGL renderer (via ANGLE) for Windows
This is for adding a EGL-based renderer which is done via the ANGLE
project, which translate EGL calls to Direct3D 9/11.  This is done as a
possible solution to issue #105, especially for cases where the needed
full GL extensions to map OpenGL to Direct3D is unavailable or
unreliable, or when the OpenGL implementation from the graphics drivers
are problematic.

To enable this, do the following:
-Build ANGLE and ensure the ANGLE libEGL.dll and libGLESv2.dll are
 available.  A sufficiently-recent ANGLE is needed for things to
 work correctly--note that the copy of ANGLE that is included in
 qtbase-5.10.1 is sufficient.  ANGLE is licensed under a BSD 3-clause
 license.
-Build libepoxy on Windows with EGL support enabled.
-Currently, prior to running GTK+ programs, the GDK_DEBUG envvar needs
 to be set with gl-gles as at least one of the flags.

Known issues:
-Only OpenGL ES 3 is supported, ANGLE's ES 2 does not support the needed
 extensions, notably GL_OES_vertex_array_object, but its ES 3 support is
 sufficient.
-There is no autodetection or fallback mechanism to enable using
 EGL/Angle automatically yet.  There are no plans to do this in this
 commit.
2020-07-30 14:26:33 +08:00
Chun-wei Fan
12a23162b3 build: Check for EGL support in libepoxy on Windows
...EGL support needs to be explicitly enabled during the build of
libepoxy on Windows as it is not enabled by default on Windows.

With this, we can add an EGL renderer for Windows that make use of
Google's libANGLE, which is a library that translates OpenGL/ES calls
to Direct3D 9/11, which will provide better hardware compatibility
on Windows and would act as one of the foundations to resolve issue #105.
2020-07-30 14:26:33 +08:00
Matthias Clasen
0b11e78064 Merge branch 'display-cleanup' into 'master'
Display cleanup

See merge request GNOME/gtk!2319
2020-07-30 03:55:23 +00:00
Matthias Clasen
488722e7c4 docs: Don't refer to nonexisting functions
gdk_surface_input_shape_combine_mask() no longer
exists.
2020-07-29 23:00:57 -04:00
Matthias Clasen
7df070d681 gdk: Move default group api to the X11 backend
This is the only place where it is implemented.
2020-07-29 22:58:37 -04:00
Matthias Clasen
4d012a6d95 Rename gdk_surface_queue_expose
We don't have expose events anymore; instead, there
is a ::render signal. So rename queue_expose to
queue_render to match.

Update all callers.
2020-07-29 22:40:01 -04:00
Matthias Clasen
c1eedf6845 gdk: Stop exporting gdk_surface_freeze_updates
The only legitimate use for freezing the frame clock
is in GDK backends. Exporting this function for
applications makes no sense.
2020-07-29 22:30:44 -04:00
Jonas Ådahl
c7c71137b2 gdk/monitor: Remove gdk_monitor_work_area and GdkMonitor::work-area
It's not a portable API, so remove it. The corresponding backend
specific functions are still available, if they were implemented, e.g.
gdk_macos_monitor_get_workarea() and gdk_x11_monitor_get_workarea().
2020-07-29 17:57:30 +02:00
Matthias Clasen
fc47e79cb6 Document gdk_device_tool_get_axes 2020-07-28 21:58:06 -04:00
Matthias Clasen
2a92ee22da gdk: Small doc fixup
We no longer use <!-- --> for plurals, gtk-doc is smart
enough to detect them without that.
2020-07-28 21:53:56 -04:00