Commit Graph

1115 Commits

Author SHA1 Message Date
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
Christoph Reiter
84e99b20ac GtkWindow: fix default empty window size with CSD
In the non-CSD case we checked for 0x0 window size requisition
and replaced it with 200x200 so the window was still visible.
This no longer works in case of CSD as the shadow and title bar
are always added to the requisition resulting in a titlebar/shadow
only window in case there is no child widget (this is currently
visible under wayland or when setting GTK_CSD=1).

Instead of special casing the final window size, special case
the child requisition paths instead. This gives us the same
requisition in both, CSD and non-CSD cases (the header bar
has a too large minimum width atm so the resulting window is
still not the same)

https://bugzilla.gnome.org/show_bug.cgi?id=751341
2015-06-23 21:16:14 +02:00
Christoph Reiter
3c9cca596f Fix calculation of edge input window size in case the real window is too small.
This error resulted in warnings like
"pixman_region32_init_rect: Invalid rectangle passed"

In case the window is smaller than handle_size * 2 the resulting
edge window got a negative size. Prevent that by limiting the
handle size to half the respective edge length. This also
prevents the corner windows from overlapping in case the window
is too small.
2015-06-22 14:22:50 +01:00
Emmanuele Bassi
97e728580c Revert "window: Check if we can use CSD before enabling them"
This reverts commit c5e5ee6749.

It turns out that this commit breaks the default sizing of GtkWindow,
which in turn causes the window to be smaller than the handle size,
which ends up sending invalid rectangles to Cairo.

We'll have to find another way to fix the CSD issue.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=751140

https://bugzilla.gnome.org/show_bug.cgi?id=750343
2015-06-22 14:21:47 +01:00
Emmanuele Bassi
9590879e2f Revert "window: Reinstate logic for should_use_csd()"
This reverts commit f043fd532d.

The whole point of having can_use_csd() return TRUE when GTK_CSD is
unset is to use it inside enable_csd().

https://bugzilla.gnome.org/show_bug.cgi?id=751140
2015-06-18 16:10:36 +01:00
Emmanuele Bassi
f043fd532d window: Reinstate logic for should_use_csd()
The old should_use_csd() function would return FALSE if the GTK_CSD
environment variable is unset; the change in commit c5e5ee6749
made it return TRUE if GTK_CSD is unset. This has a cascade effect
on the window size, which causes invalid rectangles to bubble down
to Pixman.

https://bugzilla.gnome.org/show_bug.cgi?id=751140
2015-06-18 14:52:17 +01:00
Ting-Wei Lan
f85db624eb Fix return value error in _gtk_window_get_popover_parent 2015-06-18 12:14:44 +08: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
a0ff35f032 window: Avoid rising the window of already shown popovers
This breaks stacking, as popovers are repositioned sort of frequently
(even more after show/hide animations).

https://bugzilla.gnome.org/show_bug.cgi?id=750741
2015-06-12 21:00:45 +02:00
Carlos Garnacho
551931c1c6 window: Allow more space at edges for popovers
We're clamping to the visible window edge, which misplaces text handles.
2015-06-11 17:14:23 +02:00
Emmanuele Bassi
c5e5ee6749 window: Check if we can use CSD before enabling them
The change in 03213b9509 changed the rules
as to when CSD can be enabled, but it also unconditionally enables CSD
with the implicit assumption that client-side shadows were the real
issue, and that we could work around that by drawing our own borders.
This also means that setting a titlebar for a GtkWindow will enable CSD
unconditionally.

In reality, some window managers (like Matchbox) *only* support
server-side decorations, and will ignore all hints to the contrary, to
the point of drawing decorations at random locations on top of the
window.

Since CSD are enabled unconditionally, the GTK_CSD environment variable
is also not a suitable escape hatch.

In the grand tradition of asking ourselves if we should do something
just because we can, we should split the environment checks from the
checks on what the user requested; by doing that, we can also check
when enabling client-side decorations, and ideally bail out if needed.

https://bugzilla.gnome.org/show_bug.cgi?id=750343
2015-06-03 16:06:10 +01:00
Jonas Ådahl
f6d021512a GtkWindow: Don't assume no shadow width even when not supported
Even if a window doesn't support client side shadow
(gtk_window_supports_client_shadow returns FALSE), don't assume the
shadow width is zero, as CSD may have been enabled anyway (meaning
priv->client_decorated is TRUE). In that case we still need to report
the correct width.

https://bugzilla.gnome.org/show_bug.cgi?id=749451
2015-05-18 07:46:43 -04:00
Kjell Ahlstedt
12ccebe2a4 gtkwindow: Fix a memory leak
The private data GtkGesture* drag_gesture was added by commit
13e22e2030, but it's never destroyed.
Unref it in gtk_window_finalize().

