Commit Graph

7150 Commits

Author SHA1 Message Date
Olivier Fourdan
68188fc948 wayland: Fix a race condition with xdg_popup resize
When resizing an xdg_popup immediately after the initial mapping, there
is a race condition between the client and the compositor which is
processing the initial size given by the xdg_positioner, leading to the
xdg_popup to be eventually of the wrong size.

Only way to make sure the size is correct in that case is to hide and
show the window again. Considering this occurs before the initial
configure is processed, it should not be noticeable.

https://bugzilla.gnome.org/show_bug.cgi?id=772505
2017-02-24 10:03:50 +01:00
Olivier Fourdan
e5b6375914 gdkwindow: subsurface in gdk_window_get_effective_parent()
When the GtkWidget hierarchy does not match the GdkWindow hierarchy, the
GtkWidget code may find a common ancestor that cannot be found while
traversing the GdkWindow tree using gdk_window_get_effective_parent().

This happens with for example on Wayland, a GtkPopover has another
GtkPopover as parent, in this case, the GdkWindow parent is the root
window, whereas the GtkWidget parent is the other GtkPopover.

That confuses the gtk_widget_translate_coordinates() logic which will
bail out in this case and won't return the translated coordinates.

Make gdk_window_get_effective_parent() aware of subsurfaces and use the
transient_for which represents the actual parent (whereas the parent
might be pointing to the root window).

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=774148
2017-02-23 14:10:56 +01:00
Руслан Ижбулатов
f9df0fc94c GDK W32: Handle drivers that do not send WT_CSRCHANGE after WT_PROXIMITY
Some drivers don't do that (not sure whether that is the correct behaviour
or not). Remember each WT_PROXIMITY with LOWORD(lParam) != 0 that we get,
then look for a WT_CSRCHANGE. If WT_CSRCHANGE doesn't come, but a WT_PACKET
does, assume that this device is the one that sent WT_PROXIMITY.

Also include fallback code to ensure that WT_PACKETs for an enabled device
disable the system pointer, because WT_PROXIMITY handler might have
enabled it by mistake, since it's not possible to know which device left
the proximity (it might have been a disabled device).

https://bugzilla.gnome.org/show_bug.cgi?id=778328
2017-02-19 07:12:13 +00:00
Руслан Ижбулатов
1d0fad3d70 GDK W32: Apply HiDPI scale properly to monitors
Previously HiDPI scale was retrieved and applied too late in the initialization
process to affect monitor size and monitor workarea size, but the code that
initializes these sizes *did* try to use the scale, even though it was always
getting scale=1.

To fix this, move the too-late code into monitor enumeration routine.
This also fixes a probable semantic bug where width and height were divided
by scale, again.

Now monitor and workarea should be in application pixels (i.e. divided by scale),
as intended.

https://bugzilla.gnome.org/show_bug.cgi?id=778835
2017-02-19 07:00:17 +00:00
Carlos Garnacho
d825c34ca3 gdk: Ensure GdkDragContext instantly updates drag window position
Otherwise we wait for the next gdk_drag_motion() call, which will
happen on the next motion event, making the drag window briefly visible
on the 0,0 root coordinates.

https://bugzilla.gnome.org/show_bug.cgi?id=778203
2017-02-17 19:30:46 +01:00
Руслан Ижбулатов
dca4f1e715 GDK W32: Different maximized window position for non-CSD windows
It seems that WM interprets the same MINMAXINFO contents differently
depending on which styles the window has. Play along.

https://bugzilla.gnome.org/show_bug.cgi?id=765161
2017-02-10 18:21:13 +00:00
Olivier Fourdan
7ec16c5c53 wayland: do not clamp anchor values
Clamping the anchor values as introduced in commit 9a5ffcd to fix bug
777176 breaks menu positioning.

By keeping the anchors rectangle size greater than zero, we end up
deducting some positive value from the original position, so there is no
need to clamp() actually, keeping the values positive is enough and
avoids the issue with menu positioning on the menubar.

