|
@@ -28,7 +28,7 @@
|
|
|
#include <math.h>
|
|
|
#include <time.h>
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
#include <execinfo.h>
|
|
|
#include <signal.h>
|
|
|
#include <sys/time.h>
|
|
@@ -50,6 +50,9 @@
|
|
|
#include <GL/wgl.h>
|
|
|
#include <shellscalingapi.h>
|
|
|
#endif
|
|
|
+#ifdef LAGUI_ANDROID
|
|
|
+#include <GLES3/gl3.h>
|
|
|
+#endif
|
|
|
|
|
|
LA MAIN;
|
|
|
|
|
@@ -66,14 +69,14 @@ laColumn *DEBUG_C;
|
|
|
#define LA_GUI_WNDCLASS_NAME "NUL4_GUI_CLASS"
|
|
|
#endif
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);\
|
|
|
typedef void (*glXSwapIntervalEXTProc)(Display *dpy, GLXDrawable drawable, int interval);
|
|
|
glXCreateContextAttribsARBProc glXCreateContextAttribsF;
|
|
|
glXSwapIntervalEXTProc glXSwapIntervalEXTF;
|
|
|
#endif
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
static void la_PrintWacomValuators(Display *display, XIAnyClassInfo **classes, int num_classes){
|
|
|
int i;
|
|
|
for (i = 0; i < num_classes; i++) {
|
|
@@ -440,7 +443,7 @@ void la_DestroySystemWindowWin32(laWindow* w) {
|
|
|
};
|
|
|
#endif
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
void la_HandlerSIGSEGV(int sig) {
|
|
|
void *array[30];
|
|
|
size_t sz;
|
|
@@ -454,6 +457,7 @@ void la_HandlerSIGSEGV(int sig) {
|
|
|
|
|
|
void la_glDebugOutput(GLenum source, GLenum type, unsigned int id,
|
|
|
GLenum severity, GLsizei length, const char* message, const void* userParam) {
|
|
|
+#ifndef LAGUI_ANDROID
|
|
|
// ignore non-significant error/warning codes
|
|
|
if (id==131169 || id==131185 || id==131218 || id==131204 || id==131076) return;
|
|
|
|
|
@@ -489,9 +493,11 @@ void la_glDebugOutput(GLenum source, GLenum type, unsigned int id,
|
|
|
case GL_DEBUG_SEVERITY_NOTIFICATION: strseverity = "Notification"; break;
|
|
|
}
|
|
|
logPrint("%s | %s | %s\n\n", strsource,strtype,strseverity);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void la_SetCurrentGLContextDebug(){
|
|
|
+#ifndef LAGUI_ANDROID
|
|
|
int force=MAIN.InitArgs.GLDebug;
|
|
|
if(MAIN.EnableGLDebug || force){ glEnable(GL_DEBUG_OUTPUT); }else{ glDisable(GL_DEBUG_OUTPUT); }
|
|
|
if(MAIN.GLDebugSync || force){ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); }else{ glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); }
|
|
@@ -507,6 +513,7 @@ void la_SetCurrentGLContextDebug(){
|
|
|
}
|
|
|
}
|
|
|
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, sev, 0, 0, GL_TRUE);
|
|
|
+#endif
|
|
|
}
|
|
|
void la_NotifyGLDebugChanges(){
|
|
|
MAIN.GLDebugNeedsUpdate=1; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->GLDebugNeedsUpdate=1; }
|
|
@@ -522,13 +529,16 @@ void la_SetupWindowGLStates(laWindow* w){
|
|
|
|
|
|
int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
SYSGLCONTEXT glc;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
void* egl_surf=0;
|
|
|
#ifdef LA_USE_GLES
|
|
|
egl_surf=&window->egl_surf;
|
|
|
#endif
|
|
|
SYSWINDOW hwnd = la_CreateWindowX11(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc, egl_surf);
|
|
|
#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ SYSWINDOW hwnd = la_CreateWindowWin32(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
|
|
|
+#endif
|
|
|
#ifdef _WIN32
|
|
|
SYSWINDOW hwnd = la_CreateWindowWin32(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
|
|
|
#endif
|
|
@@ -542,7 +552,7 @@ int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
window->CW = rc.right - rc.left;
|
|
|
window->CH = rc.bottom - rc.top;
|
|
|
#endif
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XWindowAttributes attr;
|
|
|
XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
window->CW =attr.width;
|
|
@@ -571,7 +581,7 @@ int la_DestroySystemWindow(laWindow* wnd){
|
|
|
#else
|
|
|
nvgDeleteGL3(wnd->nvg);
|
|
|
#endif
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
la_DestroySystemWindowX11(wnd);
|
|
|
#endif
|
|
|
#ifdef _WIN32
|
|
@@ -615,7 +625,7 @@ void laRenameWindow(laWindow* wnd, char* name){
|
|
|
if((!wnd)||MAIN.IsReadingUDF) return;
|
|
|
strSafeSet(&wnd->Title, name);
|
|
|
if(!wnd->win) return;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XStoreName(MAIN.dpy, wnd->win, name);
|
|
|
#endif
|
|
|
#ifdef _WIN32
|
|
@@ -624,7 +634,7 @@ void laRenameWindow(laWindow* wnd, char* name){
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
const char* la_ConvertCursorID(int id){
|
|
|
switch (id) {
|
|
|
case LA_ARROW: return "arrow";
|
|
@@ -731,7 +741,7 @@ laScreen* laGetWindowScreen(laWindow* w){
|
|
|
return maxs;
|
|
|
}
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
int la_GetDPI(Window* root_win){
|
|
|
XRRScreenResources *screen;
|
|
|
XRROutputInfo *info;
|
|
@@ -793,7 +803,7 @@ void laShowProgress(real p1, real p2){
|
|
|
memcpy(&MAIN.Progress.TimeCalled,&tm,sizeof(laTimeRecorder));
|
|
|
if(!MAIN.Progress.Shown){
|
|
|
int ww=PROGRESSW+LA_RH*2;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
int w=XDisplayWidth(MAIN.dpy, 0),h=XDisplayHeight(MAIN.dpy, 0);
|
|
|
XMoveResizeWindow(MAIN.dpy,MAIN.Progress.w,w/2-ww/2,h/2-LA_RH*2/2,ww,LA_RH*2);
|
|
|
long a=LA_COLOR3_TO_HEX(bg);
|
|
@@ -812,7 +822,7 @@ void laShowProgress(real p1, real p2){
|
|
|
}
|
|
|
}
|
|
|
if(p1>=0) MAIN.Progress.p1=p1; if(p2>=0) MAIN.Progress.p2=p2;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XClearWindow(MAIN.dpy,MAIN.Progress.w);
|
|
|
XFillRectangle(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,LA_RH*2,0,PROGRESSW*MAIN.Progress.p1,LA_RH);
|
|
|
XFillRectangle(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,LA_RH*2,LA_RH,PROGRESSW*MAIN.Progress.p2,LA_RH);
|
|
@@ -850,7 +860,7 @@ void laHideProgress(){
|
|
|
real t=laTimeElapsedSecondsf(&tm,&MAIN.Progress.TimeCalled);
|
|
|
if(t<0.2){ usleep((TNS_MIN2(0.2-t,0.2))*1000000); }
|
|
|
MAIN.Progress.Called = MAIN.Progress.Shown = 0;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XUnmapWindow(MAIN.dpy,MAIN.Progress.w); XSync(MAIN.dpy, 1); XFlush(MAIN.dpy);
|
|
|
#endif
|
|
|
#ifdef _WIN32
|
|
@@ -863,7 +873,7 @@ void laHideProgress(){
|
|
|
//=======================
|
|
|
|
|
|
void la_InitProgressWindow(){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
MAIN.Progress.w=XCreateSimpleWindow(MAIN.dpy, RootWindow(MAIN.dpy, 0), 0, 0, PROGRESSW+LA_RH*2, LA_RH*2, 0, BlackPixel(MAIN.dpy, 0), WhitePixel(MAIN.dpy, 0));
|
|
|
if(!MAIN.Progress.w) return;
|
|
|
Atom window_type = XInternAtom(MAIN.dpy, "_NET_WM_WINDOW_TYPE", False); long value = XInternAtom(MAIN.dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
|
|
@@ -938,7 +948,7 @@ void laProcessInitArguments(int argc, char* argv[],laInitArguments* ia) {
|
|
|
}
|
|
|
}
|
|
|
int laGetReadyWith(laInitArguments* ia){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
//signal(SIGSEGV,la_HandlerSIGSEGV);
|
|
|
#endif
|
|
|
|
|
@@ -952,7 +962,7 @@ int laGetReadyWith(laInitArguments* ia){
|
|
|
|
|
|
tnsInit();
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
SYSWINDOW root, win;
|
|
|
GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
|
|
XSetWindowAttributes swa={0};
|
|
@@ -1189,7 +1199,7 @@ int laGetReadyWith(laInitArguments* ia){
|
|
|
#ifdef _WIN32
|
|
|
int dpi=la_GetDPI(hwnd);
|
|
|
#endif
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
int dpi = la_GetDPI(DefaultRootWindow(MAIN.dpy));
|
|
|
#endif
|
|
|
if((!dpi) || dpi<144){ dpi=144; } if(dpi>300){ dpi=300; }
|
|
@@ -1360,7 +1370,7 @@ void laShutoff(int SavePrefereces){
|
|
|
|
|
|
tnsBindVertexArray(0); glDeleteVertexArrays(1,&MAIN.TempVAO);
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
tnsContextMakeCurrent(0,0,0);
|
|
|
tnsDeleteContext(MAIN.glc);
|
|
|
#ifdef LA_USE_GLES
|
|
@@ -1723,7 +1733,7 @@ void la_CommandResizeWindow(SYSWINDOW hwnd, int x, int y, int w, int h){
|
|
|
if (s) { window->OutputColorSpace = s->ColorSpace; }
|
|
|
}
|
|
|
#endif
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XWindowAttributes attr;
|
|
|
XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
window->CW = w; window->CH = h;
|
|
@@ -1755,7 +1765,7 @@ int la_OnWindowDestroy(SYSWINDOW wnd){
|
|
|
la_DestroyWindow(w);
|
|
|
|
|
|
int done=0; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
if(done) glXSwapIntervalEXTF(MAIN.dpy, w->win, 0);
|
|
|
else { glXSwapIntervalEXTF(MAIN.dpy, w->win, 1); done = 1; }
|
|
|
#endif
|
|
@@ -1769,7 +1779,7 @@ void la_MakeSpecialKeyBit(SYSWINDOW hwnd,laWindow*wnd,laEvent *e,int use_last_po
|
|
|
laListHandle *el = &wnd->EventList;
|
|
|
laEvent* last_e=el->pLast;
|
|
|
SYSWINDOW root_ret, win_ret; int rrx=0,rry=0,rx=e->x,ry=e->y,rmask=0;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XQueryPointer(MAIN.dpy, wnd->win, &root_ret,&win_ret,&rrx,&rry,&rx,&ry,&rmask);
|
|
|
e->SpecialKeyBit = ((rmask&ShiftMask)?LA_KEY_SHIFT:0)|((rmask&ControlMask)?LA_KEY_CTRL:0)|((rmask&Mod1Mask)?LA_KEY_ALT:0);
|
|
|
#endif
|
|
@@ -1819,7 +1829,7 @@ void laSendOperatorTriggerEvent(){
|
|
|
MAIN.ReTriggerOperators = 0;
|
|
|
}
|
|
|
int la_TranslateSpecialKey(int keysym){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
switch(keysym){
|
|
|
case XK_Return: return LA_KEY_ENTER;
|
|
|
case XK_BackSpace: return LA_KEY_BACKSPACE;
|
|
@@ -2990,7 +3000,7 @@ void la_WindowDefDraw(laWindow *w, laBoxedTheme *bt){
|
|
|
}
|
|
|
}
|
|
|
int laStartWindow(laWindow *w){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XMapWindow(MAIN.dpy,w->win);
|
|
|
tnsContextMakeWindowCurrent(w);
|
|
|
#endif
|
|
@@ -3031,7 +3041,7 @@ laWindow *laDesignWindow(int X, int Y, int W, int H){
|
|
|
}
|
|
|
void laSetWindowCursor(int id){
|
|
|
MAIN.CurrentCursor = id;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
Cursor c = XcursorLibraryLoadCursor(MAIN.dpy, la_ConvertCursorID(id));
|
|
|
XDefineCursor(MAIN.dpy, MAIN.CurrentWindow->win, c);
|
|
|
#endif
|
|
@@ -7421,7 +7431,7 @@ void laFinalizeOperators(){
|
|
|
|
|
|
//=================
|
|
|
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
static void la_RecordWacomMotions(XIRawEvent *event)
|
|
|
{
|
|
|
double *valuator = event->valuators.values;
|
|
@@ -7765,7 +7775,7 @@ int la_AllowInput(uint32_t ch){
|
|
|
return 0;
|
|
|
}
|
|
|
int laCopyToClipboard(unsigned char * text){
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XEvent event; SYSWINDOW owner, window=MAIN.CurrentWindow->win;
|
|
|
XSetSelectionOwner(MAIN.dpy, MAIN.selection, window, 0);
|
|
|
if (XGetSelectionOwner (MAIN.dpy, MAIN.selection) != window) return 0;
|
|
@@ -7776,7 +7786,7 @@ int la_ProcessSysMessage(){
|
|
|
int SendDelay = 0, SendIdle = 0;
|
|
|
if (!MAIN.DelayTriggered && MAIN.TimeAccum - MAIN.DelayStart > MAIN.DelayTime) SendDelay = 1;
|
|
|
if (!MAIN.IdleTriggered && MAIN.TimeAccum - MAIN.IdleStart > MAIN.IdleTime) SendIdle = 1;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
XEvent e;
|
|
|
int type;
|
|
|
|
|
@@ -7990,7 +8000,7 @@ void laMainLoop(){
|
|
|
}
|
|
|
for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
if(!w->RedrawTouched) continue; w->RedrawTouched=0;
|
|
|
-#ifdef __linux__
|
|
|
+#ifdef LA_LINUX
|
|
|
#ifdef LA_USE_GLES
|
|
|
eglSwapBuffers(MAIN.egl_dpy, w->egl_surf);
|
|
|
#else
|