Commit Graph

1629 Commits

Author SHA1 Message Date
Benjamin Otte
bb9626dc29 window: Implement snapshot() 2016-11-15 17:48:45 +01:00
Benjamin Otte
b1154be1c4 widget: Add GtkWidgetClass.snapshot() vfunc
Does the same thing as the render vfunc, only that it uses a different
prototype.
2016-11-15 17:48:45 +01:00
Benjamin Otte
93cbba6c3e gtk: Add gtk_widget_snapshot()
It's functionally equivalent to gtk_widget_get_render_node() but uses a
GtkSnapshot argument to carry the state.
2016-11-15 17:48:45 +01:00
Timm Bäder
846cf681e8 Remove gtk_widget_set_mapped
Let all the remaining callers chain up.
2016-11-05 11:56:36 +01:00
Timm Bäder
633a93f418 widget: Remove outdated comment
gtk_widget_override_color is no more.
2016-11-02 18:40:00 +01:00
Benjamin Otte
b0a5e8764c widget: Insist on widgets calling gtk_widget_set_has_window()
This way, we can grep the code for the bad widgets that set this to
TRUE and fix them.
2016-11-02 06:54:57 +01:00
Benjamin Otte
e6f711a94a inspector: Add more infrastructure
This one introduces the Recording object which is essentially a single
instance of something that happened.
The RenderRecording is an instance of an actual rendering operation.
2016-11-01 18:34:40 +01:00
Benjamin Otte
a0e63b8a07 rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the
renderer, so that they can be rendered multiple times with different
renderers.
2016-11-01 16:32:26 +01:00
Benjamin Otte
e96c485afa widget: Create render node with correct bounds
We want a render node where (0,0) is the top left of the widget.
However, we need to account for the clip origin not matching the
allocation origin.
2016-11-01 03:59:37 +01:00
Timm Bäder
c261d890ad widget: Remove damage-event 2016-10-31 19:28:28 +01:00
Timm Bäder
c25a5606d1 widget: remove show-help 2016-10-31 19:28:28 +01:00
Timm Bäder
5071206d60 widget: Remove app-paintable 2016-10-31 19:28:28 +01:00
Benjamin Otte
73cd739e19 API: widget: Remove gtk_widget_is_composited()
We don't need to clutter our API with functions that are easily
available elsewhere and effectively unused.
2016-10-29 04:49:47 +02:00
Benjamin Otte
d249e77bcb API: screen: Remove gdk_screen_is_composited()
Switch code to use gdk_display_is_composited() instead.

The new code also doesn't use a vfunc to query the property but rather
requires the backend to call set_composited()/set_rgba() to change the
value.
2016-10-29 04:49:47 +02:00
Benjamin Otte
a334316d5e API: widget: Remove GtkWidget::composited-changed signal
Nobody uses it.

If you need the functionality, listen to display changes on
your widget and then connect to the display's notify::composited.
2016-10-29 04:49:47 +02:00
Benjamin Otte
0cf4fdcb86 widget: Use gtk_widget_queue_draw() 2016-10-27 05:07:23 +02:00
Benjamin Otte
1df8b15711 gtk: Remove gdk_window_invalidate() from docs
And replace its mentions with gtk_widget_queue_draw().
2016-10-27 05:07:23 +02:00
Benjamin Otte
27ab75250c widget: Redo how gtk_widget_queue_draw() works
Before, we would immediately invalidate the GdkWindow of the widget, now
we call the parent's GtkWidgetClass.queue_draw_child() function.
This allows the parent to track redraw queueing of children.

By default GtkWidgetClass.queue_draw_child() will again chain up to its
parent while respecting the GdkWindow hierarchy for clipping.
GtkWindow is then the only widget actually invalidating the GdkWindow.