An additional benefit is to make the code a lot simpler.

https://bugzilla.gnome.org/show_bug.cgi?id=778009
2017-02-06 09:19:26 +01:00
William Hua
d9947b671a mir: handle surface placement events
This allows the Mir backend to properly emit "moved-to-rect."
2017-01-30 03:40:18 -05:00
William Hua
14c8e25cb2 mir: use mir_surface_spec_set_placement for menus
This API was added to Mir for GTK menus, combo boxes, etc.
2017-01-30 03:23:50 -05:00
Carlos Garnacho
baa83e9753 wayland: Ensure to set gtk_surface dbus properties after hide()
Currently hiding destroys the wl_surface and all related interfaces,
(including the gtk_surface1) so the next time the GdkWindow is mapped,
we don't bother to set the DBus properties. Toggle the check off so
it's actually issued again after the GdkWindow gets a gtk_surface1.

https://bugzilla.gnome.org/show_bug.cgi?id=773686
2017-01-25 18:01:26 +01:00
William Hua
5d7db3246e mir: use modal window hint 2017-01-23 10:58:09 -05:00
William Hua
a95feb4984 mir: fix compile-time warnings 2017-01-22 11:14:34 -05:00
Руслан Ижбулатов
4a5cd127ff GDK W32: Ensure that we use made-up monitors when there are none
Previously GDK only made up monitors when it initially found none. Now it
also makes up monitors when it initially finds some, but later fails to get
their informatin in a normal way and finally prunes them out, being left with
zero monitors.

Having zero-length monitor array is unexpected and causes a number
of critical warnings and some critical functionality (such as displaying
drop-down menus) fails in such cases.

Ideally, there might be such a way to interrogate W32 API that produces the
information about non-real (but active) monitors out of it so that it isn't
necessary for us to make stuff up. However, this code is already complicated,
and i am not prepared to dig W32 API to find a way to do this.

This fixes the issues people had when they accessed a Windows desktop via RDP.

https://bugzilla.gnome.org/show_bug.cgi?id=777527
2017-01-20 12:45:57 +00:00
Руслан Ижбулатов
a7ff95ce73 GDK W32: Fix idiotic gdk_win32_display_get_monitor() implementation
Replace the code borrowed from the X11 backend with the code borrowed from Wayland backend. Now GTK doesn't crash when the number of monitors is zero.
2017-01-20 09:08:41 +00:00
Carlos Garnacho
bbcc3ee456 Revert "wayland: Push NULL buffer when hiding a GdkWindow"
This reverts commit 0f2e19c010.
2017-01-19 21:21:57 +01:00
Carlos Garnacho
0f2e19c010 wayland: Push NULL buffer when hiding a GdkWindow
This is how windows are meant to be hidden as per the wayland
protocol, there's no need to destroy the xdg_surface and other
interfaces.

Also, rename gdk_wayland_window_hide_surface() to clear_surface(),
as that's what it does.

https://bugzilla.gnome.org/show_bug.cgi?id=773686
2017-01-19 16:18:22 +01:00
Rui Matos
4f80d234bf gdk/wayland: Always get the seat's key modifiers from the GdkKeymap
Elsewhere we already go through the keymap to get modifiers so we
should do the same here. In fact, this was relying on xkb modifier
mask values being bitwise compatible with GdkModifierType which isn't
necessarily true.

