Commit Graph

1086 Commits

Author SHA1 Message Date
Matthias Clasen
625f3e5f39 window: Always disconnect signal handlers
We connect to the titlebar widgets change notification regardless
whether it is internally created or not, so don't make the signal
handler disconnection conditional on that either.
2016-01-27 13:09:40 -05:00
Allison Ryan Lortie
0d109867d2 Tweak startup-notification after the first window
Presently, Gtk will only send a startup notification completion message
for the first window that is shown.  This is not good for the case of
GtkApplication, where we are expected to participate in
startup-notification for all windows.

We have avoided this problem by manually emitting the startup complete
message from after_emit in GtkApplication.

Unfortunately, this causes problems for windows that are shown with a
delay.  It is also a dirty hack.

The reason for the original behaviour is simple: there is a static
boolean in gtkwindow.c which controls it.  We remove this.

Instead, clear the startup notification ID stored in GDK when sending
the completion message.  GtkApplication will re-set this the next time
an event comes in which needs startup-notification handling.  In the
non-GtkApplication case, newly shown windows will still not send the
message, since the cookie will have been cleared.

Finally, we remove the hack from GtkApplication's after_emit.

This will probably cause some regressions in terms of lingering startup
notification messages.  The correct solution here is to always use
gtk_window_present(), including when merely opening a new document (with
a new tab, for example).

https://bugzilla.gnome.org/show_bug.cgi?id=690791
2016-01-27 18:14:40 +01:00
Matthias Clasen
cf3a781d32 Fix a typo 2016-01-26 20:57:50 -05:00
Benjamin Otte
84b788c4a5 window: Deprecate gtk_window_parse_geometry()
Geometry handling in GTK is deprecated.
2016-01-27 02:11:06 +01:00
Benjamin Otte
b22fdf24e0 window: Deprecate gtk_window_set_default_geometry()
We don't support geometries anymore.
2016-01-27 02:11:06 +01:00
Matthias Clasen
00aca5d689 Expand window style class documentation a bit 2016-01-17 12:13:59 -05:00
Olivier Fourdan
28f011eb05 wayland: prefer subsurface when possible
Quite a few applications use GTK_WINDOW_POPUP to create various
temporary windows and place then on screen. That works fine on X11 but
on Wayland there is no global coordinate system for regular surfaces.

If the application is using a gdk temp window and set a parent with
gtk_window_transient_for(), the gdk wayland backend has all it needs to
create a subsurface that can be placed at will by the application.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759738
2016-01-08 10:33:26 +01:00
Cosimo Cecchi
ef8a5fc542 window: remove unused variables 2016-01-03 00:54:16 -08:00
Christoph Reiter
6d77b9f316 gtkwindow: fix first allocation size
67ab00e01e removed the fake configure code in gtk_window_show() and
replaced it with a simple gtk_widget_realize(). The initial allocation
code in realize() only allocates the natural size or the last requested
size which now no longer is set, resulting in a too small first allocation.

This builds a configure request to compute the allocation size instead
which includes default size, CSD etc..

This problem could be seen in case of a GtkPaned in a GtkWindow with a
default size set and the pane position set as well. The first allocation
would be the natural size of the GtkPaned which would clamp the pane
position if too larg. Only the second allocation would fill the parent
window using the now wrong pane position.

https://bugzilla.gnome.org/show_bug.cgi?id=759705
2016-01-02 22:12:12 -05:00
Matthias Clasen
e93d64e4c3 Revert "Revert "window: Remove suspicious branch""
This reverts commit 2438a06d54.

See https://bugzilla.gnome.org/show_bug.cgi?id=759705
2016-01-02 22:12:12 -05:00
Matthias Clasen
8bfbb2c103 Cosmetic change 2015-12-26 21:42:10 -05:00
Matthias Clasen
2438a06d54 Revert "window: Remove suspicious branch"
This reverts commit 67ab00e01e.

See https://bugzilla.gnome.org/show_bug.cgi?id=759705
for a case where this makes a difference.
2015-12-22 07:36:58 -05:00
Daiki Ueno
75b3eec7a6 inspector: Avoid crash when canceling at startup
When clicking "Cancel" on the "Do you want to use GTK+ Inspector?"
dialog, unregister the update_debugging idle handler.  Also, steal
reference to 'inspector_window' while gtk_destroy_widget(), to make
further gtk_window_update_debugging() calls as a no-op.

https://bugzilla.gnome.org/show_bug.cgi?id=759764
2015-12-22 12:52:27 +09:00
Carlos Garnacho
4f9f3f04c0 GtkWindow: Add ignore deprecation statements
We still need access to floating devices at places
2015-12-16 19:47:07 +01:00
Carlos Garnacho
4a7589ea12 GtkWindow: Avoid GdkDeviceManager API
We can iterate over the seats' pointers, instead of over master pointers.
2015-12-16 19:47:07 +01:00
Matthias Clasen
2f544655f9 Revise CSS node documentation
Clarify the use of brackets in the CSS node diagrams:
[] means optional nodes or classes, <> means child widgets.
2015-12-16 10:58:47 -05:00
Carlos Garnacho
6ac16dc4a6 GtkWindow: Avoid gdk_device_manager_get_client_pointer()
It's now deprecated
2015-12-15 23:16:11 +01:00
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