This essentially moves redraw queueing from GDK to GTK.
2016-10-27 05:07:23 +02:00
Benjamin Otte
77038a9b0b widget: Inline function into only caller
... and remove all the checks that are not needed in this case.
2016-10-27 05:07:23 +02:00
Benjamin Otte
3fd63e1d67 widget: Improve early exit checks on queue_draw()
(1) We don't need to check for realized when we check for mapped right
    below.
(2) Empty regions don't need to be drawn.
2016-10-26 16:25:49 +02:00
Alexander Larsson
70935f0952 Drop support for offscreen GdkWindows
These complicate a lot of GdkWindow internals to implement features
that not a lot of apps use, and will be better achieved using gsk.
So, we just drop it all.
2016-10-25 09:54:37 +02:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Timm Bäder
de65f87816 container: Remove reallocate_redraws 2016-10-20 20:12:05 +02:00
Timm Bäder
18f0b80e2e widget: Remove in_reparent flag
gtk_widget_reparent is gone so we don't need this anymore.
2016-10-20 20:12:05 +02:00
Emmanuele Bassi
dace0791a9 gsk: Add the ability to create fallback renderers
While porting GTK to GskRenderer we noticed that the current fallback
code for widgets using Cairo to draw is not enough to cover all the
possible cases.

For instance, if a container widget still uses GtkWidget::draw to render
its children, and at least one of them has been ported to using render
nodes instead, the container won't know how to draw it.

For this reason we want to provide to layers above GSK the ability to
create a "fallback" renderer instance, created using a "parent"
GskRenderer instance, but using a Cairo context as the rendering target
instead of a GdkDrawingContext.

GTK will use this inside the gtk_widget_draw() implementation, if a
widget implements GtkWidgetClass.get_render_node().
2016-10-18 11:49:16 +01:00
Matthias Clasen
f74dd416d6 Make outer shadows work again
Change get_render_node to return nodes that are sized to the clip
area and expect to be placed at the clip position; change
gtk_container_propagate_render_node to place child render nodes
accordingly, and change gtk_css_gadget_get_render_node to return
nodes that are sized accordingly as well.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
9fe18f6561 gtk: Clean up render fallback node creation in GtkWidget 2016-10-18 11:49:12 +01:00
Emmanuele Bassi
354d4435b1 gtk: Add convenience function for creating render nodes
GtkWidget.create_render_node() sets up a GskRenderNode appropriate for
rendering the contents of a widget, including its bounds,
transformation, and anchor point.
2016-10-18 11:49:11 +01:00
Emmanuele Bassi
a146618de0 gsk: Rename set_offset() to set_anchor_point()
The naming is consistent with other scene graph libraries, as it
represents an additional translation transformation applied on top of
the provided transformation matrices.

We can also simplify the implementation by applying the translation when
we compute the world matrix.
2016-10-18 11:49:11 +01:00
Matthias Clasen
e7c7932d72 Fix fallback render nodes
We were allocating a surface thats big enough for the clip, and
we were setting the transform for that, but then GtkContainer
was overriding the transform with the one for the allocation.
Also, we were drawing at the clip position, not the allocation
position.
2016-10-18 11:49:11 +01:00
Emmanuele Bassi
6c92846936 widget: Fix compatibility fallbacks 2016-10-18 11:49:10 +01:00
Emmanuele Bassi
3d90a070d5 gsk: Tie render nodes to renderers
Render nodes need access to rendering information like scaling factors.
If we keep render nodes separate from renderers until we submit a nodes
tree for rendering we're going to have to duplicate all that information
in a way that makes the API more complicated and fuzzier on its
semantics.

By having GskRenderer create GskRenderNode instances we can tie nodes
and renderers together; since higher layers will also have access to
the renderer instance, this does not add any burden to callers.