https://bugzilla.gnome.org/show_bug.cgi?id=749425
2015-05-15 15:39:04 +02:00
Jonas Ådahl
08e2f958f0 GtkWindow: Manually set CSD should enable shadow width calculation
If CSD is enabled with shadow even though it "shouldn't"*, the width
should still be calculated correctly. This fixes a regression caused by
b1e5ad469c.

* gtk_window_should_use_csd () returns false

https://bugzilla.gnome.org/show_bug.cgi?id=748615
2015-05-07 15:56:14 -04:00
Jonas Ådahl
b1e5ad469c GtkWindow: Get the correct shadow width even before window is realized
The window state 'client_decorated' will only be set the window is being
realized. If anyone tries to get the shadow size before that it'd get
the with as if there always was no shadow.

This avoids negative sized opaque regions caused by the allocation being
smaller than shadow.

https://bugzilla.gnome.org/show_bug.cgi?id=748615
2015-05-06 19:55:20 +08:00
Руслан Ижбулатов
d44921a152 Enable RGBA windows on W32
Requires Vista and newer.

* Create surfaces with cairo_win32_surface_create_with_format
* Provide an rgba visual that can be distinguished from the system visual
* Make rgba visual the best available visual
* Enable alpha-transparency for all windows that we control
* Check for appropriate cairo capabilities at configure time
  (W32 - 1.14.3 newer than 2015-04-14; others - 1.14.0)

* Check for composition support before enabling CSDs
* Re-enable transparency on WM_DWMCOMPOSITIONCHANGED
Windows that were created while composition was enabled and that were CSDed
as a result and will look ugly (thick black borders or no borders at all) once
composition is disabled.
If composition is enabled afterwards, they will return back to normal.
This happens, for example, when RDP session is opened to a desktop where a GTK
application is running. For W7/Vista windows will only re-gain transparency after
the RDP session is closed. For W8 transparency will only be gone momentarily.

Windows that were created while composition was disabled will not be CSDed
automatically and will use SSD (WM decorations), while windows that are CSDed
manually will get a thin square border.
If composition is enabled afterwards, these windows will not change.
This is most noticeable for system menus (popup menus are often generated
on the fly, system menus are created once) and some dialogues (About dialogue,
for example).

https://bugzilla.gnome.org/show_bug.cgi?id=727316
2015-04-29 21:12:13 +00:00
Matthias Clasen
43cee06160 GtkWindow: Use _gtk_builder_lookup_object 2015-04-27 23:09:35 -04:00
Matthias Clasen
62b875f209 GtkWindow: Use the new helpers
Instead of issuing g_warning, fill the provided GError.
This lets us test this error handling, and is the right
thing to do. Use the new GtkBuilder helpers and
g_markup_collect_attributes to do so.
2015-04-27 01:15:24 -04:00
Cosimo Cecchi
740bcf5fe0 window: fix initial shadow width for maximized/fullscreen windows
To calculate the shadow width, we look at the value of priv->fullscreen
and priv->maximized.
Those fields will have the actual value only after GTK receives back a
window state event though, so they will be wrong in _realize(). Look at
priv->fullscreen_initially and priv->maximize_initially too, to avoid
the size changing right after realize, which would make the window
flicker if maximized at startup.

https://bugzilla.gnome.org/show_bug.cgi?id=747808
2015-04-16 22:12:56 -04:00
Matthias Clasen
a08ee01c64 csd: Fix an oversight for popups
After the recent rework of client-side shadow code, menus,
tooltips and similar popups were ending up with solid decorations.
Fix this oversight.
2015-03-23 10:41:10 -04:00
Olivier Fourdan
03213b9509 Improve CSD decorations without a compositor
It turned out that using mwm hints to instruct wms to
create border-only decorations is not really working
universally. So, instead of doing this, render a solid
frame without shadow on the client-side to handle this
case.

https://bugzilla.gnome.org/show_bug.cgi?id=746222

