Commit Graph

1069 Commits

Author SHA1 Message Date
Benjamin Otte
5cbbc62026 widget: Pass a GtkCssStyleChange instead of a bitmask 2015-12-13 04:11:58 +01:00
Benjamin Otte
971a277419 cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque
object that will compute the changes you are interested in for you.

This simplifies change signal handlers quite a bit and avoids lots of
repeated computation in every signal handler.
2015-12-12 02:16:04 +01:00
Matthias Clasen
f7cc4abbad Avoid ugly seams on half-tiled terminals
Since we're no longer doing geometry widgets, don't send
base size and increments to the window manager anymore either.
This avoids an ugly 2 pixel gap to the right and bottom of half-tiled
terminals under gnome-shell.
2015-12-07 10:11:06 -05:00
Matthias Clasen
93b3669273 Be forgiving if cursors are missing
No need to crash here. Missing cursors are ugly, but we
shouldn't crash.
2015-12-05 18:55:05 -05:00
Benjamin Otte
3ed71cf4a7 window: Deprecate gtk_window_resize_to_geometry()
And make it not do anything anymore.

Fixes erratic resizes of gnome-terminal.

https://bugzilla.gnome.org/show_bug.cgi?id=757282
2015-12-03 10:43:57 +01:00
Olivier Fourdan
de41389352 gtkwindow: Document further resize with csd
Applying the client-side decorations in the configure routine greatly
increases the chances of having the right size for the GtkHEaderBar and
border shadows.

Yet, it may be possible that these sizes change at a later point in
time, if for example the GtkHeaderBar grows in height while adding new
controls.

Mention this possible pitfall in the documentation for
gtk_window_resize().

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-12-03 09:16:29 +01:00
Olivier Fourdan
e933233479 gtkwindow: apply CSD in configure size request
Just like we did for the default size, that reduces the chances of
having the headerbar missing or wrongly sized when computing the client
side decorations controls.

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-12-02 08:41:31 +01:00
Benjamin Otte
3513e5e87b Chain up in state_flags_changed
When introducing handlers for state_flags_changed in the node
transitions, chaining up was forgotten.
2015-12-02 04:36:31 +01:00
Benjamin Otte
e1d74f7c71 window: Listen to icon theme changes on CSS
No need to connect a signal handler to the icon theme, we get notified
via CSS.
2015-12-02 03:28:36 +01:00
Benjamin Otte
bc1b53a34c css: Query icon theme from style, not from settings
No need to look at the settings when the CSS has a property for the icon
theme.
2015-12-02 03:18:26 +01:00
Benjamin Otte
67ab00e01e window: Remove suspicious branch
It seems this branch is not needed anymore. It was originally added in
1999 to support gtk_widget_realize(), but all those reasons seem
obsolete today.
Instead just call gtk_widget_realize().

If you end up at this commit when bisecting:
There is no bug that made me remove this code, it was purely meant to be
cleanup / dead code removal. I seem to have introduced a new bug or
bisecting wouldn't have let you here. So it seems we should just revert
this commit.
2015-12-02 00:29:29 +01:00
Olivier Fourdan
103d369ff6 gtkwindow: remove headerbar after disposing parent
Widgets such as gtkfilechooser may be saving their size and position on
the unmap callback, if the client-side decoration header bar is removed
first, the reported size will be wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-12-01 16:18:03 +01:00
Timm Bäder
a28103cf51 Add some more missing nullable annotations 2015-12-01 13:41:35 +01:00
Matthias Clasen
d908c38ec3 window: Use g_set_object
No need to do the same thing manually.
2015-11-30 20:45:57 -05:00
Benjamin Otte
f30b4ba22e gtkwindow: fix regression with firefox dropdown menu
Fix a regression introduced by:

commit 6866d1c widget: Make gtk_widget_queue_allocate() not resize

Where the dropdown menu in Firefox would not be relocated after the
toplevel window is moved.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=758609
2015-11-30 14:32:39 +01:00
Carlos Garnacho
4981ca9f13 GtkWindow: Reset gestures after triggering right click titlebar action
Just like it happens for window dragging, we're likely to not see the
matching button release for this event, so we must reset the controller
manually here.