Additionally, if memory measurements indicate that we are spending too
much time in the allocation of new render nodes, we can now easily
implement a free-list or a renderer-specific allocator without breaking
the API.
2016-10-18 11:49:10 +01:00
Emmanuele Bassi
43904892bc gtk: Name GSK render nodes
For debugging purposes it's helpful to name the nodes.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
dc3b240c20 Ensure that render nodes are translated
The clip rectangle may have non-zero offsets, so we need to ensure that
the GskRenderNode associated to the rendered area is translated by those
same offsets.
2016-10-18 11:49:08 +01:00
Emmanuele Bassi
b997f4c575 gtk: Use GskRenderNode to render widgets
We need a virtual function to retrieve the GskRenderNode for each
widget, which is supposed to attach its own children's GskRenderNodes.
Additionally, we want to maintain the existing GtkWidget::draw mechanism
for widgets that do not implement get_render_node() — as well as widgets
that have handlers connected to the ::draw signal.
2016-10-18 11:49:06 +01:00
Timm Bäder
a864f4d474 widget: Not all toplevels are also containers 2016-10-18 00:34:41 +02:00
Timm Bäder
d963ede668 Remove GtkUIManager 2016-10-18 00:34:41 +02:00
Timm Bäder
dd3c3b683f widget: Remove push/pop_composite_child
as well as the composite-child property
2016-10-18 00:29:18 +02:00
Timm Bäder
2ae996e242 widget: Remove gtk_widget_get_pointer 2016-10-18 00:29:18 +02:00
Timm Bäder
a4368a73a5 widget: Remove gtk_widget_reparent 2016-10-18 00:29:17 +02:00
Emmanuele Bassi
3fdbe2ea13 widget: Make gtk_widget_get_parent_muxer() as static
It's a private function, used only inside gtkwidget.c and not declared
in any private header.
2016-10-17 11:10:14 +01:00
Emmanuele Bassi
44885bcfed Remove redundant declarations 2016-10-17 11:10:14 +01:00
Benjamin Otte
4a95f8802c widget: Remove gtk_widget_set_double_buffered()
Everything is always double-buffered.
2016-10-16 18:18:58 +02:00
Benjamin Otte
cda617df4d API: sizegroup: Remove gtk_size_group_set_ignore_hidden() 2016-10-16 18:18:58 +02:00
Benjamin Otte
d4d3374729 container: Remove gtk_container_set_resize_mode() 2016-10-16 18:18:58 +02:00
Benjamin Otte
1518fe0a8f API: stylecontext: Remove state argument from getters
The argument must always be the current state.
2016-10-16 18:18:58 +02:00
Timm Bäder
ed184b3935 Remove GtkIconFactory
Move the icon size lookup API into gtkicontheme.c
2016-10-16 18:17:21 +02:00
Timm Bäder
9fd1a1bbe3 widget: Remove cursor-aspect-ratio/window-dragging style properties
And replaces its usages in GtkTextView/GtkStyleContext with a hard-coded
0.04 which was the default value for cursor-aspect-ratio.  Also remove
the public gtk_draw_insertion_cursor which used draw_insertion_cursor
which in turn looked up cursor-aspect-ratio
2016-10-16 18:17:21 +02:00
Timm Bäder
ccd3ff7fba gtkwidget: Remove gtk_widget_class_install_style_property_parser...
... from public API
2016-10-16 18:17:21 +02:00
Timm Bäder
281c1e4fe5 widget: Remove cursor-aspect-ratio style property 2016-10-16 18:17:21 +02:00
Timm Bäder
08c1c584b3 Remove GtkModifierStyle 2016-10-16 18:17:21 +02:00
Timm Bäder
9a388690f4 widget: Remove gtk_widget_override* API 2016-10-16 18:17:21 +02:00
Timm Bäder
b1d35a594e widget: Remove text-handle-width/height style properties 2016-10-16 18:17:21 +02:00
Timm Bäder
999d45b4e8 Remove various unused style properties 2016-10-16 18:17:21 +02:00
Timm Bäder
2455bd0857 widget: Remove visibility-notify-event 2016-10-16 18:17:21 +02:00
Timm Bäder
878f2e4107 widget: Remove deprecated margin-left/right properties 2016-10-16 18:17:21 +02:00
Timm Bäder
d34b7d98b2 widget: Remove gtk_widget_{s,g}et_composite_name 2016-10-16 18:17:21 +02:00
Timm Bäder
80ab5ea942 widget: Remove gtk_widget_get_requisition 2016-10-16 18:17:21 +02:00
Timm Bäder
16b0906b4a widget: Remove gtk_widget_send_expose 2016-10-16 18:17:21 +02:00
Timm Bäder
bc0cef27a2 widget: Remove gtk_widget_{s,g}et_state 2016-10-16 18:17:21 +02:00
Timm Bäder
4a2c087a1e widget: Remove gtk_widget_region_intersect 2016-10-16 18:17:21 +02:00
Timm Bäder
a80a1cf8a6 widget: Remove gtk_widget_get_child_requisition 2016-10-16 18:17:21 +02:00
Timm Bäder
b3bd5fefb1 widget: Remove gtk_widget_size_request 2016-10-16 18:17:21 +02:00
Timm Bäder
4c10807e24 widget: Remove state-changed signal 2016-10-16 18:17:21 +02:00
Timm Bäder
96d9abded8 widget: Remove deprecated style properties 2016-10-16 18:17:21 +02:00
Benjamin Otte
0df388051d API: Remove GtkStyle
All the remaining gtkrc.c stuff like GtkRcStyle goes with it.
2016-10-16 18:17:21 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Benjamin Otte
021fe010b6 API: Remove GtkPlug, GtkSocket and GtkWin32EmbedWidget 2016-10-16 18:17:21 +02:00
Benjamin Otte
89f2e17f91 API: Remove gdk_window_set_composited()
And the related call gdk_display_supports_composite().
2016-10-16 18:17:21 +02:00
Benjamin Otte
fec8069e7b API: screen: Stop storing font options
font options are only ever set by the GtkSettings object and only ever
used inside GTK, so just store them there.
2016-10-16 18:17:21 +02:00
Benjamin Otte
d09e48cec1 API: Remove -gtk_widget_get_root_window() 2016-10-16 18:17:21 +02:00
Christoph Reiter
ae8ffc775d widget: Don't print underallocation warnings by default
See similar changes:
    https://git.gnome.org/browse/gtk+/commit/?id=1b15588732f2c4e3c59994a59613d4e5c963e283
    https://git.gnome.org/browse/gtk+/commit/?id=54fdcb3ffac3383432b379f3e16e8cb0086b8101

