Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Hidden Panic
Hidden Panic [message #22222] |
Thu, 25 June 2009 16:31 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I have come across a problem with the Panic message box on X11, basically the same problem I had with Prompts. If there is a window with TopMost set on it in front of the Painc window it is impossible to read or click on.
Clearly the best solution would be to stop it crashing, but the modification below is a decent second best:
static void sPanicMessageBox(const char *title, const char *text)
{
GuiLock __;
Ctrl::ReleaseCtrlCapture();
XDisplay *display = XOpenDisplay(NULL);
if(!display)
return;
int screen = DefaultScreen(display);
int x = (DisplayWidth(display, screen) - 600) / 2;
int y = (DisplayHeight(display, screen) - 120) / 2;
Window win = XCreateSimpleWindow(display, RootWindow(display, screen),
x, y, 600, 120, 4,
BlackPixel(display, screen),
WhitePixel(display, screen));
XSizeHints size_hints;
size_hints.flags = PPosition|PSize|PMinSize;
size_hints.x = x;
size_hints.y = x;
size_hints.width = 600;
size_hints.height = 120;
size_hints.min_width = 600;
size_hints.min_height = 120;
char *h[1];
char hh[1];
*hh = 0;
h[0] = hh;
XSetStandardProperties(display, win, title, title, None, h, 0, &size_hints);
XSelectInput(display, win, ExposureMask|KeyPressMask|ButtonPressMask|StructureNotifyMask);
XGCValues values;
GC gc = XCreateGC(display, win, 0, &values);
// New section
unsigned long wina[1];
wina[0] = XAtom("_NET_WM_STATE_ABOVE");
XChangeProperty(display, win, XAtom("_NET_WM_STATE"), XAtom("ATOM"), 32,
PropModeReplace, (const unsigned char *)&wina, 1);
XMapWindow(display, win);
XSetInputFocus(display, win, RevertToParent, CurrentTime);
// End section
XRaiseWindow(display, win);
XFontStruct *font_info = XQueryFont(display, XGContextFromGC(gc));
for(;;) {
XEvent e;
XNextEvent(display, &e);
switch(e.type) {
case ButtonPress:
XFreeFont(display, font_info);
XFreeGC(display, gc);
XCloseDisplay(display);
#ifdef _DEBUG
__BREAK__;
#endif
return;
case Expose:
int y = 20;
const char *b = text;
for(;;) {
const char *e = strchr(b, '\n');
if(!e) break;
XDrawString(display, win, gc, 20, y, b, e - b);
y += font_info->max_bounds.ascent + font_info->max_bounds.descent;
b = e + 1;
}
XDrawString(display, win, gc, 20, y, b, strlen(b));
break;
}
}
}
This ensures the window is both topmost and raised to the front of the stack. Could this be committed please?
|
|
|
|
Goto Forum:
Current Time: Fri Apr 26 00:34:23 CEST 2024
Total time taken to generate the page: 0.97666 seconds
|