Commit Graph

1320 Commits

Author SHA1 Message Date
Emmanuele Bassi
6950116678 docs: Reword the deprecation notice for gtk_widget_override_*
They are a bit terse, and they should point to the preferred way of
overriding the theme, i.e. using a GtkStyleProvider for your
application, and custom style classes.
2015-03-08 14:39:18 +00:00
Matthias Clasen
1f3328c096 Avoid calling g_object_ref on NULL
gtk_widget_set_visual() allows NULL for the visual, so be
careful ot to ref it unconditionally.
2015-03-07 17:48:11 -05: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
Matthias Clasen
3569d373a2 Fix 7c4bf742e8
The objects-finalize test constructs gestures with NULL as
a widget. The recent addition of weak references was not
ready for that.
2015-03-02 20:18:15 -05: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
Debarshi Ray
7c4bf742e8 eventcontroller, widget: Don't crash if destroyed before the other
There are two scenarios. A widget sub-class owns a GtkEventController
and passes itself to it, or a controller owned by something else is
passed a widget.

In the second case, if the widget is destroyed before the controller,
we will have a crash when destructing the controller because we will
be accessing invalid memory. Adding a weak reference on the widget
addresses that problem.

This leads to a crash in the first case. When the widget is getting
destroyed, it will drop the reference to its own controller. The
controller will skip touching the widget because the weak reference
would have turned it to NULL. However, when the widget sub-class chains
up to GtkWidget it will try to free all the controllers in its list.
Unfortunately, all these controllers have already been destroyed. So
we need to guard against this too.

https://bugzilla.gnome.org/show_bug.cgi?id=745225
2015-03-02 11:53:52 +01:00
Philip Withnall
09bb109f01 docs: Expand input handling documentation to cover event masks
Also try and clarify a few things about event propagation. Move
input-handling.xml into gtk-doc’s expand_content_files variable so it
automatically links to widget documentation. Add links from
gtk_widget_add_events() and friends to the new documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=744054
2015-02-19 12:48:42 +00:00
Philip Withnall
b397dd04c4 gtk: Remove documentation references to the GTK_NO_WINDOW flag
It has been removed entirely, and replaced by
gtk_widget_get_has_window().

https://bugzilla.gnome.org/show_bug.cgi?id=744054
2015-02-19 12:48:41 +00:00
Benjamin Otte
89f635fee1 css: Add -gtk-dpi CSS property hack
This property is necessary to ensure widgets automatically update after
the text scale factor is changed desktop-wide.

And if I'm already doing a property like this, I can make it
overridable. So now you can override the dpi per-widget with CSS like
GtkSwitch {
  -gtk-dpi: 48;
}
if you want to debug things.

Long-term, we want to get rid of this property and insist on dpi being
96 everywhere and people can change the font size to get larger fonts.
2015-02-05 18:57:29 +01:00
Garrett Regier
9cbf764bcd Fix VA marshaller for GtkWidget's "event-after" signal
Just a copy and paste typo from the "event" signal.

https://bugzilla.gnome.org/show_bug.cgi?id=743593
Signed-off-by: Garrett Regier <garrettregier@gmail.com>
2015-01-28 16:40:59 -05:00
Matthias Clasen
1aee4f0384 Fix a typo
commit aa1b7fab9c introduced a misuse of G_UNLIKELY in
several places. Fix all those.
2015-01-28 10:08:13 -05:00
Benjamin Otte
aa1b7fab9c css: Remove _gtk_css_style_property_changes_affect_size()
... and _gtk_css_style_property_changes_affect_font().

Replace it with _gtk_css_style_property_get_mask_affecting().
2015-01-27 05:04:34 +01:00
Benjamin Otte
3a9bf0fe1d widget: Compute clip of children properly
For widgets with a window, we need to adjust the allocation of their
children.
2015-01-22 16:25:43 +01:00
Benjamin Otte
d879a13600 widget: Correctly handle which widgets to include in the clip
Previously, we would not include any child widget on the first
allocation, which happens right after realize(), but before map(). No
widget is drawable at that point.
2015-01-22 16:25:35 +01:00
Benjamin Otte
bd31310c40 widget: Add debug spew for setting the clip 2015-01-22 16:25:30 +01:00
Benjamin Otte
dbb8d1dd07 stylecontext: Keep track of the CSS ID
This is necessary since we do the new caching and need to distinguish
between styles with different IDs.

