Commit Graph

117 Commits

Author SHA1 Message Date
Matthias Clasen
e626038467 popover: Make it possible to constrain to toplevel
Under X11, popovers are always constrained to the toplevel
window. Under Wayland, they aren't. This commit adds a
property that allows to explicitly constrain popovers to
the toplevel, giving them the same behavior under Wayland
as under X11.

https://bugzilla.gnome.org/show_bug.cgi?id=757474
2015-12-01 17:26:25 -05:00
Timm Bäder
bd0f217ff4 GtkPopover: Restore tails
The call to gtk_style_context_get_border was accidentally removed in
2182fe7d9d.
2015-11-24 11:37:00 +01:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Matthias Clasen
87b10e6f60 popover: Avoid a crash when no relative-to widget is set
This was showing up in glade, which creates freestanding
popovers.
2015-11-17 22:48:35 -05:00
Matthias Clasen
0bfc7db1fa popover: Don't create transient CSS nodes
There is no need to save the style context here.
2015-11-06 11:50:23 -05:00
Matthias Clasen
eade244cac popover: Add the .background style class
This style class indicates that something _requires_ a background,
which is clearly the case for popovers.
2015-11-04 12:05:03 -05:00
Carlos Garnacho
9d1b8dfc61 popover: Request raise on ::show
This way latest shown popovers are ensured to be on top.

https://bugzilla.gnome.org/show_bug.cgi?id=756670
2015-11-03 07:25:33 -05:00
Matthias Clasen
e56bb49407 popover: Document differentiating style classes
There's a lot of popover variations out there.
2015-11-02 12:53:57 -05:00
Timm Bäder
33ac663b13 popover: Use element name
Pick "popover" and add .menu for popover menus
2015-10-30 15:10:35 +01:00
Carlos Garnacho
d8e41e1308 popover: Invalidate borders on tail position changes
There's nothing doing this explicitly, so tail position changes may
leave trails of older positions.

https://bugzilla.gnome.org/show_bug.cgi?id=756449
2015-10-13 02:07:24 +02:00
Timm Bäder
d8856f1b61 GtkPopover: Don't apply shape on wayland
Popovers are subsurfaces on wayland so we don't need that, and the shape
messed up hidpi popovers there.
2015-10-07 09:49:51 +02:00
Timm Bäder
3e39ec5743 GtkPopover: Make transitions faster
https://bugzilla.gnome.org/show_bug.cgi?id=755528
2015-09-29 20:59:12 -04:00
Timm Bäder
5bf47338e8 GtkPopover: Remove apply_shape field
This was introduced in 2d9c09d6 alongside a private setter, but that
setter has been removed and the field is always TRUE.
2015-09-29 15:28:55 +02:00
Timm Bäder
8a6b720632 GtkPopover: Don't resize during the transition
Call gtk_popover_update_position instead which will pick up the new
transition_diff value and pass it on to
_gtk_window_set_popover_position, which in turn will move the window
correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
2015-09-29 15:28:55 +02:00
Timm Bäder
eb8a64982e GtkPopover: Remove _get_pointed_to_coords
It's only used once and removing it only adds a single line there.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
2015-09-29 15:28:55 +02:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Benjamin Otte
63cefa199a popover: Don't inherit style from parent
Instead, inherit style from toplevel (because that's the default way,
not because it makes lots of sense).

This way, popovers don't inherit the styling from the widget that popped
them up, which is a problem in selected listbox rows, selection-mode
headerbars.
It also doesn't inherit styling where we might want it, like the osd.

But we can only have one of the two things.
2015-09-04 18:59:51 +02:00
Matthias Clasen
58f363c852 Revert "popover: Optimize the transition"
This reverts commit 84bd32a09a.

It turned out that this did break the transition in some places.
2015-08-21 18:08:30 -04:00
Matthias Clasen
775800f76e popover: Don't restore stale default widget
Only restore the saved default widget if the default hasn't been
changed while the popover was visible.
2015-08-15 23:38:20 -04:00
Matthias Clasen
84bd32a09a popover: Optimize the transition
There's no need to queue a resize here.

