Fix #44133. Approved by Gallium.

svn path=/trunk/kdebase/kwin/; revision=184025
This commit is contained in:
Luboš Luňák 2002-10-15 13:41:37 +00:00
parent 097802e89d
commit 35c890d029
3 changed files with 54 additions and 19 deletions

View file

@ -73,12 +73,19 @@ void KillWindow::start() {
escape_pressed = TRUE;
break;
}
workspace->killWindowAtPosition(ev.xbutton.x_root, ev.xbutton.y_root);
workspace->killWindowId(ev.xbutton.subwindow);
}
continue;
}
if (return_pressed)
workspace->killWindowAtPosition(QCursor::pos().x(), QCursor::pos().y());
if (return_pressed) {
Window root, child;
int dummy1, dummy2, dummy3, dummy4;
unsigned int dummy5;
if( XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
&dummy1, &dummy2, &dummy3, &dummy4, &dummy5 ) == true
&& child != None )
workspace->killWindowId( child );
}
XUngrabServer(qt_xdisplay());

View file

@ -673,7 +673,7 @@ bool Workspace::workspaceEvent( XEvent * e )
case LeaveNotify:
if ( !QWhatsThis::inWhatsThisMode() )
break;
c = findClientWidthId( e->xcrossing.window );
c = findClientWithId( e->xcrossing.window );
if ( c && e->xcrossing.detail != NotifyInferior )
QWhatsThis::leaveWhatsThisMode();
break;
@ -750,12 +750,16 @@ Client* Workspace::findClient( WId w ) const
/*!
Finds the client with window id \a w
*/
Client* Workspace::findClientWidthId( WId w ) const
Client* Workspace::findClientWithId( WId w ) const
{
for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) {
if ( (*it)->winId() == w )
return *it;
}
for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it) {
if ( (*it)->winId() == w )
return *it;
}
return 0;
}
@ -2875,21 +2879,37 @@ void Workspace::slotKillWindow()
/*!
Kills the window at position \a x, \a y
*/
void Workspace::killWindowAtPosition(int x, int y)
void Workspace::killWindowAtPosition(int, int)
{
ClientList::ConstIterator it(stacking_order.fromLast());
for ( ; it != stacking_order.end(); --it) {
Client *client = (*it);
if ( client->frameGeometry().contains(QPoint(x, y)) &&
client->isOnDesktop( currentDesktop() ) &&
!client->isTopMenu() && !client->isDesktop() &&
!client->isIconified() ) {
client->killWindow();
return;
}
}
kdWarning() << "Obsolete Workspace::killWindowAtPosition() called" << endl;
}
void Workspace::killWindowId( Window window_to_kill )
{
Window window = window_to_kill;
Client* client = NULL;
for(;;) {
client = findClientWithId( window );
if( client != NULL ) // found the client
break;
Window parent, root;
Window* children;
unsigned int children_count;
XQueryTree( qt_xdisplay(), window, &root, &parent, &children, &children_count );
if( children != NULL )
XFree( children );
if( window == root ) // we didn't find the client, probably an override-redirect window
break;
window = parent; // go up
}
if( client != NULL )
client->killWindow();
else
XKillClient( qt_xdisplay(), window_to_kill );
}
/*!
Takes a screenshot of the current window and puts it in the clipboard.
*/
@ -3230,7 +3250,7 @@ WId Workspace::getMouseEmulationWindow()
do {
w = child;
if (!c)
c = findClientWidthId( w );
c = findClientWithId( w );
XQueryPointer( qt_xdisplay(), w, &root, &child,
&root_x, &root_y, &lx, &ly, &state );
} while ( child != None && child != w );

View file

@ -143,7 +143,15 @@ public:
bool destroyClient( Client* );
/**
* @internal
* @obsolete
*/
void killWindowAtPosition(int x, int y);
/**
* @internal
*/
void killWindowId( Window window);
void killWindow() { slotKillWindow(); }
@ -359,7 +367,7 @@ private:
void focusToNull();
Client* findClientWidthId( WId w ) const;
Client* findClientWithId( WId w ) const;
void propagateClients( bool onlyStacking = FALSE);