|
@@ -22,6 +22,7 @@
|
|
|
#include <stdlib.h>
|
|
|
#include <math.h>
|
|
|
#include <time.h>
|
|
|
+#ifdef __linux__
|
|
|
#include <sys/time.h>
|
|
|
#include <X11/Xlib.h>
|
|
|
#include <X11/Xutil.h>
|
|
@@ -34,8 +35,11 @@
|
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
|
#include <X11/cursorfont.h>
|
|
|
#include <GL/glx.h>
|
|
|
-
|
|
|
-
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+#include <GL/wglew.h>
|
|
|
+#include <GL/wgl.h>
|
|
|
+#endif
|
|
|
|
|
|
LA MAIN;
|
|
|
|
|
@@ -48,13 +52,15 @@ laColumn *DEBUG_C;
|
|
|
|
|
|
#define LA_GUI_WNDCLASS_NAME "NUL4_GUI_CLASS"
|
|
|
|
|
|
+#ifdef __linux__
|
|
|
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
|
|
typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext);
|
|
|
typedef void (*glXSwapIntervalEXTProc)(Display *dpy, GLXDrawable drawable, int interval);
|
|
|
-
|
|
|
glXCreateContextAttribsARBProc glXCreateContextAttribsF;
|
|
|
glXSwapIntervalEXTProc glXSwapIntervalEXTF;
|
|
|
+#endif
|
|
|
|
|
|
+#ifdef __linux__
|
|
|
static void la_PrintWacomValuators(Display *display, XIAnyClassInfo **classes, int num_classes){
|
|
|
int i;
|
|
|
for (i = 0; i < num_classes; i++) {
|
|
@@ -156,15 +162,15 @@ void la_XErrorHandler(Display *display, XErrorEvent *event){
|
|
|
printf("X Error:\n%s\n",buf);
|
|
|
}
|
|
|
|
|
|
-Window la_CreateWindowX11(int x, int y, int w, int h, char *title, int SyncToVBlank, GLXContext* r_glc){
|
|
|
+SYSWINDOW la_CreateWindowX11(int x, int y, int w, int h, char *title, int SyncToVBlank, GLXContext* r_glc){
|
|
|
XSetWindowAttributes swa;
|
|
|
XWindowAttributes wa;
|
|
|
swa.event_mask =
|
|
|
KeyPressMask|KeyReleaseMask|StructureNotifyMask|SubstructureNotifyMask|
|
|
|
ButtonMotionMask|ButtonPressMask|ButtonReleaseMask|ExposureMask|PointerMotionMask;
|
|
|
swa.colormap = MAIN.cmap;
|
|
|
- Window root = DefaultRootWindow(MAIN.dpy);
|
|
|
- Window win = XCreateWindow(MAIN.dpy, root, x,y, w, h, 0, MAIN.xvi->depth, InputOutput, MAIN.xvi->visual, CWColormap | CWEventMask, &swa);
|
|
|
+ SYSWINDOW root = DefaultRootWindow(MAIN.dpy);
|
|
|
+ SYSWINDOW win = XCreateWindow(MAIN.dpy, root, x,y, w, h, 0, MAIN.xvi->depth, InputOutput, MAIN.xvi->visual, CWColormap | CWEventMask, &swa);
|
|
|
XSetWMProtocols(MAIN.dpy , win, &MAIN.MsgDelWindow, 1);
|
|
|
|
|
|
if(x>0||y>0){
|
|
@@ -211,37 +217,133 @@ Window la_CreateWindowX11(int x, int y, int w, int h, char *title, int SyncToVBl
|
|
|
|
|
|
return win;
|
|
|
};
|
|
|
-int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
- GLXContext glc;
|
|
|
- Window hwnd = la_CreateWindowX11(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
|
|
|
- window->win = hwnd;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+void la_DestroySystemWindowX11(laWindow* w) {
|
|
|
+ glXMakeCurrent(MAIN.dpy, None, NULL);
|
|
|
+ glXDestroyContext(MAIN.dpy, w->glc);
|
|
|
+ XDestroyWindow(MAIN.dpy, w->win);
|
|
|
+};
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+void laHideCursor() {
|
|
|
+ if (!MAIN.CurrentWindow) return;
|
|
|
+}
|
|
|
+void laShowCursor() {
|
|
|
+ if (!MAIN.CurrentWindow) return;
|
|
|
+}
|
|
|
+static PIXELFORMATDESCRIPTOR cpfd = {
|
|
|
+ sizeof(PIXELFORMATDESCRIPTOR),1,
|
|
|
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SWAP_COPY | PFD_DOUBLEBUFFER,
|
|
|
+ PFD_TYPE_RGBA,
|
|
|
+ 8,
|
|
|
+ 0, 0, 0, 0, 0, 0,
|
|
|
+ 0, 0, 0,
|
|
|
+ 0, 0, 0, 0,
|
|
|
+ 32,
|
|
|
+ 8, 0,
|
|
|
+ 0,
|
|
|
+ 0, 0, 0, 0
|
|
|
+};
|
|
|
+void la_SetupPxlFormat(HDC hdc, int* nRegularFormat, int* nMSFormat) {
|
|
|
+ int nBestMS = 0;
|
|
|
+ int i;
|
|
|
+ int iResults[9];
|
|
|
+ int iAttributes[9] = { WGL_SUPPORT_OPENGL_ARB,
|
|
|
+ WGL_ACCELERATION_ARB,
|
|
|
+ WGL_DRAW_TO_WINDOW_ARB,
|
|
|
+ WGL_DOUBLE_BUFFER_ARB,
|
|
|
+ WGL_PIXEL_TYPE_ARB,
|
|
|
+ WGL_DEPTH_BITS_ARB,
|
|
|
+ WGL_STENCIL_BITS_ARB,
|
|
|
+ WGL_SAMPLE_BUFFERS_ARB,
|
|
|
+ WGL_SAMPLES_ARB };
|
|
|
+
|
|
|
+
|
|
|
+ int nFormatCount[] = { 0 };
|
|
|
+ int attrib[] = { WGL_NUMBER_PIXEL_FORMATS_ARB };
|
|
|
+
|
|
|
+ if (!wglGetPixelFormatAttribivARB)
|
|
|
+ wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
|
|
|
+ wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
|
|
+
|
|
|
+ wglGetPixelFormatAttribivARB(hdc, 1, 0, 1, attrib, nFormatCount);
|
|
|
+
|
|
|
+ for (i = 0; i < nFormatCount[0]; i++){
|
|
|
+ wglGetPixelFormatAttribivARB(hdc, i + 1, 0, 9, iAttributes, iResults);
|
|
|
+ if (iResults[0] == 1 && iResults[1] == WGL_FULL_ACCELERATION_ARB && iResults[2] == 1)
|
|
|
+ if (iResults[3] == 1)
|
|
|
+ if (iResults[4] == WGL_TYPE_RGBA_ARB)
|
|
|
+ if (iResults[5] >= 24)
|
|
|
+ if (iResults[6] > 0) { *nRegularFormat = i; break; }
|
|
|
+ }
|
|
|
+ SetPixelFormat(hdc, *nRegularFormat, &cpfd);
|
|
|
+};
|
|
|
+void la_SetupGLEnviornment(laWindow* window, HWND hwnd) {
|
|
|
+ GLint Attrib[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, MAIN.GLMajor,
|
|
|
+ WGL_CONTEXT_MINOR_VERSION_ARB, MAIN.GLMinor,
|
|
|
+ WGL_CONTEXT_PROFILE_MASK_ARB,WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
|
|
+
|
|
|
+ 0 };
|
|
|
+ HGLRC hglrc = 0;
|
|
|
+ HDC hdc = 0;
|
|
|
+ int a, b;
|
|
|
+
|
|
|
+ hdc = GetDC(hwnd);
|
|
|
+ la_SetupPxlFormat(hdc, &a, &b);
|
|
|
+
|
|
|
+ wglMakeCurrent(0, 0);
|
|
|
+ hglrc = wglCreateContextAttribsARB(hdc, MAIN.glc, Attrib);
|
|
|
+
|
|
|
+ if (!hglrc) SEND_PANIC_ERROR("Can't Create Opengl Context!\n", );
|
|
|
+
|
|
|
+
|
|
|
+ wglMakeCurrent(hdc, hglrc);
|
|
|
+
|
|
|
+ window->win = hwnd; window->glc = hglrc; window->hdc = hdc;
|
|
|
+};
|
|
|
+SYSWINDOW la_CreateWindowWin32(int x, int y, int w, int h, char* title, int SyncToVBlank, SYSGLCONTEXT* r_glc) {
|
|
|
+ HINSTANCE* inst = &MAIN.hinstance;
|
|
|
+ HWND hwnd = CreateWindow(LA_GUI_WNDCLASS_NAME, title, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
|
|
+ x, y, w, h, 0, 0, *inst, 0);
|
|
|
+ if (!hwnd) { int a = GetLastError(); printf("%d", a); return 0; }
|
|
|
|
|
|
-
|
|
|
+ return hwnd;
|
|
|
+};
|
|
|
+void la_DestroySystemWindowWin32(laWindow* w) {
|
|
|
+ wglDeleteContext(w->glc);
|
|
|
+ ReleaseDC(w->win, w->hdc);
|
|
|
+};
|
|
|
+#endif
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
+ SYSGLCONTEXT glc;
|
|
|
+#ifdef __linux__
|
|
|
+ SYSWINDOW hwnd = la_CreateWindowX11(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
|
|
|
+ window->win = hwnd;
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
+ la_SetupGLEnviornment(window, hwnd);
|
|
|
+ RECT rc; GetClientRect(window->win, &rc);
|
|
|
+ window->CW = rc.right - rc.left;
|
|
|
+ window->CH = rc.bottom - rc.top;
|
|
|
+#endif
|
|
|
+#ifdef __linux__
|
|
|
XWindowAttributes attr;
|
|
|
XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
window->CW =attr.width;
|
|
|
window->CH = attr.height;
|
|
|
window->glc = glc;
|
|
|
+#endif
|
|
|
return 1;
|
|
|
};
|
|
|
-void la_DestroySystemWindowX11(laWindow* w){
|
|
|
- glXMakeCurrent(MAIN.dpy, None, NULL);
|
|
|
- glXDestroyContext(MAIN.dpy, w->glc);
|
|
|
- XDestroyWindow(MAIN.dpy, w->win);
|
|
|
-};
|
|
|
+
|
|
|
int la_DestroySystemWindow(laWindow* wnd){
|
|
|
+#ifdef __linux__
|
|
|
la_DestroySystemWindowX11(wnd);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void la_DestroyWindow(laWindow *wnd){
|
|
@@ -270,7 +372,9 @@ void laRenameWindow(laWindow* wnd, char* name){
|
|
|
if(!wnd) return;
|
|
|
strSafeSet(&wnd->Title, name);
|
|
|
if(!wnd->win) return;
|
|
|
+#ifdef __linux__
|
|
|
XStoreName(MAIN.dpy, wnd->win, name);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
const char* la_ConvertCursorID(int id){
|
|
@@ -286,7 +390,6 @@ const char* la_ConvertCursorID(int id){
|
|
|
return "arrow";
|
|
|
}
|
|
|
|
|
|
-void la_MakePanelTitleBar(laPanel *p, laUiDefineFunc ReplaceDefine);
|
|
|
void la_InitThreadEnviornment(){
|
|
|
|
|
|
}
|
|
@@ -328,9 +431,11 @@ void logClear(){
|
|
|
while(l=lstPopItem(&MAIN.Logs)){ strSafeDestroy(&l->Content); memFree(l); }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
#define PROGRESSW (LA_RH*15)
|
|
|
|
|
|
void laShowProgress(real p1, real p2){
|
|
|
+#ifdef __linux__
|
|
|
laBoxedTheme *bt = _LA_THEME_TAB; real* fg=laThemeColor(bt,LA_BT_TEXT); real* bg=laThemeColor(bt,LA_BT_NORMAL);
|
|
|
if(!MAIN.Progress.Called){
|
|
|
laRecordTime(&MAIN.Progress.TimeCalled); MAIN.Progress.Called=1;
|
|
@@ -357,8 +462,10 @@ void laShowProgress(real p1, real p2){
|
|
|
tnsDrawLCD7_ProgressX11(LA_RH*1.5,0,MAIN.Progress.p1);
|
|
|
tnsDrawLCD7_ProgressX11(LA_RH*1.5,LA_RH,MAIN.Progress.p2);
|
|
|
XSync(MAIN.dpy, 1); XFlush(MAIN.dpy);
|
|
|
+#endif
|
|
|
}
|
|
|
void laHideProgress(){
|
|
|
+#ifdef __linux__
|
|
|
if(!MAIN.Progress.Shown){
|
|
|
MAIN.Progress.Called=0; return;
|
|
|
}
|
|
@@ -367,11 +474,13 @@ void laHideProgress(){
|
|
|
if(t<0.2){ usleep((TNS_MIN2(0.2-t,0.2))*1000000); }
|
|
|
XUnmapWindow(MAIN.dpy,MAIN.Progress.w); XSync(MAIN.dpy, 1); XFlush(MAIN.dpy);
|
|
|
MAIN.Progress.Called = MAIN.Progress.Shown = 0;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void la_InitProgressWindow(){
|
|
|
+#ifdef __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);
|
|
@@ -381,6 +490,7 @@ void la_InitProgressWindow(){
|
|
|
XSetFillStyle(MAIN.dpy, MAIN.Progress.gc, FillSolid);
|
|
|
XSetLineAttributes(MAIN.dpy, MAIN.Progress.gc, 2, LineSolid, CapButt, JoinBevel);
|
|
|
XSync(MAIN.dpy,0);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void laSetFontFolderPath(char* absolute){
|
|
@@ -389,7 +499,8 @@ void laSetFontFolderPath(char* absolute){
|
|
|
}
|
|
|
|
|
|
int laGetReadyWith(int GLMajor, int GLMinor, int BufferSamples){
|
|
|
- Window root, win;
|
|
|
+#ifdef __linux__
|
|
|
+ SYSWINDOW root, win;
|
|
|
GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
|
|
XSetWindowAttributes swa={0};
|
|
|
XWindowAttributes wa={0};
|
|
@@ -488,6 +599,74 @@ int laGetReadyWith(int GLMajor, int GLMinor, int BufferSamples){
|
|
|
MAIN.wmstate=XInternAtom(MAIN.dpy,"_NET_WM_STATE",1);
|
|
|
MAIN.wmfullscr=XInternAtom(MAIN.dpy,"_NET_WM_STATE_FULLSCREEN",0);
|
|
|
MAIN.wmfullscroff=XInternAtom(MAIN.dpy,"_NET_WM_STATE_FULLSCREEN",0);
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ MAIN.hinstance = GetModuleHandle(NULL);
|
|
|
+
|
|
|
+ HINSTANCE* hInst = &MAIN.hinstance;
|
|
|
+ WNDCLASSEX wt;
|
|
|
+ wt.cbSize = sizeof(WNDCLASSEX);
|
|
|
+ wt.cbClsExtra = 0;
|
|
|
+ wt.cbWndExtra = 0;
|
|
|
+ wt.hbrBackground = 0;
|
|
|
+ wt.hCursor = LoadCursor(*hInst, IDC_ARROW);
|
|
|
+ wt.hIcon = LoadIcon(*hInst, IDI_WINLOGO);
|
|
|
+ wt.hIconSm = LoadIcon(*hInst, IDI_WINLOGO);
|
|
|
+ wt.hInstance = *hInst;
|
|
|
+ wt.lpfnWndProc = LA_WindowProc;
|
|
|
+ wt.lpszClassName = LA_GUI_WNDCLASS_NAME;
|
|
|
+ wt.lpszMenuName = 0;
|
|
|
+ wt.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
|
+ if (!RegisterClassEx(&wt)) return 0;
|
|
|
+
|
|
|
+ MAIN.GLMajor = GLMajor; MAIN.GLMinor = GLMinor; MAIN.BufferSamples = BufferSamples;
|
|
|
+
|
|
|
+ GLenum err;
|
|
|
+ PIXELFORMATDESCRIPTOR pfd;
|
|
|
+ HINSTANCE* hinst = &MAIN.hinstance;
|
|
|
+ HWND hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, LA_GUI_WNDCLASS_NAME,
|
|
|
+ "Temp Window For Accessing GLEW!",
|
|
|
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 100, 100,
|
|
|
+ 0, 0, *hinst, 0);
|
|
|
+ HDC hdc = GetDC(hwnd);
|
|
|
+ HGLRC hglrc = 0;
|
|
|
+
|
|
|
+ SetPixelFormat(hdc, 1, &cpfd);
|
|
|
+ hglrc = wglCreateContext(hdc);
|
|
|
+ wglMakeCurrent(hdc, hglrc);
|
|
|
+
|
|
|
+
|
|
|
+ MAIN.glc = hglrc;
|
|
|
+
|
|
|
+ if (err = glewInit()) {
|
|
|
+ printf("Init Glew Failed\n");
|
|
|
+ printf("glewGetErrorString: %s\n", glewGetErrorString(err));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ wglMakeCurrent(0, 0);
|
|
|
+ wglDeleteContext(MAIN.glc);
|
|
|
+ ReleaseDC(hwnd, hdc);
|
|
|
+ DestroyWindow(hwnd);
|
|
|
+
|
|
|
+ int a, b;
|
|
|
+ hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, LA_GUI_WNDCLASS_NAME,
|
|
|
+ "Temp Window For Accessing GLEW!",
|
|
|
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 100, 100,
|
|
|
+ 0, 0, *hinst, 0);
|
|
|
+ hdc = GetDC(hwnd);
|
|
|
+ la_SetupPxlFormat(hdc, &a, &b);
|
|
|
+ GLint Attrib[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, MAIN.GLMajor,
|
|
|
+ WGL_CONTEXT_MINOR_VERSION_ARB, MAIN.GLMinor,
|
|
|
+ WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0};
|
|
|
+ hglrc = wglCreateContextAttribsARB(hdc, 0, Attrib);
|
|
|
+
|
|
|
+ if (!hglrc) SEND_PANIC_ERROR("Can't Create Opengl Context!\n", );
|
|
|
+ MAIN.glc = hglrc;
|
|
|
+ MAIN.hdc = hdc;
|
|
|
+ wglMakeCurrent(hdc, hglrc);
|
|
|
+
|
|
|
+#endif
|
|
|
|
|
|
la_GetWorkingDirectoryInternal();
|
|
|
|
|
@@ -594,6 +773,9 @@ int laGetReady(){
|
|
|
return laGetReadyWith(3,3,0);
|
|
|
}
|
|
|
|
|
|
+void la_DestroyUiType(laUiType* uit);
|
|
|
+void la_FreeKeyMapItem(laKeyMapItem* kmi);
|
|
|
+
|
|
|
void laShutoff(int SavePrefereces){
|
|
|
if(MAIN.SavePreferenceOnExit && SavePrefereces){ laSaveUserPreferences(); }
|
|
|
transDumpMissMatchRecord("TranslationDump.txt");
|
|
@@ -636,7 +818,12 @@ void laShutoff(int SavePrefereces){
|
|
|
hshFree(&MAIN.DBInstMemLeft);
|
|
|
memNoLonger();
|
|
|
|
|
|
+#ifdef __linux__
|
|
|
glXDestroyContext(MAIN.dpy,MAIN.glc);
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ wglDeleteContext(MAIN.glc);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void laSaveUserPreferences(){
|
|
@@ -693,7 +880,7 @@ void laSetPreferenceTemplates(laUiDefineFunc PreferencePageDisplay, laUiDefineFu
|
|
|
|
|
|
|
|
|
|
|
|
-int la_IsThisSysWindow(laWindow *wnd, Window hwnd){
|
|
|
+int la_IsThisSysWindow(laWindow *wnd, SYSWINDOW hwnd){
|
|
|
if (wnd->win == hwnd) return 1;
|
|
|
else return 0;
|
|
|
};
|
|
@@ -773,18 +960,25 @@ void la_UpdateUiPlacement(laWindow *w){
|
|
|
laRecalcPanel(p);
|
|
|
}
|
|
|
}
|
|
|
-void la_CommandResizeWindow(Window hwnd, int x, int y, int w, int h){
|
|
|
+void la_CommandResizeWindow(SYSWINDOW hwnd, int x, int y, int w, int h){
|
|
|
laWindow *window = lstFindItem(hwnd, la_IsThisSysWindow, &MAIN.Windows);
|
|
|
if (!window) return;
|
|
|
-
|
|
|
+#ifdef _WIN32
|
|
|
+ RECT rc; GetClientRect(window->win, &rc);
|
|
|
+ window->CW = rc.right - rc.left;
|
|
|
+ window->CH = rc.bottom - rc.top;
|
|
|
+ window->X = rc.left; window->Y = rc.top;
|
|
|
+#endif
|
|
|
+#ifdef __linux__
|
|
|
XWindowAttributes attr;
|
|
|
XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
window->CW = w; window->CH = h;
|
|
|
window->W = w; window->H = h;
|
|
|
window->X = x; window->Y = y;
|
|
|
+#endif
|
|
|
la_UpdateUiPlacement(window);
|
|
|
}
|
|
|
-int la_OnWindowDestroy(Window wnd){
|
|
|
+int la_OnWindowDestroy(SYSWINDOW wnd){
|
|
|
laListHandle *hlst = &MAIN.Windows;
|
|
|
laWindow *w = lstFindItem(wnd, la_IsThisSysWindow, hlst);
|
|
|
if (!w) return 0;
|
|
@@ -802,22 +996,26 @@ int la_OnWindowDestroy(Window wnd){
|
|
|
|
|
|
la_DestroyWindow(w);
|
|
|
|
|
|
+#ifdef __linux__
|
|
|
int done=0; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
if(done) glXSwapIntervalEXTF(MAIN.dpy, w->win, 0);
|
|
|
else { glXSwapIntervalEXTF(MAIN.dpy, w->win, 1); done=1; while(l=lstPopItem(&h)){ lstAppendItem(&w->Layouts, l); } }
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void la_MakeSpecialKeyBit(Window hwnd,laWindow*wnd,laEvent *e,int use_last_pos){
|
|
|
+void la_MakeSpecialKeyBit(SYSWINDOW hwnd,laWindow*wnd,laEvent *e,int use_last_pos){
|
|
|
laListHandle *el = &wnd->EventList;
|
|
|
laEvent* last_e=el->pLast;
|
|
|
- Window root_ret, win_ret; int rrx=0,rry=0,rx=e->x,ry=e->y,rmask=0;
|
|
|
+ SYSWINDOW root_ret, win_ret; int rrx=0,rry=0,rx=e->x,ry=e->y,rmask=0;
|
|
|
+#ifdef __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
|
|
|
}
|
|
|
-void la_SaveEvent(Window hwnd, laEvent *e, int use_last_pos){
|
|
|
+void la_SaveEvent(SYSWINDOW hwnd, laEvent *e, int use_last_pos){
|
|
|
laListHandle *wl = &MAIN.Windows;
|
|
|
laWindow* wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
|
|
|
if (!wnd){ memFree(e); return; }
|
|
@@ -835,17 +1033,17 @@ void la_SaveEvent(Window hwnd, laEvent *e, int use_last_pos){
|
|
|
lstAppendItem(el, (laListItem *)e);
|
|
|
laMappingRequestEval();
|
|
|
};
|
|
|
-void la_SendKeyboardEvent(Window hwnd, int type, int key){
|
|
|
+void la_SendKeyboardEvent(SYSWINDOW hwnd, int type, int key){
|
|
|
laEvent *e = memAcquireSimple(sizeof(laEvent)); e->Type = type; e->key = key;
|
|
|
la_SaveEvent(hwnd, e, 1);
|
|
|
};
|
|
|
-void la_SendInputEvent(Window hwnd, uint32_t Input){
|
|
|
+void la_SendInputEvent(SYSWINDOW hwnd, uint32_t Input){
|
|
|
laEvent *e = memAcquireSimple(sizeof(laEvent));
|
|
|
e->Type = LA_INPUT; e->Input=Input;
|
|
|
|
|
|
la_SaveEvent(hwnd, e, 1);
|
|
|
}
|
|
|
-void la_SendEmptyEvent(Window hwnd){
|
|
|
+void la_SendEmptyEvent(SYSWINDOW hwnd){
|
|
|
laEvent *e = memAcquireSimple(sizeof(laEvent));
|
|
|
|
|
|
e->Type = LA_EMPTY;
|
|
@@ -857,6 +1055,7 @@ void laSendOperatorTriggerEvent(){
|
|
|
MAIN.ReTriggerOperators = 0;
|
|
|
}
|
|
|
int la_TranslateSpecialKey(int keysym){
|
|
|
+#ifdef __linux__
|
|
|
switch(keysym){
|
|
|
case XK_Return: return LA_KEY_ENTER;
|
|
|
case XK_BackSpace: return LA_KEY_BACKSPACE;
|
|
@@ -875,8 +1074,9 @@ int la_TranslateSpecialKey(int keysym){
|
|
|
case XK_Alt_R: return LA_KEY_ALT;
|
|
|
default: return keysym;
|
|
|
}
|
|
|
+#endif
|
|
|
}
|
|
|
-void la_SendMouseEvent(Window hwnd, int type, int x, int y){
|
|
|
+void la_SendMouseEvent(SYSWINDOW hwnd, int type, int x, int y){
|
|
|
|
|
|
|
|
|
|
|
@@ -888,7 +1088,7 @@ void la_SendMouseEvent(Window hwnd, int type, int x, int y){
|
|
|
la_SaveEvent(hwnd, e, 0);
|
|
|
MAIN.evLastX=x; MAIN.evLastY=y;
|
|
|
};
|
|
|
-void la_SendTimerEvent(Window hwnd, int type){
|
|
|
+void la_SendTimerEvent(SYSWINDOW hwnd, int type){
|
|
|
laEvent *e = memAcquireSimple(sizeof(laEvent));
|
|
|
e->Type = type;
|
|
|
la_SaveEvent(hwnd, e, 1);
|
|
@@ -1781,6 +1981,8 @@ void la_ClearUnusedFramebuffers(laWindow* w){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void laDeferredDestroyPanel(laPanel* p, int immediate);
|
|
|
+
|
|
|
void la_WindowDefDraw(laWindow *w, laBoxedTheme *bt){
|
|
|
laPanel *p, *NextP;
|
|
|
laLayout *l = w->CurrentLayout;
|
|
@@ -1870,9 +2072,13 @@ void la_WindowDefDraw(laWindow *w, laBoxedTheme *bt){
|
|
|
}
|
|
|
}
|
|
|
int laStartWindow(laWindow *w){
|
|
|
-
|
|
|
+#ifdef __linux__
|
|
|
XMapWindow(MAIN.dpy,w->win);
|
|
|
glXMakeContextCurrent(MAIN.dpy, w->win,w->win, w->glc);
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ ShowWindow(w->win, SW_SHOWNORMAL);
|
|
|
+#endif
|
|
|
MAIN.CurrentWindow = w;
|
|
|
if(!w->CurrentLayout){
|
|
|
if(!w->Layouts.pFirst){laDesignLayout(w, "Empty Layout");}
|
|
@@ -1892,7 +2098,7 @@ void la_AssignWindowPP(laWindow* w){
|
|
|
laWindow *laDesignWindow(int X, int Y, int W, int H){
|
|
|
laWindow *n = memAcquire(sizeof(laWindow));
|
|
|
|
|
|
- strSafeSet(&n->Title, "Empty Window");
|
|
|
+ strSafeSet(&n->Title, "Empty SYSWINDOW");
|
|
|
n->X = X; n->Y = Y; n->W = W; n->H = H;
|
|
|
n->OutputShowStripes=1;
|
|
|
n->Redraw=1;
|
|
@@ -1908,8 +2114,10 @@ laWindow *laDesignWindow(int X, int Y, int W, int H){
|
|
|
return n;
|
|
|
}
|
|
|
void laSetWindowCursor(int id){
|
|
|
+#ifdef __linux__
|
|
|
Cursor c = XcursorLibraryLoadCursor(MAIN.dpy, la_ConvertCursorID(id));
|
|
|
XDefineCursor(MAIN.dpy, MAIN.CurrentWindow->win, c);
|
|
|
+#endif
|
|
|
};
|
|
|
void la_AssignBlockPP(laBlock* b){
|
|
|
b->PP.EndInstance = b;
|
|
@@ -3148,8 +3356,8 @@ int laCheckAndMergeSubColumnsUiList(laUiList *TopUil, laColumn *c, int DoMerge){
|
|
|
return Occupied;
|
|
|
}
|
|
|
|
|
|
-laPropContainer* laUiHasExtraProps(laUiType *ut, int size, int hyper){
|
|
|
- ut->ExtraProps = laAddPropertyContainer(ut->Identifier, 0,0,L'◳',0,size,0,0,hyper);
|
|
|
+laPropContainer* laUiHasExtraProps(laUiType *ut, int size, int Hyper){
|
|
|
+ ut->ExtraProps = laAddPropertyContainer(ut->Identifier, 0,0,L'◳',0,size,0,0,Hyper);
|
|
|
ut->FakeProp = memAcquire(sizeof(laSubProp));
|
|
|
ut->FakeProp->Base.SubProp = ut->ExtraProps;
|
|
|
ut->FakeProp->Base.Identifier = ut->Identifier;
|
|
@@ -3159,8 +3367,8 @@ laPropContainer* laUiHasExtraProps(laUiType *ut, int size, int hyper){
|
|
|
|
|
|
return ut->ExtraProps;
|
|
|
}
|
|
|
-laPropContainer* laCanvasHasExtraProps(laCanvasTemplate *ct, int size, int hyper){
|
|
|
- ct->ExtraProps = laAddPropertyContainer(ct->Identifier->Ptr, 0,0,L'◳',0,size,0,0,hyper);
|
|
|
+laPropContainer* laCanvasHasExtraProps(laCanvasTemplate *ct, int size, int Hyper){
|
|
|
+ ct->ExtraProps = laAddPropertyContainer(ct->Identifier->Ptr, 0,0,L'◳',0,size,0,0,Hyper);
|
|
|
ct->FakeProp = memAcquire(sizeof(laSubProp));
|
|
|
ct->FakeProp->Base.SubProp = ct->ExtraProps;
|
|
|
ct->FakeProp->Base.Identifier = ct->Identifier->Ptr;
|
|
@@ -4319,6 +4527,7 @@ int la_ShrinkableRowElements(laRowInfo* ri){
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
+void la_RecordSocketRuntimePosition(laUiItem* ui);
|
|
|
int la_CalculateRowExpand(laRowInfo* ri, laUiItem* ui_end, int WaitAnimation){
|
|
|
int Available=ri->MaxW-ri->NonExpandW-ri->TotalPadding;
|
|
|
int ShareCount=0, Additional=0, AdditionalRemaining=0, Shrinkable=0; real NodeAddFraction=0;
|
|
@@ -4383,6 +4592,7 @@ void la_RecordSocketRuntimePosition(laUiItem* ui){
|
|
|
laUiList* la_GiveExistingPage(laListHandle* from, void* instance){
|
|
|
for(laUiList* uil=from->pFirst;uil;uil=uil->Item.pNext){ if(uil->Instance == instance){ lstRemoveItem(from,uil); return uil; } } return 0;
|
|
|
}
|
|
|
+void la_SwitchThemeQuick(laTheme* t, laTheme* DefaultTheme);
|
|
|
int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast, laPanel *ParentPanel){
|
|
|
laUiItem *ui; laListHandle TempPages={0}; laUiList* FoundUil;
|
|
|
laBoxedTheme *bt;
|
|
@@ -6266,14 +6476,14 @@ void laFinalizeOperators(){
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+#ifdef __linux__
|
|
|
static void la_RecordWacomMotions(XIRawEvent *event)
|
|
|
{
|
|
|
double *valuator = event->valuators.values;
|
|
|
int IsStylus=event->deviceid==MAIN.WacomDeviceStylus;
|
|
|
if(!IsStylus) MAIN.PointerIsEraser = 1; else MAIN.PointerIsEraser = 0;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -6290,7 +6500,95 @@ static void la_RecordWacomMotions(XIRawEvent *event)
|
|
|
|
|
|
MAIN.IsPen=1;
|
|
|
}
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+#define PARAM_2_FROM(p) LOWORD(p),HIWORD(p)
|
|
|
+LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
|
|
|
+ char buf[4] = { 0 };
|
|
|
+ short wheelmark = 0;
|
|
|
+ int WheelDir = 0;
|
|
|
+ if (!hwnd) return DefWindowProc(hwnd, message, wparam, lparam);
|
|
|
+ switch (message) {
|
|
|
+ case WM_PAINT:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case WM_MOUSEMOVE:
|
|
|
+ la_SendMouseEvent(hwnd, LA_MOUSEMOVE, PARAM_2_FROM(lparam));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_LBUTTONDOWN:
|
|
|
+ la_SendMouseEvent(hwnd, LA_L_MOUSE_DOWN, PARAM_2_FROM(lparam));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_LBUTTONUP:
|
|
|
+ la_SendMouseEvent(hwnd, LA_L_MOUSE_UP, PARAM_2_FROM(lparam));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_RBUTTONDOWN:
|
|
|
+ la_SendMouseEvent(hwnd, LA_R_MOUSE_DOWN, PARAM_2_FROM(lparam));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_RBUTTONUP:
|
|
|
+
|
|
|
+ la_SendMouseEvent(hwnd, LA_R_MOUSE_UP, PARAM_2_FROM(lparam));
|
|
|
+ break;
|
|
|
|
|
|
+ case WM_MOUSEWHEEL:
|
|
|
+ if ((wheelmark = HIWORD(wparam)) > 0) WheelDir = LA_MOUSEUP;
|
|
|
+ else if ((wheelmark = HIWORD(wparam)) < 0) WheelDir = LA_MOUSEDOWN;
|
|
|
+
|
|
|
+ la_SendMouseEvent(hwnd, WheelDir|LA_KEY_MOUSE_SCROLL, PARAM_2_FROM(lparam));
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_SYSCOMMAND:
|
|
|
+ switch (wparam) {
|
|
|
+ case SC_MAXIMIZE:
|
|
|
+ case SC_RESTORE:
|
|
|
+ la_CommandResizeWindow(hwnd, 0, 0, LOWORD(lparam), HIWORD(lparam));
|
|
|
+ break;
|
|
|
+ case SC_KEYMENU:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case WM_SIZE:
|
|
|
+ la_CommandResizeWindow(hwnd, 0, 0, LOWORD(lparam), HIWORD(lparam));
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ case WM_CHAR:
|
|
|
+ buf[0] = wparam;
|
|
|
+ la_SendInputEvent(hwnd, buf);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_SHOWWINDOW:
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case WM_DESTROY:
|
|
|
+ la_OnWindowDestroy(hwnd);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return DefWindowProc(hwnd, message, wparam, lparam);
|
|
|
+ }
|
|
|
+ return DefWindowProc(hwnd, message, wparam, lparam);
|
|
|
+}
|
|
|
+#endif
|
|
|
|
|
|
int la_UpdateOperatorHints(laWindow* w){
|
|
|
laSafeString* ss=0;
|
|
@@ -6441,12 +6739,15 @@ int la_AllowInput(uint32_t ch){
|
|
|
return 0;
|
|
|
}
|
|
|
int laCopyToClipboard(unsigned char * text){
|
|
|
- XEvent event; Window owner, window=MAIN.CurrentWindow->win;
|
|
|
+#ifdef __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;
|
|
|
strSafeSet(&MAIN.CopyPending, text);
|
|
|
+#endif
|
|
|
}
|
|
|
int la_ProcessSysMessage(){
|
|
|
+#ifdef __linux__
|
|
|
XEvent e;
|
|
|
int type;
|
|
|
|
|
@@ -6572,6 +6873,18 @@ int la_ProcessSysMessage(){
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ MSG msg;
|
|
|
+ int Processed = 0;
|
|
|
+ if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE) != 0)
|
|
|
+ Processed = 1;
|
|
|
+
|
|
|
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
|
|
+ TranslateMessage(&msg);
|
|
|
+ DispatchMessage(&msg);
|
|
|
+ };
|
|
|
+#endif
|
|
|
};
|
|
|
|
|
|
void la_PrintOperatorStack(){
|
|
@@ -6636,7 +6949,12 @@ void laMainLoop(){
|
|
|
}
|
|
|
for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
if(!w->RedrawTouched) continue; w->RedrawTouched=0;
|
|
|
+#ifdef __linux__
|
|
|
glXSwapBuffers(MAIN.dpy, w->win);
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ SwapBuffers(w->hdc);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
if(MAIN.PostFrame){ MAIN.PostFrame(); }
|
|
@@ -6647,8 +6965,10 @@ void laMainLoop(){
|
|
|
Pause = (1.0 / MAIN.TopFramerate - TimeInterval);
|
|
|
|
|
|
if (Pause > 0){
|
|
|
+#ifdef __linux__
|
|
|
int ms = Pause * 1000000.0;
|
|
|
usleep(ms);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
MAIN.TimeAccum += (MAIN.LastFrameTime = Pause+TimeInterval);
|