Commit Graph

143 Commits

Author SHA1 Message Date
Benjamin Otte
7ef5f6ef1a display: Remove x/y/w/h from create_surface() 2023-04-26 21:03:34 +02:00
Marc-André Lureau
d69cdf6c05 gdk: drop libangle GLES minimum version
GLES 2.0 version is fine now with current gtk according to B. Otte.
Let's use the same minimum requirement for all implementations.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-17 04:50:17 +00:00
Matthias Clasen
a1c5a806b3 Convert headers to #pragma once
The conversion was done by guard2one.
2023-03-31 15:11:10 -04:00
Matthias Clasen
60aaf38f39 gdk: Clean up gdkprivate.h
Move apis to more specific headers.
2022-11-17 22:49:56 -05:00
Matthias Clasen
c24a69549d Rename gdkdebug.h to gdkdebugprivate.h
This is the naming convention for private headers.
2022-09-23 23:12:01 -04:00
Christian Hergert
5316eb0c35 gdk: use EGL_KHR_swap_buffers_with_damage
It appears that NVIDIA does not implement EGL_EXT_swap_buffers_with_damage
on their EGL implementation, but does implement the KHR variant of it.
This checks for a suitable implementation and stores a pointer to the
compatible implementation within the GdkGLContextPrivate struct.
2022-03-03 01:22:01 -08:00
Chun-wei Fan
43839898b3 GDK: Force GLES 3.0+ on libANGLE
...when libANGLE is being used on Windows, by checking for a
Windows-specific an ANGLE-specific extension.
2022-01-19 11:56:32 +08:00
Benjamin Otte
dc6e831524 gdk: hdr => high depth
The term "hdr" is so overloaded, we shouldn't use them anywhere, except
from maybe describing all of this work in blog posts and other marketing
materials.

So do renames:
* hdr => high_depth
* request_hdr => prefers_high_depth

This more accurately describes what is going on.
2021-10-06 22:50:07 +02:00
Benjamin Otte
cdc85232b2 egl: Implement HDR support
If EGL supports:
* no-config contexts
* >8bits pixel formats
* (optionally) floating point pixel formats

Then select such a profile as the HDR format and use it when HDR is
requested.
2021-10-06 03:44:59 +02:00
Benjamin Otte
bc7c0d05f8 egl: Support EGL_KHR_no_config_context
If the extension is supported, we create configless contexts.

This will come in handy real soon now, we use different configs for HDR
and SDR.
2021-10-06 03:44:37 +02:00
Benjamin Otte
f8b9b309b0 egl: Move extension checks to GdkDisplay
We check the same extensions anyway, so no need to duplicate the code.
2021-10-06 03:44:36 +02:00
Benjamin Otte
bfb158d773 egl: Move initialization code and port Wayland
Moves the EGL initialization code to gdk/ so it can be shared between
backends.

Also port the Wayland backend to this code, so I know that it works.
2021-10-06 03:43:47 +02:00
Benjamin Otte
9f1d6e1f44 gl: Move vfunc
Instead of
  Display::make_gl_context_current()
we now have
  GLContext::clear_current()
  GLContext::make_current()

This fits better with the backends (we can actually implement
clearCurrent on macOS now) and makes it easier to implement different GL
backends for backends (like EGL/GLX on X11).

We also pass a surfaceless boolean to make_current() so the calling code
can decide if a surface needs to be bound or not, because the backends
were all doing whatever, which was very counterproductive.
2021-07-22 16:27:32 +02:00
Benjamin Otte
430b6f8fb1 gdk: Add GdkDisplay::init_gl vfunc
The vfunc is called to initialize GL and it returns a "base" context
that GDK then uses as the context all others are shared with. So the GL
context share tree now looks like:

+ context from init_gl
  - context1
  - context2
  ...

So this is a flat tree now, the complexity is gone.

The only caveat is that backends now need to create a GL context when
initializing GL so some refactoring was needed.

Two new functions have been added:

* gdk_display_prepare_gl()
  This is public API and can be used to ensure that GL has been
  initialized or if not, retrieve an error to display (or debug-print).
* gdk_display_get_gl_context()
  This is a private function to retrieve the base context from
  init_gl(). It replaces gdk_surface_get_shared_data_context().
2021-07-22 16:23:56 +02:00
Benjamin Otte
581e01b2da gdk: Add a private struct to GdkDisplay
... and move some members from the GdkDisplay struct.

We've always wanted to add one to isolate the display from the backends
a bit more, but so far it's never happened.

