Commit Graph

6586 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
5a4ade857a
Port ClutterText to ClutterPaintNode
The port to use ClutterPaintNodes basically mirrors what
it currently does, with the major benefit of not depending
on cogl_get_draw_framebuffer() anymore.

There are various factors that influence the number of
subnodes:

 * The background color adds a color subnode;
 * The selection adds a clip subnode, and a color subnode,
   or a color and a text subnode;

The simplest case is when the text does not overflow and
has no background color nor selection. In that case, the
render tree is simply:

    [ Dummy ]
        ↓
    [ Text ]

In contrast, the most complex case is when drawing the text
with selection, in which case the render tree looks like:

    [ Dummy ]
        ↓
    [ Clip ]
        ↓
    [ Text ] → [ Clip ]
                  ↓
               [ Color ] → [ Text ]

Since the selection may have another text color, the selected
text must be rendered again, but clipped to only cover the
selection rectangle. This is suboptimal, but it's what the
current code already does anyway.
2018-09-28 21:38:12 -03:00
Georges Basile Stavracas Neto
cc75fc88ee
clutter/paint-nodes: Use texture position to draw pango layout
When painting a ClutterText, there are two different aspects that
should be taken into account:

 1. The allocated size of the actor; and
 2. The reported size of the PangoLayout, which may be smaller or
    bigger than (1)

When (2) is bigger than (1), ClutterText has to clip the text to
only draw at the visible contents over the actor surface. In
addition to that, ClutterText also tracks the cursor position,
which makes clipping a bit more complicated.

The current ClutterTextNode.draw() implementation assumes that
the (1) also represents (2), which is not true. This makes
clipping not work.

Fix that by assuming that the position to draw the PangoLayout
is passed as the second rectangle, and the actor size is the
first one.
2018-09-27 17:06:38 -03:00
Sam Spilsbury
a8a3c1017f actor: Also recompute paint volume if we recently dropped effects
Otherwise we'll be stuck with the same paint volume on the last
frame of the given effect, which could be wrong.
2018-09-18 19:39:12 +00:00
Sam Spilsbury
5d19aee23a actor: Always use get_paint_volume override for active effects
If an effect is active and it overrides the paint volume, we should
always recompute the paint volume when requested and not use the
cache, since the paint volume override can change from call to
call depending on what phase of painting we are in. For instance,
if we are part way through painting effects and request the
paint volume, the paint volume should only go up to the current
effect, but in a later call to compute repaint regions, the
paint volume needs to expand to accomadate the effect.

This still involves a lot of recomputation in the case of effects -
in a later clutter version it would be worth adding an API to
allow effects to explicitly recompute and return a new the paint
volume up to the current effect as opposed to recomputing
the cached one.
2018-09-18 19:39:12 +00:00
Sam Spilsbury
4270eef16e actor: Fix logic error in determining terminal effect for paint volume
Previously we were checking l->data != NULL || (l->data != NULL &&
l->data != priv->current_effect). This would continue the loop even
if l->data == priv->current_effect, since l->data != NULL, which was
not the intention of that loop.

We also don't need to check that l->data != NULL before checking if
it does not match the current_effect, since we already checked
that current_effect was non-NULL before entering the loop.
2018-09-18 19:39:12 +00:00
Carlos Garnacho
9cfd185316 clutter: Handle grabs from CLUTTER_TABLET_DEVICE devices
Those would result in warnings. Actually, these should be dealt
similarly to pointers, as they get their own standalone pointer
cursor in Wayland.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/issues/540
2018-09-07 15:17:36 +02:00
Peter Hutterer
176117c5f7 device-manager-evdev: handle tablet axis motion before button and tip events
Some tablets have a noticable pointer jump on tip down/up, causing unintended
lines during drawing. Likewise, a button event may have an axis update that we
currently ignore. libinput provides tablet axis events only if no other state
changes, the client must instead get the current axis data from the tip/button
event. So let's do this, process the event axis data during tip/button as
well.

A libinput recording to reproduce is the 'dots.yml' in
https://gitlab.freedesktop.org/libinput/libinput/issues/128