https://bugzilla.gnome.org/show_bug.cgi?id=770388
2016-09-30 14:41:01 -04:00
Timm Bäder
54fdcb3ffa widget: Don't print missing allocation warning by default
This was meant to be silenced unless expicitly requested but
G_ENABLE_DEBUG is defined by default unless --disable-debug is passed to
configure, so use G_ENABLE_CONSISTENCY_CHECKS instead which is only
defined if --enable-debug is explicitly passed.
2016-09-22 09:01:06 +02:00
Emmanuele Bassi
bb705837bc Ensure drawing context is set
If somebody decides to use gtk_widget_set_double_buffered() in the
middle of a draw() then there's the risk of calling end_draw_frame()
with an invalid pointer.

Some overeager compilers may warn about the double_buffered bit field
changing values and leading to a potentially uninitialized variable.

In order to avoid compiler warnings or crashes, we can simply store the
value of the double_buffered bit field at the beginning of the rendering
and use that instead of the actual bit field.

https://bugzilla.gnome.org/show_bug.cgi?id=771463
2016-09-15 10:17:24 +01:00
Timm Bäder
5ea69a136b widget: Only warn about missing allocation if G_ENABLE_DEBUG
Not all occurrences of this warning can be fixed today, so put it behind
a G_ENABLE_DEBUG flag since it still shows legitimate problems even if
some of them are false positives.
2016-09-14 18:06:54 -04:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Carlos Garnacho
3a6d0ff2ab gtk: Add minimal handling of pad events
No real handling is yet performed, to be done through a GdkEventController

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:44 +02:00
Timm Bäder
50a0c5f242 widget: remove some unneeded function prototypes 2016-08-04 13:09:08 +02:00
Sébastien Wilmet
af5ef152b1 docs: GtkWidget::style-updated vs GtkStyleContext::changed
Explain the difference between those two signals.

