namespace gui::drivers;
import "instance"
-#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D) && !defined(ECERE_NOGL)
+#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D) && !defined(ECERE_NOGL) && !defined(__ODROID__)
import "OpenGLDisplayDriver"
#endif
-#if (defined(__unix__) || defined(__APPLE__)) && !defined(ECERE_MINIGLX)
+#if (defined(__unix__) || defined(__APPLE__)) && !defined(ECERE_MINIGLX) && !defined(__EMSCRIPTEN__)
#undef __BLOCKS__
default:
#include <unistd.h>
#include <sys/select.h>
+#if defined(__APPLE__)
+#define set _set
+#include <mach/mach.h>
+#include <mach/task.h>
+#include <mach/semaphore.h>
+#undef set
+#else
+#include <semaphore.h>
+#endif
+
//#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
+#if !defined(__EMSCRIPTEN__)
#include <X11/Xresource.h>
+#endif
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <fcntl.h>
-#if !defined(ECERE_NO3D) && !defined(ECERE_NOGL)
+#if !defined(ECERE_NO3D) && !defined(ECERE_NOGL) //&& !defined(__ODROID__)
+#if defined(__EMSCRIPTEN__)
+#include <GL/glfw.h>
+#else
#include <GL/glx.h>
#endif
+#endif
+#if !defined(__EMSCRIPTEN__)
#include <X11/extensions/Xrender.h>
+#endif
#include <X11/extensions/XShm.h>
#undef Bool
static X11Window capturedWindow = None;
static Window restrictedWindow = null;
static bool gotAnXEvent = false;
-static XEvent xEvent;
+//static XEvent xEvent;
static int joystickFD[4];
static X11Window activeWindow;
static X11Cursor systemCursors[SystemCursor];
"_NET_WM_STATE_ABOVE",
"Caps Lock",
"Num Lock",
- "Scroll Lock",
+ "Scroll Lock"
};
/*
_NET_WM_STATE_STICKY, ATOM
int format;
unsigned long count, fill;
Atom type;
- char * data = null;
- uint state = WithdrawnState;
+ byte * data = null;
+ /*uint state = WithdrawnState;
- /*if(XGetWindowProperty(xGlobalDisplay, windowHandle, atoms[wm_state], 0, 3, False,
+ if(XGetWindowProperty(xGlobalDisplay, windowHandle, atoms[wm_state], 0, 3, False,
atoms[wm_state], &type, &format, &count, &fill, &data) == Success && count)
{
state = *(uint *)data;
Screen * x_screen = XDefaultScreenOfDisplay(xGlobalDisplay);
X11Window x_root;
int current = 0;
- char *data = null;
+ byte *data = null;
int format;
unsigned long len, fill;
Atom type;
if(data)
{
+ /*
int desktops = 0;
desktops = (int)*(long *)data;
- //printf("_NET_NUMBER_OF_DESKTOPS is %d\n", desktops);
-
+ printf("_NET_NUMBER_OF_DESKTOPS is %d\n", desktops);
+ */
XFree(data);
data = null;
}
Key code;
unichar ch = 0;
KeySym keysym = NoSymbol;
- Status status;
int buflength = 0;
static long bufsize = 16;
static char *buf = NULL;
if(!buf)
buf = malloc((uint)bufsize);
- if(windowData && windowData.ic)
+
+ // TOCHECK: X*LookupString man page says we shouldn't invoke it for non KeyPress events
+ if(windowData && windowData.ic) // && event->type == KeyPress)
{
- buflength = XmbLookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status);
- if (status == XBufferOverflow)
+ Status status;
+#ifdef X_HAVE_UTF8_STRING
+ #define LookupString Xutf8LookupString
+#else
+ #define LookupString XmbLookupString
+#endif
+ buflength = LookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status);
+ if(status == XBufferOverflow)
{
buf = realloc(buf, (uint)(bufsize = buflength));
- buflength = XmbLookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status);
+ buflength = LookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status);
}
if(status != XLookupKeySym && status != XLookupBoth && release == 1)
keysym = XLookupKeysym(event, 0);
}
if(!windowData.ic)
{
- ch = (byte)Interface::TranslateKey(key, event->state & ShiftMask);
+ ch = (byte)Interface::TranslateKey(key, (event->state & ShiftMask) != 0);
// 127 is delete, we don't treat that as a character (Use (SmartKey)key == del)
if(ch == 128 || ch == 127) ch = 0;
}
{
int numBytes;
- if(code < KeyCode::enumSize) keyStates[code] = false;
+ if(key < KeyCode::enumSize)
+ keyStates[key] = false;
if(windowData && windowData.ic) ch = buflength ? UTF8GetChar(buf, &numBytes) : 0;
if(ch == 127) ch = 0;
// printf("Release! %d %d %d\n", keysym, code, ch);
int c;
if(release == 0)
{
- if(code < KeyCode::enumSize) keyStates[code] = true;
+ if(key < KeyCode::enumSize)
+ keyStates[key] = true;
if(windowData.ic && buflength)
{
static X11Bool EventChecker(void *display, XEvent *event, char * data)
{
- return (!data || (event->type == (int) data)) && event->type != NoExpose && event->type != GraphicsExpose;
+ return (!data || (event->type == (int)(intptr_t) data)) && event->type != NoExpose && event->type != GraphicsExpose;
}
static X11Bool ConfigureNotifyChecker(void *display, XConfigureEvent *event, char * data)
if(event->type == FocusIn)
{
Window window = null;
- XFindContext(xGlobalDisplay, event->window, windowContext, (XPointer *) &window);
+ // --- This deadlocks and I think Xorg should fix this.
+ // XFindContext(xGlobalDisplay, event->window, windowContext, (XPointer *) &window);
+ if((X11Window)guiApp.desktop.windowHandle == event->window)
+ window = guiApp.desktop;
+ else
+ {
+ for(window = guiApp.desktop.firstChild; window; window = window.next)
+ if((X11Window)window.windowHandle == event->window)
+ break;
+ }
if(window)
result = True;
}
while(true)
{
XWindowAttributes attributes = { 0 };
- int result;
if(!XGetWindowAttributes(xGlobalDisplay, (X11Window)window.windowHandle, &attributes))
break;
if(attributes.map_state == IsViewable)
int format;
unsigned long len, fill;
Atom type;
- char * data = null;
+ byte * data = null;
if(XGetWindowProperty(xGlobalDisplay, (X11Window)window.windowHandle,
atoms[_net_frame_extents], 0, 4,
int format;
unsigned long len, fill;
Atom type;
- char * data = null;
+ byte * data = null;
if(XGetWindowProperty(xGlobalDisplay, (X11Window)window.systemHandle, atoms[_net_wm_state], 0, 32, False,
XA_ATOM, &type, &format, &len, &fill, &data) == Success)
{
bool Initialize()
{
setlocale(LC_ALL, "en_US.UTF-8");
- // XInitThreads();
+ XInitThreads();
XSupportsLocale();
XSetLocaleModifiers("");
XSetErrorHandler(MyXErrorHandler);
#endif
xTerminate = false;
xGlobalDisplay = XOpenDisplay(null);
+
+#if (defined(__unix__) || defined(__APPLE__)) && !defined(__ANDROID__)
+ if(xGlobalDisplay)
+ XLockDisplay(xGlobalDisplay);
+#endif
+
// XSynchronize(xGlobalDisplay, True);
frameExtentSupported = unknown;
joystickFD[2] = open("/dev/js2", O_RDONLY);
joystickFD[3] = open("/dev/js3", O_RDONLY);
- systemCursors[iBeam] = XCreateFontCursor(xGlobalDisplay, XC_xterm);
- systemCursors[cross] = XCreateFontCursor(xGlobalDisplay, XC_tcross);
- systemCursors[moving] = XCreateFontCursor(xGlobalDisplay, XC_fleur);
- systemCursors[sizeNESW] = XCreateFontCursor(xGlobalDisplay, XC_bottom_left_corner);
- systemCursors[sizeNS] = XCreateFontCursor(xGlobalDisplay, XC_sb_v_double_arrow);
- systemCursors[sizeNWSE] = XCreateFontCursor(xGlobalDisplay, XC_bottom_right_corner);
- systemCursors[sizeWE] = XCreateFontCursor(xGlobalDisplay, XC_sb_h_double_arrow);
- systemCursors[hand] = XCreateFontCursor(xGlobalDisplay, XC_hand2);
- systemCursors[arrow] = XCreateFontCursor(xGlobalDisplay, XC_left_ptr);
-
if(xGlobalDisplay)
{
XWindowAttributes attributes = { 0 };
+
+ systemCursors[iBeam] = XCreateFontCursor(xGlobalDisplay, XC_xterm);
+ systemCursors[cross] = XCreateFontCursor(xGlobalDisplay, XC_tcross);
+ systemCursors[moving] = XCreateFontCursor(xGlobalDisplay, XC_fleur);
+ systemCursors[sizeNESW] = XCreateFontCursor(xGlobalDisplay, XC_bottom_left_corner);
+ systemCursors[sizeNS] = XCreateFontCursor(xGlobalDisplay, XC_sb_v_double_arrow);
+ systemCursors[sizeNWSE] = XCreateFontCursor(xGlobalDisplay, XC_bottom_right_corner);
+ systemCursors[sizeWE] = XCreateFontCursor(xGlobalDisplay, XC_sb_h_double_arrow);
+ systemCursors[hand] = XCreateFontCursor(xGlobalDisplay, XC_hand2);
+ systemCursors[arrow] = XCreateFontCursor(xGlobalDisplay, XC_left_ptr);
+
XGetWindowAttributes(xGlobalDisplay, DefaultRootWindow(xGlobalDisplay), &attributes);
xSystemDepth = attributes.depth;
xSystemVisual = attributes.visual;
Pixmap mask = XCreatePixmap(xGlobalDisplay, DefaultRootWindow(xGlobalDisplay), 1, 1, 1);
XSetWindowAttributes attributes = { 0 };
- XkbSetDetectableAutoRepeat(xGlobalDisplay, True, &autoRepeatDetectable);
+ XkbSetDetectableAutoRepeat(xGlobalDisplay, True, (int *)&autoRepeatDetectable);
XInternAtoms(xGlobalDisplay, (char**)atomNames, AtomIdents::enumSize, False, atoms);
void Terminate()
{
- XEvent e = { 0 };
+ //XEvent e = { 0 };
xTerminate = true;
// WHY WAS THIS COMMENTED HERE?
windowData = modalRoot ? modalRoot.windowData : window.windowData;
if(windowData && windowData.ic)
{
- // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, 0);
+ // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, NULL);
XSetICFocus(windowData.ic);
}
}
static Point lastPos[3];
Modifiers keyFlags = 0;
- bool doubleClick;
- uint button, buttonDouble, whichButton;
- uint buttonMask;
+ bool doubleClick = false;
+ uint button = 0, buttonDouble = 0, whichButton;
+ uint buttonMask = 0;
int x = event->x_root, y = event->y_root;
timeStamp = event->time;
if(event->button == Button1)
keyFlags.right = true;
buttonsState.right = true;
}
- else
+ else if(event->button == Button2)
{
button = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown;
buttonDouble = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick;
if(event->state & buttonMask)
break;
- doubleClick = event->time - lastTime[whichButton] < DBLCLICK_DELAY &&
- window == lastWindow[whichButton] &&
- Abs(event->x_root - lastPos[whichButton].x) < DBLCLICK_DELTA &&
- Abs(event->y_root - lastPos[whichButton].y) < DBLCLICK_DELTA;
- lastTime[whichButton] = doubleClick ? 0 : event->time;
- lastWindow[whichButton] = window;
- lastPos[whichButton].x = event->x_root;
- lastPos[whichButton].y = event->y_root;
+ if(buttonMask)
+ {
+ doubleClick = event->time - lastTime[whichButton] < DBLCLICK_DELAY &&
+ window == lastWindow[whichButton] &&
+ Abs(event->x_root - lastPos[whichButton].x) < DBLCLICK_DELTA &&
+ Abs(event->y_root - lastPos[whichButton].y) < DBLCLICK_DELTA;
+ lastTime[whichButton] = doubleClick ? 0 : event->time;
+ lastWindow[whichButton] = window;
+ lastPos[whichButton].x = event->x_root;
+ lastPos[whichButton].y = event->y_root;
+ }
if(event->state & ShiftMask) keyFlags.shift = true;
if(event->state & ControlMask) keyFlags.ctrl = true;
incref window;
if(event->button == Button4 || event->button == Button5)
{
- window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit, (event->button == Button4) ? wheelUp : wheelDown, 0);
+ window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit, { modifiers = keyFlags, code = (event->button == Button4) ? wheelUp : wheelDown }, 0);
}
- else
+ else if(button)
{
if(doubleClick)
{
}
case MotionNotify:
{
- static uint lastTime = 0;
+ //static uint lastTime = 0;
XMotionEvent * event = (XMotionEvent *) thisEvent;
while(XCheckIfEvent(xGlobalDisplay, (XEvent *)thisEvent, EventChecker, (void *)MotionNotify));
// if(event->time - lastTime > 15)
event->x_root, event->y_root, &keyFlags, false, false);
delete window;
//*if(xGlobalDisplay) XLockDisplay(xGlobalDisplay);
- lastTime = (uint)event->time;
+ //lastTime = (uint)event->time;
}
break;
}
XRaiseWindow(xGlobalDisplay, (X11Window)window.windowHandle);
SetNETWMState((X11Window)window.windowHandle, true, add, atoms[_net_wm_state_fullscreen], 0);
XGrabKeyboard(xGlobalDisplay, (X11Window)window.windowHandle, False, GrabModeAsync, GrabModeAsync, CurrentTime);
- (xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, timeStamp);
+ XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, timeStamp);
XInterface::UpdateRootWindow(window);
break;
}
if(activeWindow != (X11Window)window.windowHandle)
{
- XFocusChangeEvent *event = (XFocusChangeEvent *) thisEvent;
Window modalRoot = window.FindModal();
XWindowData windowData;
if(window.parent && window == window.parent.activeChild) break;
incref window;
- //if(window.creationActivation == activate)
+ //if(window.creationActivation == activate && guiApp.desktop.active)
{
if(modalRoot)
modalRoot.ExternalActivate(true, true, window, null); // lastActive);
windowData = modalRoot ? modalRoot.windowData : window.windowData;
if(windowData && windowData.ic)
{
- // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, 0);
+ // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, NULL);
XSetICFocus(windowData.ic);
}
//delete lastActive;
else
#endif
{
- XFocusChangeEvent *event = (XFocusChangeEvent *) thisEvent;
if(window.parent && window != window.parent.activeChild && window != guiApp.interimWindow) break;
incref window;
{
XConfigureEvent * event = (XConfigureEvent *) thisEvent;
bool unmaximized = false;
+ bool um = false;
if(!window.visible || fullScreenMode) break;
while(XCheckIfEvent(xGlobalDisplay, (XEvent *)thisEvent, (void *)ConfigureNotifyChecker, (void *)window.windowHandle));
//if(event->x - desktopX != window.position.x || event->y - desktopY != window.position.y || event->width != window.size.w || event->height != window.size.h)
-
- X11UpdateState(window, &unmaximized);
+ X11UpdateState(window, &um);
+ unmaximized = false;
{
bool offset = false;
int x, y, w, h;
- if(unmaximized && window.nativeDecorations)
+ if(unmaximized && window.nativeDecorations && ((BorderBits)window.borderStyle).fixed)
{
if(window.nativeDecorations && RequestFrameExtents((X11Window)window.windowHandle))
WaitForFrameExtents(window, false);
if(x != rootX || y != rootY)
{
- /*if(event->send_event)
- offset = true;*/
- x = rootX;
- y = rootY;
+ if(!event->send_event)
+ {
+ // offset = true;
+ x = rootX;
+ y = rootY;
+ }
}
}
x -= desktopX;
y -= desktopY;
- if(window.nativeDecorations && window.state != maximized)
+ if(window.nativeDecorations && window.state != maximized && ((BorderBits)window.borderStyle).fixed)
{
x -= windowData.decor.left;
y -= windowData.decor.top;
}
}
- window.Position(x, y, w, h, true, true, true, true, false, unmaximized);
+ window.Position(x, y, w, h, um, true, true, true, false, unmaximized);
// Break the anchors for moveable/resizable windows
// Avoid doing this if the translation wasn't in sync as it will cause the window to move around
window.ExternalActivate(true, true, window, null); // lastActive);
if(windowData && windowData.ic)
{
- // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, 0);
+ // XSetICValues(ic, XNClientWindow, window.windowHandle, XNFocusWindow, window.windowHandle, NULL);
//XSetICFocus(windowData.ic);
}
}
//*XUnlockDisplay(xGlobalDisplay);
}
- char ** GraphicsDrivers(int * numDrivers)
+ const char ** GraphicsDrivers(int * numDrivers)
{
- static char *graphicsDrivers[] = { "X", "OpenGL" };
+ static const char *graphicsDrivers[] = { "X", "OpenGL" };
*numDrivers = sizeof(graphicsDrivers) / sizeof(char *);
- return (char **)graphicsDrivers;
+ return (const char **)graphicsDrivers;
}
void GetCurrentMode(bool * fullScreen, int * resolution, int * colorDepth, int * refreshRate)
}
else
{
- static bool firstTime = true;
- firstTime = false;
+ //static bool firstTime = true;
+ //firstTime = false;
desktopX = desktopY = desktopW = desktopH = 0;
RepositionDesktop(false);
attributes.override_redirect = (window.interim || (!atomsSupported[_net_wm_state] && !window.nativeDecorations)) ? True : False;
attributes.event_mask = EVENT_MASK;
//printf("%s\n", guiApp.defaultDisplayDriver);
-#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D) && !defined(ECERE_NOGL)
+#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D) && !defined(ECERE_NOGL) && !defined(__ODROID__)
if(window.dispDriver == class(OpenGLDisplayDriver) || !strcmp(guiApp.defaultDisplayDriver, "OpenGL"))
{
int samples;
};
visualInfo = glXChooseVisual(xGlobalDisplay, DefaultScreen(xGlobalDisplay), attrList);
}
+#elif defined(__ODROID__)
+ if(!visualInfo)
+ {
+ // System visual not working on ODROID?
+ int attrList[] =
+ {
+ GLX_USE_GL, GLX_DEPTH_SIZE, 1,
+ GLX_RGBA,
+ GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None
+ };
+ visualInfo = glXChooseVisual(xGlobalDisplay, DefaultScreen(xGlobalDisplay), attrList);
+ }
#endif
depth = visualInfo ? visualInfo->depth : (window.alphaBlend ? 32 : xSystemDepth);
visual = visualInfo ? visualInfo->visual : (window.alphaBlend ? FindFullColorVisual (xGlobalDisplay, &depth) : xSystemVisual);
XChangeProperty(xGlobalDisplay, windowHandle, atoms[_net_wm_window_type], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&hints, count);
+ if(window.stayOnTop)
+ SetNETWMState((X11Window)windowHandle, false, add, atoms[_net_wm_state_above], 0);
+
{
XWMHints xwmHints;
xwmHints.flags = InputHint;
int num_missing_charsets = 0;
char *default_string;
XFontSet fontset;
- XRectangle area = { 0, 0, 400, 400 };
+ //XRectangle area = { 0, 0, 400, 400 };
XVaNestedList argList;
// sprintf(fontString, "-*-%s-*-r-*-*-*-%d-*-*-*-*-*-*", "Helvetica" /*window.font.faceName*/, (int)(window.font.size * 20));
{
if ( atoms[_motif_wm_hints] != None )
{
+ BorderBits borderBits = (BorderBits)window.borderStyle;
+ bool hasTitleBar = borderBits.fixed;
MWM_Hints hints
{
- (window.nativeDecorations ? 0 : MWM_HINTS_DECORATIONS)|MWM_HINTS_FUNCTIONS,
+ ((window.nativeDecorations && hasTitleBar) ? 0 : MWM_HINTS_DECORATIONS)|MWM_HINTS_FUNCTIONS,
(window.hasClose ? MWM_FUNC_CLOSE : 0) |
(fullScreenMode || window.hasMaximize ? MWM_FUNC_MAXIMIZE : 0) |
(fullScreenMode || window.hasMinimize ? MWM_FUNC_MINIMIZE : 0) |
- ((fullScreenMode || window.moveable || ((BorderBits)window.borderStyle).fixed) ? MWM_FUNC_MOVE : 0) |
- (fullScreenMode || ((BorderBits)window.borderStyle).sizable ? MWM_FUNC_RESIZE : 0),
+ ((fullScreenMode || window.moveable || hasTitleBar) ? MWM_FUNC_MOVE : 0) |
+ (fullScreenMode || borderBits.sizable ? MWM_FUNC_RESIZE : 0),
0, 0, 0
};
XChangeProperty(xGlobalDisplay, windowHandle, atoms[_motif_wm_hints], atoms[_motif_wm_hints], 32,
XUngrabPointer(xGlobalDisplay, CurrentTime);
}
- if(fullScreenMode || !window.nativeDecorations || !RequestFrameExtents(windowHandle))
+ if(fullScreenMode || !window.nativeDecorations || !((BorderBits)window.borderStyle).fixed || !RequestFrameExtents(windowHandle))
((XWindowData)window.windowData).gotFrameExtents = true;
window.windowHandle = (void *)windowHandle;
// -- Window manipulation ---
- void SetRootWindowCaption(Window window, char * name)
+ void SetRootWindowCaption(Window window, const char * name)
{
if(window.windowHandle)
{
//Logf("Position root window %s\n", window.name);
if(window.windowHandle && (!window.parent || !window.parent.display))
{
- bool visible = window.visible;
if(window.visible && window.created)
+ {
+ long t = (window.creationActivation == activate && guiApp.desktop.active) ? (int)timeStamp : 0;
+ XChangeProperty(xGlobalDisplay, (X11Window)window.windowHandle, atoms[_net_wm_user_time],
+ XA_CARDINAL,32,PropModeReplace, (byte *)&t, 1);
XMapWindow(xGlobalDisplay, (X11Window)window.windowHandle);
+ }
if(window.state == minimized && atomsSupported[_net_wm_state]) return;
if(window.nativeDecorations)
x += desktopX;
y += desktopY;
- if(!fullScreenMode && (!atomsSupported[_net_wm_state] || window.state != maximized))
+ if(!fullScreenMode && (!atomsSupported[_net_wm_state] || (window.state != maximized || !window.visible)))
{
if(move && resize)
XMoveResizeWindow(xGlobalDisplay, (X11Window)window.windowHandle, x, y, w, h);
XResizeWindow(xGlobalDisplay, (X11Window)window.windowHandle, w, h);
// Reset min/max for fixed size windows on WMs not looking at MWM_FUNC_RESIZE (e.g. Cinnamon)
- if(window.style.fixed && !window.style.sizable)
+ if(window.style.fixed && !window.style.sizable && window.state != maximized)
{
XSizeHints hints = { 0 };
long supplied;
void OrderRootWindow(Window window, bool topMost)
{
-
+ SetNETWMState((X11Window)window.windowHandle, false, topMost ? add : remove, atoms[_net_wm_state_above], 0);
}
void SetRootWindowColor(Window window)
void SetRootWindowState(Window window, WindowState state, bool visible)
{
+ WindowState curState = window.state;
+ *&window.state = state;
// Old WM (e.g. TWM), use built-in decorations
if(!atomsSupported[_net_wm_state])
window.nativeDecorations = false;
{
if(!windowData.currentlyVisible)
{
+ long t = (window.creationActivation == activate && guiApp.desktop.active) ? timeStamp : 0;
+ XChangeProperty(xGlobalDisplay, (X11Window)window.windowHandle, atoms[_net_wm_user_time],
+ XA_CARDINAL,32,PropModeReplace, (byte *)&t, 1);
XMapWindow(xGlobalDisplay, (X11Window)window.windowHandle);
windowData.currentlyVisible = true;
WaitForViewableWindow(window);
- if(window.creationActivation == activate && state != minimized)
+ if(window.creationActivation == activate && guiApp.desktop.active && state != minimized)
ActivateRootWindow(window);
}
if(state == minimized && atomsSupported[_net_wm_state])
{
- uint iconic = IconicState;
+ //uint iconic = IconicState;
// SetNETWMState(window.windowHandle, true, add, atoms[_net_wm_state_hidden], null);
/*
if(atomsSupported[_net_wm_state])
{
// Maximize / Restore the window
- SetNETWMState((X11Window)window.windowHandle, true, state == maximized ? add : remove,
- atoms[_net_wm_state_maximized_vert], atoms[_net_wm_state_maximized_horz]);
+ if(curState != state)
+ SetNETWMState((X11Window)window.windowHandle, true, state == maximized ? add : remove,
+ atoms[_net_wm_state_maximized_vert], atoms[_net_wm_state_maximized_horz]);
+
if(state == maximized)
{
// Prevent the code in ConfigureNotify to think the window has been unmaximized
}
//XFlush(xGlobalDisplay);
}
+ *&window.state = curState;
}
void FlashRootWindow(Window window)
{
+ void * hwnd = window.windowHandle;
+ Window master = window.master, rootWindow = (master && master != guiApp.desktop) ? master.rootWindow : null;
+ if(!window.style.showInTaskBar && rootWindow && (window._isModal || window.style.interim))
+ hwnd = rootWindow.windowHandle;
+
// printf("Attempting to flash root window\n");
- SetNETWMState((X11Window)window.windowHandle, true, add, atoms[_net_wm_state_demands_attention], 0);
+ SetNETWMState((X11Window)hwnd, true, add, atoms[_net_wm_state_demands_attention], 0);
}
void ActivateRootWindow(Window window)
//printf("Activate root window %s\n", window._class.name);
if(!windowData.currentlyVisible)
{
+ long t = (window.creationActivation == activate && guiApp.desktop.active) ? timeStamp : 0;
+ XChangeProperty(xGlobalDisplay, (X11Window)window.windowHandle, atoms[_net_wm_user_time],
+ XA_CARDINAL,32,PropModeReplace, (byte *)&t, 1);
XMapWindow(xGlobalDisplay, (X11Window)window.windowHandle);
WaitForViewableWindow(window);
windowData.currentlyVisible = true;
event.send_event = 1;
event.format = 32;
event.data.l[0] = /*0*/ 1;
- event.data.l[1] = timeStamp;
+ // WMs will complain about using CurrentTime here, but when ActivateRootWindow() is called we really need to take over,
+ // otherwise a debugged application stays on top of the IDE when we hit a breakpoint (there was no user interaction with the IDE,
+ // but it really should be activated)
+ event.data.l[1] = CurrentTime; //timeStamp;
event.data.l[2] = activeWindow; //guiApp.desktop.activeChild.windowHandle;
#ifdef _DEBUG
(short)(caretOwner.caretPos.y - caretOwner.scroll.y + caretOwner.absPosition.y - window.absPosition.y)
};
XVaNestedList argList = XVaCreateNestedList(0, XNSpotLocation, &cursor_location, NULL);
- XSetICValues(windowData.ic, XNPreeditAttributes, argList, 0);
+ XSetICValues(windowData.ic, XNPreeditAttributes, argList, NULL);
}
}
}
AnyPropertyType, &type,&format,&len, &dummy, &data) == Success)
{
clipBoard.text = new char[size+1];
- strncpy(clipBoard.text, data, size);
+ strncpy(clipBoard.text, (char *)data, size);
clipBoard.text[size] = '\0';
XFree(data);
result = true;
return (bool)state;
}
else
- return keyStates[key.code];
+ {
+ if(key == alt)
+ return keyStates[leftAlt] || keyStates[rightAlt];
+ else if(key == shift)
+ return keyStates[leftShift] || keyStates[rightShift];
+ else if(key == control)
+ return keyStates[leftControl] || keyStates[rightControl];
+ else
+ return keyStates[key.code];
+ }
}
void SetTimerResolution(uint hertz)
}
}
-default dllexport void * __attribute__((stdcall)) IS_XGetDisplay()
+default dllexport void * IS_XGetDisplay()
{
return xGlobalDisplay;
}
-default dllexport void * __attribute__((stdcall)) IS_XGetWindow(Window window)
+default dllexport void * IS_XGetWindow(Window window)
{
return window.windowHandle ? window.windowHandle : window.rootWindow.windowHandle;
}