From 626d2700c1d06873f203def546ba90dfe6be0bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 19 Sep 2006 12:20:19 +0000 Subject: [PATCH] Merge compile fixes from trunk to work with current SVN. svn path=/branches/work/kwin_composite/; revision=586383 --- kcmkwin/kwindecoration/kwindecoration.cpp | 4 + main.cpp | 9 ++- workspace.cpp | 52 +++++++++++-- workspace.h | 90 +++++++++++------------ 4 files changed, 102 insertions(+), 53 deletions(-) diff --git a/kcmkwin/kwindecoration/kwindecoration.cpp b/kcmkwin/kwindecoration/kwindecoration.cpp index 96652480ff..c333764623 100644 --- a/kcmkwin/kwindecoration/kwindecoration.cpp +++ b/kcmkwin/kwindecoration/kwindecoration.cpp @@ -62,6 +62,8 @@ #include #include #include +#include "kwindecorationadaptor.h" +#include // KCModule plugin interface // ========================= @@ -73,6 +75,8 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QStringList &) kwinConfig("kwinrc"), pluginObject(0) { + new DecorationAdaptor(this); + QDBusConnection::sessionBus().registerObject("/KWinClientDecoration", this); kwinConfig.setGroup("Style"); plugins = new KDecorationPreviewPlugins( &kwinConfig ); diff --git a/main.cpp b/main.cpp index 0466a23bb1..d4a1046c69 100644 --- a/main.cpp +++ b/main.cpp @@ -30,6 +30,7 @@ License. See the file "COPYING" for the exact licensing terms. #include "options.h" #include "sm.h" #include "utils.h" +#include "effects.h" #define INT8 _X11INT8 #define INT32 _X11INT32 @@ -117,6 +118,8 @@ Application::Application( ) options = new Options; atoms = new Atoms; + + initting = false; // TODO // create workspace. (void) new Workspace( isSessionRestored() ); @@ -143,6 +146,8 @@ Application::~Application() if( owner.ownerWindow() != None ) // if there was no --replace (no new WM) XSetInputFocus( display(), PointerRoot, RevertToPointerRoot, xTime() ); delete options; + delete effects; + delete atoms; } void Application::lostSelection() @@ -277,9 +282,9 @@ KDE_EXPORT int kdemain( int argc, char * argv[] ) QString appname; if (KWinInternal::screen_number == 0) - appname = "org.kde.kwin"; + appname = "kwin"; else - appname.sprintf("org.kde.kwin-screen-%d", KWinInternal::screen_number); + appname.sprintf("kwin-screen-%d", KWinInternal::screen_number); QDBusConnection::sessionBus().interface()->registerService( appname, QDBusConnectionInterface::DontQueueService ); diff --git a/workspace.cpp b/workspace.cpp index 5b8ccd25ca..d89650f3a4 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -42,6 +42,7 @@ License. See the file "COPYING" for the exact licensing terms. #include "group.h" #include "rules.h" #include "kwinadaptor.h" +#include "unmanaged.h" #include #include @@ -122,7 +123,8 @@ Workspace::Workspace( bool restore ) topmenu_space( NULL ), set_active_client_recursion( 0 ), block_stacking_updates( 0 ), - forced_global_mouse_grab( false ) + forced_global_mouse_grab( false ), + damage_region( None ) { new KWinAdaptor( "org.kde.kwin", "/KWin", QDBusConnection::sessionBus(), this ); @@ -166,10 +168,12 @@ Workspace::Workspace( bool restore ) ColormapChangeMask | SubstructureRedirectMask | SubstructureNotifyMask | - FocusChangeMask // for NotifyDetailNone + FocusChangeMask | // for NotifyDetailNone + ExposureMask ); - Shape::init(); + Extensions::init(); + setupCompositing(); // compatibility long data = 1; @@ -318,6 +322,7 @@ void Workspace::init() connect(&reconfigureTimer, SIGNAL(timeout()), this, SLOT(slotReconfigure())); connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows())); + connect( &compositeTimer, SIGNAL( timeout()), SLOT( compositeTimeout())); connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), this, SLOT(slotReconfigure())); @@ -355,7 +360,11 @@ void Workspace::init() XWindowAttributes attr; XGetWindowAttributes(display(), wins[i], &attr); if (attr.override_redirect ) + { + if( attr.map_state != IsUnmapped && attr.c_class != InputOnly && compositing()) + createUnmanaged( wins[ i ] ); continue; + } if( topmenu_space && topmenu_space->winId() == wins[ i ] ) continue; if (attr.map_state != IsUnmapped) @@ -418,6 +427,7 @@ void Workspace::init() Workspace::~Workspace() { + finishCompositing(); blockStackingUpdates( true ); // TODO grabXServer(); // use stacking_order, so that kwin --replace keeps stacking order @@ -429,6 +439,10 @@ Workspace::~Workspace() (*it)->releaseWindow( true ); // no removeClient() is called ! } + for( UnmanagedList::ConstIterator it = unmanaged.begin(); + it != unmanaged.end(); + ++it ) + (*it)->release(); delete desktop_widget; delete tab_box; delete popupinfo; @@ -475,6 +489,18 @@ Client* Workspace::createClient( Window w, bool is_mapped ) return c; } +Unmanaged* Workspace::createUnmanaged( Window w ) + { + Unmanaged* c = new Unmanaged( this ); + if( !c->track( w )) + { + Unmanaged::deleteUnmanaged( c, Allowed ); + return NULL; + } + addUnmanaged( c, Allowed ); + return c; + } + void Workspace::addClient( Client* c, allowed_t ) { Group* grp = findGroup( c->window()); @@ -514,6 +540,11 @@ void Workspace::addClient( Client* c, allowed_t ) updateToolWindows( true ); } +void Workspace::addUnmanaged( Unmanaged* c, allowed_t ) + { + unmanaged.append( c ); + } + /* Destroys the client \a c */ @@ -568,6 +599,12 @@ void Workspace::removeClient( Client* c, allowed_t ) updateClientArea(); } +void Workspace::removeUnmanaged( Unmanaged* c, allowed_t ) + { + assert( unmanaged.contains( c )); + unmanaged.removeAll( c ); + } + void Workspace::updateFocusChains( Client* c, FocusChainChange change ) { if( !c->wantsTabFocus()) // doesn't want tab focus, remove @@ -864,7 +901,7 @@ void Workspace::slotSettingsChanged(int category) /*! Reread settings */ -KWIN_PROCEDURE( CheckBorderSizesProcedure, cl->checkBorderSizes() ); +KWIN_PROCEDURE( CheckBorderSizesProcedure, Client, cl->checkBorderSizes() ); void Workspace::slotReconfigure() { @@ -921,6 +958,11 @@ void Workspace::slotReconfigure() updateTopMenuGeometry(); updateCurrentTopMenu(); } + + if( options->useTranslucency ) + setupCompositing(); + else + finishCompositing(); loadWindowRules(); for( ClientList::Iterator it = clients.begin(); @@ -1622,7 +1664,7 @@ void Workspace::slotGrabWindow() QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() ); //No XShape - no work. - if( Shape::available()) + if( Extensions::shapeAvailable()) { //As the first step, get the mask from XShape. int count, order; diff --git a/workspace.h b/workspace.h index 91ba1dbbaf..bc6e72b1a2 100644 --- a/workspace.h +++ b/workspace.h @@ -77,7 +77,7 @@ class Workspace : public QObject, public KDecorationDefines virtual ~Workspace(); static Workspace * self() { return _self; } - + bool workspaceEvent( XEvent * ); KDecoration* createDecoration( KDecorationBridge* bridge ); @@ -87,6 +87,9 @@ class Workspace : public QObject, public KDecorationDefines template< typename T > Client* findClient( T predicate ); template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate ); template< typename T > void forEachClient( T procedure ); + template< typename T > Unmanaged* findUnmanaged( T predicate ); + template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate ); + template< typename T > void forEachUnmanaged( T procedure ); QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const; QRect clientArea( clientAreaOption, const Client* c ) const; @@ -242,6 +245,9 @@ class Workspace : public QObject, public KDecorationDefines void removeGroup( Group* group, allowed_t ); Group* findClientLeaderGroup( const Client* c ) const; + // only called from Unmanaged::release() + void removeUnmanaged( Unmanaged*, allowed_t ); + bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data ); void focusToNull(); // SELI public? @@ -276,6 +282,13 @@ class Workspace : public QObject, public KDecorationDefines void requestDelayFocus( Client* ); void toggleTopDockShadows(bool on); + + void addDamage( const QRect& r ); + void addDamage( int x, int y, int w, int h ); + void addDamage( XserverRegion r, bool destroy ); + void addDamage( Toplevel* c, const QRect& r ); + void addDamage( Toplevel* c, int x, int y, int w, int h ); + void addDamage( Toplevel* c, XserverRegion r, bool destroy ); public slots: void refresh(); @@ -288,48 +301,8 @@ class Workspace : public QObject, public KDecorationDefines void slotSwitchDesktopDown(); void slotSwitchToDesktop( int ); - void slotSwitchToDesktop1() { return slotSwitchToDesktop( 1 ); } - void slotSwitchToDesktop2() { return slotSwitchToDesktop( 2 ); } - void slotSwitchToDesktop3() { return slotSwitchToDesktop( 3 ); } - void slotSwitchToDesktop4() { return slotSwitchToDesktop( 4 ); } - void slotSwitchToDesktop5() { return slotSwitchToDesktop( 5 ); } - void slotSwitchToDesktop6() { return slotSwitchToDesktop( 6 ); } - void slotSwitchToDesktop7() { return slotSwitchToDesktop( 7 ); } - void slotSwitchToDesktop8() { return slotSwitchToDesktop( 8 ); } - void slotSwitchToDesktop9() { return slotSwitchToDesktop( 9 ); } - void slotSwitchToDesktop10() { return slotSwitchToDesktop( 10 ); } - void slotSwitchToDesktop11() { return slotSwitchToDesktop( 11 ); } - void slotSwitchToDesktop12() { return slotSwitchToDesktop( 12 ); } - void slotSwitchToDesktop13() { return slotSwitchToDesktop( 13 ); } - void slotSwitchToDesktop14() { return slotSwitchToDesktop( 14 ); } - void slotSwitchToDesktop15() { return slotSwitchToDesktop( 15 ); } - void slotSwitchToDesktop16() { return slotSwitchToDesktop( 16 ); } - void slotSwitchToDesktop17() { return slotSwitchToDesktop( 17 ); } - void slotSwitchToDesktop18() { return slotSwitchToDesktop( 18 ); } - void slotSwitchToDesktop19() { return slotSwitchToDesktop( 19 ); } - void slotSwitchToDesktop20() { return slotSwitchToDesktop( 20 ); } //void slotSwitchToWindow( int ); void slotWindowToDesktop( int ); - void slotWindowToDesktop1() { return slotWindowToDesktop( 1 ); } - void slotWindowToDesktop2() { return slotWindowToDesktop( 2 ); } - void slotWindowToDesktop3() { return slotWindowToDesktop( 3 ); } - void slotWindowToDesktop4() { return slotWindowToDesktop( 4 ); } - void slotWindowToDesktop5() { return slotWindowToDesktop( 5 ); } - void slotWindowToDesktop6() { return slotWindowToDesktop( 6 ); } - void slotWindowToDesktop7() { return slotWindowToDesktop( 7 ); } - void slotWindowToDesktop8() { return slotWindowToDesktop( 8 ); } - void slotWindowToDesktop9() { return slotWindowToDesktop( 9 ); } - void slotWindowToDesktop10() { return slotWindowToDesktop( 10 ); } - void slotWindowToDesktop11() { return slotWindowToDesktop( 11 ); } - void slotWindowToDesktop12() { return slotWindowToDesktop( 12 ); } - void slotWindowToDesktop13() { return slotWindowToDesktop( 13 ); } - void slotWindowToDesktop14() { return slotWindowToDesktop( 14 ); } - void slotWindowToDesktop15() { return slotWindowToDesktop( 15 ); } - void slotWindowToDesktop16() { return slotWindowToDesktop( 16 ); } - void slotWindowToDesktop17() { return slotWindowToDesktop( 17 ); } - void slotWindowToDesktop18() { return slotWindowToDesktop( 18 ); } - void slotWindowToDesktop19() { return slotWindowToDesktop( 19 ); } - void slotWindowToDesktop20() { return slotWindowToDesktop( 20 ); } //void slotWindowToListPosition( int ); void slotWindowMaximize(); @@ -406,11 +379,10 @@ class Workspace : public QObject, public KDecorationDefines void cleanupTemporaryRules(); void writeWindowRules(); void slotBlockShortcuts(int data); - // kompmgr void setPopupClientOpacity(int v); void resetClientOpacity(); void setTransButtonText(int value); - // end + void compositeTimeout(); protected: bool keyPressMouseEmulation( XKeyEvent& ev ); @@ -458,6 +430,8 @@ class Workspace : public QObject, public KDecorationDefines // this is the right way to create a new client Client* createClient( Window w, bool is_mapped ); void addClient( Client* c, allowed_t ); + Unmanaged* createUnmanaged( Window w ); + void addUnmanaged( Unmanaged* c, allowed_t ); Window findSpecialEventWindow( XEvent* e ); @@ -499,6 +473,9 @@ class Workspace : public QObject, public KDecorationDefines void closeActivePopup(); void updateClientArea( bool force ); + + void setupCompositing(); + void finishCompositing(); SystemTrayWindowList systemTrayWins; @@ -535,6 +512,7 @@ class Workspace : public QObject, public KDecorationDefines ClientList clients; ClientList desktops; + UnmanagedList unmanaged; ClientList unconstrained_stacking_order; ClientList stacking_order; @@ -654,8 +632,8 @@ class Workspace : public QObject, public KDecorationDefines Window null_focus_window; bool forced_global_mouse_grab; friend class StackingUpdatesBlocker; - - //kompmgr + QTimer compositeTimer; + XserverRegion damage_region; QSlider *transSlider; QPushButton *transButton; }; @@ -827,7 +805,27 @@ inline void Workspace::forEachClient( T procedure ) return forEachClient( procedure, TruePredicate()); } -KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value ); +template< typename T > +inline Unmanaged* Workspace::findUnmanaged( T predicate ) + { + return findUnmanagedInList( unmanaged, predicate ); + } + +template< typename T1, typename T2 > +inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate ) + { + for ( UnmanagedList::ConstIterator it = unmanaged.begin(); it != unmanaged.end(); ++it) + if ( predicate( const_cast< const Unmanaged* >( *it))) + procedure( *it ); + } + +template< typename T > +inline void Workspace::forEachUnmanaged( T procedure ) + { + return forEachUnmanaged( procedure, TruePredicate()); + } + +KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value ); inline bool Workspace::hasClient( const Client* c ) { return findClient( ClientMatchPredicate( c ));