https://bugzilla.gnome.org/show_bug.cgi?id=770112
2017-01-17 18:12:54 +01:00
Rui Matos
33c10204e4 gdk/wayland: Don't add GDK_META_MASK to gdk mod masks if MOD1 is set
Gtk+ treats MOD1 as a synonym for Alt, and does not expect it to be
mapped around, so we should avoid adding GDK_META_MASK if MOD1 is
already included to avoid confusing gtk+ and applications that rely on
that behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=770112
2017-01-17 18:12:54 +01:00
William Hua
248ef2d6a0 mir: properly handle empty clipboard
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
William Hua
41732391d8 mir: paste clipboard data from content-hub
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
William Hua
5c4c3f1afd mir: copy clipboard data to content-hub
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
William Hua
210d1279e5 mir: connect to content-hub
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
William Hua
0acb58b40f mir: track focused window
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
William Hua
b6baa088dc mir: implement window properties
https://bugzilla.gnome.org/show_bug.cgi?id=775732
2017-01-16 17:11:16 -05:00
Olivier Fourdan
9a5ffcd1b5 wayland: avoid 0 width/height anchor rectangle
Passing a rectangle with zero width or height to xdg_shell-v6
set_anchor_rect() will cause a protocol error and terminate the client,
as with gedit when pressing the Win key.

Reason for this is because the rectangle used to set the anchor comes
from gtk_text_layout_get_iter_location() which uses the pango layout
width/height, which can be empty if there is not character at the given
location.

Make sure we don't use 0 as width or height as an anchor rectangle to
avoid the protocol error, and compensate the logical position of the
given rectangle if the size is changed, so that the actual position
remains as expected by the client.

https://bugzilla.gnome.org/show_bug.cgi?id=777176
2017-01-16 13:55:36 +01:00
Matthias Clasen
6da8cbc87e Deprecate gdk_window_process[_all]_updates
These functions should not be used anymore now that we have a
frame clock, and are gone in GTK+ 4
2017-01-10 20:25:15 -05:00
Rui Matos
99abc6363a gdk/wayland: Handle non-existant gsettings keys
Since we're a library, crashing on gsettings keys, whose presence is out
of our control, isn't appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=775846
2017-01-10 15:18:09 +01:00
Rui Matos
22b1e0b678 gdk/wayland: Add support for the gtk-enable-primary-paste gsetting
The gsetting was recently added so that we can have this configurable
on the wayland backend too.

https://bugzilla.gnome.org/show_bug.cgi?id=775846
2017-01-10 15:18:09 +01:00
Руслан Ижбулатов
eece8a7dd2 GDK W32: Use keyboard hook to detect AeroSnap combinations better
Windows WM handles AeroSnap for normal windows on keydown. We did this
on keyup only because we do not get a keydown message, even if Windows WM
does nothing with a combination. However, in some specific cases it DOES
do something - and we have no way to detect that. Specifically, winkey+downarrow
causes maximized window to be restored by WM, and GDK fails to detect that. Then
GDK gets a keyup message, figures that winkey+downarrow was pressed and released,
and handles the combination - by minimizing the window.

To overcome this, install a low-level keyboard hook (high-level ones have
the same problem as normal message loop - they don't get messages when
Windows WM handles combinations) and use it to detect interesting key combinations
before Windows WM has a chance to block them from being processed.

Once an interesting combination is detected, post a message to the window, which
will be handled in due order.

It should be noted that this code handles key repetitions in a very crude manner.

The downside is that AeroSnap will not work if hook installation function call fails.
Also, this is a global hook, and if the hook procedure does something wrong, bad things
can happen.

https://bugzilla.gnome.org/show_bug.cgi?id=776031
2017-01-10 12:54:43 +00:00
Руслан Ижбулатов
ca79296061 GDK W32: Handle CapsLock as part of the key shift level
Instead of using some kind of flawed logic about modifying a keypress result
when CapsLock is toggled, just add a CapsLock shift level (and all derived
shift levels, i.e. Shift+CapsLock and CapsLock+AltGr and Shift+CapsLock+AltGr)
and query Windows keyboard layout API about the result of keypresses involving
CapsLock.

Keysym table is going to be (roughly) twice as large now, but CapsLock'ed
keypresses will give correct results for some keyboard layouts (such as
Czech keyboard layout, which without this change produces lowercase letters
for CapsLock->[0,2,3,4...] instead of uppercase ones).