https://bugzilla.gnome.org/show_bug.cgi?id=753568
2015-08-15 22:02:40 -04:00
Timm Bäder
ddcb309b5b GtkPopover: Set interpolate-size on the stack...
... in gtk_popover_bind_model
and gtk_popover_menu_init
2015-07-20 10:26:06 +02:00
Carlos Garnacho
7f57f63eba gtkwindow: Only allow unrestricted positioning to text handle popovers
This behavior has been made optional on add_popover() time, text handles
will keep being able to overflow the window, in order to allow text
selection on views too close to the window edge.

Regular GtkPopovers are reinstaurated to the previous size positioning
logic though, that is, limited by the visible area of the window.
2015-07-06 16:39:06 +02:00
Carlos Garnacho
76dc8aced5 window: Add concept of popover "parent"
This will be the widget that the popover relates to (::pointing-to in
GtkPopover, ::parent in GtkTextHandle).

Additional API to check the popover/parent relationship between widgets
has been added, which will be useful wherever this is necessary in a
generic manner.

https://bugzilla.gnome.org/show_bug.cgi?id=750993
2015-06-17 15:56:42 +02:00
Carlos Garnacho
a01fe14056 popover: Avoid hiding modal popovers if another popover is taking focus
Due to popover modality itself, there's quite high chances the popover
stealing focus has been triggered from within, so stay friendly to it.
Hiding the popover here will only hide the grabbing popover too if this
happens.

https://bugzilla.gnome.org/show_bug.cgi?id=750741
2015-06-12 21:00:45 +02:00
Carlos Garnacho
2be6d09c9e popover: Be lenient wrt visibility of popovers too close to widget borders
The check used to hide the popover if the pointed area fell partly out of
the widget allocation, textviews now can trigger that with text selections
too close to the visible edge, as a small extra area around is now reserved.

The check has been changed to only hide the popover if the pointed area
falls completely outside the widget allocation.
2015-06-12 12:07:30 +02:00
Timm Bäder
d3a18de97e gtkpopover: Update the menu's alignment
... when the popover position changes.
2015-05-29 17:37:04 +02:00
Matthias Clasen
2bb1ed69f0 GtkPopover: Clean up default widget on dispose
We forgot to drop the ref we take. Thankfully our
tests caught this.
2015-05-12 07:57:04 -04:00
Matthias Clasen
1f51c506c3 Fix precondition in gtk_popover_get_default_widget
We need to return a value here.
2015-05-04 09:28:46 -04:00
Timm Bäder
c28275f4ec GtkPopover: Don't ref NULL widgets
gtk_window_get_default_widget returns NULL if the window does not have a
default widget, so don't ref it in that case.
2015-05-03 20:03:56 +02:00
Matthias Clasen
e1c1fc59e5 Add default widget handling to popovers
Add a new API, gtk_popover_set_default_widget, that can be
used to make a widget act as default while the popover is
shown. This is useful in dialog-like popovers.

http://bugzilla.gnome.org/show_bug.cgi?id=747664
2015-05-02 20:34:28 -04:00
Kjell Ahlstedt
2495edc9fd GtkPopover:pointing-to: GdkRectangle instead of cairo_rectangle_int_t
cairo_rectangle_int_t was replaced by GdkRectangle in commit
552c29b488, but the type of the pointing-to
property was not changed.

To avoid breaking old code that sets or gets the property with a GValue
of type CAIRO_GOBJECT_TYPE_RECTANGLE_INT, transformation functions between
CAIRO_GOBJECT_TYPE_RECTANGLE_INT and GDK_TYPE_RECTANGLE are registered on
the first call to gdk_rectangle_get_type().

https://bugzilla.gnome.org/show_bug.cgi?id=723394
2015-04-21 09:05:26 +02:00
Matthias Clasen
ac931e9506 popover: Remove signal handlers in dispose
If we don't, they may get triggered at an inopportune
time later, causing us to crash.

See
https://bugzilla.redhat.com/show_bug.cgi?id=1203499

https://bugzilla.gnome.org/show_bug.cgi?id=747539
2015-04-09 06:39:11 -04:00
Carlos Garnacho
cff1694c99 popover: Add show/hide transitions
These have the same visual effect and timing than the gnome-shell ones.
During the hide animation, the popover has been made to take focus
elsewhere, and refuse to take any pointer/keyboard input until the popover
is shown again.

This has been based on work from Timm Bäder.

