Commit Graph

1036 Commits

Author SHA1 Message Date
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
Matthias Clasen
15b9feda22 widget: Add more inline getters
Add a getter for state flags, and use it where appropriate.
2015-09-07 12:23:09 -04:00
Matthias Clasen
0f92a43e10 Move GtkWidgetPrivate to gtkwidgetprivate.h
This lets us use inlined getters for members in there,
avoiding the type checks in the public getters.
2015-09-07 02:40:22 -04:00
Matthias Clasen
f3d92735ac window: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
2015-09-06 17:11:34 -04:00
Benjamin Otte
5037d134c5 window: Only update the inspector once
Instead of queueing a new idle handler every time we call
gtk_window_update_debugging(), only queue one if none is queued that.

Saves a lot of work, in particular when templates create context menus
for every row in a large listbox as in the gtk-demo listbox example.
2015-08-26 15:46:07 +02:00
Matthias Clasen
0455e56517 window: Set name on idle
Use gdk_threads_add_idle, and set a name on the source to aid
debugging, as we do everywhere else.
2015-08-15 16:05:11 -04:00
Matthias Clasen
a6b52c4275 Revert "Revert "Revert "gtkwindow: Reset maximize / fullscreen_initially on state changes"""
This reverts commit 8001b2c1b3.
2015-08-12 19:35:52 -04:00
Matthias Clasen
5cea77de38 Revert "Revert "Revert "window: fix initial shadow width for maximized/fullscreen windows"""
This reverts commit 968ac90e89.
2015-08-12 19:35:10 -04:00
Matthias Clasen
8001b2c1b3 Revert "Revert "gtkwindow: Reset maximize / fullscreen_initially on state changes""
This reverts commit de2ea1ebaa.

No reason in the commit message was given for the revert, and we need
this for proper behavior on map.
2015-08-12 14:40:31 -07:00
Jasper St. Pierre
968ac90e89 Revert "Revert "window: fix initial shadow width for maximized/fullscreen windows""
This reverts commit 8b695cc727.

No reason in the commit message was given for the revert, and we need
this for proper behavior on map.
2015-08-12 14:40:20 -07:00
Carlos Garnacho
69c9cb85e2 gtkwindow: bail out on WM operations in the presence of grabs
These operations will require a grab on the WM side, so we can spare the
attempt from the WM to take a grab when we're certain it won't suceed.

https://bugzilla.gnome.org/show_bug.cgi?id=752327
2015-08-04 17:59:01 +02:00
Matthias Clasen
859db92183 Remove a redundant assignment 2015-07-27 08:07:27 -04:00
Matthias Clasen
b2b4a3bb0a Fix a warning 2015-07-26 01:49:19 -04:00
Matthias Clasen
5c2759af3c Use standard cursor names
This changes GTK+ to use gdk_cursor_new_from_name() with the
'standard' css names, instead of GdkCursorType.

https://bugzilla.gnome.org/show_bug.cgi?id=652085
2015-07-26 01:45:06 -04:00
Jeremy Whiting
f9d903995d Added api to set a window to fullscreen on a given monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=752677
2015-07-25 07:08:59 -06:00
Matthias Clasen
3fec234c22 inspector: Rescan toplevels when they change
This ensures that windows appear in the inspectors tree when
they are created, and it prevents GTK_DEBUG=interactive from
coming up with an empty object tree.

https://bugzilla.gnome.org/show_bug.cgi?id=752664
2015-07-23 21:28:28 -04:00
Matthias Clasen
1138d4f489 Another fix for unmapped window states
The previous fix was falling into the crack between
realized and mapped - we would apply the state when a window
is just realized, then unset the _initially flag, and then
when the window gets mapped, we'd undo the state. To fix
this, go back to the way things were when these flags were
first introduced.

