Skip to content

Commit

Permalink
Have lumina-screenshot use the current window stacking order for dete…
Browse files Browse the repository at this point in the history
…rmining which window is under the mouse click (in the case of layered windows at the click point).
  • Loading branch information
beanpole135 committed May 6, 2016
1 parent 10ed6f0 commit 87e3920
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ void MainUI::mouseReleaseEvent(QMouseEvent *ev){
//In the middle of selecting a window to take a screenshot
// Get the window underneath the mouse click and take the screenshot
QList<WId> wins = XCB->WindowList();
QList<WId> stack = XCB->WM_Get_Client_List(true);
cwin = 0;
//qDebug() << "Try to select window:" << ev->globalPos();
for(int i=0; i<wins.length() && cwin==0; i++){
if( XCB->WindowGeometry(wins[i], true).contains(ev->globalPos()) ){ cwin = wins[i]; }
//for(int i=0; i<stack.length(); i++){
for(int i=stack.length()-1; i>=0 && cwin==0; i--){ //work top->bottom in the stacking order
if(!wins.contains(stack[i])){ continue; }
if( XCB->WindowGeometry(stack[i], true).contains(ev->globalPos()) && XCB->WindowState(stack[i])!=LXCB::INVISIBLE ){
qDebug() << "Found Window:" << i << XCB->WindowClass(stack[i]);
cwin = stack[i];
}
}
qDebug() << " - Got window:" << cwin;
if(cwin==this->winId()){ return; } //cancelled
Expand Down

0 comments on commit 87e3920

Please sign in to comment.