Kwin raises the following sound events via KNotifyClient:

"Window Close"
	 "Window Iconify"
                  "Window DeIconify"
                  "Window Maximize"
                  "Window UnMaximize"
                  "Window Sticky"
                  "Window UnSticky"
                  "Window New"
                  "Window Delete"
                  "Window Trans New"
                  "Window Trans Delete"
                  "Window Shade Up"
                  "Window Shade Down"
                  "Window Move Start"
                  "Window Move End"
                  "Window Resize Start"
                  "Window Resize End"

svn path=/trunk/kdebase/kwin/; revision=48752
This commit is contained in:
Matthias Ettrich 2000-05-07 20:38:11 +00:00
parent 2c5bfad0cf
commit 6a36c54a7f
7 changed files with 200 additions and 52 deletions

View file

@ -6,7 +6,7 @@ SUBDIRS = pics clients
bin_PROGRAMS = kwin
lib_LTLIBRARIES = kwin.la
kwin_la_SOURCES = atoms.cpp client.cpp main.cpp stdclient.cpp workspace.cpp tabbox.cpp options.cpp plugins.cpp KWinInterface.skel
kwin_la_SOURCES = atoms.cpp client.cpp main.cpp stdclient.cpp workspace.cpp tabbox.cpp options.cpp plugins.cpp events.cpp KWinInterface.skel
kwin_la_LIBADD = $(LIB_KDEUI)
kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version

25
README
View file

@ -21,7 +21,7 @@ TitlebarDoubleClickCommand=Move|Resize|
CommandActiveTitlebar1 |
CommandActiveTitlebar2 |
CommandActiveTitlebar3 |
CommandActiveTitlebar3 |
CommandInactiveTitlebar1 |
CommandInactiveTitlebar2 |
CommandInactiveTitlebar3 |
@ -30,7 +30,7 @@ TitlebarDoubleClickCommand=Move|Resize|
CommandWindow3 |
CommandAll1 |
CommandAll2 |
CommandAll3
CommandAll3
=
Raise |
Lower |
@ -43,10 +43,29 @@ TitlebarDoubleClickCommand=Move|Resize|
Activate and pass click |
Move |
Resize |
Nothing
Nothing
Kwin raises the following sound events via KNotifyClient:
"Window Close"
"Window Iconify"
"Window DeIconify"
"Window Maximize"
"Window UnMaximize"
"Window Sticky"
"Window UnSticky"
"Window New"
"Window Delete"
"Window Trans New"
"Window Trans Delete"
"Window Shade Up"
"Window Shade Down"
"Window Move Start"
"Window Move End"
"Window Resize Start"
"Window Resize End"
Have fun,

View file

@ -16,6 +16,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <qwhatsthis.h>
#include "workspace.h"
#include "client.h"
#include "events.h"
#include "atoms.h"
#include <X11/X.h>
#include <X11/Xos.h>
@ -164,10 +165,10 @@ static void ungrabButton( WId winId, int modifier )
XUngrabButton( qt_xdisplay(), AnyButton, modifier | LockMask, winId );
}
/*!
/*!
Called by the client to notify the window wrapper when activation
state changes.
Releases the passive grab for some modifier combinations when a
window becomes active. This helps broken X programs that
missinterpret LeaveNotify events in grab mode to work properly
@ -457,8 +458,9 @@ void Client::manage( bool isMapped )
setMappingState( state );
if ( state == NormalState && isOnDesktop( workspace()->currentDesktop() ) ) {
Events::raise( isTransient() ? Events::TransNew : Events::New );
show();
if ( options->focusPolicyIsReasonable() )
if ( options->focusPolicyIsReasonable() && wantsTabFocus() )
workspace()->requestFocus( this );
}
@ -663,6 +665,7 @@ bool Client::unmapNotify( XUnmapEvent& e )
*/
void Client::withdraw()
{
Events::raise( isTransient() ? Events::TransDelete : Events::Delete );
setMappingState( WithdrawnState );
KWM::moveToDesktop( win, -1 ); // compatibility
releaseWindow();
@ -910,6 +913,7 @@ void Client::mouseReleaseEvent( QMouseEvent * e)
|| ( isResize() && options->resizeMode != Options::Opaque ) )
XUngrabServer( qt_xdisplay() );
setGeometry( geom );
Events::raise( isResize() ? Events::ResizeEnd : Events::MoveEnd );
moveResizeMode = FALSE;
releaseMouse();
releaseKeyboard();
@ -944,6 +948,7 @@ void Client::mouseMoveEvent( QMouseEvent * e)
QPoint p( e->pos() - moveOffset );
if ( (QABS( p.x()) >= 4) || (QABS( p.y() ) >= 4 )) {
moveResizeMode = TRUE;
Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart );
grabMouse( cursor() ); // to keep the right cursor
if ( ( isMove() && options->moveMode != Options::Opaque )
|| ( isResize() && options->resizeMode != Options::Opaque ) )
@ -1190,10 +1195,12 @@ void Client::iconify()
if ( isShade() )
setShade( FALSE );
if ( workspace()->iconifyMeansWithdraw( this ) ) {
Events::raise( isTransient() ? Events::TransDelete : Events::Delete );
setMappingState( WithdrawnState );
hide();
return;
}
Events::raise( Events::Iconify );
setMappingState( IconicState );
hide();
// TODO animation (virtual function)
@ -1202,67 +1209,65 @@ void Client::iconify()
void Client::closeWindow()
{
if ( Pdeletewindow ){
sendClientMessage( win, atoms->wm_protocols, atoms->wm_delete_window);
}
else {
// client will not react on wm_delete_window. We have not choice
// but destroy his connection to the XServer.
XKillClient(qt_xdisplay(), win );
workspace()->destroyClient( this );
}
Events::raise( Events::Close );
if ( Pdeletewindow ){
sendClientMessage( win, atoms->wm_protocols, atoms->wm_delete_window);
}
else {
// client will not react on wm_delete_window. We have not choice
// but destroy his connection to the XServer.
XKillClient(qt_xdisplay(), win );
workspace()->destroyClient( this );
}
}
void Client::maximize( MaximizeMode m)
{
QRect clientArea = workspace()->clientArea();
QRect clientArea = workspace()->clientArea();
// qDebug("Client::maximise() - area: l: %d r: %d t: %d b: %d",
// clientArea.left(), clientArea.right(),
// clientArea.top(), clientArea.bottom());
if (isShade())
setShade( FALSE );
if (isShade())
setShade(false);
if (geom_restore.isNull()) {
if (geom_restore.isNull()) {
Events::raise( Events::Maximize );
geom_restore = geometry();
geom_restore = geometry();
switch (m) {
switch (m) {
case MaximizeVertical:
setGeometry(
QRect(QPoint(x(), clientArea.top()),
adjustedSize(QSize(width(), clientArea.height())))
);
break;
case MaximizeVertical:
case MaximizeHorizontal:
setGeometry(
QRect(QPoint(x(), clientArea.top()),
adjustedSize(QSize(width(), clientArea.height())))
);
break;
setGeometry(
QRect(
QPoint(clientArea.left(), y()),
adjustedSize(QSize(clientArea.width(), height())))
);
break;
case MaximizeHorizontal:
default:
setGeometry(
QRect(
QPoint(clientArea.left(), y()),
adjustedSize(QSize(clientArea.width(), height())))
);
break;
setGeometry(
QRect(clientArea.topLeft(), adjustedSize(clientArea.size()))
);
}
default:
maximizeChange(true);
setGeometry(
QRect(clientArea.topLeft(), adjustedSize(clientArea.size()))
);
} else {
Events::raise( Events::UnMaximize );
setGeometry(geom_restore);
QRect invalid;
geom_restore = invalid;
maximizeChange(false);
}
maximizeChange(true);
} else {
setGeometry(geom_restore);
QRect invalid;
geom_restore = invalid;
maximizeChange(false);
}
}
@ -1537,6 +1542,10 @@ void Client::setSticky( bool b )
if ( is_sticky == b )
return;
is_sticky = b;
if ( is_sticky )
Events::raise( Events::Sticky );
else
Events::raise( Events::UnSticky );
if ( !is_sticky )
setDesktop( workspace()->currentDesktop() );
workspace()->setStickyTransientsOf( this, b );

View file

@ -1,3 +1,8 @@
/*****************************************************************
kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#ifndef CLIENT_H
#define CLIENT_H

75
events.cpp Normal file
View file

@ -0,0 +1,75 @@
/*****************************************************************
kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#include "events.h"
#include <knotifyclient.h>
void Events::raise( Event e )
{
static bool forgetIt = FALSE;
if ( forgetIt )
return; // no connection was possible, don't try each time
QString event;
switch ( e ) {
case Close:
event = "Window Close";
break;
case Iconify:
event = "Window Iconify";
break;
case DeIconify:
event = "Window DeIconify";
break;
case Maximize:
event = "Window Maximize";
break;
case UnMaximize:
event = "Window UnMaximize";
break;
case Sticky:
event = "Window Sticky";
break;
case UnSticky:
event = "Window UnSticky";
break;
case New:
event = "Window New";
break;
case Delete:
event = "Window Delete";
break;
case TransNew:
event = "Window TransNew";
break;
case TransDelete:
event = "Window TransDelete";
break;
case ShadeUp:
event = "Window ShadeUp";
break;
case ShadeDown:
event = "Window ShadeDown";
break;
case MoveStart:
event = "Window Move Start";
break;
case MoveEnd:
event = "Window Move End";
break;
case ResizeStart:
event = "Window Resize Start";
break;
case ResizeEnd:
event = "Window Resize End";
break;
}
if ( !event )
return;
if ( !KNotifyClient::event( event ) )
forgetIt = TRUE;
}

37
events.h Normal file
View file

@ -0,0 +1,37 @@
/*****************************************************************
kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#ifndef EVENTS_H
#define EVENTS_H
class Events
{
public:
enum Event {
Close,
Iconify,
DeIconify,
Maximize,
UnMaximize,
Sticky,
UnSticky,
New,
Delete,
TransNew,
TransDelete,
ShadeUp,
ShadeDown,
MoveStart,
MoveEnd,
ResizeStart,
ResizeEnd
};
static void raise( Event );
};
#endif

View file

@ -19,6 +19,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include "tabbox.h"
#include "atoms.h"
#include "plugins.h"
#include "events.h"
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
@ -862,6 +863,8 @@ void Workspace::activateClient( Client* c)
setCurrentDesktop( c->desktop() );
}
raiseClient( c );
if ( c->isIconified() )
Events::raise( Events::DeIconify );
c->show();
iconifyOrDeiconifyTransientsOf( c );
if ( options->focusPolicyIsReasonable() )