Signed-off-by: Olivier Fourdan <fourdan@xfce.org>
2015-03-22 01:34:37 -04:00
Benjamin Otte
4b2cdb37fb cssnode: Remove timestamp from gtk_css_node_validate()
GtkCssNode knows its own timestamp.
2015-03-18 15:23:32 +01:00
Benjamin Otte
5833858abf cssnode: Make parent style change part of GtkCssNode 2015-03-18 15:23:32 +01:00
Benjamin Otte
75b633ae08 cssnode: Only pass a boolean for parent changes
Nobody cares what changed in the parent, so don't track it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
b92fe2fa85 widget: Add gtk_widget_get_css_node()
and replace gtk_style_context_get_root() with it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
28043f0a92 cssnode: Refactor invalidation propagation
We want to be sure to gtk_css_node_invalidate() all potential changes.
2015-03-18 15:23:30 +01:00
Benjamin Otte
4cc2af2db1 stylecontext: Move validation into GtkCssNode 2015-03-18 15:23:29 +01:00
Carlos Garnacho
b4b23580a6 window: Protect against popover destruction on ::unmap
On popover_unmap(), perform the gtk_widget_unmap() call last, so the
GtkWindowPopover data is ensured to be alive throughout the function
if the popover widget is destroyed right on ::unmap.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:27:06 +01:00
Carlos Garnacho
622a930c5a window: reset both press/drag gestures when move/resize drag starts
Now that this is split in two separate gestures, both must be reset
when the WM grabs the pointer. Also, do on resize drags like on move
drags, and claim the gesture before resetting, so the ownership is
properly transferred across any other widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=745969
2015-03-10 16:48:16 +01:00
Matthias Clasen
5ced234144 Revert "csd: Drop the GTK_FRAME_EXTENTS requirement"
This reverts commit fb9a6bb6d8.

In a recent test, I've found that Xfce and Mate now support
this, so they will not be affected by this requirement. And
adding the check back will solve the 'client-side shadow'
problem in KDE.
2015-03-09 20:48:47 -04:00
Carlos Garnacho
40c8d8bcf4 window: Add comment documenting the target widget checks during window drag
Was suggested during review of
https://bugzilla.gnome.org/show_bug.cgi?id=745562#c2
2015-03-05 11:52:24 +01:00
Carlos Garnacho
08494f86a0 widget: Improve hack to ignore drags from widgets using motion events
Postpone until the last moment whether the target widget still
potentially uses updates from this sequence, or window dragging
actually applies because all gestures on the target went to denied
state.

This fixes window dragging on empty space in a headerbar that is
contained in a paned (as in e.g. gedit).

https://bugzilla.gnome.org/show_bug.cgi?id=745562
2015-03-04 21:20:29 -05:00
Carlos Garnacho
d070e4c742 gtkwindow: Do not show subsurface windows for hidden popover widgets
This is really just necessary when we have a visible widget, otherwise
the window would temporarily linger with odd size and surface.

https://bugzilla.gnome.org/show_bug.cgi?id=743427
2015-03-02 12:11:59 +01:00
Carlos Garnacho
13e22e2030 gtkwindow: Move window dragging to a standalone drag gesture
The gesture is hooked to the capture phase, so it works for buttons in
header bars and whatnot. In order to be friendly to the widget it is
capturing events from, an ugly hack is in place to avoid capturing
events when the target widget has a gesture that would consume motion
events.
2015-03-02 12:03:39 +01:00
Matthias Clasen
b3043e429b Avoid a crash in the inspector under wayland
The Wayland-specific popover code in GtkWindow was not doing the
right thing with the separate display connection we use for the
inspector.
2015-02-17 09:37:18 -05:00
Jasper St. Pierre
a34a0224e4 gtkwindow: Don't set the background if the window is app-paintable
This fixes transparent DND windows.
2015-02-13 18:22:34 -08:00
Matthias Clasen
ac497c6e8f csd: Always raise on primary titlebar click
This matches more closely what typical window managers do.
Pointed out in
https://bugzilla.redhat.com/show_bug.cgi?id=1158472
2015-02-13 08:51:28 -05:00
Carlos Garnacho
d053db289e window: Unparent popover before unmapping/unrealizing
Otherwise spurious invariants warnings may happen before the popover
is removed from the window.
2015-02-05 15:09:35 +01:00
Carlos Garnacho
cc511268a0 window: call gtk_widget_unmap() on popover widgets unconditionally
is_visible() wasn't the right check to perform here before unmapping,
and gtk_widget_unmap() already avoids being doubly called by checking
gtk_widget_get_mapped() anyway.
2015-02-05 15:09:28 +01:00
Carlos Garnacho
3f4df0644c window: Only claim the sequence if keeping the grab
If the grab belongs elsewhere, the window won't claim the sequence right
away. The sequence may still be claimed afterwards when window dragging
starts, but simple clicks won't be consumed this way.

This makes it possible to close popovers when clicking on the title region,
while still permitting touch/button 1 interaction for every other purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=743257
2015-01-28 17:11:12 +00: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
Christian Hergert
fb8791cd16 window: fallback to window muxer if no widget has focus
This ensures that we can still match accelerators for the window even
if no widget currently has focus.
2014-12-08 20:19:33 -08:00
Carlos Soriano
235837ad49 gtkwindow: Use actions from focused widget to activate accel
Currently we only take into account the window GActionGroup for
activating the accels.