https://bugzilla.gnome.org/show_bug.cgi?id=758661
2015-11-25 21:59:48 +01:00
Benjamin Otte
923ad2767a window: Don't lose position information
Before calling gdk_window_move_resize(), store the full configure
request, not just width and height.

Fixes firefox randomly losing position of its dropdown windows.

https://bugzilla.gnome.org/show_bug.cgi?id=758609
2015-11-25 20:31:27 +01:00
Christoph Reiter
308aec53c6 gtkwindow: apply CSD adjustments to the default size when used instead of when setting it
Before the resulting window size would differ if the default size was set
before adding a headerbar vs after. Now the saved state is again the actual
requested size and it is adjusted at the time we request a window size.

https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-11-19 21:42:24 +01:00
Olivier Fourdan
1080ffdf19 window: maximize on double click only if allowed
GtkHeaderBar will not show the maximize button if the window in not of
type normal or not resizeable.

Use the same restriction for double-click actions as well.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=757530
2015-11-19 15:04:03 -05:00
Jonas Platte
6a69c01e42 Fix return annotations for GtkWindow
Add nullable annotations for functions that may return NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=753520
2015-11-19 15:01:31 -05:00
Olivier Fourdan
370e3469c6 gtkwindow: apply csd offset to set/get_default_size
An application may use gtk_window_get_size() to retrieve the current
window size and later reuse that size with
gtk_window_set_default_size().

gtk_window_set_default_size() and gtk_window_get_default_size() should
also take client side decorations offset into account.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-11-18 08:35:31 +01:00
Benjamin Otte
55735cee2f window: Don't invalidate cssnode during get_preferred_width()
Getting the shadow width must not call gtk_style_context_set_state()
because that will invalidate the node and cause a style-updated emission
which can cause gtk_widget_queue_resize() calls.

And calling queue_resize() from get_preferred_size() essentially means
the size is permanently invalid because you invalidate it while
querying it.

This causes flickering of windows when going from/to backdrop state. To
avoid this we either need to fix the theme to not have different shadow
sizes in those cases or we need to ensure the window doesn't flicker in
the first place.
2015-11-14 18:32:08 +01:00
Olivier Fourdan
f2b373add8 gtkwindow: css offset for toplevel only
At the time gtk_window_move() or gtk_window_resize() get called, there
is no way to predict if a popup window will actually draw its shadow, so
applying an offset in this case may end up with a wrong size or
positioning for such windows.

Changing the logic in gtk_window_should_use_csd() as previously done to
address that issue will cause some other breakage as popup windows may
not draw a shadow but still need CSD.

So best is to actually apply client side decorations offset for regular,
top level windows only. This is actually a lot simpler and safer and
less likely to cause additional breakage.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-11-10 12:35:23 -05:00
Olivier Fourdan
9757ea2c49 gtkwindow: Fix resize without "_GTK_FRAME_EXTENTS"
git commit a5b1cdd0 introduced a regression where CSD windows are not
resizable with metacity.

Reason being that metacity does not support "_GTK_FRAME_EXTENTS" and
therefore gtk_window_supports_client_shadow() would always return FALSE.

This explains why it works with window managers which support
"_GTK_FRAME_EXTENTS" such as mutter/gnome-shell or xfwm4.

Partially revert commit a5b1cdd0 to reinstate the logic in
get_shadow_width().

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=757805
2015-11-09 14:17:53 +01:00
Matthias Clasen
e1182ec0e1 window: Don't pass wrong state to context
GtkStyleContext warns nowadays if one queries properties
from a different state. So, don't do that.
2015-11-06 22:47:16 -05:00
Matthias Clasen
ad214e1871 window: Add a diagram to the CSS documentation 2015-11-05 16:13:06 -05:00
Matthias Clasen
b4c650ae85 window: Use permanent CSS nodes
gtk_style_context_save_named() has drawbacks that we want to avoid.
2015-11-05 16:06:49 -05:00
Carlos Garnacho
fa3e0be80c GtkWindow: make popover stacking explicit
The list of popovers will specify the stacking order, a
_gtk_window_raise_popover() private call has been added so popover
widgets can request being on top.