https://bugzilla.gnome.org/show_bug.cgi?id=741405
2015-02-20 14:44:17 +01:00
Carlos Garnacho
4ba2c9ad87 popover: Unset the grab when the popover loses its parent
This ensures the grab and signal handlers are removed if the parent goes
NULL.
2015-02-05 15:09:51 +01:00
Carlos Garnacho
5837c1c710 popover: Keep a ref on the parent scrollable
This ensures the scrollable is still alive on dispose(), and properly unset
after disconnecting all signal handlers.
2015-02-05 15:08:12 +01:00
Ting-Wei Lan
2c6ac1fa3e popover: Add a missing #ifdef 2014-12-24 21:59:49 +08:00
Carlos Garnacho
96f7c11f48 window: Use subsurfaces for popovers on wayland
On the wayland backend, set up GDK_WINDOW_SUBSURFACE windows
for popovers. In the popover code, the popover-relative-to-parent
calculation had to be tweaked, and it's been made to always prefer
the given popover position, since there's no sizing limitations.

https://bugzilla.gnome.org/show_bug.cgi?id=738891
2014-12-23 13:55:24 +01:00
Carlos Garnacho
ba22ae8cce popover: Clamp tail gap limits by the tail height on that side
All popover sides have extra margins to possibly hold the tail, this is
accounted for in gtk_popover_get_rect_coords(), and should be accounted
for too in the tail position calculation.

This fixes the gtk_render_frame_gap() warnings seen when a popover is
pushed far too close to window sides.
2014-12-13 18:02:29 +01:00
Carlos Garnacho
99791007a7 popover: Ensure there is a child before focusing it
Fixes a warning in empty popovers being shown.
2014-12-13 17:11:25 +01:00
Carlos Garnacho
ccdcff9456 popover: make smarter wrt previous focus widget lifetime
If the previous focus widget is unmapped (eg. hidden, scheduled for
destruction, etc), make the popover forget about it and grant focus
back to the window itself.
2014-12-02 15:49:23 +01:00
Matthias Clasen
e26fddc544 Avoid a critical
gtk_window_get_focus can return NULL, deal with it.

https://bugzilla.gnome.org/show_bug.cgi?id=740812
2014-11-27 18:24:12 -05:00
Carlos Garnacho
50076ed95b popover: Send key events only to the focus widget
gtk_window_propagate_key_event() will run unstopped from the focus widget up to the
popover if GDK_EVENT_PROPAGATE was returned along the chain, resulting in infinite
recursion. This could be just triggered by pressing some modifier key on an entry...
2014-11-26 15:30:52 +01:00
Carlos Garnacho
dde77704ed popover: Forward key events to focus widget while visible/modal
This is the expected behavior while the popover keeps the grab, leaving
this up to the toplevel implementation gives place to key handlers
connected there to handle the event otherwise, and maybe redirect key
events somewhere else.
2014-11-25 14:08:34 +01:00
Timm Bäder
9b83858d9a Revert "popover: Add show/hide transition"
This reverts commit 17f48e3a9e.
2014-11-17 18:39:00 +01:00
Timm Bäder
17f48e3a9e popover: Add show/hide transition 2014-11-17 18:37:47 +01:00
Matthias Clasen
49cf85509a GtkPopover: Survive attach_widget == NULL
We can't render a tail, but otherwise things should just work.
This will be useful in glade.
2014-11-14 06:16:41 -05:00
Carlos Garnacho
733f70ea84 gtkpopover: Fix allocation of child widget wrt margins
During size request, all sides' margins are ensured to be as big
as TAIL_HEIGHT, just to avoid possible relocation loops if the
popover doesn't fit in its original position. This must be
accounted for in size_allocate() as well.
2014-11-13 20:32:36 +01:00
Matthias Clasen
e41a8cf6fc Use GtkStack:vhomogeneous for popover menus
This allows us to get rid of a size group.
2014-10-26 15:03:58 -04:00
Timm Bäder
4d075cf202 popover: Use the right area for drawing the background
The border shouldn't be subtracted.
2014-10-26 15:21:06 +01:00
Benjamin Otte
91467a45fc stylecontext: Deprecate functions
- gtk_style_context_get_background_color()
- gtk_style_context_get_border_color()

Those functions shouldn't be used anymore, because they don't represent
anything from the CSS styling we support. The background color often
isn't used due to background images and there are actually 4 different
border colors (1 for each side) - if there isn't also a border image in
use.
2014-10-03 06:18:06 +02:00