Commit Graph

977 Commits

Author SHA1 Message Date
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