However, the application could have some custom GActionGroup in the
chain of focused widgets that could want to activate some action if
some accel is activated while that widget is focused.

To allow applications to set accels on widgets that use custom
GActionGroups, simply use the muxer of the focused widget, which
already contains the actions of the parents.

https://bugzilla.gnome.org/show_bug.cgi?id=740682
2014-12-08 20:19:33 -08:00
Matthias Clasen
8753ef6129 Render shadows for half-tiled windows
Without this, side-by-side half-tiled windows are hard to discern.

https://bugzilla.gnome.org/show_bug.cgi?id=708857
2014-11-27 18:24:12 -05:00
Jasper St. Pierre
2cd835c076 gtkwindow: Optimize GtkStyleContext usage 2014-11-25 11:05:36 -08:00
Matthias Clasen
c7f3b93d99 Keep gtk_window_set_hide_titlebar_when_maximized working
This broke in 510c2cdfb6.

https://bugzilla.gnome.org/show_bug.cgi?id=740287
2014-11-24 06:49:19 -05:00
Emmanuele Bassi
36fedb0c4b window: GtkPlug is conditionally supported on X11 only
We cannot do a type check on it if we don't have the X11 backend
compiled in.

https://bugzilla.gnome.org/show_bug.cgi?id=739885
2014-11-10 15:08:44 +00:00
Emmanuele Bassi
cdcd3ca359 Hide GdkWindow libgtk_only API in the private vtable
These are the last two global GDK symbols that have a libgtk_only
suffix.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Carlos Garnacho
52a90758f9 gtkwindow: claim the press sequence when clicking on the titlebar
This event might not have an action yet, but certainly accounts, and
should be triggering recognition.

This fixes a crash when attempting to drag CSD windows through touch. As
since cfaec2d2f5, gtk_gesture_single_get_current_sequence() would
rightfully return NULL if the gesture didn't enter recognition, making
event lookup fail.
2014-11-07 13:54:10 +01:00
William Hua
063f79b594 mir: enable csd 2014-11-06 16:18:53 -05:00
Carlos Garnacho
d9a433daf7 gtkwindow: Resort to regular event bubbling by all means on non-toplevels
If the multipress gesture is not created (ie. not a toplevel GtkWindow),
also avoid possibly calling gtk_widget_event() on the events gotten here.
2014-11-04 19:03:27 +01:00
Carlos Garnacho
03a30e462e gtkwindow: Do not create the multipress gesture for plugs
GtkPlugs may "qualify" as toplevels, even though they're not meant to
be WM manipulated, so refuse to create the multipress gesture for these
too.
2014-11-04 19:03:18 +01:00
Matthias Clasen
120abd9a6e csd: Improve appearance inside glade
glade turns windows into non-toplevels, so we can easily recognize
that situation and avoid adding a humongous shadow area.
2014-11-01 14:49:02 -04:00
Matthias Clasen
778865f316 Fix toplevel input shape for csd windows
We need to maintain the application-set and the the csd
input shape separately, and intersect them to pass them
down.
2014-10-28 20:23:47 -04:00
Matthias Clasen
4cf6edda55 wayland: Make window opacity work
Under wayland, the compositor doesn't have a 'overall window alpha'
knob, we just need to add the alpha to the buffers we send.
Client-side alpha, if you want to call it that.

Implement this by reusing the existing alpha support for non-toplevel
widgets. As a side-effect of the implementation, windows with RGBA
visual under X will now also use per-pixel alpha, instead of
overall alpha.
2014-10-28 10:28:23 -04:00
Jasper St. Pierre
5f980cd8de gtkwindow: Use gdk_cursor_new_for_display
Otherwise, this crashes the inspector, since it now uses multi-display
technology, and on Wayland, resources like the cursor are client-private.
2014-10-27 21:22:44 -07:00
Matthias Clasen
182dd3c1ea Fix a mixup in popover realization
When the window is on a non-default screen, popover_realize
ended up passing a visual and a parent_window from different
screens into gdk_window_new, which doesn't work. Fix it by
using the visual of the parent window.
2014-10-24 23:36:35 -04:00
Matthias Clasen
fea13fcfc1 Fix a problem with screen changes and csd
When a new screen is set on a window, we unrealize it, to
recreate all the resources. But we don't reset the client_decorated
flag, so realize() doesn't call create_decoration() - which makes
sense, since the decoration already exists. But the side-effect
of create_decoration() is to select the rgba visual, and visuals
are per-screen.

