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:
parent
b6681ddc3a
commit
1276eb044f
5 changed files with 71 additions and 71 deletions
|
@ -51,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <KDE/KGlobal>
|
#include <KDE/KGlobal>
|
||||||
#include <KDE/KLocalizedString>
|
#include <KDE/KLocalizedString>
|
||||||
#include <KDE/KNotification>
|
#include <KDE/KNotification>
|
||||||
|
#include <KDE/KSelectionWatcher>
|
||||||
|
|
||||||
#include <xcb/composite.h>
|
#include <xcb/composite.h>
|
||||||
#include <xcb/damage.h>
|
#include <xcb/damage.h>
|
||||||
|
|
53
main.cpp
53
main.cpp
|
@ -67,6 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "sm.h"
|
#include "sm.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
#include "workspace.h"
|
||||||
#include "xcbutils.h"
|
#include "xcbutils.h"
|
||||||
|
|
||||||
#define INT8 _X11INT8
|
#define INT8 _X11INT8
|
||||||
|
@ -94,6 +95,58 @@ bool initting = false;
|
||||||
*/
|
*/
|
||||||
static bool kwin_sync = 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.
|
// errorMessage is only used ifndef NDEBUG, and only in one place.
|
||||||
// it might be worth reevaluating why this is used? I don't know.
|
// it might be worth reevaluating why this is used? I don't know.
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
18
main.h
18
main.h
|
@ -23,12 +23,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
#include <kapplication.h>
|
#include <kapplication.h>
|
||||||
#include "workspace.h"
|
#include <KDE/KSelectionWatcher>
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
namespace KWin
|
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
|
class Application : public KApplication
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
53
utils.cpp
53
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
|
#endif
|
||||||
|
|
||||||
QByteArray getStringProperty(WId w, Atom prop, char separator)
|
QByteArray getStringProperty(WId w, Atom prop, char separator)
|
||||||
|
|
17
utils.h
17
utils.h
|
@ -30,8 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kwinglobals.h>
|
#include <kwinglobals.h>
|
||||||
// KDE
|
// KDE
|
||||||
#include <KDE/NET>
|
#include <KDE/NET>
|
||||||
#include <KDE/KSelectionWatcher>
|
|
||||||
// Qt
|
// Qt
|
||||||
|
#include <QList>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QScopedPointer>
|
#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
|
// Class which saves original value of the variable, assigns the new value
|
||||||
// to it, and in the destructor restores the value.
|
// to it, and in the destructor restores the value.
|
||||||
// Used in Client::isMaximizable() and so on.
|
// Used in Client::isMaximizable() and so on.
|
||||||
|
|
Loading…
Reference in a new issue