Also, the stacking on popovers is ensured on gtk_window_size_allocate(),
after the size/stacking changes on the child widget have finished, this
will ensure popovers are kept on top of window contents.

https://bugzilla.gnome.org/show_bug.cgi?id=756670
2015-11-03 07:14:36 -05:00
Olivier Fourdan
a5b1cdd0c1 GtkWindow: Fix the shadow width logic
Previous commit 305b34a "GtkWindow: fix move/get position with CSD"
introduced a regression because some windows presumably use shadows but
actually don't, resulting in a negative offset being wrongly applied.

Problem is that get_shadow_width() would return non-zero shadows even
for windows that have no shadow, thus causing the negative offset.

Fix the logic in get_shadow_width() and gtk_window_should_use_csd() so
that get_shadow_width() returns accurate values.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-11-03 09:33:34 +01:00
Benjamin Otte
bef44ab294 window: Don't queue resizes when inhibiting resizes
Since the frame clock, the inhibit happens on the GDK level, so this
code is no longer necessary.
2015-10-28 19:44:29 +01:00
Benjamin Otte
6866d1c06e widget: Make gtk_widget_queue_allocate() not resize
This commit toggles the big switch. We now don't run size_allocate()
from the toplevel up anymore in cases where we don't need to.

Things might be broken in subtle ways as a result of this commit. We'll
have to find them and fix them.
2015-10-28 19:44:28 +01:00
Benjamin Otte
a31123e9f0 sizegroup: Skip resizes on widgets that have resize queued
Widgets that already have a resize queued don't need to walk the whole
parent chain and queue another resize. It's enough to do it once per
resize.

This also means that sizegroups cannot use the shortcut of just
invalidating the first widget in the group anymore. That widget might
already have a resize queued while others don't.
2015-10-28 19:44:28 +01:00
Benjamin Otte
08974a1e9a window: Ignore geometry widget
Ignore the geometry widget passed to gtk_window_set_geometry_hints().
Usind the widget itself was a hack that complicates the size request
machinery.

It is also incorrect in that it doesn't respect height-for-width.

Last but not least, it was only used by gnome-terminal and that
application can easily work without it.
2015-10-28 19:44:27 +01:00
Olivier Fourdan
305b34aa15 GtkWindow: fix move/get position with CSD
Take into account and compensate for the size of the client side
decorations widgets in gtk_window_move() and gtk_window_get_pos()
including gravity.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-10-26 08:40:36 +01:00
Olivier Fourdan
3450f53907 GtkWindow: add up CSD size in gtk_window_resize()
When client side decoration is used, the size passed to
gtk_window_resize() or retrieved from gtk_window_get_size() for top-
level windows also accounts for the client side decorations widgets
such as the title bar or the shadow borders.

Add up the size of these additional controls to the given size to get
the size expected.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=756618
2015-10-26 08:40:36 +01:00
Owen W. Taylor
1571d2872f GtkWindow: draw the frame and shadow even for app-paintable windows
If a window is decorated, we need to draw the frame and shadow, even if
it is app-paintable - it's just nonsense to have a frame that we handle
events on, but expect the app to paint it. (We paint the titlebar in
any case.) If a client wants to handle all painting, it should use an
undecorated window.

https://bugzilla.gnome.org/show_bug.cgi?id=756886
2015-10-22 11:05:03 -04:00
Benjamin Otte
371f501632 window: Name the decoration style 2015-10-22 16:42:48 +02:00
Benjamin Otte
244d9ffeee window: Refactor function
Move gtk_style_context_save() into the function that sets up the
decoration rendering.
2015-10-22 16:42:48 +02:00
Jonas Ådahl
364732f2e6 GtkWindow: Enlarge the type hint private field
Make it what it is - the enum - so that that it is sure that the hint
will fit in the field. Without this, any hint that doesn't fit in 3
bits will be truncated to the 3 least significant bits, causing
unexpected behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=756496
2015-10-14 10:32:31 +08:00
Olivier Fourdan
42b02d9d01 window: ignore resize increments for maximized/fullscreen
Once a window is maximized/fullscreen, resize increments should be
ignored otherwise the window may appear smaller than the screen size.

