Platform/Unix/X11Display: Implement missing interface functions.
* getPosition * setVisible * minimize * maximize * grabCursor (only stub. to get the code to compile)
This commit is contained in:
parent
40e4f95452
commit
56c24f7118
2 changed files with 64 additions and 1 deletions
|
|
@ -7,6 +7,11 @@
|
|||
#include "GLXContext.h"
|
||||
#include "X11Display.h"
|
||||
|
||||
// Sometimes not defined in headers.
|
||||
#ifndef _NET_WM_STATE_TOGGLE
|
||||
#define _NET_WM_STATE_TOGGLE 2
|
||||
#endif
|
||||
|
||||
namespace sp {
|
||||
|
||||
X11Display::
|
||||
|
|
@ -61,7 +66,7 @@ bool X11Display::create(DisplayDescription description)
|
|||
protocols = getAtom("WM_DELETE_WINDOW");
|
||||
XSetWMProtocols(m_disp, m_win, &protocols, 1);
|
||||
|
||||
XMapWindow(m_disp, m_win);
|
||||
setVisible(true);
|
||||
|
||||
setSize(description.mode.width, description.mode.height);
|
||||
|
||||
|
|
@ -125,6 +130,49 @@ void X11Display::setPosition(unsigned int x, unsigned int y)
|
|||
::XMoveWindow(m_disp, m_win, x, y);
|
||||
}
|
||||
|
||||
Vector2u X11Display::getPosition() const
|
||||
{
|
||||
Vector2u pos(0, 0);
|
||||
XWindowAttributes attr;
|
||||
|
||||
if (XGetWindowAttributes(m_disp, m_win, &attr)) {
|
||||
pos.x = attr.x;
|
||||
pos.y = attr.y;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
void X11Display::setVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
::XMapWindow(m_disp, m_win);
|
||||
} else {
|
||||
::XUnmapWindow(m_disp, m_win);
|
||||
}
|
||||
}
|
||||
|
||||
void X11Display::minimize()
|
||||
{
|
||||
::XIconifyWindow(m_disp, m_win, m_screen);
|
||||
}
|
||||
|
||||
void X11Display::maximize()
|
||||
{
|
||||
::XClientMessageEvent ev = {};
|
||||
|
||||
ev.type = ClientMessage;
|
||||
ev.window = m_win;
|
||||
ev.message_type = getAtom("_NET_WM_STATE");
|
||||
ev.format = 32;
|
||||
ev.data.l[0] = _NET_WM_STATE_TOGGLE;
|
||||
ev.data.l[1] = getAtom("_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
ev.data.l[2] = getAtom("_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
ev.data.l[3] = 1;
|
||||
|
||||
::XSendEvent(m_disp, DefaultRootWindow(m_disp), False,
|
||||
SubstructureNotifyMask, (XEvent*) &ev);
|
||||
}
|
||||
|
||||
void X11Display::setCaption(const std::string& caption)
|
||||
{
|
||||
::XStoreName(m_disp, m_win, caption.c_str());
|
||||
|
|
@ -190,6 +238,11 @@ void X11Display::showCursor(bool value)
|
|||
XDefineCursor(m_disp, m_win, value ? m_cur_last : m_cur_hidden);
|
||||
}
|
||||
|
||||
void X11Display::grabCursor(bool value)
|
||||
{
|
||||
// TODO (this is abit harder on X11 than windows.)
|
||||
}
|
||||
|
||||
void X11Display::processEvent(const ::XEvent& event)
|
||||
{
|
||||
Vector2u size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue