2009-08-22 08:24:06 +00:00
|
|
|
#ifndef X11Util_h
|
|
|
|
#define X11Util_h
|
|
|
|
|
2009-08-24 16:17:15 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// x11util.h
|
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-24 16:17:15 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:17:15 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
#include <QX11Info>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#endif
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
|
|
|
class X11Util
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
public:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! singleton
|
|
|
|
static X11Util& get( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! Atoms enumeration
|
|
|
|
enum Atoms
|
|
|
|
{
|
|
|
|
_NET_SUPPORTED,
|
|
|
|
_NET_WM_STATE,
|
|
|
|
_NET_WM_MOVERESIZE
|
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
enum Direction
|
|
|
|
{
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOPLEFT=0,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOP=1,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOPRIGHT=2,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_RIGHT=3,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT=4,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOM=5,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT=6,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_LEFT=7,
|
|
|
|
_NET_WM_MOVERESIZE_MOVE=8,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_KEYBOARD=9,
|
2009-09-09 00:55:55 +00:00
|
|
|
_NET_WM_MOVERESIZE_MOVE_KEYBOARD=10
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! supported atoms
|
|
|
|
bool isSupported( const Atoms& atom );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! move/resize widget using X11 window manager
|
|
|
|
/*! returns true on success */
|
|
|
|
bool moveResizeWidget( WId, int screen, QPoint, Direction, Qt::MouseButton button = Qt::LeftButton );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
#ifdef Q_WS_X11
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! find atom
|
|
|
|
Atom findAtom( const Atoms& atom );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
#endif
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
private:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! constructor
|
|
|
|
X11Util( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atom names
|
2009-09-09 00:55:55 +00:00
|
|
|
typedef std::map<Atoms, QString> AtomNameMap;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atom names
|
2009-09-14 23:10:19 +00:00
|
|
|
void initializeAtomNames( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atom names
|
2009-09-14 23:10:19 +00:00
|
|
|
const AtomNameMap& atomNames( void ) const
|
|
|
|
{ return atomNames_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-14 23:10:19 +00:00
|
|
|
AtomNameMap atomNames_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! supported atoms
|
|
|
|
typedef std::map<Atoms, bool > SupportedAtomMap;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! supported atoms
|
2009-09-14 23:10:19 +00:00
|
|
|
const SupportedAtomMap& supportedAtoms( void ) const
|
|
|
|
{ return supportedAtoms_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-14 23:10:19 +00:00
|
|
|
SupportedAtomMap supportedAtoms_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
#ifdef Q_WS_X11
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atom map
|
|
|
|
typedef std::map<Atoms, Atom> AtomMap;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atoms
|
2009-09-14 23:10:19 +00:00
|
|
|
// const AtomMap& atoms( void ) const
|
|
|
|
AtomMap& atoms( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{ return atoms_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! atoms
|
|
|
|
AtomMap atoms_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
#endif
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-24 06:27:49 +00:00
|
|
|
}
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#endif
|