2011-12-03 22:41:37 +01:00
|
|
|
/*
|
2013-01-08 19:21:54 +01:00
|
|
|
* Copyright (c) 2010-2013 OTClient <https://github.com/edubart/otclient>
|
2011-12-03 22:41:37 +01: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 IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef X11WINDOW_H
|
|
|
|
#define X11WINDOW_H
|
|
|
|
|
|
|
|
#include "platformwindow.h"
|
|
|
|
#include <framework/graphics/glutil.h>
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
2012-04-20 12:16:03 +02:00
|
|
|
#ifdef OPENGL_ES
|
2011-12-03 22:41:37 +01:00
|
|
|
#include <EGL/egl.h>
|
2012-04-20 12:16:03 +02:00
|
|
|
#else
|
|
|
|
#include <GL/glx.h>
|
2011-12-03 22:41:37 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
class X11Window : public PlatformWindow
|
|
|
|
{
|
|
|
|
void internalOpenDisplay();
|
|
|
|
void internalCreateWindow();
|
|
|
|
bool internalSetupWindowInput();
|
|
|
|
|
|
|
|
void internalCheckGL();
|
|
|
|
void internalChooseGLVisual();
|
|
|
|
void internalCreateGLContext();
|
|
|
|
void internalDestroyGLContext();
|
|
|
|
void internalConnectGLContext();
|
|
|
|
|
|
|
|
void *getExtensionProcAddress(const char *ext);
|
|
|
|
bool isExtensionSupported(const char *ext);
|
|
|
|
|
|
|
|
public:
|
|
|
|
X11Window();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void terminate();
|
|
|
|
|
|
|
|
void move(const Point& pos);
|
|
|
|
void resize(const Size& size);
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
void maximize();
|
|
|
|
void poll();
|
|
|
|
void swapBuffers();
|
|
|
|
void showMouse();
|
|
|
|
void hideMouse();
|
|
|
|
|
2013-01-25 14:17:51 +01:00
|
|
|
void setMouseCursor(int cursorId);
|
|
|
|
void restoreMouseCursor();
|
|
|
|
|
2011-12-03 22:41:37 +01:00
|
|
|
void setTitle(const std::string& title);
|
|
|
|
void setMinimumSize(const Size& minimumSize);
|
|
|
|
void setFullscreen(bool fullscreen);
|
|
|
|
void setVerticalSync(bool enable);
|
2013-01-08 21:45:27 +01:00
|
|
|
void setIcon(const std::string& file);
|
2011-12-03 22:41:37 +01:00
|
|
|
void setClipboardText(const std::string& text);
|
|
|
|
|
|
|
|
Size getDisplaySize();
|
|
|
|
std::string getClipboardText();
|
2011-12-30 05:50:19 +01:00
|
|
|
std::string getPlatformType();
|
2011-12-03 22:41:37 +01:00
|
|
|
|
2013-01-25 14:17:51 +01:00
|
|
|
protected:
|
|
|
|
int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot);
|
|
|
|
|
2011-12-03 22:41:37 +01:00
|
|
|
private:
|
|
|
|
Display *m_display;
|
|
|
|
XVisualInfo *m_visual;
|
|
|
|
Window m_window;
|
|
|
|
Window m_rootWindow;
|
|
|
|
Colormap m_colormap;
|
2013-01-25 14:17:51 +01:00
|
|
|
std::vector<Cursor> m_cursors;
|
2011-12-03 22:41:37 +01:00
|
|
|
Cursor m_cursor;
|
2013-01-25 14:17:51 +01:00
|
|
|
Cursor m_hiddenCursor;
|
2011-12-03 22:41:37 +01:00
|
|
|
XIM m_xim;
|
|
|
|
XIC m_xic;
|
|
|
|
int m_screen;
|
|
|
|
Atom m_wmDelete;
|
|
|
|
std::string m_clipboardText;
|
|
|
|
|
2012-04-20 12:16:03 +02:00
|
|
|
#ifndef OPENGL_ES
|
2011-12-03 22:41:37 +01:00
|
|
|
GLXContext m_glxContext;
|
2012-04-12 22:00:08 +02:00
|
|
|
GLXFBConfig *m_fbConfig;
|
2011-12-03 22:41:37 +01:00
|
|
|
#else
|
|
|
|
EGLConfig m_eglConfig;
|
|
|
|
EGLContext m_eglContext;
|
|
|
|
EGLDisplay m_eglDisplay;
|
|
|
|
EGLSurface m_eglSurface;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|