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

19
README
View file

@ -47,6 +47,25 @@ TitlebarDoubleClickCommand=Move|Resize|
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>
@ -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,6 +1209,7 @@ void Client::iconify()
void Client::closeWindow()
{
Events::raise( Events::Close );
if ( Pdeletewindow ){
sendClientMessage( win, atoms->wm_protocols, atoms->wm_delete_window);
}
@ -1217,21 +1225,18 @@ void Client::maximize( MaximizeMode m)
{
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);
setShade( FALSE );
if (geom_restore.isNull()) {
Events::raise( Events::Maximize );
geom_restore = geometry();
switch (m) {
case MaximizeVertical:
setGeometry(
QRect(QPoint(x(), clientArea.top()),
adjustedSize(QSize(width(), clientArea.height())))
@ -1257,7 +1262,7 @@ void Client::maximize( MaximizeMode m)
maximizeChange(true);
} else {
Events::raise( Events::UnMaximize );
setGeometry(geom_restore);
QRect invalid;
geom_restore = invalid;
@ -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() )