Fixes various test cases.
2015-01-20 01:07:13 +01:00
Carlos Garnacho
b8e87d4762 widget: Free the controller list on finalize()
If this is done on dispose(), the widget may be destroyed (and its
controllers list NULLified) within _gtk_widget_run_controllers(),
causing warnings/crashes when it just tried to hop on the next
controllers.

Freeing the controllers here should be a safety net for implementations,
so it also makes sense to do this late. The widgets that choose to
free their controllers on dispose can still do so, and get
_gtk_widget_remove_controller() called for these as an indirect result.
2015-01-14 17:11:25 +01:00
Matthias Clasen
53c388b724 Some formatting cleanups 2014-12-21 22:58:23 -05:00
Benjamin Otte
42a6ae6c6c widget: Set the allocation via gtk_widget_set_allocation()
There is no good reason to assign the value directly.

Also, this fixes d23f3254b7
where widgets that chained up instead of calling
gtk_widget_set_allocation() would not draw becaues of empty clip.
2014-12-20 20:41:18 +01:00
Benjamin Otte
d23f3254b7 widget: Handle setting clip differently
(1) Get rid of supports_clip flag. All widgets (implicitly) support
clip.

(2) Don't reset the clip to { 0, 0, 0, 0 } before the "size-allocate"
signal.

(3) Make gtk_widget_set_allocation() set the clip (to the allocation).
This ensures that eveyr widget has a clip set.
Note: It overrides previous calls to gtk_widget_set_clip(), while in
3.14 this didn't happen.

(4) As the clip is set by gtk_widget_set_allocation() now, don't set
it after the "size-allocate" signal anymore.

This fixes calls to gtk_widget_queue_draw() from inside the
size_allocate vfunc.
2014-12-19 19:20:07 +01:00
Christian Hergert
661da5558c widget: add helpers to resolve GActionGroups available to GtkWidget
These functions, while added for use by the GTK inspector, are generally
useful to applications that need to resolve what action groups are
available to a particular GtkWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=741386
2014-12-11 15:25:41 -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
64fd964703 GtkWidget: Don't return FALSE as a pointer
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=741251
2014-12-08 09:16:24 -05:00
Matthias Clasen
06745bc0aa Add a note to the ::destroy docs
Clarify that ::destroy is not suitable for saving widget state.

https://bugzilla.gnome.org/show_bug.cgi?id=710793
2014-12-07 18:12:46 -05:00
Jasper St. Pierre
579c7f80a0 gtkwidget: Fix a typo preventing the CSD input shape from applying
We were setting "csd-shade" but reading from "csd-region".
2014-12-01 18:01:49 -08:00
Benjamin Otte
7ecdaaacb2 widget: Clarify some corner cases
I checked Cairo source code (actually pixman, as Cairo just passes
through) to make sure that the behavior stays identical: negative values
cause an error message from pixman, zero is allowed. Both return an
empty region which gtk_widget_queue_draw_region() would then proceed to
ignore.
2014-11-29 03:42:28 +01:00
Jasper St. Pierre
0c09d44509 gtkwidget: Remove unnecessary code in get_state_flags
Any time has_focus is called, we will call gtk_widget_update_state_flags
which will assign the state flags properly.
2014-11-25 11:04:36 -08:00
Matthias Clasen
8765970ba1 Remove a redundant call
No need to set shapes twice in a row.
2014-10-29 06:49:59 -04:00
Matthias Clasen
c9ad936011 Drop an unused variable 2014-10-29 06:49:58 -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
Matthias Clasen
a55000613a Add private API to query tick callbacks
This information can be useful for debugging purposes.
2014-10-24 08:34:13 -04:00
Bastien Nocera
d0f4e73999 gtkwidget: Fix typo in comment 2014-10-21 10:10:50 +02:00
Matthias Clasen
d7b64c63e0 Improve tooltip-text/markup docs
Clarify priorities between the two,
https://bugzilla.gnome.org/show_bug.cgi?id=681185
2014-10-19 23:28:34 -04:00
Matthias Clasen
e3ef5d6fd2 GtkTooltip: Move nonexported API to a private header
This is our standard practice nowadays.
2014-10-19 22:51:21 -04:00
Alexander Larsson
d0147a6f2c Add gdk_window_mark_paint_from_clip and call from widget drawing
This is a new function that gets called every time we're drawing
some area in the Gtk paint machinery. It is a no-op right now, but
it will be required later to keep track of what areas which
we previously rendered with GL was overwritten with cairo contents.
2014-10-13 10:43:31 -04:00
Matthias Clasen
63efdca223 Deprecate GtkWidget override APIs
This is better done with css and style classes nowadays.
2014-09-30 00:08:59 -04:00
Benjamin Otte
9a8a4a8b14 widget: Don't assume opacity is 100%
... just because there is no style context instantiated yet. Instead,
instantiate a style context during realize() and ask it.