Fixes #289
2018-09-07 19:54:06 +10:00
Carlos Garnacho
85284acb00 clutter/x11: Implement keycode lookup from keysyms on virtual key devices
Unfortunately XKeysymToKeycode() falls short in that it coalesces keysyms
into keycodes pertaining to the first level (i.e. lowercase). Add a
ClutterKeymapX11 method (much alike its GdkKeymap counterpart) to look up
all matches for the given keysym.

Two other helper methods have been added so the virtual device can fetch
the current keyboard group, and latch modifiers for key emission. Combining
all this, the virtual device is now able to handle keycodes in further
levels.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/135
2018-08-28 12:22:52 +02:00
Carlos Garnacho
aaed7c9a4f clutter: Set can_show_preedit flag on ClutterText
It is certainly able to visualize preedit text inline, so it must
announce itself as such.
2018-08-23 20:03:51 +00:00
Carlos Garnacho
fa8930817e clutter: Refactor ClutterText IM focus in into separate function
A just focused ClutterInputFocus must set itself up correctly on
all situations. Refactor this into a function, so it can be used
for the case where a ClutterText gets editable while focused.
2018-08-23 20:03:51 +00:00
Daniel van Vugt
b8340f1355 clutter-text: Avoid clipping the wrong framebuffer
`ClutterText` painting for editable single_line_mode actors like `StEntry`
is always clipped by:

`cogl_framebuffer_push_rectangle_clip (fb, 0, 0, alloc_width, alloc_height)`

So it's difficult to get the rectangle wrong. However in cases where the
target framebuffer has changed (`cogl_push_framebuffer`) such as when
updating `ClutterOffscreenEffect` we had the wrong old value of `fb`. And
so would be clipping the wrong framebuffer, effectively not clipping at all.
2018-08-20 18:07:32 +00:00
Andrea Azzarone
e1513b6b00 clutter/x11: Detect auto-repeated key events
Detect auto-repeated key events using the XIKeyRepeat flag.
2018-08-20 10:16:33 +00:00
Andrea Azzarone
0f40541bb2 clutter/enum: Add CLUTTER_EVENT_FLAG_REPEATED for auto-repeated events 2018-08-20 10:16:33 +00:00
Jonas Ådahl
24aef44baf virtual-input/evdev: Translate from button internal codes to evdev
Sending button events to a ClutterVirtualInputDevice, the API expects
button codes to be of the internal clutter type. The evdev
implementation incorrectly assumed it was already prepared evdev event
codes, which was not the case. Fix the evdev implementation to translate
from the internal representation to evdev before passing it along to
ClutterSeatEvdev.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/190
2018-08-09 13:04:07 +00:00
Daniel van Vugt
b393f3d540 clutter/actor: Inherit clone branch depth from parent
Children added to a parent after that parent (or its ancestors)
have already been cloned now inherit the clone branch depth of
the parent. Otherwise `clutter_actor_is_in_clone_paint` on the child
could return FALSE when it should have been returning TRUE.
2018-08-01 11:53:10 +08:00
Florian Müllner
7fdaf7721c Don't cast free function passed to g_clear_pointer
The function is intentionally provided as macro to not require a
cast. Recently the macro was improved to check that the passed in
pointer matches the free function, so the cast to GDestroyNotify
is now even harmful.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
2018-07-31 23:40:01 +02:00
Florian Müllner
4fe594bf9c clutter: Stop using g_type_class_add_private()
It is now deprecated in favor of the G_ADD_PRIVATE() macro (usually
called via G_DEFINE_WITH_PRIVATE()).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
2018-07-31 23:40:01 +02:00
Carlos Garnacho
161d2540e6 ClutterActor: Preserve valid paint volumes till the next relayout/repaint
Cuts down approximately all paint volume calculations when there's
windows that redraw frequently, but don't move.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2018-07-13 11:42:28 +00:00
Corentin Noël
2a45b7de7c clutter-input-device-xi2: Check for null group_modes before unref 2018-06-07 12:54:56 +01:00
Daniel van Vugt
62c67be4c8 clutter-actor: Fix uninitialized matrix multiply
`modelview` is uninitialized and the `apply` function just multiplies it.
What we really want is to initialize `modelview` so replace `apply` with
`get`.

