Commit Graph

384 Commits

Author SHA1 Message Date
Emmanuele Bassi
c1c59bd898 x11/stage: Resize on window-scaling-factor changes
If we get a change in the window scaling factor we want to resize the
backing store of each stage, so we use the notification on the
ClutterSettings:window-scaling-factor property to do so.

https://bugzilla.gnome.org/show_bug.cgi?id=705915
2014-01-20 12:26:46 +00:00
Emmanuele Bassi
2c8a19b8c1 x11/stage: Remove CLUTTER_SCALE handling
Use the ClutterSettings:window-scaling-factor property instead.

https://bugzilla.gnome.org/show_bug.cgi?id=705915
2014-01-20 12:26:46 +00:00
Emmanuele Bassi
69eb2e5f3b settings: Add window scaling related settings
We share two settings with GDK, so we can pick the window scaling factor
and the unscaled font resolution when we initialize Clutter.

https://bugzilla.gnome.org/show_bug.cgi?id=705915
2014-01-20 12:26:46 +00:00
Rui Matos
ce1f8f1dd0 device-manager-xi2: Fix device instances leaking on removal
Don't add an extra reference when adding to the devices hash table. We
already own the initial reference.

https://bugzilla.gnome.org/show_bug.cgi?id=712812
2013-11-21 19:34:14 +01:00
Jasper St. Pierre
c2b0b9aace input-device-xi2: Calculate the correct state for button events
The state that the X server sends for button events, by specification,
contains the button state before the event. We need to synthesize in
the result of the event in order to determine what the current button
state is.

https://bugzilla.gnome.org/show_bug.cgi?id=712322
2013-11-14 14:30:30 -05:00
Jasper St. Pierre
0fda81feab Remove use of XFixes for showing/hiding the cursor
XFixesShowCursor / XFixesHideCursor does not actually take the suppled
window argument into account -- the effect is actually global. Use
XDefineCursor instead.

https://bugzilla.gnome.org/show_bug.cgi?id=707071
2013-11-14 18:34:40 +00:00
Jasper St. Pierre
98e03fc03f device-manager-xi2: Clamp coordinates of events to the stage coordinates
The X server can sometimes send us coordinates in the negatives or above
our window in extreme cases. Ensure that the user never sees this.
2013-11-14 18:34:40 +00:00
Jasper St. Pierre
1de024b5fa device-manager-xi2: Don't divide by the scale factor twice
The coordinates we pass into translate_axes are already scaled.
2013-11-14 18:34:40 +00:00
Emmanuele Bassi
300c76df17 x11: Ensure we have a stage before accessing its fields
For some XI2 we do not have a Stage associated to the event window.

Original patch by: Giovanni Campagna <scampa.giovanni@gmail.com>
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=708439
2013-09-20 10:56:57 +01:00
Emmanuele Bassi
75f81fee70 x11: Apply the window scaling factor
On high DPI density displays we create surfaces with a size scaled up by
a certain factor. Even if the contents stay at the same relative size
and position, we need to compensate the scaling both when changing the
surface size, and when dealing with input.

https://bugzilla.gnome.org/show_bug.cgi?id=705915
2013-09-19 22:51:52 +01:00
Giovanni Campagna
59f1e531f9 ClutterEvent: add API to query the full keyboard state when the event was generated
When talking to other applications or serializing the modifier
state (and in particular when implementing a wayland compositor),
the effective modifier state alone is not sufficient, one needs
to know the base, latched and locked modifiers.

Previously one could do with backend specific functionality
such as clutter_device_manager_evdev_get_xkb_state(), but the
problem is that the internal data structures are updated as
soon as the events are fetched from the upstream source, but
the events are reported to the application some time later,
and thus the two can get out of sync.
This way, on the other hand, the information is cached in the
event, and provided to the application with the value that
was current when the event was generated.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:18:23 +02:00
Emmanuele Bassi
c2d5dd2d11 x11: Remove unused variable 2013-07-12 09:57:23 +01:00
Jasper St. Pierre
01707f0da9 input-device-x11: Remove more dead code
It seems this API has never been used..
2013-07-11 14:09:43 -04:00
Jasper St. Pierre
e62cf4745f device-manager: Select for events on XIAllMasterDevices
This removes a bit of work that we have to do for every device, and makes it
easy for mutter to patch out parts of the event mask it doesn't want.