Fixes problems with dim labels not being dimmed on first show.

Testcase included.

https://bugzilla.gnome.org/show_bug.cgi?id=735240
2014-09-07 01:57:10 +02:00
Matthias Clasen
d55e3b25a7 Fix various compiler warnings
Mostly missing declarations and missing statics.
2014-09-05 21:21:49 -04:00
Benjamin Otte
01d644b7ee widget: Don't connect to GtkModifierStyle::changed
Changes to the modifier style will be picked up by the
GtkStyleProviderPrivate::changed signal. And that signal will actually
invalidate properly.
2014-08-27 17:57:10 +02:00
Benjamin Otte
b5a8b7ef3b widget: Make _gtk_set_simple_clip() take an optional content clip 2014-08-21 00:54:07 +02:00
Matthias Clasen
c9da8bf2b3 Revert "docs: Fix broken gtk-doc formatting"
This reverts commit a7562dd38f.

I prefer to not confuse gtk-doc with doc comments for private
functions.
2014-08-18 08:18:02 -04:00
Rico Tzschichholz
a7562dd38f docs: Fix broken gtk-doc formatting
Fixes broken introspection of GtkTranslateFunc
2014-08-18 13:27:05 +02:00
Matthias Clasen
d206d694fd GtkWidget: fix up docs minimally 2014-08-16 21:40:39 -04:00
Benjamin Otte
65cc3630c8 widget: Add checks for setting state flags
This is more for GTK developers to catch when they forgot to change
GTK_STATE_FLAGS_BITS after adding a new state flag than to prevent
widget developers from using the wrong flags.
2014-08-16 16:34:15 +02:00
Benjamin Otte
36a2e7ca8e css: Add a :checked pseudoclass
https://bugzilla.gnome.org/show_bug.cgi?id=733967
2014-08-16 16:34:14 +02:00
Carlos Garnacho
62507776fe widget: Include event controllers' event mask on gtk_widget_get_events()
gtk_widget_get_events() must indeed tell about events enabled purely through
a GtkEventController, those events will most surely trigger event handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=734357
2014-08-12 14:28:34 +02:00
Matthias Clasen
327b097725 Trivial: Use g_clear_object more
It no longer has atomic overhead, so we can use it everywhere.
2014-08-09 10:16:27 +02:00
Benjamin Otte
52dd0f5014 widget: Add widget state when appending to widget path
Make gtk_widget_path_append_for_widget() add the state flags of the
widget, too.

This enables the ability to select pseudoclasses on all elements in a
selector.
2014-07-19 23:42:39 +02:00
Benjamin Otte
3e82d12abd widget: Remove special case for clipping
Labels now call gtk_widget_set_clip() so there is no longer a need to
exclude them from clipping.
2014-07-10 18:56:35 +02:00