2011-10-20 10:17:00 +02:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
* @file guiX11.cpp
|
|
|
|
* @brief Gui abstraction layer (Sources)
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @date 20/10/2011
|
|
|
|
* @par Project
|
|
|
|
* ewol
|
|
|
|
*
|
|
|
|
* @par Copyright
|
|
|
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY.
|
|
|
|
*
|
|
|
|
* Licence summary :
|
|
|
|
* You can modify and redistribute the sources code and binaries.
|
|
|
|
* You can send me the bug-fix
|
|
|
|
*
|
|
|
|
* Term of the licence in in the file licence.txt.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ewolDebug.h>
|
2011-10-20 18:24:43 +02:00
|
|
|
#include <etkString.h>
|
2011-10-20 10:17:00 +02:00
|
|
|
#include <guiX11.h>
|
|
|
|
|
2011-10-20 18:24:43 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include <GL/glut.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
//#define TEST_MODE_1
|
2011-10-20 18:24:43 +02:00
|
|
|
|
|
|
|
namespace guiAbstraction {
|
2011-10-21 15:07:56 +02:00
|
|
|
|
2011-10-24 14:52:11 +02:00
|
|
|
extern "C" {
|
|
|
|
typedef struct Hints
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long functions;
|
|
|
|
unsigned long decorations;
|
|
|
|
long inputMode;
|
|
|
|
unsigned long status;
|
|
|
|
} Hints;
|
|
|
|
}
|
2011-10-21 15:07:56 +02:00
|
|
|
class X11systemInterface
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Atom del_atom;
|
|
|
|
Display *m_display;
|
|
|
|
GLXFBConfig fbconfig;
|
|
|
|
Window WindowHandle, GLXWindowHandle;
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
bool m_run;
|
|
|
|
ewol::Windows* m_uniqueWindows;
|
|
|
|
|
|
|
|
bool CreateX11Context(void)
|
|
|
|
{
|
|
|
|
int x,y, attr_mask;
|
|
|
|
XSizeHints hints;
|
|
|
|
XWMHints *StartupState;
|
|
|
|
XTextProperty textprop;
|
|
|
|
XSetWindowAttributes attr;
|
2011-10-24 14:52:11 +02:00
|
|
|
static char *title = (char*)"APPLICATION Title ... (todo)";
|
2011-10-21 15:07:56 +02:00
|
|
|
|
|
|
|
// Connect to the X server
|
|
|
|
m_display = XOpenDisplay(NULL);
|
|
|
|
if(NULL == m_display) {
|
|
|
|
EWOL_CRITICAL("Could not open display X.");
|
|
|
|
exit(-1);
|
|
|
|
} else {
|
|
|
|
EWOL_INFO("Display opened.");
|
|
|
|
}
|
|
|
|
int Xscreen = DefaultScreen(m_display);
|
|
|
|
Window Xroot = RootWindow(m_display, Xscreen);
|
|
|
|
|
|
|
|
int numfbconfigs;
|
|
|
|
int VisualData[] = {
|
|
|
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
|
|
|
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
|
|
|
GLX_DOUBLEBUFFER, True,
|
|
|
|
GLX_RED_SIZE, 1,
|
|
|
|
GLX_GREEN_SIZE, 1,
|
|
|
|
GLX_BLUE_SIZE, 1,
|
|
|
|
GLX_ALPHA_SIZE, 1,
|
|
|
|
GLX_DEPTH_SIZE, 1,
|
|
|
|
None
|
|
|
|
};
|
2011-10-24 14:52:11 +02:00
|
|
|
XVisualInfo *visual = NULL;
|
2011-10-21 15:07:56 +02:00
|
|
|
GLXFBConfig *fbconfigs = glXChooseFBConfig(m_display, Xscreen, VisualData, &numfbconfigs);
|
|
|
|
for(int i = 0; i<numfbconfigs; i++) {
|
|
|
|
visual = glXGetVisualFromFBConfig(m_display, fbconfigs[i]);
|
|
|
|
if(!visual) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
XRenderPictFormat * pictFormat = XRenderFindVisualFormat(m_display, visual->visual);
|
|
|
|
if(!pictFormat) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pictFormat->direct.alphaMask > 0) {
|
|
|
|
fbconfig = fbconfigs[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a colormap - only needed on some X clients, eg. IRIX
|
|
|
|
attr.colormap = XCreateColormap(m_display, Xroot, visual->visual, AllocNone);
|
|
|
|
|
|
|
|
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.event_mask = StructureNotifyMask
|
2011-10-24 14:52:11 +02:00
|
|
|
| SubstructureNotifyMask
|
2011-10-21 15:07:56 +02:00
|
|
|
| EnterWindowMask
|
|
|
|
| LeaveWindowMask
|
|
|
|
| ExposureMask
|
|
|
|
| ButtonPressMask
|
|
|
|
| ButtonReleaseMask
|
|
|
|
| OwnerGrabButtonMask
|
|
|
|
| KeyPressMask
|
2011-10-24 14:52:11 +02:00
|
|
|
| KeyReleaseMask
|
|
|
|
| PointerMotionMask
|
|
|
|
| FocusChangeMask
|
|
|
|
| SubstructureRedirectMask;
|
2011-10-21 15:07:56 +02:00
|
|
|
|
|
|
|
// set no background at the gui
|
|
|
|
attr.background_pixmap = None;
|
|
|
|
|
|
|
|
// select internal attribute
|
|
|
|
attr_mask = CWBackPixmap | CWColormap | CWBorderPixel | CWEventMask;
|
|
|
|
// Create the window
|
|
|
|
width = DisplayWidth(m_display, DefaultScreen(m_display))/2;
|
|
|
|
height = DisplayHeight(m_display, DefaultScreen(m_display))/2;
|
|
|
|
x=width/2;
|
|
|
|
y=height/4;
|
|
|
|
|
|
|
|
// Real create of the window
|
|
|
|
WindowHandle = XCreateWindow(m_display,
|
|
|
|
Xroot,
|
|
|
|
x, y, width, height,
|
|
|
|
1,
|
|
|
|
visual->depth,
|
|
|
|
InputOutput,
|
|
|
|
visual->visual,
|
|
|
|
attr_mask, &attr);
|
|
|
|
|
|
|
|
if( !WindowHandle ) {
|
|
|
|
EWOL_CRITICAL("Couldn't create the window");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Configure it... (ok, ok, this next bit isn't "minimal") */
|
|
|
|
textprop.value = (unsigned char*)title;
|
|
|
|
textprop.encoding = XA_STRING;
|
|
|
|
textprop.format = 8;
|
|
|
|
textprop.nitems = strlen(title);
|
|
|
|
|
|
|
|
hints.x = x;
|
|
|
|
hints.y = y;
|
|
|
|
hints.width = width;
|
|
|
|
hints.height = height;
|
|
|
|
hints.flags = USPosition|USSize;
|
|
|
|
|
|
|
|
StartupState = XAllocWMHints();
|
|
|
|
StartupState->initial_state = NormalState;
|
|
|
|
StartupState->flags = StateHint;
|
|
|
|
|
|
|
|
XSetWMProperties(m_display, WindowHandle,&textprop, &textprop,/* Window title/icon title*/
|
|
|
|
NULL, 0,/* Argv[], argc for program*/
|
|
|
|
&hints, /* Start position/size*/
|
|
|
|
StartupState,/* Iconised/not flag */
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
XFree(StartupState);
|
|
|
|
|
|
|
|
/* Open it, wait for it to appear */
|
|
|
|
XMapWindow(m_display, WindowHandle);
|
|
|
|
//XIfEvent(m_display, &event, WaitForMapNotify, (char*)&WindowHandle);
|
|
|
|
|
|
|
|
// Set the kill atom so we get a message when the user tries to close the window
|
|
|
|
if ((del_atom = XInternAtom(m_display, "WM_DELETE_WINDOW", 0)) != None) {
|
|
|
|
XSetWMProtocols(m_display, WindowHandle, &del_atom, 1);
|
|
|
|
}
|
2011-10-24 14:52:11 +02:00
|
|
|
|
|
|
|
//code to remove decoration
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
|
|
|
|
Hints hints;
|
|
|
|
Atom property;
|
|
|
|
hints.flags = 2;// Specify that we're changing the window decorations.
|
|
|
|
hints.decorations = 0;// 0 (false) means that window decorations should go bye-bye
|
|
|
|
property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true);
|
|
|
|
if (0 != property) {
|
|
|
|
XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
|
|
|
|
XMapWindow(m_display, WindowHandle);
|
|
|
|
} else {
|
|
|
|
EWOL_ERROR("Can not get the property for the rmoving decoration of the X11 system ....");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2011-10-21 15:07:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreateOGlContext(void)
|
|
|
|
{
|
|
|
|
/* See if we can do OpenGL on this visual */
|
|
|
|
int dummy;
|
|
|
|
if (!glXQueryExtension(m_display, &dummy, &dummy)) {
|
|
|
|
EWOL_CRITICAL("OpenGL not supported by X server");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the OpenGL rendering context */
|
|
|
|
GLXContext RenderContext = glXCreateNewContext(m_display, fbconfig, GLX_RGBA_TYPE, 0, True);
|
|
|
|
if (!RenderContext) {
|
|
|
|
EWOL_CRITICAL("Failed to create a GL context");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLXWindowHandle = glXCreateWindow(m_display, fbconfig, WindowHandle, NULL);
|
|
|
|
|
|
|
|
/* Make it current */
|
|
|
|
if (!glXMakeContextCurrent(m_display, GLXWindowHandle, GLXWindowHandle, RenderContext)) {
|
|
|
|
EWOL_CRITICAL("glXMakeCurrent failed for window");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Draw(void)
|
|
|
|
{
|
2011-10-24 14:52:11 +02:00
|
|
|
//EWOL_DEBUG("redraw (" << width << "," << height << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
if(NULL == m_uniqueWindows) {
|
|
|
|
//EWOL_DEBUG("Has No Windows set...");
|
|
|
|
|
|
|
|
// set the size of the open GL system
|
|
|
|
glViewport(0,0,width,height);
|
|
|
|
|
|
|
|
// Clear the screen with transparency ...
|
|
|
|
glClearColor(0.750, 0.750, 0.750, 0.5);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glOrtho(0., (float)width, 0., (float)height, 1., 20.);
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
glTranslatef(0, 0, -5);
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
glColor3f(1., 0., 0.); glVertex3f( .25*(float)width, .25*(float)height, 0.);
|
|
|
|
glColor3f(0., 1., 0.); glVertex3f( .75*(float)width, .25*(float)height, 0.);
|
|
|
|
glColor3f(0., 0., 1.); glVertex3f( .75*(float)width, .75*(float)height, 0.);
|
|
|
|
glColor3f(1., 1., 0.); glVertex3f( .25*(float)width, .75*(float)height, 0.);
|
|
|
|
glEnd();
|
|
|
|
} else {
|
|
|
|
m_uniqueWindows->SysDraw();
|
|
|
|
}
|
|
|
|
/* Swapbuffers */
|
|
|
|
glXSwapBuffers(m_display, GLXWindowHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
X11systemInterface(void)
|
|
|
|
{
|
|
|
|
CreateX11Context();
|
|
|
|
CreateOGlContext();
|
|
|
|
m_run = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
~X11systemInterface(void)
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Setwindow(ewol::Windows* newWindows)
|
|
|
|
{
|
|
|
|
m_uniqueWindows = newWindows;
|
|
|
|
if (NULL != m_uniqueWindows) {
|
|
|
|
m_uniqueWindows->CalculateSize((double)width, (double)height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Run(void)
|
|
|
|
{
|
|
|
|
// main cycle
|
|
|
|
while(true == m_run) {
|
|
|
|
XEvent event;
|
2011-10-24 14:52:11 +02:00
|
|
|
// main X boucle :
|
2011-10-21 15:07:56 +02:00
|
|
|
while (XPending(m_display)) {
|
|
|
|
XNextEvent(m_display, &event);
|
|
|
|
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case ClientMessage:
|
|
|
|
{
|
|
|
|
Atom atom = XInternAtom(m_display, "WM_DELETE_WINDOW", false);
|
2011-10-24 14:52:11 +02:00
|
|
|
if((int64_t)atom == (int64_t)event.xclient.data.l[0]) {
|
2011-10-21 15:07:56 +02:00
|
|
|
if (NULL != m_uniqueWindows) {
|
|
|
|
m_uniqueWindows->SysOnKill();
|
|
|
|
}
|
|
|
|
Stop();
|
|
|
|
}
|
2011-10-20 18:24:43 +02:00
|
|
|
}
|
|
|
|
break;
|
2011-10-21 15:07:56 +02:00
|
|
|
case ConfigureNotify:
|
|
|
|
width = event.xconfigure.width;
|
|
|
|
height = event.xconfigure.height;
|
2011-10-20 18:24:43 +02:00
|
|
|
break;
|
2011-10-21 15:07:56 +02:00
|
|
|
}
|
|
|
|
// parse event
|
|
|
|
if(NULL == m_uniqueWindows) {
|
|
|
|
EWOL_DEBUG("Has No Windows set...");
|
|
|
|
} else {
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case ConfigureNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"ConfigureNotify\" Origin(" << event.xconfigure.x << "," << event.xconfigure.y << ") Size(" << event.xconfigure.width << "," << event.xconfigure.height << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->CalculateSize((double)event.xconfigure.width, (double)event.xconfigure.height);
|
|
|
|
break;
|
|
|
|
case Expose:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"Expose\"");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->SysOnExpose();
|
|
|
|
break;
|
|
|
|
case ButtonPress:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"ButtonPress\" (" << (double)event.xbutton.x << "," << (double)event.xbutton.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
if ( event.xbutton.button & Button2 ) {
|
|
|
|
m_uniqueWindows->GenEventInput(2, ewol::EVENT_INPUT_TYPE_DOWN, (double)event.xbutton.x, (double)event.xbutton.y);
|
|
|
|
} else if (event.xbutton.button & Button1) {
|
|
|
|
m_uniqueWindows->GenEventInput(1, ewol::EVENT_INPUT_TYPE_DOWN, (double)event.xbutton.x, (double)event.xbutton.y);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"ButtonRelease\" (" << (double)event.xbutton.x << "," << (double)event.xbutton.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
if(event.xbutton.button & Button2) {
|
|
|
|
m_uniqueWindows->GenEventInput(2, ewol::EVENT_INPUT_TYPE_UP, (double)event.xbutton.x, (double)event.xbutton.y);
|
|
|
|
} else if (event.xbutton.button & Button1) {
|
|
|
|
m_uniqueWindows->GenEventInput(1, ewol::EVENT_INPUT_TYPE_UP, (double)event.xbutton.x, (double)event.xbutton.y);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EnterNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (double)event.xcrossing.x << "," << (double)event.xcrossing.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (double)event.xcrossing.x, (double)event.xcrossing.y);
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"MotionNotify\" (" << (double)event.xmotion.x << "," << (double)event.xmotion.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_MOVE, (double)event.xmotion.x, (double)event.xmotion.y);
|
|
|
|
break;
|
|
|
|
case LeaveNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (double)event.xcrossing.x << "," << (double)event.xcrossing.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_LEAVE, (double)event.xcrossing.x, (double)event.xcrossing.y);
|
|
|
|
break;
|
|
|
|
case FocusIn:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"FocusIn\"");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->SetFocus();
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"FocusOut\"");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->RmFocus();
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
|
2011-10-21 15:07:56 +02:00
|
|
|
{
|
|
|
|
char buf[11];
|
|
|
|
KeySym keysym;
|
|
|
|
XComposeStatus status;
|
|
|
|
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
|
|
|
|
buf[count] = '\0';
|
|
|
|
if(event.type == KeyPress) {
|
|
|
|
// TODO : set the char here...
|
|
|
|
} else {
|
|
|
|
// TODO : set the char here...
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//case DestroyNotify:
|
|
|
|
// break;
|
|
|
|
case MapNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"MapNotify\"");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->SysOnShow();
|
|
|
|
break;
|
|
|
|
case UnmapNotify:
|
2011-10-24 14:52:11 +02:00
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"UnmapNotify\"");
|
2011-10-21 15:07:56 +02:00
|
|
|
m_uniqueWindows->SysOnHide();
|
|
|
|
break;
|
2011-10-24 14:52:11 +02:00
|
|
|
default:
|
|
|
|
EWOL_DEBUG("X11 event : " << event.type << " = \"???\"");
|
2011-10-20 18:24:43 +02:00
|
|
|
}
|
2011-10-21 15:07:56 +02:00
|
|
|
}
|
2011-10-20 18:24:43 +02:00
|
|
|
}
|
2011-10-21 15:07:56 +02:00
|
|
|
Draw();
|
|
|
|
usleep( 100000 );
|
2011-10-20 18:24:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
void Stop(void)
|
2011-10-20 18:24:43 +02:00
|
|
|
{
|
2011-10-21 15:07:56 +02:00
|
|
|
m_run = false;
|
2011-10-20 18:24:43 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-20 10:17:00 +02:00
|
|
|
#undef __class__
|
|
|
|
#define __class__ "guiAbstraction"
|
|
|
|
|
2011-10-20 18:24:43 +02:00
|
|
|
static bool guiAbstractionIsInit = false;
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
static guiAbstraction::X11display * myDisplay = NULL;
|
|
|
|
static guiAbstraction::X11eventMng * myEventManager = NULL;
|
|
|
|
#else
|
|
|
|
static guiAbstraction::X11systemInterface * myX11Access = NULL;
|
|
|
|
#endif
|
2011-10-20 10:17:00 +02:00
|
|
|
void guiAbstraction::Init(int32_t argc, char *argv[])
|
|
|
|
{
|
2011-10-20 18:24:43 +02:00
|
|
|
if (false == guiAbstractionIsInit) {
|
|
|
|
// set the gui is init :
|
|
|
|
guiAbstractionIsInit = true;
|
|
|
|
EWOL_INFO("INIT for X11 environement");
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
myDisplay = new guiAbstraction::X11display("");
|
|
|
|
myEventManager = new guiAbstraction::X11eventMng(*myDisplay);
|
|
|
|
#else
|
|
|
|
myX11Access = new guiAbstraction::X11systemInterface();
|
|
|
|
#endif
|
2011-10-20 18:24:43 +02:00
|
|
|
} else {
|
|
|
|
EWOL_CRITICAL("Can not INIT X11 ==> already init before");
|
|
|
|
}
|
2011-10-20 10:17:00 +02:00
|
|
|
}
|
|
|
|
|
2011-10-20 18:24:43 +02:00
|
|
|
|
2011-10-20 10:17:00 +02:00
|
|
|
void guiAbstraction::Run(void)
|
|
|
|
{
|
2011-10-20 18:24:43 +02:00
|
|
|
if (true == guiAbstractionIsInit) {
|
|
|
|
EWOL_INFO("Start Running");
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
myEventManager->Run();
|
|
|
|
#else
|
|
|
|
myX11Access->Run();
|
|
|
|
#endif
|
2011-10-20 18:24:43 +02:00
|
|
|
EWOL_INFO("Stop Running");
|
|
|
|
} else {
|
|
|
|
EWOL_CRITICAL("Can not Run X11 ==> not init ... ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void guiAbstraction::Stop(void)
|
|
|
|
{
|
|
|
|
if (true == guiAbstractionIsInit) {
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
myEventManager->Stop();
|
|
|
|
#else
|
|
|
|
myX11Access->Stop();
|
|
|
|
#endif
|
2011-10-20 18:24:43 +02:00
|
|
|
} else {
|
|
|
|
EWOL_CRITICAL("Can not Stop X11 ==> not init ... ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newOne)
|
2011-10-20 18:24:43 +02:00
|
|
|
{
|
|
|
|
if (true == guiAbstractionIsInit) {
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
myEventManager->Setwindow(newOne);
|
|
|
|
#else
|
|
|
|
myX11Access->Setwindow(newOne);
|
|
|
|
#endif
|
2011-10-20 18:24:43 +02:00
|
|
|
} else {
|
|
|
|
EWOL_CRITICAL("Can not set Windows X11 ==> not init ... ");
|
|
|
|
}
|
2011-10-20 10:17:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void guiAbstraction::UnInit(void)
|
|
|
|
{
|
2011-10-20 18:24:43 +02:00
|
|
|
if (true == guiAbstractionIsInit) {
|
|
|
|
EWOL_INFO("UN-INIT for X11 environement");
|
2011-10-21 15:07:56 +02:00
|
|
|
#ifdef TEST_MODE_1
|
|
|
|
if (NULL != myEventManager) {
|
|
|
|
delete(myEventManager);
|
|
|
|
}
|
|
|
|
if (NULL != myDisplay) {
|
|
|
|
delete(myDisplay);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (NULL != myX11Access) {
|
|
|
|
delete(myX11Access);
|
|
|
|
}
|
|
|
|
#endif
|
2011-10-20 18:24:43 +02:00
|
|
|
guiAbstractionIsInit = false;
|
|
|
|
} else {
|
|
|
|
EWOL_CRITICAL("Can not Un-Init X11 ==> not init ... ");
|
|
|
|
}
|
2011-10-20 10:17:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|