Keymap update time also increases accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=165385
2017-01-10 07:59:53 +00:00
Carlos Garnacho
ab66c3d7bf wayland: Disable EGL swap interval
We have a frame clock that ensures rendering is done as per the
output vsync. There is no need to have Mesa do the same for us.

This, most notably, ensures Mesa doesn't schedule frame callbacks
that will be left unattended if the compositor stops throttling
frames for its surface, this is eg. the case if the toplevel is
moved to another workspace.

Also, given a SwapInterval!=0 will always bring these unexpected
side effects, check that it's possible to disable it, and spew
a debug message if that isn't the case.

https://bugzilla.gnome.org/show_bug.cgi?id=769835
2017-01-09 19:04:23 +01:00
Carlos Garnacho
c4f1545c5e wayland: Add fake mimetype for local DnD cases
If there are no targets, DnD is probably intended to be local,
add a mimetype for matching then. The wayland protocol requires
at least one wl_data_offer.target call with the mimetype selected
for transfer.
2017-01-09 19:04:23 +01:00
Руслан Ижбулатов
125ef3539c GDK W32: Special handling for VK_PAUSE
Similar to VK_DIVIDE, this key can't be mapped to a scancode by
MapVirtualKeyEx(). Googling suggests that this is a known bug.

https://bugzilla.gnome.org/show_bug.cgi?id=769214
2017-01-09 15:15:52 +00:00
Руслан Ижбулатов
3326fba524 GDK W32: Change WM_SYSMENU style switch logic
Instead of checking for window state and giving it extra styles that
fit, just give it all styles that it is missing. It turned out that
otherwise it is impossible to, for example, restore a maximized window
via sysmenu. Also, be more flexible towards GDK/WM window state mismatches
and consider the window minimized/maximized if *either* GDK or WM thinks so.

https://bugzilla.gnome.org/show_bug.cgi?id=776485
2017-01-09 14:17:32 +00:00
Руслан Ижбулатов
51645b5851 GDK W32: Remove unneeded assertion
Just set check_for_dpi_awareness = TRUE and eventually it will be handled
correctly, even if setDpiAwareFunc() returns E_ACCESSDENIED or shcore functions
are NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=777031
2017-01-09 10:00:22 +00:00
Jonas Ådahl
5bae71f896 wayland: Handle subsurface as popup parent
When a subsurface is used as a parent of a popup, GDK needs to traverse
up to the transient-for as the next parent, to properly find the parent
used by the popup positioner. This is because the parent of a popup
must always either be an xdg_popup or an xdg_surface, but traversing
the "parent" (in GDK terms) upwards from a subsurface will end up on
the fake root window before we hit the actual parent (in Wayland terms).

https://bugzilla.gnome.org/show_bug.cgi?id=776225
2017-01-06 10:44:54 +08:00
Руслан Ижбулатов
a1aee4602c GDK W32: Handle maximizing correctly for small primary monitors
When primary monitor is smaller than the actual monitor on which the
window is being maximized, the WM will do widnow size adjustments
that will completely screw the window size if we try to make it
smaller than 100% fullscreen (to account for taskbar size, for example).

Fix this by overriding maximized window size during WM_WINDOWPOSCHANGING.

https://bugzilla.gnome.org/show_bug.cgi?id=775808
2016-12-24 17:29:50 +00:00
Debarshi Ray
2b32008eeb Mention that gdk_window_create_similar_image_surface inherits the scale
https://bugzilla.gnome.org/show_bug.cgi?id=776132
2016-12-17 22:50:48 +01:00
Olivier Fourdan
78f8f236e9 wayland: apply empty input shape on parent commit
For subsurfaces, the new state which includes the input shape is not
applied by the compositor if the subsurface is in effective synchronous
mode.

So we need to apply the input shape once parent surface is in effective
desynchronized mode, which is when it's committed, otherwise the input
shape may never be applied if the widget is not using being_paint() /
end_paint() to draw on its subsurface, like clutter does.

We do that only for empty input shape as those won't need update when
the subsurface is resized, for all other non-empty input shape, the
client still has to use begin_paint()/end_paint() for the input shape to
be applied.