Fix this by looking for the rgba visual in set_screen(), and
replacing it with the rgba visual for the new screen, if necessary.
2014-10-24 15:57:33 -04:00
Matthias Clasen
c5c21bb1cf GtkWindow: Add a getter for the custom titlebar
This is needed for the glade integration of CSD windows.
2014-10-18 12:51:30 -04:00
Matthias Clasen
8821d488c5 GtkWindow: Avoid an early exit
When gtk_window_set_titlebar (win, NULL) is called, we were taking
an early exit and forgot to re-map the window. This does not normally
happen in practice, but glade is about to get a 'csd' switch which
lets one toggle back and forth between titlebar and no titlebar.
2014-10-17 13:59:39 -04:00
Carlos Garnacho
1ae5c2a138 window: unset menubar before unsetting focus on dispose()
If the menubar has an app-menu popover, and it is shown at the time of
disposing the window, it will attempt to transfer focus back to the
previous focus widget when undoing modality, even though the dispose()
code already did set_focus(NULL) previously.

At the time the popover is removed, there aren't many hints as to whether
the toplevel or the focus widget are being destroyed (ie. not still under
in_destruction), so just swap the order of these two calls.

For every other popover, this would all happen within dispose/destroy,
which is handled better.
2014-10-14 15:47:06 +02:00
Matthias Clasen
42280f6c4e inspector: Add a way to disable the warning dialog 2014-10-09 23:38:44 -04:00
Matthias Clasen
92e52fd188 Add a style class to fullscreened windows
This will let us tweak stuff that gets shown in fullscreen windows,
https://bugzilla.gnome.org/show_bug.cgi?id=654051
2014-09-26 18:08:46 -04:00
Matthias Clasen
2cb31edf6f inspector: Show the warning dialog without delay
The delay was a mistaken attempt to work around a problem that
is now better understood, see
https://bugzilla.gnome.org/show_bug.cgi?id=735338
2014-09-26 09:50:33 -04:00
Matthias Clasen
3b62f2f01d GtkWindow: improve the inspector keybinding
Binding signals can return a boolean indicating whether they
handled the event. Use that here and return FALSE if the
inspector keybinding is disabled.
2014-09-26 09:50:33 -04:00
Matthias Clasen
fcec9b9812 Use titlebar action settings for CSD windows
Instead of hardcoding these actions, consult the settings.
Note that not all of the actions supported by gnome-shell are
implemented here, only maximize, minimize, lower, and menu.

https://bugzilla.gnome.org/show_bug.cgi?id=729782
2014-09-25 14:54:49 -04:00
Matthias Clasen
d20fdd18eb Factor out titlebar click actions
So they can be made configurable.

https://bugzilla.gnome.org/show_bug.cgi?id=729782
2014-09-25 14:54:49 -04:00
Carlos Garnacho
6b7b55f9b2 gtkwindow: run ::event and specific handlers for EWMH action triggering events
This gives an opportunity for implementations to handle these events
differently, instead of hardcoding the WM-triggering behavior.

gtk_window_event() only forwards events for WM management if the event
widget is not the window (ie. caught when bubbling), so is safe to be
called here without triggering gtk_window_handle_wm_event() twice.

This commit is an adaption to master of
https://bugzilla.gnome.org/show_bug.cgi?id=736702#c1 by Cosimo Cecchi.
2014-09-22 20:51:24 -04:00
Matthias Clasen
3c96ea0ae7 inspector: Look up the schema recursively
This is the recommended way to use this function. It should
also fix problems with the inspector when GSETTINGS_SCHEMA_DIR
is set.

https://bugzilla.gnome.org/show_bug.cgi?id=737027
2014-09-20 19:52:23 -04:00
Jasper St. Pierre
df236fba58 gtkwindow: Make sure to update the shadow width, opaque region and border windows when realizing
Otherwise, they might not be properly set before the window is mapped.

For the opaque region and border window, it means that they won't get
set before the next size allocation, which tends to not be a bit deal.

For the shadow width, though, _GTK_FRAME_EXTENTS has a different meaning
when it's set before the window is mapped, so we need to make sure that
it's properly set when the window is mapped.
2014-09-19 17:39:46 -06:00
Matthias Clasen
a1af365566 Don't forget to allocate popovers
When GtkApplicationWindow has a menubar, we don't chain up
to the GtkWindow size_allocate, which used to position the
popovers. Move that to _gtk_window_set_allocation() which
is always called by GtkApplicationWindow.