https://bugzilla.gnome.org/show_bug.cgi?id=703969
2013-07-11 14:09:43 -04:00
Jasper St. Pierre
032688800c device-manager: Don't pass the event mask around
There's no point in doing this, as we always use a constant event mask.
Simply do what everything else does.

https://bugzilla.gnome.org/show_bug.cgi?id=703969
2013-07-11 14:09:43 -04:00
Jasper St. Pierre
e38ea7a20f x11: Remove support for XInput 1
Now we either use core X11 or XInput 2.

https://bugzilla.gnome.org/show_bug.cgi?id=703969
2013-07-11 14:03:43 -04:00
Jasper St. Pierre
0b32f99bd1 backend-x11: Remove bad branch prediction
This will only get once, at in Clutter initialization time.

https://bugzilla.gnome.org/show_bug.cgi?id=703969
2013-07-10 17:22:48 -04:00
Emmanuele Bassi
dc7d42d87a x11: Replace deprecated Cogl API 2013-07-03 18:24:27 +01:00
Emmanuele Bassi
41bb03da2d Use the new macros for adding private data 2013-07-03 18:04:32 +01:00
Emmanuele Bassi
2e905dd9d4 Fix annotations for signal arguments
The introspection scanner started warning about mismatched arguments
number.
2013-07-03 13:13:41 +01:00
Matthias Clasen
d343cc6289 x11: trap errors when calling XIQueryDevice
Devices can disappear at any time, causing XIQueryDevice
to throw an error. At the same time, plug a memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=701974
2013-06-10 21:45:47 -04:00
Emmanuele Bassi
03296e30e7 Fix compilers warnings when debugging is disabled 2013-04-04 11:53:38 +01:00
Jasper St. Pierre
c26d724f3d clutter-backend: Request XI2.3
Since XIQueryVersion, the bad API that it is, chooses the first client
version that it gets, we need to ensure that we pass XIQueryVersion the
new XI2.3 version, knowing fully well that Clutter won't be confused
by the new features.

https://bugzilla.gnome.org/show_bug.cgi?id=692466
2013-03-12 17:09:29 -04:00
Jasper St. Pierre
009da0c6ce x11: Always request XI2.2
The X server should fill in the minor version that it supports in the
case where it only supports the older version. We should not get a
BadRequest or fail the version check if we pass something higher.

https://bugzilla.gnome.org/show_bug.cgi?id=692466
2013-03-12 17:09:29 -04:00
Sebastian Keller
9dbc01b61f xi2: Reset scroll info for correct device on device change 2013-03-12 17:09:29 -04:00
Rui Matos
40ef7a5f6e x11/xi2: Factor the XKB group state in to fill events' modifier_state
Otherwise XkbTranslateKeyCode() won't yeld the correct keysyms when
group > 1.

https://bugzilla.gnome.org/show_bug.cgi?id=695260
2013-03-06 13:36:09 +01:00
Rui Matos
b01469c8f3 x11/clutter-keymap-x11: Honor XkbNewKeyboardNotify events
We already select for XkbNewKeyboardNotify events but are not acting
on them. Start doing so.

https://bugzilla.gnome.org/show_bug.cgi?id=694267
2013-02-24 18:35:53 +01:00
Damien Lespiau
3e479a3326 cogl: Don't use cogl_xlib_set_diplay()
This function is deprecated and has been replaced by set_display() on
the renderer. This is done in the get_renderer() vfunc of both the x11
and gdk backends already.

Actually cogl_xlib_set_diplay() is now a no-op and can be safely removed.

https://bugzilla.gnome.org/show_bug.cgi?id=687652
2013-02-20 23:06:28 +00:00
Rui Matos
c0469601c7 x11/device-manager-xi2: Fix slave to master association
A slave is associated to a master device, not the other way around.