Now that I'm about to add more data to GdkDisplay, it's a good excuse to
start.
2021-07-22 16:23:56 +02:00
Matthias Clasen
ba108f261f gdk: Drop some unused private api
No users of gdk_display_peek_event, gdk_display_has_pending
_gdk_display_event_data_copy or _gdk_display_event_data_free,
so drop all of these, and related vfuncs.
2020-10-07 21:02:22 -04:00
Matthias Clasen
b3786b7b07 gdk: Slim down gdkinternals.h more
Move things to the private headers they belong in.
2020-08-14 07:45:53 -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
Carlos Garnacho
25ea17a6fc gdk: Drop source_device argument from _gdk_display_device_grab_update()
It's just passed around and used nowhere.
2020-07-29 01:27:51 +02:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Carlos Garnacho
5f29b8fcec gdk: Drop GdkGrabOwnership
We no longer expose such low level tweaks, this is essentially
unused.
2020-06-23 23:42:53 +02:00
Emmanuele Bassi
1c856a208f Rename master and slave device
We already use the "logical/virtual" and "physical" names in the
documentation, there's no reason to use loaded terms just because X11
uses them.
2020-06-18 19:22:20 +01:00
Matthias Clasen
346bba6592 Bring back gdk_display_put_event
It is still needed in WebKit.
2020-05-29 09:26:50 -04:00
Matthias Clasen
48f8affb2c gdk: Make event-related apis private
Without a way to create events, there is no point
in allowing gdk_display_put_event to be used from
the outside. And little good can come out of using
the other apis, so just make them all private.
2020-05-28 14:53:08 -04:00
Matthias Clasen
d6818475d7 gdk: Simplify gdk_display_supports_input_shapes
Make this a display property, and do away with
the vfunc in favor of a private setter, to match
how we handle other display characteristics.
2020-05-17 22:05:24 -04:00
Matthias Clasen
287c40276a gdk: Drop gdk_display_supports_shapes
The apis to set shapes on surfaces are gone,
so there is no point in providing this information
on GdkDisplay.
2020-05-17 21:52:15 -04:00
Benjamin Otte
4c7914dc49 display: Remove unneeded getters
Applications can use the listmodel instead.
2020-05-17 07:32:37 +02:00
Benjamin Otte
9a30019268 display: Remove the monitor signals
Applications can listen to GdkDisplay:monitors::items-changed if they
want to track monitor changes.
2020-05-17 07:10:34 +02:00
Benjamin Otte
dd7d76f389 gdk: Add gdk_display_get_monitors()
Returns a GListModel of GDK_TYPE_MONITOR.

This will replace the current andling of monitors in GdkDisplay.
2020-05-13 07:00:35 +02:00
Benjamin Otte
188e28e196 display: Remove unused vfunc 2020-05-13 04:51:52 +02:00
Benjamin Otte
c0c8e93d90 display: Remove gdk_display_get_last_seen_time()
Replace the only usage - in the X11 backend - with an X11-specific call.
2020-05-13 04:48:22 +02:00
Benjamin Otte
28dced597f gdk: Remove gdk_text_property_to_utf8_list_for_display()
A lot of files became empty now, so they have been removed, which makes
this commit seem larger than it is.
2020-02-23 01:59:26 +01:00
Benjamin Otte
6442ec2f8d gdk: Remove gdk_utf8_to_string_target()
Only keep the X11 version around in the backend.
2020-02-23 01:59:00 +01:00
Matthias Clasen
31bf9da63a Strip const from GdkEvent
Events are refcounted structs, and we generally don't
pass these as const.
2020-02-21 00:51:02 -05:00
Matthias Clasen
712a5d4f25 Get rid of GdkSurfaceImpl
We don't need the complicated wrapper system anymore,
since client-side windows are gone. This commit moves
all the vfuncs to GtkSurfaceClass, and changes the
backends to just derive their surface implementation
from GdkSurface.
2019-05-28 20:25:14 +00:00
Matthias Clasen
47fb092393 gdk: Drop GdkWindowAttr
All the information in it is already contained
in the surface object we pass along, and none
of the backend implementations were using the
attributes at all.
2019-05-28 20:25:14 +00:00
Matthias Clasen
f692974e5a gdk: Remove remnants of client-side windows
Now that all surfaces are native, we don't need
to separately keep track of grab surfaces and
their native ancestor anymore.
2019-05-28 20:25:14 +00:00
Timm Bäder
2146fd28f8 GdkDisplay: Use a GQueue for the events queue 2019-02-10 10:31:27 +01:00
Matthias Clasen
cd99f82e0c Merge branch 'master' into 'issue1084'
# Conflicts:
#   gdk/gdk.c
2018-06-20 14:21:24 +00:00
Benjamin Otte
a1cee7fa65 surface: Kill event masks
In particular, this patch removes:
  gdk_surface_get_events()
  gdk_surface_set_events()
  gdk_surface_get_device_events()
  gdk_surface_set_device_events()

Event masks so far still exist for grabs.
2018-06-18 23:49:52 +02:00
Mario Sanchez Prada
938448e0ef display: Add new virtual gdk_display_get_startup_notification_id() method.
Includes implementation for Wayland and X11, which are the only backends
implementing the Startup Notification Protocol, returns NULL otherwise.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Benjamin Otte
813e9c95fb gdk: Add Cairo context implementations for all backends
And make the GdkCairoContext as abstract.

