Bug 332702 - Widget explorer and activity switcher opens sometimes in middle of screen
Summary: Widget explorer and activity switcher opens sometimes in middle of screen
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: unspecified Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
: 341881 347338 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-27 17:05 UTC by Bhushan Shah
Modified: 2015-08-24 10:01 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot (500.75 KB, image/png)
2014-03-27 17:05 UTC, Bhushan Shah
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bhushan Shah 2014-03-27 17:05:28 UTC
Created attachment 85792 [details]
screenshot

See screenshot.

Steps to reproduce

1) place a very little window like xterm at left top corner
2) now open widget explorer

Extra fun
1) now close it, and move window a little
2) start widget explorer
3) Find it attached to window.
Comment 1 Bhushan Shah 2014-03-27 17:13:04 UTC
Same with activity switcher, moving to kwin.
Comment 2 Thomas Lübking 2014-03-27 17:19:52 UTC
Why does the widget explorer take part in placement?
Does it not set an explicit position?

I doubt there's a difference in the activity switcher and widget explorer clients.
Comment 3 Bhushan Shah 2014-03-27 17:22:07 UTC
(In reply to comment #2)
> Does it not set an explicit position?
It sets I think..
Comment 4 Thomas Lübking 2014-03-27 17:23:21 UTC
Well, i doubt so - try a more explicit placement strategy (eg. zero cornered)
Comment 5 Thomas Lübking 2014-03-27 17:25:30 UTC
Does eg. yakuake still show up at the correct position?
Comment 6 Bhushan Shah 2014-03-27 17:28:58 UTC
I don't have Yakuake installed.. CC'ing notmart
Comment 7 Thomas Lübking 2014-03-27 17:31:58 UTC
 kwrite --geometry +20+80
Comment 8 Bhushan Shah 2014-03-27 17:44:11 UTC
Hmm, it appears at right place.
Comment 9 Bhushan Shah 2014-03-27 17:47:09 UTC
but what I noticed is windows started by plasma-shell are at not right place if another window is at 0x0

Example, 

1) desktop settings
2) Widget explorer
3) Activity chooser
Comment 10 Thomas Lübking 2014-03-27 17:58:44 UTC
the default (smart) placement strategy starts searching for a free slot in the upper left corner - try a more explicit one (zero cornered, centered - kcmshell4 kwinoptions, last tab)
Comment 11 Bhushan Shah 2014-03-28 05:35:07 UTC
(In reply to comment #10)
> the default (smart) placement strategy starts searching for a free slot in
> the upper left corner - try a more explicit one (zero cornered, centered -
> kcmshell4 kwinoptions, last tab)
kcmshell4?? :O this is kwin5 and I don't have any kcmshell5.. :O
Comment 12 Bhushan Shah 2014-03-28 05:37:24 UTC
nevermind found it"
Comment 13 Bhushan Shah 2014-03-28 05:39:06 UTC
okay so setting it to "Zero-cornered" worked. now I get widget explorer at correct place. Can you explain me what was wrong with smart option?
Comment 14 Thomas Lübking 2014-03-28 07:32:20 UTC
nothing - the window gets placed and that should not happen.
as placement avoiding in general (still) works (passing ang explicit geometry), this means the client does not request a position -> plasma bug, it's not in kwin by 99.9% chance.
Comment 15 Martin Klapetek 2014-04-01 15:35:40 UTC
I think I have an idea about this, I'm on it.
Comment 16 Martin Klapetek 2014-04-01 15:37:05 UTC
Erm, wrong bug, I meant to post this on bug 332850, sorry.

Note that I looked into this as well, the widget explorer does not set explicit position afaics, maybe it should?
Comment 17 Marco Martin 2014-04-02 17:38:54 UTC
Git commit ada24e2bc7978dd23a1b6bc7b57d68967fea1cc3 by Marco Martin.
Committed on 02/04/2014 at 17:36.
Pushed by mart into branch 'master'.

explicitly move at topLeft of availableRect
Related: bug 332850

M  +4    -1    desktoppackage/contents/views/Desktop.qml

http://commits.kde.org/plasma-desktop/ada24e2bc7978dd23a1b6bc7b57d68967fea1cc3
Comment 18 David Edmundson 2014-04-02 20:23:33 UTC
Now we have the position being set from that QML and from the dialog in updateVisibility -> syncToMainItemSize -> popupPosition

Having two bits of code doing things is a bit messy and will cause problems down the line.
Comment 19 Marco Martin 2014-04-03 09:48:01 UTC
hmm, no, it doesn't have a visualparent, so shouldn't ever do popupPosition()
Comment 20 David Edmundson 2014-04-03 13:41:15 UTC
It definitely used to... probably why this bug resurfaced

Lets close this and reopen if this bug ever comes back.
Comment 21 Bhushan Shah 2014-04-03 15:21:34 UTC
That fixed it but only too some extent...

If I restart plasma-shell and try to reproduce this with steps given I can still reproduce it but only *once*..
Comment 22 Martin Klapetek 2014-05-02 11:27:46 UTC
Still happens in today's build, follow the steps in #1 to reproduce.
Comment 23 Marco Martin 2014-06-03 12:21:42 UTC
periodical ping:
does anybody can still reproduce?
I can't anymore
(followed steps of #1)
Comment 24 Bhushan Shah 2014-06-03 12:25:06 UTC
yes, still valid.
Comment 25 kdeuser56 2014-06-04 18:30:22 UTC
happens here too
Comment 26 David Edmundson 2014-06-24 10:53:28 UTC
Flags on the window have changed This /might/ have fixed it.

Please reopen if you ever see this again.
Comment 27 David Edmundson 2014-06-29 18:08:54 UTC
*** Bug 336747 has been marked as a duplicate of this bug. ***
Comment 28 Vishesh Handa 2014-07-02 13:53:24 UTC
Steps to reproduce -

1. Open System Settings in "Windowed-mode" (not maximized)
2. While System Settings is still open open the widgets explorer. It will be opened to the right of the System Settings.
Comment 29 enoopt.adams 2014-07-07 03:24:24 UTC
Still a problem on my system.
Comment 30 David Edmundson 2014-09-26 14:56:36 UTC
I /hope/ 62d240b7d652539d9fc52dd464c049d4befa8055 in plasma-framework has fixed this.

I haven't seen it since.
Comment 31 Bhushan Shah 2014-09-27 12:59:18 UTC
Sadly not yet solved, if you have window at 0, 0 it will open at wrong place..
Comment 32 enoopt.adams 2014-09-28 02:28:45 UTC
Only fix I have for it is to make a window rule, set plasmashell, dock window type, initial placement top left corner, and force keep above,
Comment 33 Bhushan Shah 2014-12-14 14:55:57 UTC
*** Bug 341881 has been marked as a duplicate of this bug. ***
Comment 34 Bhushan Shah 2015-05-07 12:25:40 UTC
*** Bug 347338 has been marked as a duplicate of this bug. ***
Comment 35 Nikola Schnelle 2015-05-07 12:42:15 UTC
Steps to reproduce in plasma 5.3:
1. Reboot system
2. Open some program/window
3. Open activity switcher or widget explorer 

This happens only on clean boot. After popping up for the first time on wrong place (next to the opened window), next time(s) they pop up on expected place.
Comment 36 David Edmundson 2015-08-18 10:38:31 UTC
Seems kwin is moving it in a method called KWin::Placement::placeSmart 

gdb trace.

#0  KWin::Client::move (this=0xf3b2b0, x=1656, y=0, force=KWin::AbstractClient::NormalGeometrySet)
    at /home/david/projects/kde5/src/kde/workspace/kwin/geometry.cpp:2059
#1  0x00007ffff773a9b8 in KWin::Placement::placeSmart (this=0x7c1b30, c=0xf3b2b0, area=...)
    at /home/david/projects/kde5/src/kde/workspace/kwin/placement.cpp:342
#2  0x00007ffff7739ad4 in KWin::Placement::place (this=0x7c1b30, c=0xf3b2b0, area=..., 
    policy=KWin::Placement::Smart, nextPlacement=KWin::Placement::Unknown)
    at /home/david/projects/kde5/src/kde/workspace/kwin/placement.cpp:102
#3  0x00007ffff77398f1 in KWin::Placement::place (this=0x7c1b30, c=0xf3b2b0, area=...)
    at /home/david/projects/kde5/src/kde/workspace/kwin/placement.cpp:76
#4  0x00007ffff7775cf8 in KWin::Client::manage (this=0xf3b2b0, w=41943053, isMapped=false)
    at /home/david/projects/kde5/src/kde/workspace/kwin/manage.cpp:399
#5  0x00007ffff76e0239 in KWin::Workspace::createClient (this=0x6aaae0, w=41943053, is_mapped=false)


342         c->move(x_optimal, y_optimal);

(gdb) frame 1
(gdb) print c->x()
$11 = 0
(gdb) print x_optimal
$12 = 1656

client position is  0 when kwin starts processing it, then it gets moved elsewhere





interestingly the second time we have:

#0  KWin::Client::move (this=0xf33830, x=0, y=0, force=KWin::AbstractClient::NormalGeometrySet)
    at /home/david/projects/kde5/src/kde/workspace/kwin/geometry.cpp:2059
#1  0x00007ffff7775499 in KWin::Client::manage (this=0xf33830, w=41943053, isMapped=false)
    at /home/david/projects/kde5/src/kde/workspace/kwin/manage.cpp:334
#2  0x00007ffff76e0239 in KWin::Workspace::createClient (this=0x6aaae0, w=41943053, is_mapped=false)
    at /home/david/projects/kde5/src/kde/workspace/kwin/workspace.cpp:485

so it's taking a different path in manage(), one that sends it through the (quetionably named) smart placement.
Comment 37 David Edmundson 2015-08-18 11:24:21 UTC
and the difference is...

m_geometryHints.hasPosition returns false the first time.
Comment 38 David Edmundson 2015-08-21 16:35:48 UTC
Found it! 

Deep deep down in the Qt XCB backend there is a line:

    if (qt_window_private(window())->positionAutomatic) 
        tell kwin the position and size
   else
       tell kwin the size

positionAutomatic starts true and is set to false on any call to setGeometry();
so if you explicitly set geometry to 0,0 it will till the WM we have a position.

However, setX, setY have a check before to see if it's doing a no-op, so this flag never gets unset.
IMHO it's a bug in QWindow there, and I'll write a patch for Qt there.

It only happens once because afterwards kwin moves the window, which ends up calling a setGeometry in QWindow.

However, I think we want an early bodge. Either I set X to -1 before we show it and set it back to 0 in Desktop.qml   or we put a random setGeometry call into dialog.
Comment 39 David Edmundson 2015-08-24 10:01:58 UTC
Git commit 544e98da26ffc6a71f9a0a8f1c38ce505cb930d1 by David Edmundson.
Committed on 24/08/2015 at 10:01.
Pushed by davidedmundson into branch 'Plasma/5.4'.

Fix widget explorer sometimes opening on the wrong side of the screen.

Work around a Qt bug.

If there is no setGeometry call on QWindow the XCB backend will not pass
our requested position to kwin
as our window position tends to be 0, setX,setY no-ops and means we
never set a position as far as QWindow is concerned
by setting it to something silly and setting it back before we show the
window we avoid that bug.

Qt patch also filed (https://codereview.qt-project.org/123989)
so hopefully this can be removed in future if that gets merged.
REVIEW: 124869

M  +7    -0    desktoppackage/contents/views/Desktop.qml

http://commits.kde.org/plasma-desktop/544e98da26ffc6a71f9a0a8f1c38ce505cb930d1