340 |
|
* Open display (window or fullscreen) |
341 |
|
*/ |
342 |
|
|
343 |
+ |
// Set WM_DELETE_WINDOW protocol on window (preventing it from being destroyed by the WM when clicking on the "close" widget) |
344 |
+ |
static Atom WM_DELETE_WINDOW = (Atom)0; |
345 |
+ |
static void set_window_delete_protocol(Window w) |
346 |
+ |
{ |
347 |
+ |
WM_DELETE_WINDOW = XInternAtom(x_display, "WM_DELETE_WINDOW", false); |
348 |
+ |
XSetWMProtocols(x_display, w, &WM_DELETE_WINDOW, 1); |
349 |
+ |
} |
350 |
+ |
|
351 |
|
// Wait until window is mapped/unmapped |
352 |
|
void wait_mapped(Window w) |
353 |
|
{ |
400 |
|
// Set window name |
401 |
|
XStoreName(x_display, the_win, GetString(STR_WINDOW_TITLE)); |
402 |
|
|
403 |
+ |
// Set delete protocol property |
404 |
+ |
set_window_delete_protocol(the_win); |
405 |
+ |
|
406 |
|
// Make window unresizable |
407 |
|
XSizeHints *hints; |
408 |
|
if ((hints = XAllocSizeHints()) != NULL) { |
1434 |
|
else if (XCheckTypedEvent(x_display, SelectionClear, &event)) |
1435 |
|
ClipboardSelectionClear(&event.xselectionclear); |
1436 |
|
|
1437 |
+ |
// Window "close" widget clicked |
1438 |
+ |
else if (XCheckTypedEvent(x_display, ClientMessage, &event)) { |
1439 |
+ |
if (event.xclient.format == 32 && event.xclient.data.l[0] == WM_DELETE_WINDOW) { |
1440 |
+ |
ADBKeyDown(0x7f); // Power key |
1441 |
+ |
ADBKeyUp(0x7f); |
1442 |
+ |
} |
1443 |
+ |
} |
1444 |
+ |
|
1445 |
|
XDisplayUnlock(); |
1446 |
|
break; |
1447 |
|
} |