Add "Since: 3.0" for GtkStyleContext::changed, since that signal has
been added in commit 9f84e101bf, present
since 2.91.6.

https://bugzilla.gnome.org/show_bug.cgi?id=769047
2016-07-25 09:26:41 -04:00
Sébastien Wilmet
3432587f89 docs: add missing info for gtk_widget_get_style_context()
It is important to know whether the returned object can or cannot
change, for a certain widget. For example to connect to the
GtkStyleContext::changed signal.

https://bugzilla.gnome.org/show_bug.cgi?id=769047
2016-07-25 09:26:41 -04:00
Matthias Clasen
8db8891c66 Use g_clear_object in a few more places 2016-07-25 08:32:08 -04:00
Emmanuele Bassi
8f1fd7d964 docs: Fix typo. 2016-07-12 18:09:20 +01:00
Emmanuele Bassi
c0dae6c146 docs: Attempt a better explanation for gtk_widget_destroy()
Clarify the nature of this function, and the expectations after it's
been called.
2016-07-12 12:44:23 +01:00
Timm Bäder
d52f6ff710 widget: Don't unnecessarily export function
_gtk_widget_get_translation_to_window is only used in gtkwidget.c
2016-06-27 14:43:53 +02:00
Emmanuele Bassi
40ee61a686 gtk: Keep Firefox working in the DrawingContext world
Firefox does a bunch of interesting things with GTK.

If the top-level GtkWindow does not have a "csd" style class associated,
Firefox will happily draw the contents of the container used to render
HTML and XUL directly on the top level's GdkWindow; on the other hand,
if a "csd" style class is found, the MozContainer will create a new
child window, and draw on it.

Then, Firefox will proceed to disable double buffering on both the
top-level window and the MozContainer (unless they are backed by the
same GdkWindow, in which case only the top-level will be
single-buffered) *and* it will add a GDK_EXPOSURE_MASK flag to the
MozContainer events for good measure (even if this is only needed for
GTK+ 2.x).

After landing the GdkDrawingContext API in GdkWindow, GTK enabled
automatic double buffering on all top-level windows backed by a native
surface, ad most users of single buffering rely on child widgets instead
of top-levels, and we'd still like to have the same double buffering
behaviour for all top-levels on all backends. Obviously, with Firefox
disabling double buffering on the top-level window, the change broke
their drawing mechanism.

Ideally, Firefox could be fixed to not disable double buffering on the
top-level window when MozContainer has a separate GdkWindow — i.e. the
CSD case — but since we did introduce a slight change of behaviour in
fringe users of the GTK+ API, let's keep backwards compatibility with
the old code for a little while longer, and create an intermediate Cairo
context unbound from the GdkDrawingContext, like we used to do until
GTK+ 3.20.
2016-06-22 11:41:59 +01:00
Emmanuele Bassi
c3f4fe334d Deprecate gtk_widget_send_expose()
We have various replacements for what this function does, and we are not
calling it internally any more.
2016-06-10 16:13:27 +01:00
Emmanuele Bassi
c5d0522a23 Deprecate the gdk_window_begin/end_paint family of functions
They are replaced by the more appropriate gdk_window_begin_draw_frame()
and gdk_window_end_draw_frame() functions.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Emmanuele Bassi
dda6a0d385 Associate the drawing context to the Cairo context
Instead of associating the GdkWindow that created the GdkDrawingContext
we can directly bind the Cairo context to the GDK drawing context.