Who knows what bugs this may have caused...
2018-05-31 15:43:27 +08:00
Marco Trevisan (Treviño)
15f41c9f68 device-manager-evdev: Add main seat to seats by default
Treat the main seat as other seats, so we don't have to handle it differently
in specific places. This was already the case before when a real device
was plugged before the startup, but not applied when hotplugging a device.
2018-05-29 10:35:51 +00:00
Marco Trevisan (Treviño)
2a38601b42 device-manager-evdev: Free the main seat on finalize 2018-05-29 10:35:51 +00:00
Marco Trevisan (Treviño)
d7bdc1591f device-manager-evdev: Set and unset the stage for the main seat too
When no input devices are available on startup the device manager might be fast
enough to be constructed so that no default stage is set yet, and thus when
main seat virtual devices are created they won't have a proper stage set.
If then we plug a real device, the events that an input manager could generate
won't be associated to any stage and thus won't be processed.

We need then ensure that when we update the stage for the device manager we
(un)associate it also to the main seat devices.
2018-05-29 10:35:51 +00:00
Marco Trevisan (Treviño)
3e85ac8131 clutter-device-evdev: Get devices from main seat if no real seat is set
In devices such as ARM boards there could be no input devices connected on
startup, leading to a crash when we try to process artificial events that
could be queued (as gnome-shell does when syncing pointer).

Those events still should refer to a device and, in case we don't have one
provided by libinput we should still return the core devices defined in the
main seat.
2018-05-15 12:09:59 +01:00
Marco Trevisan (Treviño)
5f83d9a5c8 clutter-seat-evdev: Add function to get device by id 2018-05-15 12:05:39 +01:00
Florian Müllner
a30166a547 clutter: Don't reference invalid pc in gir
Cally is built into clutter itself rather than exposed as a separate
library.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2018-05-07 21:44:47 +02:00
Carlos Garnacho
8cf42cd06c clutter: Plug minor leak
clutter_stage_manager_list_stages() returns a copied list, which
should be freed.
2018-04-22 00:52:19 +02:00
Carlos Garnacho
b5328c977e clutter: Set slave=master in IM forwarded key events
The fix is twofold. On one hand, it makes sense not to relate IM (nor
any other) generated events to a HW device. On the other hand, if we
are unfortunate that an IM event is in flight when we are switching
to another TTY, it may arrive at a time when the source device is no
longer existent.
2018-04-22 00:52:05 +02:00
Olivier Fourdan
6df2b7af55 clutter/evdev: Don't ignore CAPS lock as modifier
Mark CAPS lock as a modifier (as it should) so that when using XKB
options to change the default behaviour of CAPS lock, the new assigned
key can by used as a sticky key as well.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/112
2018-04-18 17:07:21 +02:00
Olivier Fourdan
c01b099dbd clutter/evdev: ignore injected events from IM
Input method can inject key events, which leads to multiple reported key
press/release events for a single user action.

Ignore those events as this confuses keyboard accessibility.
2018-04-18 17:07:21 +02:00
Carlos Garnacho
3684f6b0ac clutter: Apply input hints/purpose on ClutterTextInputFocus focus in
And make the ClutterText-level properties independent from the input
focus, as those properties can be set anytime, not just when the
ClutterText actor is focused.

https://gitlab.gnome.org/GNOME/mutter/issues/66

Closes: #66
2018-04-03 14:55:17 +00:00
Yussuf Khalil
8286557a05 clutter: Avoid unnecessary relayouts in ClutterText
We can save an unnecessary relayout if the required size to fully draw the text
is equal to the currently allocated size after the underlying text buffer or
attributes that only affect the PangoLayout have changed.
2018-03-22 21:21:43 +01:00
Ting-Wei Lan
4e6114b14d configure: Don't declare functions in AC_TRY_LINK and AC_TRY_COMPILE
https://bugzilla.gnome.org/show_bug.cgi?id=792717
2018-03-21 13:14:50 +00:00
handsome-feng
b8a81128e0 Fix some spelling errors
https://gitlab.gnome.org/GNOME/mutter/merge_requests/45
2018-03-21 13:22:35 +08:00
Carlos Garnacho
481e87032c clutter: Give the ClutterTextInputFocus a first stab at handling key events
Actor keybindings were dispatched in an earlier return path, which means
the IM doesn't get to see certain key events. Flip the order around so the
IM has an opportunity to handle all keypresses.

