diff --git a/gale/context/wayland/Context.cpp b/gale/context/wayland/Context.cpp new file mode 100644 index 0000000..41b0c66 --- /dev/null +++ b/gale/context/wayland/Context.cpp @@ -0,0 +1,1415 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { + #include + #include + #include + #include + #include + #include + #include +} + +#include + +bool hasDisplay = false; +#define DEBUG_WAYLAND_EVENT +#ifdef DEBUG_WAYLAND_EVENT + #define WAYLAND_DEBUG GALE_DEBUG + #define WAYLAND_VERBOSE GALE_VERBOSE + #define WAYLAND_INFO GALE_INFO + #define WAYLAND_CRITICAL GALE_CRITICAL +#else + #define WAYLAND_DEBUG GALE_VERBOSE + #define WAYLAND_VERBOSE GALE_VERBOSE + #define WAYLAND_INFO GALE_VERBOSE + #define WAYLAND_CRITICAL GALE_VERBOSE +#endif + +// see this ... https://jan.newmarch.name/Wayland/Input/ + +static void global_registry_handler(void* _data, struct wl_registry* _registry, uint32_t _id, const char* _interface, uint32_t _version); +static void global_registry_remover(void* _data, struct wl_registry* _registry, uint32_t _id); + +static const struct wl_registry_listener registry_listener = { + global_registry_handler, + global_registry_remover +}; + + +class WAYLANDInterface : public gale::Context { + private: + gale::key::Special m_guiKeyBoardMode; + bool m_inputIsPressed[MAX_MANAGE_INPUT]; + struct wl_display* m_display; + std::string m_uniqueWindowsName; + bool m_run; + + + struct wl_compositor* m_compositor; + struct wl_surface* m_surface; + struct wl_egl_window* m_egl_window; + struct wl_region* m_region; + struct wl_shell* m_shell; + struct wl_shell_surface* m_shell_surface; + + EGLDisplay m_egl_display; + EGLConfig m_egl_conf; + EGLSurface m_egl_surface; + EGLContext m_egl_context; + + public: + WAYLANDInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) : + gale::Context(_application, _argc, _argv), + m_display(nullptr), + m_run(false), + m_compositor(nullptr), + m_surface(nullptr), + m_egl_window(nullptr), + m_region(nullptr), + m_shell(nullptr), + m_shell_surface(nullptr) { + WAYLAND_INFO("WAYLAND:INIT"); + for (int32_t iii=0; iii Kill Requested ..."); + OS_Stop(); + // We do not close here but in the application only: + //m_run = false; + } + break; + } + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Selection AREA // + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + case SelectionClear: { + // Selection has been done on an other program == > clear ours ... + WAYLAND_INFO("WAYLAND event SelectionClear"); + #ifdef DEBUG_WAYLAND_EVENT + { + XSelectionRequestEvent *req=&(event.xselectionrequest); + if (req->property == 0) { + GALE_ERROR("Get nullptr ATOM ... property"); + break; + } + if (req->target == 0) { + GALE_ERROR("Get nullptr ATOM ... target"); + break; + } + char * atomNameProperty = XGetAtomName(m_display, req->property); + char * atomNameTarget = XGetAtomName(m_display, req->target); + GALE_INFO("WAYLAND property: \"" << atomNameProperty << "\""); + GALE_INFO("WAYLAND target: \"" << atomNameTarget << "\""); + if (atomNameProperty != nullptr) { + XFree(atomNameProperty); + } + if (atomNameTarget != nullptr) { + XFree(atomNameTarget); + } + } + #endif + if (m_clipBoardOwnerPrimary == true) { + m_clipBoardOwnerPrimary = false; + } else if (m_clipBoardOwnerStd == true) { + m_clipBoardOwnerStd = false; + } else { + GALE_ERROR("WAYLAND event SelectionClear == > but no selection requested anymore ..."); + } + break; + } + case SelectionNotify: + WAYLAND_INFO("WAYLAND event SelectionNotify"); + if (event.xselection.property == None) { + GALE_VERBOSE(" == > no data ..."); + } else { + unsigned char *buf = 0; + Atom type; + int format; + unsigned long nitems, bytes; + XGetWindowProperty(m_display, + m_WindowHandle, + event.xselection.property, + 0, // offset + (~0L), // length + False, // delete + AnyPropertyType, // reg_type + &type,// *actual_type::return, + &format,// *actual_format_return + &nitems,// *nitems_return + &bytes, // *bytes_after_return + &buf// **prop_return); + ); + if (m_clipBoardRequestPrimary == true) { + std::string tmpppp((char*)buf); + gale::context::clipBoard::setSystem(gale::context::clipBoard::clipboardSelection, tmpppp); + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(gale::context::clipBoard::clipboardSelection); + } else { + std::string tmpppp((char*)buf); + gale::context::clipBoard::setSystem(gale::context::clipBoard::clipboardStd, tmpppp); + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(gale::context::clipBoard::clipboardStd); + } + } + break; + case SelectionRequest: { + WAYLAND_INFO("WAYLAND event SelectionRequest"); + XSelectionRequestEvent *req=&(event.xselectionrequest); + #ifdef DEBUG_WAYLAND_EVENT + { + if (req->property == 0) { + GALE_ERROR("Get nullptr ATOM ... property"); + break; + } + if (req->selection == 0) { + GALE_ERROR("Get nullptr ATOM ... selection"); + break; + } + if (req->target == 0) { + GALE_ERROR("Get nullptr ATOM ... target"); + break; + } + char * atomNameProperty = XGetAtomName(m_display, req->property); + char * atomNameSelection = XGetAtomName(m_display, req->selection); + char * atomNameTarget = XGetAtomName(m_display, req->target); + GALE_INFO(" from: " << atomNameProperty << " request=" << atomNameSelection << " in " << atomNameTarget); + if (nullptr != atomNameProperty) { XFree(atomNameProperty); } + if (nullptr != atomNameSelection) { XFree(atomNameSelection); } + if (nullptr != atomNameTarget) { XFree(atomNameTarget); } + } + #endif + + std::string tmpData = ""; + if (req->selection == XAtomSelection) { + tmpData = gale::context::clipBoard::get(gale::context::clipBoard::clipboardSelection); + } else if (req->selection == XAtomClipBoard) { + tmpData = gale::context::clipBoard::get(gale::context::clipBoard::clipboardStd); + } + const char * magatTextToSend = tmpData.c_str(); + Atom listOfAtom[4]; + if(strlen(magatTextToSend) == 0 ) { + respond.xselection.property= None; + } else if(XAtomTargetTarget == req->target) { + // We need to generate the list of the possibles target element of atom + int32_t nbAtomSupported = 0; + listOfAtom[nbAtomSupported++] = XAtomTargetTarget; + listOfAtom[nbAtomSupported++] = XAtomTargetString; + listOfAtom[nbAtomSupported++] = XAtomTargetStringUTF8; + listOfAtom[nbAtomSupported++] = None; + XChangeProperty( m_display, + req->requestor, + req->property, + XA_ATOM, + 32, + PropModeReplace, + (unsigned char*)listOfAtom, + nbAtomSupported ); + respond.xselection.property=req->property; + GALE_INFO(" == > Respond ... (test)"); + } else if(XAtomTargetString == req->target) { + XChangeProperty( m_display, + req->requestor, + req->property, + req->target, + 8, + PropModeReplace, + (unsigned char*)magatTextToSend, + strlen(magatTextToSend)); + respond.xselection.property=req->property; + GALE_INFO(" == > Respond ..."); + } else if (XAtomTargetStringUTF8 == req->target) { + XChangeProperty( m_display, + req->requestor, + req->property, + req->target, + 8, + PropModeReplace, + (unsigned char*)magatTextToSend, + strlen(magatTextToSend)); + respond.xselection.property=req->property; + GALE_INFO(" == > Respond ..."); + } else { + respond.xselection.property= None; + } + respond.xselection.type= SelectionNotify; + respond.xselection.display= req->display; + respond.xselection.requestor= req->requestor; + respond.xselection.selection=req->selection; + respond.xselection.target= req->target; + respond.xselection.time = req->time; + XSendEvent (m_display, req->requestor,0,0,&respond); + // flush the message on the pipe ... + XFlush (m_display); + break; + } + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + case Expose: + WAYLAND_INFO("WAYLAND event Expose"); + specialEventThatNeedARedraw = true; + break; + case GraphicsExpose: + WAYLAND_INFO("WAYLAND event GraphicsExpose"); + specialEventThatNeedARedraw = true; + break; + case NoExpose: + WAYLAND_INFO("WAYLAND event NoExpose"); + break; + case CreateNotify: + WAYLAND_INFO("WAYLAND event CreateNotify"); + break; + case DestroyNotify: + WAYLAND_INFO("WAYLAND event DestroyNotify"); + break; + case GravityNotify: + WAYLAND_INFO("WAYLAND event GravityNotify"); + break; + case VisibilityNotify: + WAYLAND_INFO("WAYLAND event VisibilityNotify"); + break; + case CirculateNotify: + WAYLAND_INFO("WAYLAND event CirculateNotify"); + break; + case ReparentNotify: + WAYLAND_INFO("WAYLAND event ReparentNotify"); + break; + case PropertyNotify: + specialEventThatNeedARedraw=true; + WAYLAND_INFO("WAYLAND event PropertyNotify"); + break; + case ConfigureNotify: + specialEventThatNeedARedraw=true; + WAYLAND_INFO("WAYLAND event ConfigureNotify"); + if (m_display == event.xconfigure.display) { + //GALE_INFO("WAYLAND event ConfigureNotify event=" << (int32_t)event.xconfigure.event << " Window=" << (int32_t)event.xconfigure.window << " above=" << (int32_t)event.xconfigure.above << " border_width=" << (int32_t)event.xconfigure.border_width ); + m_originX = event.xconfigure.x; + m_originY = event.xconfigure.y; + OS_Move(vec2(event.xconfigure.x,event.xconfigure.y)); + WAYLAND_INFO("WAYLAND configure windows position : (" << m_originX << "," << m_originY << ")"); + m_currentHeight = event.xconfigure.height; + m_currentWidth = event.xconfigure.width; + WAYLAND_INFO("WAYLAND configure windows size : (" << m_currentHeight << "," << m_currentWidth << ")"); + OS_Resize(vec2(event.xconfigure.width, event.xconfigure.height)); + } + break; + case ButtonPress: + WAYLAND_INFO("WAYLAND event ButtonPress"); + m_cursorEventX = event.xbutton.x; + m_cursorEventY = (m_currentHeight-event.xbutton.y); + if (event.xbutton.button < MAX_MANAGE_INPUT) { + m_inputIsPressed[event.xbutton.button] = true; + } + OS_SetInput(gale::key::type::mouse, + gale::key::status::down, + event.xbutton.button, + vec2(event.xbutton.x, m_cursorEventY)); + break; + case ButtonRelease: + WAYLAND_INFO("WAYLAND event ButtonRelease"); + m_cursorEventX = event.xbutton.x; + m_cursorEventY = (m_currentHeight-event.xbutton.y); + if (event.xbutton.button < MAX_MANAGE_INPUT) { + m_inputIsPressed[event.xbutton.button] = false; + } + OS_SetInput(gale::key::type::mouse, + gale::key::status::up, + event.xbutton.button, + vec2(event.xbutton.x, m_cursorEventY)); + break; + case EnterNotify: + WAYLAND_INFO("WAYLAND event EnterNotify"); + m_cursorEventX = event.xcrossing.x; + m_cursorEventY = (m_currentHeight-event.xcrossing.y); + //GALE_DEBUG("WAYLAND event : " << event.type << " = \"EnterNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); + //gui_uniqueWindows->GenEventInput(0, gale::EVENT_INPUT_TYPE_ENTER, (float)event.xcrossing.x, (float)event.xcrossing.y); + m_curentGrabDelta -= vec2(m_originX, -m_originY); + GALE_VERBOSE("change grab delta of : " << vec2(m_originX, m_originY) ); + break; + case LeaveNotify: + WAYLAND_INFO("WAYLAND event LeaveNotify"); + m_cursorEventX = event.xcrossing.x; + m_cursorEventY = (m_currentHeight-event.xcrossing.y); + //GALE_DEBUG("WAYLAND event : " << event.type << " = \"LeaveNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); + m_curentGrabDelta += vec2(m_originX, -m_originY); + GALE_VERBOSE("change grab delta of : " << vec2(m_originX, m_originY) ); + break; + case MotionNotify: + WAYLAND_INFO("WAYLAND event MotionNotify"); + if( m_grabAllEvent == true + && event.xmotion.x == int32_t(m_forcePos.x()) + && event.xmotion.y == int32_t(m_forcePos.y()) ) { + WAYLAND_VERBOSE("WAYLAND reject mouse move (grab mode)"); + // we get our requested position... + m_positionChangeRequested = false; + m_curentGrabDelta = vec2(0,0); + } else { + m_cursorEventX = event.xmotion.x; + m_cursorEventY = (m_currentHeight-event.xmotion.y); + if(m_grabAllEvent == true) { + m_cursorEventX -= m_forcePos.x(); + m_cursorEventY -= (m_currentHeight-m_forcePos.y()); + } + vec2 newDelta = vec2(m_cursorEventX, m_cursorEventY); + if(m_grabAllEvent == true) { + m_cursorEventX -= m_curentGrabDelta.x(); + m_cursorEventY -= m_curentGrabDelta.y(); + } + m_curentGrabDelta = newDelta; + // For compatibility of the Android system : + bool findOne = false; + for (int32_t iii=0; iii= 0) { + // repeated kay from previous element : + if (count > 0) { + // transform it in unicode + m_lastKeyPressed = utf8::convertChar32(buf); + } + WAYLAND_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << m_lastKeyPressed); + OS_setKeyboard(m_guiKeyBoardMode, + gale::key::keyboard::character, + (event.type==KeyPress?gale::key::status::down:gale::key::status::up), + thisIsAReapeateKey, + m_lastKeyPressed); + if (thisIsAReapeateKey == true) { + OS_setKeyboard(m_guiKeyBoardMode, + gale::key::keyboard::character, + (event.type!=KeyPress?gale::key::status::down:gale::key::status::up), + thisIsAReapeateKey, + m_lastKeyPressed); + } + } else { + GALE_WARNING("Unknow event Key : " << event.xkey.keycode << " res='" << buf << "' repeate=" << thisIsAReapeateKey); + } + } + break; + } + if (find == true) { + //GALE_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) ); + OS_setKeyboard(m_guiKeyBoardMode, + keyInput, + (event.type==KeyPress?gale::key::status::down:gale::key::status::up), + thisIsAReapeateKey); + if (thisIsAReapeateKey == true) { + OS_setKeyboard(m_guiKeyBoardMode, + keyInput, + (event.type!=KeyPress?gale::key::status::down:gale::key::status::up), + thisIsAReapeateKey); + } + } + } + break; + } + //case DestroyNotify: + // break; + case MapNotify: + WAYLAND_INFO("WAYLAND event : MapNotify"); + specialEventThatNeedARedraw=true; + OS_Show(); + break; + case UnmapNotify: + WAYLAND_INFO("WAYLAND event : UnmapNotify"); + specialEventThatNeedARedraw=true; + OS_Hide(); + break; + default: + WAYLAND_INFO("WAYLAND event : " << event.type << " = \"???\""); + break; + } + } + if(m_run == true) { + if (m_doubleBuffered && hasDisplay) { + #if defined(__TARGET_OS__Web) + glfwSwapBuffers(); + #else + glXSwapBuffers(m_display, m_WindowHandle); + #endif + XSync(m_display,0); + } + // draw after switch the previous windows ... + //GALE_DEBUG("specialEventThatNeedARedraw"< no icon ..."); + return; + case 16: + break; + case 24: + break; + case 32: + break; + default: + GALE_CRITICAL("Unknow thys type of bitDepth : " << depth); + return; + } + char* tmpVal = new char[4*dataImage.getWidth()*dataImage.getHeight()]; + if (nullptr == tmpVal) { + GALE_CRITICAL("Allocation error ..."); + return; + } + char* tmpPointer = tmpVal; + switch(depth) { + case 16: + for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); + int16_t tmpVal = (((uint16_t)((uint16_t)tmpColor.r()>>3))<<11) + + (((uint16_t)((uint16_t)tmpColor.g()>>2))<<5) + + ((uint16_t)((uint16_t)tmpColor.b()>>3)); + *tmpPointer++ = (uint8_t)(tmpVal>>8); + *tmpPointer++ = (uint8_t)(tmpVal&0x00FF); + } + } + break; + case 24: + for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); + *tmpPointer++ = tmpColor.b(); + *tmpPointer++ = tmpColor.g(); + *tmpPointer++ = tmpColor.r(); + tmpPointer++; + } + } + break; + case 32: + for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); + *tmpPointer++ = tmpColor.a(); + *tmpPointer++ = tmpColor.b(); + *tmpPointer++ = tmpColor.g(); + *tmpPointer++ = tmpColor.r(); + } + } + break; + default: + return; + } + + XImage* myImage = XCreateImage(m_display, + m_visual->visual, + depth, + ZPixmap, + 0, + (char*)tmpVal, + dataImage.getWidth(), + dataImage.getHeight(), + 32, + 0); + + Pixmap tmpPixmap = XCreatePixmap(m_display, + m_WindowHandle, + dataImage.getWidth(), + dataImage.getHeight(), + depth); + switch(tmpPixmap) { + case BadAlloc: + GALE_ERROR("WAYLAND: BadAlloc"); + break; + case BadDrawable: + GALE_ERROR("WAYLAND: BadDrawable"); + break; + case BadValue: + GALE_ERROR("WAYLAND: BadValue"); + break; + default: + GALE_DEBUG("Create Pixmap OK"); + break; + } + GC tmpGC = DefaultGC(m_display, DefaultScreen(m_display) ); + int error = XPutImage(m_display, + tmpPixmap, + tmpGC, + myImage, + 0, 0, 0, 0, + dataImage.getWidth(), + dataImage.getHeight()); + switch(error) { + case BadDrawable: + GALE_ERROR("WAYLAND: BadDrawable"); + break; + case BadGC: + GALE_ERROR("WAYLAND: BadGC"); + break; + case BadMatch: + GALE_ERROR("WAYLAND: BadMatch"); + break; + case BadValue: + GALE_ERROR("WAYLAND: BadValue"); + break; + default: + GALE_DEBUG("insert image OK"); + break; + } + // allocate a WM hints structure. + XWMHints* win_hints = XAllocWMHints(); + if (win_hints == nullptr) { + GALE_ERROR("XAllocWMHints - out of memory"); + return; + } + // initialize the structure appropriately. first, specify which size hints we want to fill in. in our case - setting the icon's pixmap. + win_hints->flags = IconPixmapHint; + // next, specify the desired hints data. in our case - supply the icon's desired pixmap. + win_hints->icon_pixmap = tmpPixmap; + // pass the hints to the window manager. + XSetWMHints(m_display, m_WindowHandle, win_hints); + GALE_INFO(" == > might be done "); + // finally, we can free the WM hints structure. + XFree(win_hints); + + // Note when we free the pixmap ... the icon is removed ... == > this is a real memory leek ... + //XFreePixmap(m_display, tmpPixmap); + + myImage->data = nullptr; + XDestroyImage(myImage); + delete[] tmpVal; + #endif + */ + } + /****************************************************************************************/ + bool createOGlContext() { + #if 0 + WAYLAND_INFO("WAYLAND:CreateOGlContext"); + #if defined(__TARGET_OS__Web) + /* create a GLX context */ + GContext RenderContext = wglCreateContext(m_display, 0, GL_TRUE); + /* connect the glx-context to the window */ + wglMakeCurrent(m_display, m_WindowHandle, RenderContext); + if (glwIsDirect(m_display, RenderContext)) { + GALE_INFO("XF86 DRI enabled\n"); + } else { + GALE_INFO("XF86 DRI NOT available\n"); + } + #else + /* create a GLX context */ + GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); + /* connect the glx-context to the window */ + glXMakeCurrent(m_display, m_WindowHandle, RenderContext); + if (glXIsDirect(m_display, RenderContext)) { + GALE_INFO("XF86 DRI enabled\n"); + } else { + GALE_INFO("XF86 DRI NOT available\n"); + } + #endif + // enable vertical synchronisation : (some computer has synchronisation disable) + setVSync(true); + #endif + return true; + } + /****************************************************************************************/ + void setTitle(const std::string& _title) { + WAYLAND_INFO("WAYLAND: set Title (START)"); + /* + XTextProperty tp; + tp.value = (unsigned char *)_title.c_str(); + tp.encoding = XA_WM_NAME; + tp.format = 8; + tp.nitems = strlen((const char*)tp.value); + XSetWMName(m_display, m_WindowHandle, &tp); + XStoreName(m_display, m_WindowHandle, (const char*)tp.value); + XSetIconName(m_display, m_WindowHandle, (const char*)tp.value); + XSetWMIconName(m_display, m_WindowHandle, &tp); + */ + WAYLAND_INFO("WAYLAND: set Title (END)"); + } + void openURL(const std::string& _url) { + std::string req = "xdg-open "; + req += _url; + system(req.c_str()); + return; + } + /****************************************************************************************/ + void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) { + /* + switch (_clipboardID) { + case gale::context::clipBoard::clipboardSelection: + if (m_clipBoardOwnerPrimary == false) { + m_clipBoardRequestPrimary = true; + // generate a request on WAYLAND + XConvertSelection(m_display, + XAtomSelection, + XAtomTargetStringUTF8, + XAtomGALE, + m_WindowHandle, + CurrentTime); + } else { + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(_clipboardID); + } + break; + case gale::context::clipBoard::clipboardStd: + if (m_clipBoardOwnerStd == false) { + m_clipBoardRequestPrimary = false; + // generate a request on WAYLAND + XConvertSelection(m_display, + XAtomClipBoard, + XAtomTargetStringUTF8, + XAtomGALE, + m_WindowHandle, + CurrentTime); + } else { + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(_clipboardID); + } + break; + default: + GALE_ERROR("Request an unknow ClipBoard ..."); + break; + } + */ + } + /****************************************************************************************/ + void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) { + /* + switch (_clipboardID) { + case gale::context::clipBoard::clipboardSelection: + // Request the selection : + if (m_clipBoardOwnerPrimary == false) { + XSetSelectionOwner(m_display, XAtomSelection, m_WindowHandle, CurrentTime); + m_clipBoardOwnerPrimary = true; + } + break; + case gale::context::clipBoard::clipboardStd: + // Request the clipBoard : + if (m_clipBoardOwnerStd == false) { + XSetSelectionOwner(m_display, XAtomClipBoard, m_WindowHandle, CurrentTime); + m_clipBoardOwnerStd = true; + } + break; + default: + GALE_ERROR("Request an unknow ClipBoard ..."); + break; + } + */ + } +}; + + +static void global_registry_handler(void* _data, struct wl_registry* _registry, uint32_t _id, const char* _interface, uint32_t _version) { + WAYLANDInterface* interface = (WAYLANDInterface*)_data; + if (interface == nullptr) { + return; + } + interface->registryHandler(_registry, _id, _interface, _version); +} + +static void global_registry_remover(void* _data, struct wl_registry* _registry, uint32_t _id) { + WAYLANDInterface* interface = (WAYLANDInterface*)_data; + if (interface == nullptr) { + return; + } + interface->registryRemover(_registry, _id); +} + + +/** + * @brief Main of the program + * @param std IO + * @return std IO + */ +int gale::run(gale::Application* _application, int _argc, const char *_argv[]) { + etk::init(_argc, _argv); + WAYLANDInterface* interface = new WAYLANDInterface(_application, _argc, _argv); + if (interface == nullptr) { + GALE_CRITICAL("Can not create the WAYLAND interface ... MEMORY allocation error"); + return -2; + } + int32_t retValue = interface->run(); + delete(interface); + interface = nullptr; + return retValue; +} diff --git a/lutin_gale.py b/lutin_gale.py index 1135caa..5e65a5f 100644 --- a/lutin_gale.py +++ b/lutin_gale.py @@ -64,7 +64,11 @@ def configure(target, my_module): if "Web" in target.get_type(): my_module.add_src_file('gale/context/SDL/Context.cpp') elif "Linux" in target.get_type(): - my_module.add_src_file('gale/context/X11/Context.cpp') + # TODO : Do it better ... + if False: + my_module.add_src_file('gale/context/X11/Context.cpp') + else: + my_module.add_src_file('gale/context/wayland/Context.cpp') # check if egami is present in the worktree: this is for the icon parsing ... my_module.add_optionnal_depend('egami', ["c++", "-DGALE_BUILD_EGAMI"]) elif "Windows" in target.get_type(): @@ -157,7 +161,14 @@ def configure(target, my_module): "SDL" ]) elif "Linux" in target.get_type(): - pass + if False: + my_module.add_depend("X11") + else: + my_module.add_depend([ + 'wayland', + 'egl', + 'gles2' + ]) elif "Android" in target.get_type(): my_module.add_depend(["SDK", "jvm-basics"]) # add tre creator of the basic java class ... diff --git a/sample/basic.cpp b/sample/basic.cpp index 8969dd8..39e9364 100644 --- a/sample/basic.cpp +++ b/sample/basic.cpp @@ -98,7 +98,7 @@ class MainApplication : public gale::Application { mat4 tmpMatrix = projMatrix * camMatrix; m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); - #if 0 + #if 1 // position: m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, GALE_SAMPLE_VBO_VERTICES); // color: