Commit Graph

181 Commits

Author SHA1 Message Date
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Carlos Garnacho
5785db64ce popover: Update to using GdkEvent API 2017-09-19 18:39:02 +02:00
Matthias Clasen
af5d3e3299 popover: Fix a warning
We were unintentionally disconnecting an already-disconnected
signal handler in some cases. Don't do that, it causes warnings.
2017-09-06 08:04:33 -04:00
Timm Bäder
619ee3797d popover: Initialize some locals
gtk_popover_get_pointing_to does not fill the given rect in every case.
2017-08-28 11:17:47 +02:00
Matthias Clasen
41f26ea7a6 wayland: Stop using subsurfaces for popovers
Subsurfaces don't currently work with our new rendering,
and this makes popovers unusable. We can go back to using
subsurfaces for popovers when this is fixed.
2017-08-26 15:34:46 -04:00
Daniel Boles
12693c6fe3 Popover: Include window shadows in overshoot calcs
.update_position() enforces that non-Wayland platforms must position a
Popover within its parent Window. We use the allocation of the Window
to translate the position and check for overshoot on each of its sides.
Calling Widget.get_allocation() of a CSD Window includes its shadows.

But shadows were not excluded from the area in which we can position.
Thus, Popovers could get positioned in the shadow of CSD windows, where,
at least on X11, no input is received. Therefore, positioning a Popover
over a shadow meant its child widgets within that area became unusable.

Fix by calling Window.get_shadow() and including it in the overshoot on
each side. This adjusts for how the allocation includes shadows, making
overshoots with and without shadows the same. Thus, we avoid considering
shadows as viable for positioning, favouring a side where input works.

https://bugzilla.gnome.org/show_bug.cgi?id=786209
2017-08-24 21:32:05 +01:00
Timm Bäder
0fe396e516 popover: Remove double assignment 2017-08-14 21:29:18 +02:00
Matthias Clasen
46f7804f3a Fix a problem with focus handling in modal popovers
When the popover is dismissed, we return the focus to
where it came from. However, by using gtk_widget_grab_focus,
we were messing up the selection if that widget happens to
be an entry. Special-case GtkEntry and use
gtk_entry_grab_focus_without_selecting to avoid this issue.
2017-08-12 18:48:14 -04:00
Timm Bäder
765aff3f0e popover: Fix arrow position
Remove all the manual css margin handling since that's being done for us
automatically now.
2017-08-03 11:07:59 +02:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
f637006b3e popover: Add a contents node
Remove the special case in gtkwidget.c where we didn't draw any css
background/border for popovers. Instead, rely on themes to not style the
popover node and add a contents gizmo that gets the actual css styling.
We then requeste enough space for the popover to draw both the contents
and the arrow on the side.
2017-07-19 21:27:15 -04:00
Timm Bäder
4b0da8682d popover: set the shape on the correct window
the parent window is now the toplevel's window.
2017-07-19 21:27:15 -04:00
Timm Bäder
bda2f4f582 popover: Create subsurface on wayland 2017-07-19 21:27:14 -04:00
Timm Bäder
bc807789ba popover: "Fix" child allocation
This is still wrong but will be fixed in the future.
2017-07-19 21:27:14 -04:00
Timm Bäder
9350a0f85b popover: Remove useless if case
rect is not nullable, so stop checking if it is NULL and instead add a
g_return_val_if_fail guard.
2017-07-19 21:27:13 -04:00
Timm Bäder
1d4d5b2eb9 popover: Stop looking at padidng and border in measure
GtkWidget does it for us now
2017-07-19 21:27:12 -04:00
Timm Bäder
60e053f52a Remove calls to gtk_widget_set_allocation
gtk_widget_size_allocate_with_baselines does it automatically now.
2017-07-19 21:27:12 -04:00
Carlos Garnacho
ee894903c7 gtkpopover: Use event coordinates right away to detect clicks outside.
There's no need anymore to translate coordinates, the event already contains
popover-relative ones.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Olof-Joachim Frahm
1681d4ad77 Move style change for popover creation.
Creating with `gtk_popover_new_from_model` should be exactly the same as
if via `gtk_popover_new` plus `gtk_popover_bind_model`.

