virtualkeyboard: report the size of the inputwindow
AbandonedPublic

Authored by mart on Dec 12 2018, 3:05 PM.

Details

Reviewers
bshah
graesslin
Group Reviewers
Plasma
KWin
Summary

This makes it possible for application to shift the textboxes when using
virtualkeyboard.

Test Plan

tested with test QML code

Diff Detail

Repository
R108 KWin
Branch
mart/resizeforkeyboard
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 7987
Build 8005: arc lint + arc unit
bshah created this revision.Dec 12 2018, 3:05 PM
Restricted Application added a project: KWin. · View Herald TranscriptDec 12 2018, 3:05 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
bshah requested review of this revision.Dec 12 2018, 3:05 PM

tested with test QML code

What QML code exactly?

I would expect you would need to map the virtual keyboard to global space, then map that to the local co-ordinates of the relevant buffer.

bshah planned changes to this revision.Dec 12 2018, 4:13 PM

Seems gives wrong results with multiscreen as discussed on IRC. will update.

bshah added a comment.Dec 12 2018, 4:25 PM

I also realized that I am passing this wrong information, I am passing it just keyboard position, which is not what client is interested in if I understand it correctly.

I also realized that I am passing this wrong information, I am passing it just keyboard position, which is not what client is interested in if I understand it correctly.

Yeah, as the comment says it's about the overlap. Which is not totally trivial, otherwise I would have added it instead of a todo :-P Basically we need to calculate the overlap of the client in screen geometry with the input window in screen geometry and transfer this overlap (if there is any) to client coordinates. To make it worse this needs to also handle window decoration which is something the client doesn't know about. Oh and of course the scaling of the surface needs to be considered.

I know we don't have tests yet for the virtual keyboard, but this is a functionality I wouldn't dare to add without having some good test cases at hand. Especially for such situations as virtual keyboard on one screen, application on other screen, overlap, no overlap, deco, scaling, etc.

course the scaling of the surface needs to be considered.

It doesn't, API states surface-local.

course the scaling of the surface needs to be considered.

It doesn't, API states surface-local.

which means we need to map back, that's what I wrote :-)

Surface-local means the same logical-coordinate size that we use in kwin's screen geometry. If you ignore scale, everything should just work.
Only protocol that uses buffer-local needs mapping.

mart added a comment.Dec 13 2018, 10:14 AM

to get the actual geometry of the client would be basing on Workspace::self()->activeClient() ok?
(not other way to get the position i think?)

mart commandeered this revision.Dec 13 2018, 11:16 AM
mart added a reviewer: bshah.
mart updated this revision to Diff 47505.Dec 13 2018, 11:17 AM
  • track window and keyboard changes
mart added a comment.EditedDec 13 2018, 11:20 AM

this tries to send just the intersection of the geometries and to track keyboard resize + target window geometry changes

graesslin requested changes to this revision.Dec 13 2018, 4:35 PM
graesslin added inline comments.
virtualkeyboard.cpp
117

The active window is not necessarily the window getting input events.

120

nullptr!

238

Sorry, this doesn't work. We need surface local coordinates which exclude window decoration. Also as mentioned above the active client is not guaranteed to get keyboard events.

This revision now requires changes to proceed.Dec 13 2018, 4:35 PM
graesslin added inline comments.Dec 13 2018, 4:37 PM
virtualkeyboard.h
66

I don't see trackedClient being used at all.

mart added inline comments.Dec 14 2018, 9:24 AM
virtualkeyboard.cpp
117

is it possible to get the window which is actually getting them?

graesslin added inline comments.Dec 14 2018, 4:26 PM
virtualkeyboard.cpp
117

SeatInterface::focusedTextInputSurface gives you the surface currently having the text input focus.

mart updated this revision to Diff 47762.Dec 18 2018, 1:26 PM
  • use seat()->focusedTextInputSurface()
mart updated this revision to Diff 47765.Dec 18 2018, 2:10 PM

adjust window geom by decoration margins

graesslin added inline comments.Dec 19 2018, 5:39 PM
virtualkeyboard.cpp
191

?

243

Sorry, but this still doesn't work. You are thinking in windows, but these are surfaces. The surface you have could be a sub-surface. You need to map from global space to surface space. IIRC we have a matrix to transform this. See for example: https://api.kde.org/frameworks/kwayland/html/classKWayland_1_1Server_1_1SeatInterface.html#a56910bce41378def01ee27a6e8b8c6fe

But this is for text input surface, not pointer. The pointer surface might be a different to the text input. It might mean we have to add new API to KWayland.

mart added inline comments.Dec 20 2018, 6:04 PM
virtualkeyboard.cpp
243

tough if i cannot base on a window for it, is there a singal anywhere in surfaceinterface on how i can take the geometry and most important listen to geometry changes?
i can't find anything about it

graesslin added inline comments.Dec 21 2018, 3:59 PM
virtualkeyboard.cpp
243

Yeah, overall it looks like we cannot really support this easily. I would tend to say we can ignore sub surfaces here, but it's quite likely that those change when overlapped by virtual keyboard.

We have a few bits:

  • we can get the root surface from any surface
  • we can Toplevel for the surface
  • surface provides a signal when the subsurface tree changes
  • on Toplevel we have an input transformation to map from global coordinate system to root surface coordinate system
  • KWayland internally can support mapping coordinates from root surface to sub surface

So either connect to the relevant signals in KWin or extend KWayland to do the calculation for the overlap from global to surface local coordinate system.

mart added inline comments.Jan 7 2019, 3:08 PM
virtualkeyboard.cpp
243

would be the SubSurfaceInterface::pos member?

would this reasoning be correct?

so, if a surface is a subsurface

  • get the main surface
  • get its pos in the surface
  • get the toplevel of the surface

*final position is toplevel position + "pos" of the subsurface

mart added a comment.Jan 9 2019, 4:44 PM
This comment was removed by mart.
mart added a comment.Jan 9 2019, 5:00 PM

or should be
QRegion SurfaceInterface::input() const;

always translated to the toplevel surface coordinates if is a subsurface?

mart updated this revision to Diff 51055.Feb 6 2019, 8:21 PM
  • try to track subsurfaces as well
mart added a subscriber: romangg.Feb 7 2019, 3:00 PM

had a discussion about it with @romangg and Dorota from Purism at the plasma mobile sprint and came to the conf=clusion that at first instead we want to resize the toplevel window where the focused surface belongs to a temporary size while the keyboard is open.

the 3rd version of the input protocol removed completely the overlapping area, so if this behavior is needed to be used again, a protocol extension will have to be written

mart updated this revision to Diff 51110.Feb 7 2019, 4:42 PM
  • resize the focused window t make room for the keyboard
mart added a comment.Feb 7 2019, 4:56 PM

last revision was done by mistake, look at D18818 instead

mart abandoned this revision.Feb 7 2019, 5:45 PM