-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwm.cc
More file actions
68 lines (52 loc) · 2.06 KB
/
wm.cc
File metadata and controls
68 lines (52 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
-------------------------------------------------------------------------
OBJECT NAME: wm.c
FULL NAME: Window Manager callbacks
ENTRY POINTS: SetupTrapWMClose()
equalScaling()
STATIC FNS: none
DESCRIPTION: Trap Window Manater close
COPYRIGHT: University Corporation for Atmospheric Research, 2000-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include <Xm/Protocols.h>
static Atom property, protocol;
/* -------------------------------------------------------------------- */
void WMdismiss(Widget w, XtPointer client, XtPointer call)
{
// Handle the window popdown event
// printf("Window dismiss requested by window manager! %u %u %u\n", w, client, call);
XtUnmanageChild((Widget)client);
XtPopdown(XtParent((Widget)client));
}
/* -------------------------------------------------------------------- */
void WMquit(Widget w, XtPointer client, XtPointer call)
{
// Handle the window close event
printf("Window close requested by window manager!\n");
XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
Quit(0, 0, 0);
}
/* -------------------------------------------------------------------- */
void SetupTrapWMClose(Widget appShell)
{
// Trap Window Manager close
property = XmInternAtom(XtDisplay(appShell), "WM_PROTOCOLS", False);
protocol = XmInternAtom(XtDisplay(appShell), "WM_DELETE_WINDOW", True);
XmAddProtocols(appShell, property, &protocol, 1);
// Quit if any of the primary WM close buttons are pressed.
XmAddProtocolCallback(appShell, property, protocol, WMquit, (XtPointer)NULL);
}
/* -------------------------------------------------------------------- */
void WindowManagerCloseSetDismiss(Widget shell, Widget win)
{
XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
XmAddProtocolCallback(shell, property, protocol, WMdismiss, (XtPointer)win);
}
/* -------------------------------------------------------------------- */
void WindowManagerCloseSetQuit(Widget shell)
{
XmAddProtocolCallback(shell, property, protocol, WMquit, (XtPointer)NULL);
}
/* END WM.C */