https://bugzilla.gnome.org/show_bug.cgi?id=736205
2014-09-06 21:32:53 -04:00
Matthias Clasen
84ff0c201a Don't set an input shape unless client-decorated
We were actually setting an input shape larger than the window
in !csd, and this was confusing at least openbox.

https://bugzilla.gnome.org/736064
2014-09-06 15:43:11 -04:00
Carlos Garnacho
ee93db1659 window: Add private API to hardcode the main GdkWindow for a GtkWindow
This must be called while the window is not realized yet, and sets the
GdkWindow that will be used for the next GtkWindow's realize/unrealize
cycle. The GtkWindow takes ownership on the GdkWindow, and as such it
will be destroyed when the widget is unrealized.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:54 +02:00
Carlos Garnacho
c38651cac4 gtkwindow: Add private API to mark as subsurface
This is a rather hackish way to let GTK+ widgets declare popup windows
as subsurfaces, so they may work on wayland without the need of xdg_popup,
and without many changes yet on the GTK+ side.

https://bugzilla.gnome.org/show_bug.cgi?id=695504
2014-08-26 23:06:01 +02:00
Carlos Garnacho
c17d3ee8fe window: Set GtkGestureSingle::button to 0 on multipress gesture
This gesture handles events from multiple buttons, so ensure the
gesture still does so after the default value change.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:53:40 +02:00
Carlos Garnacho
131123c71a window: Set multipress gesture phase to be GTK_PHASE_NONE explicitly
This used to rely on the default value, which has changed to a saner default.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:49:39 +02:00
Carlos Garnacho
5b8267028d window: Update popover positions on ::size-allocate
Popovers may get relocations optimized away if only x/y changed
in the GtkAllocation. So make sure the toplevel updates popover
positions on all situations.

https://bugzilla.gnome.org/show_bug.cgi?id=729140
2014-08-03 18:37:53 +02:00
Carlos Garnacho
25721ae3e7 window: Only avoid queueing resizes if the popover position didn't change
If the same position is requested on a popover, it should at least ensure
the window is realized and raised, even if no resizes are queued on the
content. Otherwise other widgets being mapped might raise the windows over
the popover's if its original position is unchanged.

https://bugzilla.gnome.org/show_bug.cgi?id=734129
2014-08-03 01:12:12 +02:00
Matthias Clasen
785c9f5e2c Remove a reference to a non-existing function 2014-08-02 22:26:05 +02:00
Matthias Clasen
14eccae603 GtkWindow: Add a way to declare initial focus in ui files
With this commit, it is possible to use <initial-focus name="blah">
to declare the initial focus widget for a window.

This is related to
https://bugzilla.gnome.org/show_bug.cgi?id=734033
2014-08-02 11:58:13 +02:00
Matthias Clasen
f15ebc2dd2 GtkWindow: Make set_focus work before show
So far, gtk_window_set_focus just did not work when called on
a hidden window. Change it to record the desired focus widget
for hidden windows, and apply it when the window gets shown.

This is similar to how we tread other window properties that
can't be set before the window is realized, like maximized
or fullscreen.

This is related to
https://bugzilla.gnome.org/show_bug.cgi?id=734033
2014-08-02 11:38:23 +02:00
Jasper St. Pierre
a3c12ffccb gtkwindow: Clean up gtk_window_move_resize a bit more
Don't shadow existing variables. Instead of sharing the allocation and
then overwriting the width/height when convenient, declare it in the
block we use it in, as, really, the three different paths are all
extremely different, and there's no sense in sharing the variable.
2014-07-17 13:10:50 -04:00
Jasper St. Pierre
927b5a592f gtkwindow: Remove a bogus comment
gtk_window_configure_event certainly doesn't fill the new allocation
in. We're filling it in right here!
2014-07-17 13:10:50 -04:00
Jasper St. Pierre
2e4018c386 gtkwindow: Clean up the code for an optimization
It's hard to figure out what the "expected_reply" means except under
close examination -- it's actually talking about whether this was a
reply to a ConfigureRequest or not. The inversion in the check doesn't
help either.

