Calculate first clickable point, from the top-left
ClosedPublic

Authored by kmaterka on Jul 26 2019, 7:19 PM.

Details

Summary

Wine is using XWindow Shape Extension for transparent tray icons.
We need to find first clickable point starting from top-left.

BUG: 399234

Test Plan

Bug fix test:

  1. Enable KWin compositing;
  2. Download this test program (SHA-1: 63ae606aee64259091e7f82436d4ecdf3a6e9047): https://www.nirsoft.net/utils/tflash210.zip
  3. Run the .exe with Wine Staging
  4. Right click on the icon
  5. Context menu should show

Regression test:

  1. Run XChat
  2. Right click
  3. Context menu should show in the same place as without patch

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
kmaterka created this revision.Jul 26 2019, 7:19 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJul 26 2019, 7:19 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
kmaterka requested review of this revision.Jul 26 2019, 7:19 PM
kmaterka edited projects, added Plasma: Workspaces; removed Plasma.
Restricted Application edited projects, added Plasma; removed Plasma: Workspaces. · View Herald TranscriptJul 29 2019, 9:32 AM

Thanks for doing some work on xembedsniproxy!

xembed-sni-proxy/sniproxy.cpp
239 ↗(On Diff #62621)

This is quite expensive to do every frame (some animate), I think we can do something else, see below.

530 ↗(On Diff #62621)

I don't think clickpoint has to be a member variable, we only use it within the context of this method.

We can make it a local variable evaluated within sendClick. Relative to frame updates, clicks are quite rare.

551 ↗(On Diff #62621)

+ m_clickPoint ?

kmaterka updated this revision to Diff 62723.Jul 29 2019, 10:38 AM
kmaterka marked 3 inline comments as done.

Review changes. Call to the calculateClickPoint is local and on only on mouse click, not on every icon update.

xembed-sni-proxy/sniproxy.cpp
576

This point was marked as closed, but not changed. Probably my fault for not expanding.

We move the window so that it's at x-clickPoint
The relative point is clickPoint.x

The absolute position of the click should be offset by the same amount. I would have expected

event->root_x = x + clickPoint.x
event->root_y = y + clickPoint.y

in both places

kmaterka added inline comments.
xembed-sni-proxy/sniproxy.cpp
576

root_x/root_y coordinates are relative to the root window (in most cases = screen). Local x and y variables hold coordinates of the pointer, which is also relative to the root window. We are not changing pointer position nor root window position.
In original implementation embedable tray window was moved to the pointer location, so that pointer was at (0,0) relative to the tray window. Now we are moving it a little bit further (in the top-left direction), so the coordinates relative to the tray windows must change. If I understand this correctly, it is stored in event_x/event_y. I don't have any experience with XCB, I just followed this documentation:
https://www.x.org/releases/X11R7.7/doc/man/man3/xcb_button_press_event_t.3.xhtml

239 ↗(On Diff #62621)

You are correct, calculate click point might be heavy (when set, it goers thou all window regions and calculates vector length). I will change that.

530 ↗(On Diff #62621)

You are correct, calculate click point might be heavy (when set, it goers thou all window regions and calculates vector length). I will change that.

551 ↗(On Diff #62621)

Root X/Y should remain the same, we are not moving mouse pointer, only the underlying window. GTK is checking mouse state and mosue location, better not to mess with it.
Setting event_x/y is optional and my first implementation ignored this. Without event_x/y it looks bad for Wine applications. Wine is always showing context menu at [0,0] (or [event_x, event_y] to be precise) of the tray icon regardless of the pointer location. It is fine when underlying X window is aligned with the icon in the system tray - it is OK when menu always appears at the corner of the icon. Unfortunately our icon is not aligned, we are moving underlying window (so that click at x,y will hit the underlying window). Changing event_x tricks Wine and menu is shown at the mouse location.

kmaterka set the repository for this revision to R120 Plasma Workspace.
davidedmundson accepted this revision.Aug 15 2019, 4:03 PM
This revision is now accepted and ready to land.Aug 15 2019, 4:03 PM
This revision was automatically updated to reflect the committed changes.