That also applies to configure requests as well.

https://bugzilla.gnome.org/show_bug.cgi?id=751368
2015-10-01 16:17:42 +02:00
Timm Bäder
b92213e49d GtkWindow: Don't needlessly resize popovers
Check whether the given popover even changed size in
_gtk_window_set_popover_position. If not, just move its GdkWindow
without calling gtk_widget_queue_resize. Using popover_get_rect here is
still relatively costly, but popover_size_allocate would be doing that
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
2015-09-29 15:28:55 +02:00
Matthias Clasen
ac198a3ce6 Add a few more inlined getters 2015-09-28 06:29:50 -04:00
Timm Bäder
02306867c3 GtkWindow: Check for popover realized-ness before unrealizing
https://bugzilla.gnome.org/show_bug.cgi?id=755473
2015-09-23 23:26:44 -04:00
Carlos Garnacho
e3d21accd0 window: cancel unclaimed sequences after GtkEventController::handle_event.
To GtkGesture machinery, if an event triggers a controller/gesture signal,
and gesture reset/cancellation as a result, the event has been managed
after all.

Commit e3bd895667 effectively changed the return value of the
wrapping gtk_event_controller_handle_event() function, which broke some
paths (eg. gtk_popover_button_press() wouldn't while the GTK+ grab was
active for this reason because the button press event was consumed early
on gtk_window_check_handle_wm_event()).

That patch is not too off-track given potential child widgets' behavior,
we want nonetheless to distinguish the denied vs cancelled paths here
(because GtkWindow itself relies on the GtkGesture behavior described in
the first paragraph on the begin_move/resize paths), so just reset
gestures after the event has already gone through the GtkEventController
so the return value is unaffected.
2015-09-21 14:32:44 +02:00
Carlos Garnacho
e3bd895667 window: Reset on unhandled gestures right away
Traditionally a sequence is set to GTK_EVENT_SEQUENCE_DENIED state when
it is to be ignored, which means it is dormant, but still managed by the
gesture (accounting, "denied" sequences still make "slots" in multitouch
gesture busy, etc...).

This gesture will run for all button presses and releases in the window
though when presses happen on the "window content" region, and we can't
account for every children to be as educated as setting the proper mask
on every window, or ensuring events will be propagated as they should.

In order to cater for this, just reset the gestures, we can live without
such accounting in these specific GtkGestureSingle gestures.

https://bugzilla.gnome.org/show_bug.cgi?id=754098
2015-09-18 12:51:22 +02:00
Benjamin Otte
07a574dddd window: Use gtk_widget_queue_resize()
_gtk_container_queue_resize() is a private function and probably
shouldn't have even been used in 1999 when this call was originally
added.
2015-09-14 23:36:58 +02:00
Benjamin Otte
51a1bc21af Revert "Avoid type checking overhead for resize-mode"
This reverts commit 3eacfa88f2.

Apart from the patch not being correct, we don't want to expose private
structures in header files if we can avoid it.
And this type-checking overhead is not an optimization that is even
measurable.

https://bugzilla.gnome.org/show_bug.cgi?id=754932
2015-09-12 21:27:24 +02:00
Matthias Clasen
3eacfa88f2 Avoid type checking overhead for resize-mode 2015-09-12 12:50:38 -04:00
Matthias Clasen
95cf550e15 window: Avoid unnecessary detours
Don't call gtk_widget_get_screen on a window - it only ends up
calling gtk_window_get_screen in the end, anyway.
2015-09-12 12:50:38 -04:00
Matthias Clasen
0368cbd256 window: Use internal more internal getters 2015-09-08 08:07:33 -04:00