diff --git a/composite.cpp b/composite.cpp index 223afc7544..63b0735277 100644 --- a/composite.cpp +++ b/composite.cpp @@ -51,6 +51,7 @@ along with this program. If not, see . #include #include #include +#include #include #include diff --git a/main.cpp b/main.cpp index ed051f8272..6786145023 100644 --- a/main.cpp +++ b/main.cpp @@ -67,6 +67,7 @@ along with this program. If not, see . #include "sm.h" #include "utils.h" #include "effects.h" +#include "workspace.h" #include "xcbutils.h" #define INT8 _X11INT8 @@ -94,6 +95,58 @@ bool initting = false; */ static bool kwin_sync = false; +//************************************ +// KWinSelectionOwner +//************************************ + +KWinSelectionOwner::KWinSelectionOwner(int screen_P) + : KSelectionOwner(make_selection_atom(screen_P), screen_P) +{ +} + +Atom KWinSelectionOwner::make_selection_atom(int screen_P) +{ + if (screen_P < 0) + screen_P = DefaultScreen(display()); + char tmp[ 30 ]; + sprintf(tmp, "WM_S%d", screen_P); + return XInternAtom(display(), tmp, False); +} + +void KWinSelectionOwner::getAtoms() +{ + KSelectionOwner::getAtoms(); + if (xa_version == None) { + Atom atoms[ 1 ]; + const char* const names[] = + { "VERSION" }; + XInternAtoms(display(), const_cast< char** >(names), 1, False, atoms); + xa_version = atoms[ 0 ]; + } +} + +void KWinSelectionOwner::replyTargets(Atom property_P, Window requestor_P) +{ + KSelectionOwner::replyTargets(property_P, requestor_P); + Atom atoms[ 1 ] = { xa_version }; + // PropModeAppend ! + XChangeProperty(display(), requestor_P, property_P, XA_ATOM, 32, PropModeAppend, + reinterpret_cast< unsigned char* >(atoms), 1); +} + +bool KWinSelectionOwner::genericReply(Atom target_P, Atom property_P, Window requestor_P) +{ + if (target_P == xa_version) { + long version[] = { 2, 0 }; + XChangeProperty(display(), requestor_P, property_P, XA_INTEGER, 32, + PropModeReplace, reinterpret_cast< unsigned char* >(&version), 2); + } else + return KSelectionOwner::genericReply(target_P, property_P, requestor_P); + return true; +} + +Atom KWinSelectionOwner::xa_version = None; + // errorMessage is only used ifndef NDEBUG, and only in one place. // it might be worth reevaluating why this is used? I don't know. #ifndef NDEBUG diff --git a/main.h b/main.h index 97b8cdd08f..c865deafbd 100644 --- a/main.h +++ b/main.h @@ -23,12 +23,26 @@ along with this program. If not, see . #define MAIN_H #include -#include "workspace.h" -#include "utils.h" +#include namespace KWin { +class KWinSelectionOwner + : public KSelectionOwner +{ + Q_OBJECT +public: + explicit KWinSelectionOwner(int screen); +protected: + virtual bool genericReply(Atom target, Atom property, Window requestor); + virtual void replyTargets(Atom property, Window requestor); + virtual void getAtoms(); +private: + Atom make_selection_atom(int screen); + static Atom xa_version; +}; + class Application : public KApplication { Q_OBJECT diff --git a/utils.cpp b/utils.cpp index 9c7f31db04..e9ee51f5bf 100644 --- a/utils.cpp +++ b/utils.cpp @@ -118,59 +118,6 @@ void Motif::readFlags(WId w, bool& got_noborder, bool& noborder, } } -//************************************ -// KWinSelectionOwner -//************************************ - -KWinSelectionOwner::KWinSelectionOwner(int screen_P) - : KSelectionOwner(make_selection_atom(screen_P), screen_P) -{ -} - -Atom KWinSelectionOwner::make_selection_atom(int screen_P) -{ - if (screen_P < 0) - screen_P = DefaultScreen(display()); - char tmp[ 30 ]; - sprintf(tmp, "WM_S%d", screen_P); - return XInternAtom(display(), tmp, False); -} - -void KWinSelectionOwner::getAtoms() -{ - KSelectionOwner::getAtoms(); - if (xa_version == None) { - Atom atoms[ 1 ]; - const char* const names[] = - { "VERSION" }; - XInternAtoms(display(), const_cast< char** >(names), 1, False, atoms); - xa_version = atoms[ 0 ]; - } -} - -void KWinSelectionOwner::replyTargets(Atom property_P, Window requestor_P) -{ - KSelectionOwner::replyTargets(property_P, requestor_P); - Atom atoms[ 1 ] = { xa_version }; - // PropModeAppend ! - XChangeProperty(display(), requestor_P, property_P, XA_ATOM, 32, PropModeAppend, - reinterpret_cast< unsigned char* >(atoms), 1); -} - -bool KWinSelectionOwner::genericReply(Atom target_P, Atom property_P, Window requestor_P) -{ - if (target_P == xa_version) { - long version[] = { 2, 0 }; - XChangeProperty(display(), requestor_P, property_P, XA_INTEGER, 32, - PropModeReplace, reinterpret_cast< unsigned char* >(&version), 2); - } else - return KSelectionOwner::genericReply(target_P, property_P, requestor_P); - return true; -} - -Atom KWinSelectionOwner::xa_version = None; - - #endif QByteArray getStringProperty(WId w, Atom prop, char separator) diff --git a/utils.h b/utils.h index da0da279d3..1ec8fa5e00 100644 --- a/utils.h +++ b/utils.h @@ -30,8 +30,8 @@ along with this program. If not, see . #include // KDE #include -#include // Qt +#include #include #include #include @@ -193,21 +193,6 @@ public: }; }; -class KWinSelectionOwner - : public KSelectionOwner -{ - Q_OBJECT -public: - explicit KWinSelectionOwner(int screen); -protected: - virtual bool genericReply(Atom target, Atom property, Window requestor); - virtual void replyTargets(Atom property, Window requestor); - virtual void getAtoms(); -private: - Atom make_selection_atom(int screen); - static Atom xa_version; -}; - // Class which saves original value of the variable, assigns the new value // to it, and in the destructor restores the value. // Used in Client::isMaximizable() and so on.