Make the code cleaner by moving it above the freeze/thaw case, and
making the check more explicit and without a confusing variable. If we
haven't sent any ConfigureRequests out, then it must be a gratuitous
ConfigureNotify.
2014-07-15 14:49:16 -04:00
Jasper St. Pierre
b7a8bde895 gtkwindow: Fix the comment for an optimization
The optimization was incorrect, and so it was changed in commit
2bf6824, but the comment to go along with it was never updated.
2014-07-15 14:49:16 -04:00
Jasper St. Pierre
1fb2756b99 gtkwindow: Remove the unused GTK_WINDOW_REGION_EDGE 2014-07-07 16:30:51 -04:00
Matthias Clasen
a19bc50f64 GtkWindow: Elaborate the keybindings
Keep Ctrol-Shift-D as a straight toggle-the-inspector keybinding,
but make Ctrl-Shift-I always bring up the inspector, and point
it at the widget under the pointer.
2014-07-06 22:37:57 -04:00
Matthias Clasen
b5958d677f GtkWindow: Update default for has-default-grip
It is now FALSE.
2014-07-03 15:23:34 -04:00
Jasper St. Pierre
ece9ae4bc5 gtkwindow: Remove resize grips
Resize grips were introduced for GNOME 3.0, before we had any of the
"new GNOME app" features like invisible borders and CSD. With OS X 10.6
and 10.7, Apple has replaced the classic grips in their applications
with invisible borders as well.

New GNOME app designs don't use resize grips anymore and the new
default theme for GTK+, Adwaita, disables them entirely by forcing their
width and height to 0.

They're past their time. Remove the code to support them. This can
always be reverted if some app relies on them.
2014-07-03 12:58:41 -04:00
Jasper St. Pierre
ed273e7518 gtkwindow: Fix compile warnings 2014-07-03 10:55:31 -04:00
Matthias Clasen
b369719bcd inspector: Handle the dialog more carefully
When showing and hiding the inspector window repeatedly without
dismissing the dialog, we were hiding the inspector, but not
the dialog, leading to a confusing user experience.

https://bugzilla.gnome.org/show_bug.cgi?id=732443
2014-07-02 22:52:10 -04:00
Jasper St. Pierre
796dc682bc gtkwindow: Refactor out some similar code for grips 2014-06-27 09:19:50 -04:00
Jasper St. Pierre
1210b693a0 gtkwindow: Merge some similar code 2014-06-27 09:19:49 -04:00
Jasper St. Pierre
95cb816666 gtkwindow: Remove a dead chain-up
GtkWidget / GtkBin don't have configure-event handlers, so we don't need
to attempt to chain up to them.
2014-06-27 09:19:49 -04:00
Jasper St. Pierre
9c37b3de74 gtk: Don't use GObjectClass.constructor
Use the newer constructed instead, which has a fast path in GObject.
2014-06-26 19:06:43 -04:00
Jasper St. Pierre
75e770bc50 gtkwindow: Remove a dumb invalidate_rect from our configure_event
We shouldn't invalidate the entire window when we receive a
ConfigureNotify. That's just broken.
2014-06-26 15:58:45 -04:00
Jasper St. Pierre
46e7f7f456 gtkwindow: Remove a vestigal line of painting for OR windows
Since we have a paint clock, we shouldn't be sending out EXPOSE events
for OR windows inside the ALLOCATE cycle. The idea here was that we
would have to wait for a map to get an OR window to paint to, but since
then this has been abstracted away inside GDK and the paint clock.
2014-06-26 15:58:45 -04:00
Jasper St. Pierre
35f618e71d gtkwindow: Remove an unnecessary set of grip setting
We already update the grip position in _gtk_window_set_allocation, which
is done through the size_allocate above. Receiving a ConfigureNotify
also won't ever change a grip's visibility, so there's no point in
refreshing it.
2014-06-26 15:58:45 -04:00
Jasper St. Pierre
6325e4a037 gtkwindow: Force CSD on Wayland
We rely on CSD here on the Wayland platform and giving the opportunity
to turn it off doesn't make too much sense.
2014-06-26 10:32:10 -04:00
Carlos Garnacho
3ef1b387bc window: Only claim a button=1 press sequence when dragging is about to happen
This way plain clicks can be handled in gtkmain through the usual delivery mechanism,
and get possibly handled too by widgets holding a GTK+ grab. If window dragging is to
be started, the sequence will be claimed (and a grab will happen afterwards), notifying
properly the grabbing widget that event delivery was interrupted.

This makes it possible to dismiss popovers by clicking on window headerbars, while
still making it possible to drag the window with the popover opened.
2014-06-12 14:27:35 +02:00
Matthias Clasen
2d05bf1492 csd: Fix non-resizable windows
For csd override-redirect windows, we don't set up resize handles,
but we were not ignoring the margin in all places, causing some
size calculations to go wrong.
2014-06-11 00:04:04 -04:00
Matthias Clasen
bde4e86357 Allow csd for override-redirect windows
This commit makes it possible to use client-side decorations for
override-redirect windows by calling _gtk_window_request_csd()
before realizing the window. Since the wm won't do interactive
resizing for us in this case anyway, don't bother creating
the border windows we use for this purpose on regular toplevels.

