With the removal of grabs from the public API, we need a replacement API
to let applications bypass system keyboard shortcuts.
A typical use case for this API is remote desktop or virtual machine
viewers which need to inhibit the default system keyboard shortcuts so
that the remote session or virtual host gets those instead of the local
environment.
Close: https://gitlab.gnome.org/GNOME/gtk/issues/982
GTK defines various types that are meant to be derivable only within GTK
itself, and "final" from the perspective of consumers of the GTK API.
The existing macros defined by GObject, such as G_DECLARE_FINAL_TYPE and
G_DECLARE_DERIVABLE_TYPE, lack this functionality.
While we wait for GObject to get this kind of macro, we should define
our own.
Without this, the back buffers of the wrong size
keep being used, causing flickery misdraws, as
seen when expanding the expander in the popover
in widget-factory.
surface->x/y (and various x,y arguments) should be in the parent
coordinates, so treat it as such. We also keep track of the root coords
as these are needed for popup positioning.
Also, drop the isTemp property server side and the weird initial
placement at (100, 100) in the daemon. We now fully control window
placement from the client instead. If this is not we want we should do
a serious design for that but until then lets do the simplest thing.
In firefox, onload will trigger when the image is loaded, but at
that point it may not be decoded yet so showing it will sometimers
trigger flashes. We use the new decode() feature instead which ensures
both that the image is loaded *and* decoded, thus fixing the flashes.
These fixes were done blindly, to make the ci pass,
and will need review by somebody with access to an
actual win32 system to make sure the surface subtypes
are implemented properly.
There is no shape combining going on anymore, so
call this just gdk_surface_set_input_region, and
remove the offset arguments too. All callers pass
0 anyway.
Update all callers and implementations.
This is not quite right, and only temporary, since
it makes GDK_IS_POPUP (surface) true for every surface.
Eventually, the implementation will be moved to the
backends.
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.
Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
Drop the input-mode, since it only makes sense for
floating devices, which we don't have anymore. And renamt
::input-source to ::source, to match the getter.
Update all users.
replace all uses with const char * (non-interned).
Also remove a lot fo juggling from atom to GdkAtom to string and back.
The X Atom hash table is now mapping to (again, non-interned) strings.
We were not properly converting the coordinates we
got to root coordinates. This was showing up as offsets
between the actual drop target and the area where drops
can happen, e.g. when dragging over a stack switcher
to switch pages.
We were forgetting to clean up the ::xevent signal
handler in some error cases. Move the signal connection
later, when we know the drag is going forward, and
use g_signal_connect_object to make sure the signal
handler is not forgotten.
This allows treating drop events like touch events, which GTK groups by
event sequence.
It's a bit ugly that we just case the GdkDrop pointer, but event
sequences are only meant to be unique pointer ids, so it's fine.
When a popup is already showing, and gdk_surface_present_popup() is
called, if the layout didn't change, we're not really interested in
relayouting.
In the future, we'll be able to get notified if position of the popup
would change by some environmental changes, but until then, just don't
support it.
Rearrange a few things, and move some booleans
into the Any struct, by using a bitfield there.
Some more cleanup could be done - the flags field
with its PENDING and FLUSHED members appears
entirely unused. Nobody is setting those flags.
Restructure the getters for event fields to
be more targeted at particular event types.
Update all callers, and replace all direct
event struct access with getters.
As a side-effect, this drops some unused getters.
Make the event translator return a new event, instead of
filling in a half-constructed one.
Update the two implementation in GdkX11Display and
GdkDeviceManagerXI2.
Instead of passing a half-constructed event and expect
it to be filled in, pass the surface as in argument, and
add an out argument for a newly constructed GdkEvent.
Add private API to construct events. This is a step towards
making events readonly, and not objects anymore.
The constructors here are sufficient to convert the Wayland
backend over. More may be added for other backends as needed.
Open issues:
- history
Replace the gdk_surface_move_to_rect() API with a new GdkSurface
method called gdk_surface_present_popup() taking a new GdkPopupLayout
object describing how they should be laid out on screen.
The layout properties provided are the same as the ones used with
gdk_surface_move_to_rect(), except they are now set up using
GdkPopupLayout.
Calling gdk_surface_present_popup() will either show the popup at the
position described using the popup layout object and a new unconstrained
size, or reposition it accordingly.
In some situations, such as when a popup is set to autohide, presenting
may immediately fail, in case the grab was not granted by the display
server.
After a successful present, the result of the layout can be queried
using the following methods:
* gdk_surface_get_position() - to get the position relative to its
parent
* gdk_surface_get_width() - to get the current width
* gdk_surface_get_height() - to get the current height
* gdk_surface_get_rect_anchor() - to get the anchor point on the anchor
rectangle the popup was effectively positioned against given
constraints defined by the environment and the layout rules provided
via GdkPopupLayout.
* gdk_surface_get_surface_anchor() - the same as the one above but for
the surface anchor.
A new signal replaces the old "moved-to-rect" one -
"popup-layout-changed". However, it is only intended to be emitted when
the layout changes implicitly by the windowing system, for example if
the monitor resolution changed, or the parent window moved.
We can map a non-grabbing popup wherever, it's just the grabbing
popup-chain that needs to be ensured not to break any ordering rules.
Fix this by managing two lists; one of open popups, and another for
grabbing ones.
The returned position should be relative to the parent surface, but
GdkSurface::x,y were only managed properly for O-R windows. This makes
it correct for regular windows too.
Now popups surfaces are always created with the parent set, so we don't
need to implement vorious guess work to try to find what the parent
might be. Remove that code and just use GdkSurface::parent which is
where the parent set during construction ends up at.
Add event queues specifically for surface configuration events
(xdg_surface.configure, xdg_toplevel.configure, xdg_popup.configure etc)
so that a configuration can be completed without having side effects on
other surfaces. This will be used to synchronously configure specific
GdkSurfaces, as is needed by the Gtk layout mechanisms.
The freezing is conditioned on various state, so lets make the thawing a
bit more robust. Without this there was a risk that we'd thaw too many
times if there was a frame callback requested while the conditions for
the freezing were not met.
Content providers are meant to be immutable, apart from very special
cases, but in those cases they need to emit
gdk_content_provider_content_changed().
Having a constructor that just uses a get_func invites abuse of this
by not making developers aware of those requirments.
In fact, all users in GTK failed to do this.
Instead, code should use the GtkDragSource::prepare signal to create
content providers when needed.
The same problem exists with gdk_content_provider_new_with_formats(),
but this commit doesn't touch that.
Otherwise the compositor gets all confused when it's trying to make
drag happen but we know it's not going to happen.
After all, we exchange data behind its back, we just need to keep it
informed.
1. GdkDrop does deserialization, so add the deserialize formats
2. If the drop is local, we can copy straight from the drag, so we can
also copy all its formats. This fixes cases where the backend would
drop formats it doesn't support.
For a given OpenGL context, macOS in particular does not support enumeration / detection of OpenGL features that have been promoted to core OpenGL functionality. It is possible other drivers are the same. This change assumes support for GL_ARB_texture_non_power_of_two with OpenGL 2.0+, GL_ARB_texture_rectangle with OpenGL 3.1+ and GL_EXT_framebuffer_blit with OpenGL 3.0+. I failed to find definitive information on whether GL_GREMEDY_frame_terminator has been promoted to OpenGL core, or whether GL_ANGLE_framebuffer_blit or GL_EXT_unpack_subimage have been promoted to core in OpenGL ES. This change results in a significant GtkGLArea performance boost on macOS.
Closes#2428
The function is fundamentally broken for unbounded surfaces.
If a surface is unbounded, we cannot represent this as a
cairo_rectangle_int_t, and using the return value doesn't work because
it's already used for something else.
In GTK3, unbounded surfaces aren't a problem, but GTK4 uses recording
surfaces.
So better remove that function before we keep using it and using it
wrong.
The marks are averaged based on the name, so this makes more sense.
Also rename the map/unmap marks to have the same capitalization as
everything else.
I was getting CI failures like:
../gdk/gdkprofiler.c: In function ‘add_markvf’:
../gdk/gdkprofiler.c:111:3: error: function ‘add_markvf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
This drops the marks for before/after-paint as they are internal
things that very rarely use any time, and also flush/resume-events
as any events reported here will get separate marks so will be easy
to see anyway.
Also, we rename the entire frameclock cycle to "frameclock cycle"
rather than "paint_idle" which is rather cryptic.
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.
Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.
We also expand to G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).
Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
This allows us to avoid hand-rolling g_strdup_printf calls,
but also moves the printf into the called function where
it doesn't bloat the code of the calling function if the profiler
is not running.
All the code in e.g. init_randr15() divides the physical resolutions with
the screen scale, however if we get the screen scale from xsettings
rather than e.g. GDK_SCALE the initial setup is using the wrong value.
So, whenever the screen scale size is changed we need to trigger
a re-read of the randr data
1. Rename the thing
2. Turn it from a signal to a vfunc
3. Pass the GtkCssStyleChange to it
We don't export any public API about the GtkCssStyleChange yet, it's
just a boring opaque struct.
We're not in the business of adding Cairo APIs. That's Cairo's job.
Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.
This reverts commit afa6cc2369.
This was blocking the clean exit from the testdbus shutdown in
the defaultvalues test. The proxy was keeping the connection alive
which blocks g_test_dbus_down().
This adds a GDK_DEBUG=default-settings flag which disables reads
from xsettings and Xft resources, and enables this for the testsuite.
This is one less way to get different testresults depending on the
environment. In particular, it was failing the css tests for me
due to getting the wrong font size because i have a different dpi.
We only have implementations of this on X11 and Win32,
so make it available as backend api there.
Update all callers to use either the backend api, or
just monitor 0.