https://bugzilla.gnome.org/show_bug.cgi?id=752765
2015-07-23 17:54:50 -04:00
Matthias Clasen
f30637bbae GtkWindow: Rework the _initially variables
Go back to use these variables only for pre-mapped state changes.
Their use got muddied over the years, and it was hard to keep track
of what is acutal state, and what just a queued request.
2015-07-22 23:28:39 -04:00
Matthias Clasen
8b695cc727 Revert "window: fix initial shadow width for maximized/fullscreen windows"
This reverts commit 740bcf5fe0.
2015-07-22 23:16:52 -04:00
Matthias Clasen
de2ea1ebaa Revert "gtkwindow: Reset maximize / fullscreen_initially on state changes"
This reverts commit 862e0dab03.
2015-07-22 23:16:44 -04:00
Benjamin Otte
04883e72fa window: Set the type hint when it changes, not just on map()
There is no reason to wait until map() to reset a type hint on the GDK
window. Just set it when it changes.
2015-07-19 04:45:25 +02:00
Benjamin Otte
b0ac837271 window: g_object_notify() on type-hint change 2015-07-19 04:45:25 +02:00
Benjamin Otte
38a07cde75 window: Don't update type hint when it didn't change 2015-07-19 04:45:25 +02:00
Benjamin Otte
7a16039c2d window: Allow setting type hint on mapped windows 2015-07-19 04:45:25 +02:00
Benjamin Otte
8a238c7886 window: Don't keep 2 type hints
1. This confuses the code as it's using the old type hint with the new
type hint on GDK window creation

2. It only existed as a workaround for old code that directly accessed
window->type_hint which hasn't been possible since 3.0.
2015-07-19 04:45:25 +02:00
Matthias Clasen
0bb2567ff5 GtkWindow: Fix a use-after-free
We were printing a string in a warning after freeing it.
Also, fix an x/y typo that might cause popovers to be
mispositioned.
2015-07-17 19:19:24 -04: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
Olivier Fourdan
c806f9b709 ignore size inc when maximized/fullscreen
Under Wayland, fullscreen/maximized windows may not cover the entire
area when a size increment is specified.

Ignore size increments for fullscreen/maximized windows just like most
window managers do under X11 so that windows with size increments can
still be fullscreen or fully maximized under Wayland as well.

https://bugzilla.gnome.org/show_bug.cgi?id=751368
2015-07-03 16:21:13 +02:00
Jasper St. Pierre
862e0dab03 gtkwindow: Reset maximize / fullscreen_initially on state changes
Since 740bcf5, we use these properties to properly compute shadow widths
for unmapped windows. If a client calls gtk_window_maximize and a window
manager unmaximizes a window, we should draw borders, so we need to
reset these when we get the property notification.
2015-07-01 17:50:23 -07:00
Cosimo Cecchi
e67b4874eb window: don't override background every style_updated()
This queues an unnecessary resize on the toplevel, and is not needed
anymore, now that GtkWidget does not call
gtk_style_context_set_background() on the window's GdkWindow anymore.
2015-07-01 16:09:23 -07:00
Cosimo Cecchi
74f2d9448f window: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Christoph Reiter
5d17b0af54 GtkWindow: don't increase the preferred size for empty windows if there is a size request set.
This fixes a reftest broken by commit 84e99b20ac

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-07-01 09:32:19 -07:00
Jasper St. Pierre
04e727709d window: Don't send startup notifications for offscreen / popup windows
The WM isn't aware of O-R (popup) or offscreen windows. If somebody
maps an offscreen or a popup GTK+ window before the main window, we'll
complete the sequence before a "real" window is mapped. Make sure to
ignore these for startup notifies.
2015-06-29 14:26:45 -07:00
Christoph Reiter
48ea0cbe4b GtkWindow: some min/nat size corrections.
Don't add the container border to the title request size; it
is only used for the child widget.

Don't call gtk_widget_get_preferred_width_for_height() for
the title bar with an unrelated height and subtract the title
bar height before querying the child widget width.

Guard against negative size requests after substracting the
borders/shadows and the title bar.

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-06-24 10:58:30 +02:00