Commit Graph

1566 Commits

Author SHA1 Message Date
Emmanuele Bassi
a977094e18 window: Remove all old mnemonic handling API 2020-03-18 23:00:51 -04:00
Emmanuele Bassi
09400b6bfe Add GtkShortcutManager
This adds an interface for taking care of shortcut controllers with
managed scope.

Only GtkWindow currently implements this interface, so we need to ensure
that we check if any top-level widget we reach is a shortcuts manager
before we call into it.
2020-03-18 23:00:50 -04:00
Benjamin Otte
bea2dcef8f window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2020-03-18 23:00:50 -04:00
Benjamin Otte
cc13b47542 window: Get rid of public APIs that shouldn't be
Event controllers should have replaced all of them.
And if they haven't, apps need to fix their code (I'm
looking at you Gimp).
2020-03-18 23:00:50 -04:00
Benjamin Otte
e62154c91f trigger: Add an alternative trigger
And use it.

I just added it to GtkWidget just to show that I can.
The real reason I want it is for gamepad/joystick triggers
in games, so that it becomes possible to select 2 different
triggers (gamepad and keyboard) for the same shortcut.
2020-03-18 23:00:49 -04:00
Benjamin Otte
0f6c5da28d window: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Matthias Clasen
7a46157edf window: Set min size properly
When we are mapping the window, we need to compute
a proper min size, otherwise the 1, 1 sticks and
makes all windows shrinkable to nothing.
2020-03-17 20:46:57 -04:00
Matthias Clasen
c9ec1c6af1 Drop focus-related properties
We don't use these, and they are only implemented on X11.
2020-03-14 19:28:00 -04:00
Matthias Clasen
6f156dad7f window: Drop keep above/below 2020-03-14 15:16:56 -04:00
Matthias Clasen
fb7ef8f62c window: Drop sticky
This is an X11-only concept that we don't have
on Wayland.
2020-03-14 14:34:39 -04:00
Matthias Clasen
dfda88038e window: Drop gtk_window_set_attached_to
We are no longer attaching windows to widgets.
2020-03-14 02:00:10 -04:00
Matthias Clasen
81be6ff46b Move edge-constraints to GdkToplevel 2020-03-12 15:30:11 -04:00
Matthias Clasen
6edff8cd67 gtk: use toplevel state getter 2020-03-12 14:56:20 -04:00
Matthias Clasen
9266881691 window: Use GdkToplevel 2020-03-12 14:56:20 -04:00
Matthias Clasen
11c91065cf window: Drop type hints 2020-03-11 19:36:04 -04:00
Matthias Clasen
b2ae6ce8ff surface: Rename gdk_surface_input_shape_combine_region
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.
2020-03-11 19:35:56 -04:00
Matthias Clasen
78d71eb439 Simplify surface move/drag api
Drop the with_device variants, and always pass a device.
2020-03-11 19:35:55 -04:00
Matthias Clasen
6f36d9865e Drop gtk_window_begin_move/resize_drag
These are just simple wrappers around GdkSurface
api, and we don't need them.
2020-03-11 19:35:55 -04:00
Benjamin Otte
a411959c91 droptarget: Redo
This is a huge reorganization of GtkDropTarget. I did not know how to
split this up, so it's unfortunately all one commit.

Highlights:

- Split GtkDropTarget into GtkDropTarget and GtkDropTargetAsync
  GtkDropTarget is the simple one that only works with GTypes and offers
  a synchronous interface.
  GtkDropTargetAsync retains the full old functionality and allows
  handling mime types.

- Drop events are handled differently
  Instead of picking a single drop target and sending all DND events to
  it, every event is sent to every drop target. The first one to handle
  the event gets to call gdk_drop_status(), further handlers do not
  interact with the GdkDrop.
  Of course, for the ultimate GDK_DROP_STARTING event, only the first
  one to accept the drop gets to handle it.
  This allows stacking DND event controllers that aren't necessarily
  interested in handling the event or that might decide later to drop
  it.

- Port all widgets to either of those
  Both have a somewhat changed API due to the new event handling.
  For the ones who should use the sync version, lots of cleanup was
  involved to operate on a sync API.
2020-03-02 03:18:55 +01:00
Matthias Clasen
0ffb35c9e7 Drop device grabs
We were not using this api at all, so lets drop it.
2020-02-28 16:27:42 -05:00
Timm Bäder
6056ca9265 window: Carry an extra input region
This will be used in the inspector to make it possible to click through
the inspector window.
2020-02-25 14:18:24 +01:00
Timm Bäder
6b970c6813 widget: Remove set_csd_input_shape
Replace the only caller (unsurprisingly from gtkwindow.c) with a direct
call to gdk_surface_input_shape_combine_region.
2020-02-25 14:18:24 +01:00
Matthias Clasen
a43d13aa74 popover: Drop ::relative-to
It is enough to just set the parent (and make the parent
call gtk_native_check_resize in size_allocate).

This commit removes the relative_to argument to the
constructors of GtkPopover and GtkPopoverMenu, and
updates all callers.
2020-02-24 20:46:41 -05:00
Benjamin Otte
f656cbdc5b Ensure all natives request at least a 1px wide surface
FIXME: Is this necessary?