https://gitlab.gnome.org/GNOME/mutter/issues/65

Closes: #65
2018-03-13 20:00:10 +00:00
Carlos Garnacho
0bf0e5780c clutter/x11: Communicate proper group/mode on pad events.
So we can trigger actions for the right mode.

https://gitlab.gnome.org/GNOME/mutter/issues/48

Closes: #48
2018-03-03 16:07:24 +00:00
Carlos Garnacho
d7c5e57134 clutter/x11: Implement missing ClutterInputDevice pad vmethods
Use libwacom to be able to find out modes, groups and button roles on
pad devices.

https://gitlab.gnome.org/GNOME/mutter/issues/48

Closes: #48
2018-03-03 16:07:23 +00:00
Carlos Garnacho
8d2f794bd3 clutter/x11: Plug a leak 2018-02-27 14:09:48 +01:00
Jonas Ådahl
a1517cae1c clutter/device-manager: Add way to check virtual device support
This is needed so that mutter can let applications using the remote
desktop API to know whether touch screens are supported.
2018-02-23 19:33:31 +08:00
Jonas Ådahl
542502be53 clutter/x11: Add pointer motion support to virtual devices
As the other virtual input event delivery mechanisms, this also uses
the XTEST protocol.
2018-02-23 19:33:31 +08:00
Jonas Ådahl
203a0b37ed clutter: Add smooth scroll and touch API to virtual devices
So far only implemented on the evdev backend,as X11 doesn't support touch
devices nor smooth scrolling via XTEST.
2018-02-23 19:33:31 +08:00
Jonas Ådahl
b6477a826d clutter/evdev: Don't treat device touch slots as seat slots
IF two touch devices have colliding touch point IDs they'd interfere on
the seat. To avoid this, always allocate a seat wide slot for each
device wide slot, but don't use device slots directly in the seat.
2018-02-23 19:33:31 +08:00
Jonas Ådahl
95adc45b71 clutter/evdev: Move touch notification to seat 2018-02-23 19:24:07 +08:00
Jonas Ådahl
f20daf567d clutter: Silence gtk-doc warning 2018-02-23 19:24:07 +08:00
Carlos Garnacho
bcd5882081 clutter: Check the ClutterTextInputFocus has focus before filtering events
Checking correct state is responsibility of the ClutterInputFocus user, and
it is indeed possible to get a focused ClutterText while its
ClutterInputFocus didn't get itself focused (eg. lack of IM).

https://gitlab.gnome.org/GNOME/mutter/issues/36

Closes: #36
2018-02-18 15:22:13 +01:00
Carlos Garnacho
37aab9280a clutter/text: Be more pervasive at updating input method state
More concretely, ensure preedit text goes away after commit/focus_out,
and update cursor position right after focus_in.
2018-02-12 14:44:30 +01:00
Jonas Ådahl
61bc1a7d6f clutter/x11: Remove video memory purge API
Clutter doesn't handle it anyway, and mutter now creates the
CoglRenderer object itself so we don't need this API anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2018-02-07 11:04:51 +08:00
Jason Gerecke
91df801ffb clutter/evdev: Add support for BTN_STYLUS3
BTN_STYLUS3 is defined by the Linux 4.15 kernel and is sent when the
third button on a stylus is pressed. At the moment, only Wacom's "Pro
Pen 3D" has three stylus buttons. Pressing this button triggers a button
8 event to be sent under X11, so we use the same mapping here.

https://bugzilla.gnome.org/show_bug.cgi?id=790033
2018-01-30 19:28:02 +01:00
Ray Strode
58bb61e161 clutter/stage: Set framebuffer state directly
clutter_set_viewport always operates on the draw fb, but
mutter sometimes has an offscreen fb it uses instead.

This commit uses the non-deprecated, clutter_framebuffer_set_viewport
function, which takes an explicit fb argument.

Closes: https://gitlab.gnome.org/GNOME/mutter/merge_requests/2
2018-01-25 11:41:54 +08:00
Carlos Garnacho
513c278077 clutter: Make ClutterText request toggling the input panel
So gnome-shell is able to show the OSK for it.
2018-01-18 16:20:45 +01:00