The idea of this and thje following commits is to get rid of all
Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c)
by moving that code into the Cairo context files.
In particular, the GdkSurfaceClass.begin_frame/end_frame()
functions (which are currently exclusively used by the Cairo code
should end up being moved to GdkDrawContextClass.begin/end_frame().

This has multiple benefits:

1. It unifies code between the different drawing contexts.
   GL lives in GLContext, Vulkan in VulkanContext and Cairo in
   CairoContext. In turn, this makes it way easier to reason about
   what's going on in surface-specific code. Currently pretty much
   all backends do things wrong when they want to sync to drawing
   or to the frame clock.

2. It makes the API of GdkSurface smaller. No drawing code (apart
   from creating the contexts) needs to remain.

3. It confines Cairo to the Drawcontext, thereby making it way
   more obvious when backends are still using it in situations
   where it may now conflict with OpenGL (like when doing the dnd
   failed animation or in the APIs that I'm removing in this
   branch).

4. We have 2 very different types of Cairo contexts: The X/win32
   model, where we have a natively supported Cairo backend but do
   double buffering ourselves and use similar surfaces and the
   Wayland/Broadway model where we use image surfaces without any
   Cairo backend support and have to submit the buffers manually.
   By not sharing code between those 2 versions, we can make the
   actual code way smaller. We also get around the need to create
   1x1 image surfaces in the Wayland backend where we pretend
   there's a native Cairo surface.
2018-04-24 23:16:12 +02:00
Alexander Larsson
8d05fcd35c Fix up indentation after GdkSurface rename
This fixes up a lot of the indentation issues from the
rename of windows to surfaces, at least the ones in the headers
and many others.
2018-03-21 09:06:31 +01:00
Alexander Larsson
3dce0dcca7 GdkSurface: Rename lots of stuff from window->surface
Mostly these are internal things, but the major public change is
that event.window is now event.surface.
2018-03-20 15:14:10 +01:00
Alexander Larsson
9a7e721181 GdkSurface: Rename various functions and variables
This is an automatic rename of various things related
to the window->surface rename.

Public symbols changed by this is:
 GDK_MODE_WINDOW
 gdk_device_get_window_at_position
 gdk_device_get_window_at_position_double
 gdk_device_get_last_event_window
 gdk_display_get_monitor_at_window
 gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_drag_window
 gdk_draw_context_get_window
 gdk_drawing_context_get_window
 gdk_gl_context_get_window
 gdk_synthesize_window_state
 gdk_surface_get_window_type
 gdk_x11_display_set_window_scale
 gsk_renderer_new_for_window
 gsk_renderer_get_window
 gtk_text_view_buffer_to_window_coords
 gtk_tree_view_convert_widget_to_bin_window_coords
 gtk_tree_view_convert_tree_to_bin_window_coords

The commands that generated this are:

git sed -f g "GDK window" "GDK surface"
git sed -f g window_impl surface_impl
(cd gdk; git sed -f g impl_window impl_surface)
git sed -f g WINDOW_IMPL SURFACE_IMPL
git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE
git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface
git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface
git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface
git sed -f g gsk_renderer_get_window gsk_renderer_get_surface
git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface

(cd gdk; git sed -f g window_type surface_type)
git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type

git sed -f g window_at_position surface_at_position
git sed -f g event_window event_surface
git sed -f g window_coord surface_coord
git sed -f g window_state surface_state
git sed -f g window_cursor surface_cursor
git sed -f g window_scale surface_scale
git sed -f g window_events surface_events
git sed -f g monitor_at_window monitor_at_surface
git sed -f g window_under_pointer surface_under_pointer
(cd gdk; git sed -f g for_window for_surface)
git sed -f g window_anchor surface_anchor
git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL
git sed -f g native_window native_surface
git sed -f g source_window source_surface
git sed -f g dest_window dest_surface
git sed -f g drag_window drag_surface
git sed -f g input_window input_surface

git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 12:05:26 +01:00
Alexander Larsson
890080ebf7 GdkWindow -> GdkSurface: File renames
Rename all *window.[ch] source files.

This is an automatic operation, done by the following commands:

for i in $(git ls-files gdk | grep window); do
    git mv $i $(echo $i | sed s/window/surface/);
    git sed -f g $(basename $i) $(basename $i | sed s/window/surface/) ;
done

git checkout NEWS* po-properties po
2018-03-20 11:46:11 +01:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Matthias Clasen
77bab4e027 gdk: Drop some unused cursor apis
The query function for cursor sizes and capabilities
are not very interesting. At least, they are not used
in GTK+, and all backends but X11 just hardcode
made-up values anyway. So, lets drop them.
2018-01-16 23:32:01 -05:00
Matthias Clasen
c5fc841285 gdk: Reorganize env vars
Drop GDK_GL, GDK_VULKAN and GDK_RENDERING_MODE.
Merge the useful bits into GDK_DEBUG.
Drop unused debug flags (CURSOR).
2018-01-14 17:05:04 -05:00