Could the surfaces just clamp to 1x1 themselves?
We recently declared that surfaces can decide on whatever size they want
so natives need to inspect the size they requested anyway.
2020-02-22 05:50:07 +01:00
Matthias Clasen
e062137b2c motion controller: Match focus event propagation
Make the crossing event generation for pointer events
match what we do for focus now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
5a2f829a40 Split off GtkEventControllerFocus
Split the focus tracking into a separate
GtkEventControllerFocus, and change the API one more time.
We are back to having ::focus-in and ::focus-out signals.

Update all users.
2020-02-21 00:51:03 -05:00
Matthias Clasen
89c3a7ab24 wip: Add more information to crossing events
Add fields for direct descendents to GtkCrossingData,
and populate them when emitting focus change events.

Also add accessors for these fields to GtkEventControllerKey,
and verify that they are set properly in the focus test.

Not done yet: Do the same for pointer crossing events.
2020-02-21 00:51:03 -05:00
Matthias Clasen
b1eaa502df events: reorganize getters
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.
2020-02-21 00:51:03 -05: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
2416b4e2a0 Stop using gdk_event_get_target
We can now get the target widget from the gesture
that we are using to find the event in the first
place.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e54e48f6d1 Explicitly pass the target to handle_event
Pass the event propagation target explicitly down to
the event controllers. This is a step towards getting
rid of gdk_event_set_target.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e3158a1bfb Make crossing events handled the same way 2020-02-21 00:50:59 -05:00
Matthias Clasen
23c67f8c67 New focus change handling
Instead of relying on gdk's antiquated crossing events,
create a new GtkCrossingData struct that contains the
actual widgets, and a new event controller vfunc that
expects this struct. This also saves us from making sense
of X's crossing modes and details, and makes for a
generally simpler api.

The ::focus-in and ::focus-out signals of GtkEventControllerKey
have been replaced by a single ::focus-change signal that
takes GtkCrossingData as an argument. All callers have
been updated.
2020-02-21 00:47:53 -05:00
Matthias Clasen
1b2289ad9b Stop using gtk_get_event_target
This is just a thin wrapper around gdk_event_get_target,
so use that directly.
2020-02-21 00:47:53 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
374c9dd880 window: Use event constructors 2020-02-21 00:40:52 -05:00
Benjamin Otte
80ba7fd682 dragdest: Make gtk_drop_target_new() args be transfer full
Saves tons of code.
2020-02-17 04:04:21 +01:00
Benjamin Otte
c1f71ee3e8 window: Remove GtkWindowType and window->type
And remove code that was making decisions on the type and just use
the part for toplevels.
2020-02-14 21:18:49 +01:00
Benjamin Otte
a278edab22 window: Remove type argument from gtk_window_new() 2020-02-14 21:18:49 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
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.
2020-02-12 11:25:34 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
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.
2020-02-12 11:05:01 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
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.
2020-02-12 10:44:17 +01:00
Alexander Larsson
1698369d52 Merge branch 'icon-theme-api-rework' into 'master'
Icon theme api rework

See merge request GNOME/gtk!1390
2020-02-10 12:45:56 +00:00
Timm Bäder
d3857f8bd3 window: Move variable initialziation just before usage 2020-02-07 13:16:45 -05:00
Timm Bäder
655711fef2 Rename gtk_widget{get,set,has}_style_class to _css_class
We want to use css instead of style everywhere now.
2020-02-07 13:16:45 -05:00
Timm Bäder
b7ee2cbc28 Start using GtkWidget's new style class API 2020-02-07 13:16:32 -05:00
Timm Bäder
c0fef36692 Window: inline function into only caller 2020-02-07 13:15:59 -05:00
Alexander Larsson
6317fd3529 Replace last users of gtk_icon_paintable_download_texture ()
These now render the paintable to a cairo surface and convert that
to a texture. This is sort of a hack, but its only used in two
special cases internally and in two hacky test apps.
2020-02-06 17:47:56 +01:00
Alexander Larsson
d69f7fd63e IconTheme: Never fail a lookup or icon load
If icon lookup fails or if loading it fails later, just always
fall back to the built in image-missing icon. Nobody is handling
missing icons in a sane way anyway.

If you *truly* need to handle missing icons, you need to manually
use gtk_icon_theme_has_icon().

While changing the loading code I also fixed an issue where it
was always passing "png" to pixbuf, now it also handles "xpm" if
that is the filename suffix.
2020-02-06 09:38:25 +01:00
Alexander Larsson
b529f77827 IconTheme: Simplify icon scaling
We had a pretty complex setup where we tried to avoid scaling up themes from dirs
that specified a size. However, not only was it very complex, but it didn't quite
work with window scales, because when using e.g. a size 32 directory for 16@2x
the dir size is wrong anyway. Additionally it turns out most code either picks
an existing icon size, or uses the FORCE_SIZE flags, so it doesn't seem
like a useful behaviour.

This change drops the FORCE_SIZE flags, and always scales
icons. Additionally it moves the scaling of the icon to rendering,
which seems more modern, and allows us to (later) share icons loaded
for different sizes that happened to use the same source file (at
different scales).

Note that this changes the behaviour of
gtk_icon_paintable_download_texture() is it now returns the unscaled
source icon. However, ignore thats, as I plan to remove this function
and replace it with a way to render a paintable to a cairo-surface
instead.
2020-02-06 09:38:25 +01:00