https://bugzilla.gnome.org/show_bug.cgi?id=692971
2013-02-01 10:13:01 +01:00
Yanko Kaneti
069abd1122 xi2: Fix access beyond array boundaries 2013-02-01 06:17:36 +02:00
Jasper St. Pierre
4691878a76 x11: Ignore num lock / scroll lock for event state
As x11 considers num lock and scroll lock to be modifiers, code that
checks for an exact modifier combination will fail if naively done when
num lock or scroll lock are turned on. Applications that want to ignore
these modifiers will need to use XKB to manually mask out the modifier
state.

As it is very unlikely that applications will want to care about the
state of num lock or scroll lock for key press/key release events, mask
out the num lock and scroll lock keys automatically.

https://bugzilla.gnome.org/show_bug.cgi?id=690664
2013-01-14 12:56:07 -05:00
Daniel Stone
1a0e501efd X11: Use XFixes for show/hide cursor
This has been disabled since February 2008, on the grounds that XFixes
didn't work reliably for hiding cursors.  This has almost certainly been
fixed then and seems to work entirely reliably across a number of X
servers released in the past few years, and is definitely better than a
1x1 black dot for a cursor.

Helpfully though, where the spec states that the cursor will be hidden
when inside the specified window or one of its children, it actually
only uses the window to look up the Screen, and hides the cursor across
the entire Screen.  So, when using this, we also need to track crossing
events.

If it's still broken, this needs to be fixed in the X server.

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

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-01-10 17:10:50 +00:00
Emmanuele Bassi
47c1e26385 Enable XInput support by default
Instead of using core events, we should move into the XXI century, and
use the XInput extension.

https://bugzilla.gnome.org/show_bug.cgi?id=673838
2012-12-18 01:27:31 +00:00
Jasper St. Pierre
9614dff158 xi2: Reset the correct scroll axes on DeviceChanged
Otherwise, we'll have incorrect scrolling when we switch hardware
devices without switching virtual devices. For example, on a ThinkPad,
scroll using the touchpad, move the eraser mouse, and then scroll again:
the deltas will be wrong. This also matches what GTK+ does.

https://bugzilla.gnome.org/show_bug.cgi?id=689258
2012-11-29 16:50:54 -05:00
Emanuele Aina
35faaf604c x11: set the stage for core events with no associated stage
When the last touch has been released the stage on the
corresponding master device (eg. the virtual core pointer) is set
to NULL and no mouse events can be delivered until an ENTER event
has occurred and the stage pointer restored.

This is due to the fact that the master devices can send both
touch events and mouse events, forwarding events coming from the
attached slave devices.

To restore delivery of mouse events we need to ensure that the
stage is set on each ButtonPress, ButtonRelease and Motion event
coming from master devices.

https://bugzilla.gnome.org/show_bug.cgi?id=684509
2012-09-24 17:08:24 +01:00
Emanuele Aina
a6abf86e94 input-device: print device number in debug messages
https://bugzilla.gnome.org/show_bug.cgi?id=684530
2012-09-24 17:04:08 +01:00
Emmanuele Bassi
950e60f824 x11: Add EventSequence → touch detail accessor
The ClutterEventSequence structure is a fully opaque type; on X11, it is
just an unsigned integer that gets converted into a pointer, but in the
future it may become a fully fledged data structure.

Obviously, we cannot tell people to just dereference the pointer into an
integer in order to use it, and still retain the ability to change the
type; for this reason, we need a proper accessor function to convert the
EventSequence into a touch detail, to be used with the XInput API.
2012-09-05 09:43:47 +01:00
Lionel Landwerlin
d6a0f7eb61 input-device: don't reset a device's stage until all touch points are gone
803b3bafb6 introduced a new issue for
multi touch events.

In the case where 2 touch events for 2 different touch points are
processed in the same iteration, a call to
_clutter_stage_remove_device() when processing the first event will
remove the stage setting of the InputDevice. That means Clutter will
skip the second event, because it can't find a stage to which relate
the event, so no related actor and so no emission.

To fix this we move the _clutter_stage_(add/remove)_device() calls
into the input device. This way the input device can find out exactly
when to call these functions (i.e. when no touch point were previously
active or when no touch point remain active).