Cairo contexts created via gdk_cairo_create() go back to not having a
GdkWindow associated to them, like they did before we introduced the
gdk_window_begin_draw_frame() API.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Emmanuele Bassi
a7ef37da2a Add GdkDrawingContext
Instead of giving out Cairo contexts, GdkWindow should provide a
"drawing context", which can then create Cairo contexts on demand; this
allows us to future proof the API for when we're going to use a
different rendering pipeline, like OpenGL.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Emmanuele Bassi
2c7b21718f Simplify the widget rendering entry point
Now that GDK has the appropriate API, we can simplify the widget drawing
code into a single function.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Benjamin Otte
775e277ab9 widget: Add classes to widget path even if no style context exists yet
This removes leftover code from when classes where added to the style
context.
Now that they get added directly to css nodes, the classes can exist
without a style context.

https://bugzilla.gnome.org/show_bug.cgi?id=767312
2016-06-07 16:12:18 +02:00
Timm Bäder
a961b05200 widget: Avoid a deprecation warning 2016-06-02 21:52:11 +02:00
Matthias Clasen
f168de3ada Add a warning for a broken situation
When we emit ::draw, the widget should not have alloc_needed set
anymore. If this happens, it indicates a broken situation. Add a
warning to help tracking down why this might occur.

See https://bugzilla.gnome.org/show_bug.cgi?id=765410
2016-05-30 16:19:29 -04:00
Matthias Clasen
b90ae2cfbf Add a deprecation note
Mark GtkWidget:style property as deprecated in the docs.
2016-05-23 20:40:03 -04:00
Alban Browaeys
cd305c1970 widget: fix GtkLabelAccessible NULL links.
Fix testsuite/a11y/about.ui GtkAboutDialog :
"CRITICAL **: atk_hyperlink_get_start_index: assertion 'ATK_IS_HYPERLINK (link)' failed"
That is set widget->priv->accessible as soon as accessible object is generated.

When accessible object is created accessible->priv->widget is set,
if widget->priv->accessible is not , then _gtk_label_accessible_update_links
exits early, thus without creating the links on the accessible side.
(This as it checks for the widget to have the accessible set before proceeding).

https://bugzilla.gnome.org/show_bug.cgi?id=766458
2016-05-15 10:24:34 -04:00
Benjamin Otte
ddcf47026d widget: No longer postpone style-updated on unrealized widgets
GTK used to not emit GtkWidget::style-updated on widgets that weren't
realized. This sped up construction of complex widgetry in the early
days of GTK3 where we instantly invalidated on every change.
We don't do that anymore, so in theory (and in my limited testing with
widget-factory) this shouldn't be a prolem anymore.

What is a problem though is that postponing style-updated leads to 2
problems:
(1) Unrealized widgets will not emit style-updated which may cause them
    to not properly update their state and return wrong values from
    get_preferred_width/height() etc
(2) Emitting style-updated during realize can happen too late.
    When a widget is not made child-visible by its parent (common
    examples: notebook, paned) it will also not be realized when the
    parent is initially shown. However, when they get realized later
    (after a resize of the parent), they will emit style-updated (and
    potentially queue a resize) during size-allocate.

https://bugzilla.gnome.org/show_bug.cgi?id=765700
2016-05-14 18:48:22 +02:00
Timm Bäder
7116988bcb widget: Add Since annotation to gtk_widget_queue_allocate 2016-05-10 12:53:42 +02:00
Ray Strode
3cba63b2f8 widget: add missing detail to ::query-tooltip emission
This was an oversight in commit dfb368e29bb58b4313b578f0ce75cfc8ead9a1.
2016-05-06 22:31:45 -04:00
Matthias Clasen
3c09783005 Clean up builder parser data after parsing
No need to have these linger around in qdata.
2016-05-06 16:09:12 -04:00
Matthias Clasen
0f116135f4 Avoid emitting ::style-set by name
GtkStyle is deprecated, but we still emit ::style-set quite
a bit, so lets at least not be slow while doing it.
2016-05-06 10:14:07 -04:00