Also remove the style if the model is unbound at any point.
2017-05-05 11:37:20 +02:00
Timm Bäder
43cdeee3c4 widget: Save pointer to focus child
Do the same thing GtkContainer does.
2017-03-31 09:50:39 +02:00
Timm Bäder
78a36cf4bb popover: Simplify gtk_popover_measure 2017-02-05 15:03:35 +01:00
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01:00
Timm Bäder
ab051fd53f Don't hide windows and popovers in init()
Instead, don't make them visible in gtk_widget_init in the first place.
2017-01-20 21:51:05 +01:00
Timm Bäder
33d41fccdd Hide popovers and toplevels by default 2017-01-20 21:33:37 +01:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Timm Bäder
47d4ad71fb Remove gtk_container_snapshot_child
Replace it with the already existing gtk_widget_snapshot_child.
2017-01-07 17:19:30 +01:00
Benjamin Otte
4d9eedafcd roundedbox: Add gtk_rounded_boxes_init_for_style()
Instead of making people intiialize a rectangle and then applying border
radius manually, provide a constructor that does it for them.
While doing that, also allow people to instead request the padding box
or the content box.

Refactor all relevant code to use this new constructor.
2016-12-20 18:01:12 +01:00
Benjamin Otte
95a2a5c54c gtk: Remove GtkJunctionSides 2016-12-20 18:01:12 +01:00
Benjamin Otte
f96f16899d roundedbox: Remove _gtk_rounded_box_path()
Use gsk_rounded_rect_path() instead.

That's a private GSK function, be we can just include its header.
2016-12-20 18:01:10 +01:00
Benjamin Otte
e26f84fca0 gtk: Remove GtkRoundedBox struct
Use GskRoundedRect instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
d1b80a6baa gtk: Don't push cairo nodes
We want to split nodes into containers and nodes that do actual drawing.
So pushing nodes that do drawing is exactly the wrong thing.

Also fix up GtkPopover. There's no need for it to push anything.
2016-12-20 18:01:09 +01:00
Benjamin Otte
e8381f84d6 snapshot: Convert GtkPopover 2016-11-15 17:49:19 +01:00
Ernestas Kulik
3885e85f77 popover: pop down when pressing escape
Simply hiding the popover may introduce inconsistencies in application
behavior, since popping up/down is the usual use case.

https://bugzilla.gnome.org/show_bug.cgi?id=773885
2016-11-03 15:46:04 +02:00
Benjamin Otte
a0e63b8a07 rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the
renderer, so that they can be rendered multiple times with different
renderers.
2016-11-01 16:32:26 +01:00
Timm Bäder
679b515170 popover: convert to indirect rendering 2016-10-31 19:29:35 +01:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Timm Bäder
3573cdc0cd popover: Remove deprecated API 2016-10-18 00:29:19 +02:00
Benjamin Otte
6a399ebd15 popover: Use gdk_window_new_child() 2016-10-18 00:22:35 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Benjamin Otte
1518fe0a8f API: stylecontext: Remove state argument from getters
The argument must always be the current state.
2016-10-16 18:18:58 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Carlos Garnacho
769ee1156d popover: Update scrollable on relative-to hierarchy changes
The relative-to widget may be reparented itself into/out of a
scrollable. In this cases make the hierachy-changed handler to
unset the parent scrollable when unparented, and look up again
the parent scrollable after it's reparented.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Carlos Garnacho
588a1dce2b popover: Add helper functions around setting up an scrollable
gtk_popover_set_scrollable_full() takes care of the signal connected
on the scrollable itself, in addition to the adjustment signals the
popover listens to.

gtk_popover_update_scrollable() looks up the current relative-to
widget hierarchy and updates the current scrollable.

The places where the scrollable is being maintained have been updated
to use these functions.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Timm Bäder
857997be8c popover: Skip first frame when transitioning
Similar to what we do in GtkStack.
2016-09-03 12:24:58 +02:00
Timm Bäder
ce1ae60da2 popover: Propagate drawing 2016-09-01 15:20:12 +02:00
Timm Bäder
2c04941c5c popover: Fix hfw/wfh size request
Since we're using _get_rect_coords in size-allocate when allocating the
size of the child widget, use the newly introduced _get_rect_for_size to
calculate the difference between the passed size_for and the one we're
supposed to pass on to the child widget.
2016-09-01 15:16:58 +02:00
Timm Bäder
7f1ab32e60 popover: Introduce _get_rect helper for a size
When calculating the requested size of a popover, we need to do the
exact same same thing _get_rect_coords did, but not for the
current popopver allocation. Add _get_rect_for_size that can be used for
this purpose
2016-09-01 15:15:18 +02:00
Timm Bäder
5c696a7ee3 popover: Clarify transitions-enabled deprecation
https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-20 20:54:20 +02:00