Move KWinSelectionOwner to main.(h|cpp)

KWinSelectionOwner is only used in KWin::Application which means that
utils is the wrong place for it.

REVIEW: 110245
This commit is contained in:
Martin Gräßlin 2013-04-30 09:15:29 +02:00
parent b6681ddc3a
commit 1276eb044f
5 changed files with 71 additions and 71 deletions

View file

@ -51,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KGlobal>
#include <KDE/KLocalizedString>
#include <KDE/KNotification>
#include <KDE/KSelectionWatcher>
#include <xcb/composite.h>
#include <xcb/damage.h>

View file

@ -67,6 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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

18
main.h
View file

@ -23,12 +23,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MAIN_H
#include <kapplication.h>
#include "workspace.h"
#include "utils.h"
#include <KDE/KSelectionWatcher>
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

View file

@ -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)

17
utils.h
View file

@ -30,8 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kwinglobals.h>
// KDE
#include <KDE/NET>
#include <KDE/KSelectionWatcher>
// Qt
#include <QList>
#include <QPoint>
#include <QRect>
#include <QScopedPointer>
@ -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.