https://bugzilla.gnome.org/show_bug.cgi?id=774534
2016-12-15 13:30:05 +01:00
Emmanuele Bassi
33e4826efd gl: Check for GL_EXT_framebuffer_blit before using glBlitFramebuffer
We check when we realize the GdkGLContext, but we never use the check
before using the API, and it breaks on drivers that do not implement the
extension, or on drivers that only support OpenGL ES 2.0.
2016-12-14 20:55:21 +00:00
Olivier Fourdan
7f39c7cbf7 wayland: destroy subsurfaces along with parents
Wayland subsurfaces can have other native window parents, but those need
to be destroyed along with the rest of the window hierarchy otherwise
an assert() is reached.

https://bugzilla.gnome.org/show_bug.cgi?id=774915
2016-12-05 10:57:04 +01:00
Matthias Clasen
43b2b107f1 wayland: Don't warn if we loose the compositor connection
And instead, exit cleanly. This avoids filling the logs with
these warnings from every single application that has a
connection to the compositor.
2016-11-30 13:46:34 -05:00
Matthias Clasen
c70ba3a4f0 x11: Don't warn if the display is closed
This causes a storm of warnings from all applications in the logs
whenever the display goes away, and is not useful.
2016-11-30 13:46:29 -05:00
Olivier Fourdan
57a14565c6 wayland: Check for subsurface looking up the toplevel
gdk_window_get_toplevel() walks up the windows tree looking for the
corresponding toplevel window, but needs to account for subsurfaces as
well on Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=775319
2016-11-30 10:06:40 +01:00
Matthias Clasen
cf4fd0d3e3 Reduce a warning to a message
The warning interferes with having a testcase to check this behavior,
so reduce this to a message.
2016-11-28 14:43:07 -05:00
Andrew Chadwick
0b129f3534 win32 event: check for NULL display or dev mgr
The recent Wintab testing revealed an interesting edge case: we cannot
for certain say that windowing system messages will not be received
while the default display and its device manager are still being set up.
We've ruled out the Wintab case now, but cannot rule out some future bit
of runtime DLL code doing stuff at this critical time.

This commit detects and avoids a potential null pointer dereference in
the message handling code while detecting grabs. Grabs don't really
exist yet, if the default display and/or its device manager are not yet
globally known.

https://bugzilla.gnome.org/show_bug.cgi?id=774379
2016-11-28 15:05:13 +00:00
Olivier Fourdan
605303681b wayland: Place subsurfaces relative to their parent
Now that subsurfaces can be created as child of another GdkWindow (and
not just the root window), they must be placed according to the location
of their parent, i.e. the abs_x/abs_y must be updated and taken into
account when placing and moving subsurfaces under Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=774917
2016-11-24 09:33:35 +01:00
Andrew Chadwick
66a08bf3a6 wintab: init only after the display is assigned
Only attempt to initialize Wintab after the display manager announces
that the first default display has been set. Fixes a segfault during
initialization of specific tablet drivers' wintab32.dlls. Add assertions
and verbose comments explaining this nonsense because this stuff is a
pain to have to keep fixing.

https://bugzilla.gnome.org/show_bug.cgi?id=774379
2016-11-22 12:52:00 +01:00
Andrew Chadwick
dd6a00bb31 wintab tilt: Check return location for validity
https://bugzilla.gnome.org/show_bug.cgi?id=774265
2016-11-22 12:17:32 +01:00
Andrew Chadwick
61a57465ea win32: Fix tilt from Wintab devices
Move the orientation sanity-checks into the packet decode func.
Rationale: the packet handling func may otherwise read beyond the end of
device->last_axis_data.

Also expand them to cope with my test Huion's weird reporting.

Also correct the azimuth angle to align with GDK's presentation.

Most importantly, fix annoying comment typo.

https://bugzilla.gnome.org/show_bug.cgi?id=774265
2016-11-22 11:22:16 +01:00