https://bugzilla.gnome.org/show_bug.cgi?id=682362
2012-09-03 21:50:24 +01:00
Tomeu Vizoso
d5332d1e4c stage: Remove tracking input devices, it's not used
https://bugzilla.gnome.org/show_bug.cgi?id=683126
2012-09-03 21:50:19 +01:00
Emmanuele Bassi
b2b22dbe6c x11/device-manager-xi2: Put XIPointerEmulated under conditionals
There are a couple of debugging messages using XInput 2.2 symbols
unconditionally, and it breaks builds on older systems.

https://bugzilla.gnome.org/show_bug.cgi?id=683219
2012-09-02 22:48:52 +01:00
Emmanuele Bassi
31b8b2e22f x11: Add debug notes for pointer-emulated 2012-07-18 17:14:17 -04:00
Emmanuele Bassi
2a31a93c5e x11/xi2: Do not generate scroll events on ButtonRelease
Scroll events are generated on ButtonPress only in the core event
handling, so it should happen the same if we use XInput.

https://bugzilla.gnome.org/show_bug.cgi?id=680088
2012-07-17 10:13:12 -04:00
Emmanuele Bassi
b985c4035e Deprecate ClutterTexture's API
ClutterTexture is full of side effects that have been picked up over the
years; they make improving ClutterTexture harder than necessary, as well
as making subclassing impossible without introducing weird behaviours in
the child classes as well.

Since Clutter 1.10 we have the ClutterImage content type, which is
side-effects free, given that it just paints texture data using the
state of the actor.

Sadly, we still have subclasses of ClutterTexture, both deprecated and
not, so we cannot deprecate ClutterTexture right out; the type and
structures will still be available, like we do for ClutterGroup, but the
whole API should be moved to the deprecated section, waiting for the
time in which we can get rid of it all.
2012-07-11 13:22:21 +01:00
Emmanuele Bassi
0e4c6d0a87 Deprecate clutter_threads_enter()/leave()
Acquiring the Clutter lock to mark critical sections is not portable,
and not recommended to implement threaded applications with Clutter.

The recommended pattern is to use worker threads, and schedule UI
updates inside idle or timeout handlers within the main loop. We should
enforce this pattern by deprecating the threads_enter()/leave()
functions. For compatibility concerns, we need internal API to acquire
the main lock during frame processing dispatch.

https://bugzilla.gnome.org/show_bug.cgi?id=679450
2012-07-11 13:22:19 +01:00
Matthias Clasen
e3ca87784e XI2: Avoid a crash in event translation
It is possible that we get a DeviceChanged event for a device
that is not in the hash table yet. E.g. I've seen this when
using xrandr to change screen resolution. Prevent a crash in
this case.

https://bugzilla.gnome.org/review?bug=678439
2012-06-20 07:22:12 -04:00
Bastien Nocera
2bb84d9169 x11/device-manager-xi2: Fix assertions with touch
When getting touch events, the device manager would try
to pass an invalid device to translate_axes().

clutter_event_set_device() will only update event->touch.device
for touch events, not event->motion.device, as used.

Fixes Totem crashing on mouse motion/button press when using
a touchpad.

https://bugzilla.gnome.org/show_bug.cgi?id=675371
2012-05-03 19:32:07 +02:00
Emmanuele Bassi
0dd74ca3fb docs: Annotation fixes
The introspection scanner has become slightly more annoying, in the hope
that people start fixing their annotations. As it turns out, it was the
right move.
2012-04-30 17:17:41 +01:00
Emmanuele Bassi
26d8ad7479 Be resilient in case there is no device manager
It's possible to run Clutter with the 'null' input backend, which means
that clutter_device_manager_get_default() may return NULL. In the future
we may add a default dummy device manager, but right now it's safer to
just add a simple NULL check in the places where we ask for the device
manager.
2012-04-26 13:56:00 +01:00
Cosimo Cecchi
032870dccc device-manager: select/unselect device events as device change
When a device is added or changes, select/unselect events from X
accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=673644
2012-04-24 18:49:42 -04:00
Cosimo Cecchi
d61515322a x11/device-manager-xi2: Flip deltas around
Up/down is Y.
2012-04-20 18:33:16 +01:00