To make this accessible to themes, we set a "csd" style class
on client-side decorated windows. With this, .window-frame.csd.menu
can be used to define the shadow for csd menus, and .menu can be
used to define a border for menus under non-composited wms.

https://bugzilla.gnome.org/show_bug.cgi?id=731187
2014-06-09 14:01:42 -04:00
Matthias Clasen
510c2cdfb6 GtkWindow: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:30:55 -04:00
Matthias Clasen
05cabd3557 GtkWindow: Trivial cleanup 2014-06-09 13:30:55 -04:00
Matthias Clasen
3aa1350bd0 GtkWindow: always input-shape csd windows
Even if we don't have border windows, we need to set the input
shape so we ignore clicks in the shadow region.
2014-06-06 22:07:14 -04:00
Matthias Clasen
7a0642743d Fix up internal function naming
Even if you believe this functionality belongs into gdk, it
is not ok to name internal functions in gtkwindow.c gdk_window...
2014-06-04 06:38:20 -04:00
Matthias Clasen
872fbfacd3 Split GtkWindowGroup into its own file
gtkwindow.c is too big and too messy. This is a small step
towards making it better.
2014-06-04 06:24:05 -04:00
Carlos Garnacho
3c0ebf65cf window: Only check for the event widget if clicked on the "content" region
Every button press/release event reaching the the multipress gesture in GtkWindow
and happening in the "title" region must be handled, regardless of the event widget.
Children there wanting the event(s) for themselves are (and were always) expected
to stop event propagation.

So the only place to check for the event widget's "window-dragging" style property
is the "content" region, which matches the pre-gestures behavior.

This fixes some issues with sequences being mistakenly claimed (and events not
propagated further) on situations it shouldn't.
2014-06-02 18:38:25 +02:00
Carlos Garnacho
00656ed10b window: Handle manually bubbled events
The multipress gesture must react to either direct events on the
GtkWindow (special cased through _gtk_widget_check_handle_wm_event),
or bubbled events from child widgets. Ensure bubbled events go
through the gesture, those are fed manually to make sure events are
only handled once, in either one or other place. The implicit grab
will ensure that doesn't change mid-action.
2014-06-02 18:38:25 +02:00
Carlos Garnacho
7f33706c12 window: Refactor _gtk_window_check_handle_wm_event()
Separate the event widget check from event handling
2014-06-02 18:38:25 +02:00
Carlos Garnacho
d9bdb9a137 window: Do not raise border windows on each size allocation
This prevents these windows from being raised above popovers, which
is about the only child widget that may overlap with those anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=730589
2014-05-27 17:56:59 +02:00
Carlos Garnacho
a8e833dc5c window: Avoid double event processing in the multipress event controller
The events to those are fed outside the regular event propagation scheme,
through _gtk_window_check_handle_wm_event(), so set the controller to
GTK_PHASE_NONE so events aren't processed first manually, and then
automatically.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Matthias Clasen
6896c979a9 GtkWindow: Only use a multipress gesture for toplevels
There is no point in creating and attaching this gesture
for override-redirect windows, so don't do it.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Matthias Clasen
c6c41262b6 GtkWindow: Don't leak the gesture 2014-05-23 19:54:28 +02:00
Carlos Garnacho
ff627511b7 window: update to gesture widget-level API changes 2014-05-23 19:54:26 +02:00
Carlos Garnacho
61e88c251e window: Use gestures for window moving/resizing
A multipress gesture is used to control all this, replacing
single/double click custom code, and triggering window dragging
when the multipress is stopped, yet active (ie. the sequence remains
pressed).
2014-05-23 19:54:24 +02:00
Matthias Clasen
2df80d7a4d inspector: Repeat the keybinding warning
Show the confirmation dialog every time the keybinding is used,
until the user clicks OK.
2014-05-22 18:37:43 -04:00
Jasper St. Pierre
0ea1a526f9 gtkwindow: Use window-manager-side window menus
This avoids a bunch of policy problems with deciding how to lay
out the window menu under different WMs.

For now, we use the special event _GTK_SHOW_WINDOW_MENU, but we
hope to have this standardized in wm-spec quite soon, as KDE wants
it as well.
2014-05-21 18:41:07 -04:00
Piotr Drąg
df61db6dbc Improve punctuation in a new translatable string 2014-05-17 20:20:45 +02:00
Matthias Clasen
b4a57a0f0c inspector: Add a first-time warning
With the keybinding, it is possible that users may trigger the
inspector unintentionally. Show a dialog that informs them about
whats going on and gives them a chance to back out.

The warning dialog can be bypassed with the
org.gtk.Settings.Debug inspector-warning setting.
2014-05-16 21:51:42 -04:00