2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value Sym_Any;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
Time Get_Time (time) s48_value time; {
|
|
|
|
if (S48_EQ_P(time, Sym_Now))
|
2001-05-08 10:21:00 -04:00
|
|
|
return CurrentTime;
|
2001-05-14 09:48:37 -04:00
|
|
|
return (Time)s48_extract_integer (time);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static Get_Mode (m) s48_value m; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (m, T_Boolean);
|
2001-05-14 09:48:37 -04:00
|
|
|
return S48_EQ_P(m, S48_TRUE) ? GrabModeSync : GrabModeAsync;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Grab_Pointer (win, ownerp, events, psyncp, ksyncp, confine_to,
|
|
|
|
cursor, time) s48_value win, ownerp, events, psyncp, ksyncp, confine_to,
|
2001-05-08 10:21:00 -04:00
|
|
|
cursor, time; {
|
|
|
|
Check_Type (win, T_Window);
|
|
|
|
Check_Type (ownerp, T_Boolean);
|
|
|
|
return Bits_To_Symbols ((unsigned long)XGrabPointer (WINDOW(win)->dpy,
|
|
|
|
WINDOW(win)->win,
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_EQ_P(ownerp, S48_TRUE), Symbols_To_Bits (events, 1, Event_Syms),
|
2001-05-08 10:21:00 -04:00
|
|
|
Get_Mode (psyncp), Get_Mode (ksyncp),
|
|
|
|
Get_Window (confine_to), Get_Cursor (cursor), Get_Time (time)),
|
|
|
|
0, Grabstatus_Syms);
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Ungrab_Pointer (d, time) s48_value d, time; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XUngrabPointer (DISPLAY(d)->dpy, Get_Time (time));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Grab_Button (win, button, mods, ownerp, events, psyncp, ksyncp,
|
|
|
|
confine_to, cursor) s48_value win, button, mods, ownerp, events,
|
2001-05-08 10:21:00 -04:00
|
|
|
psyncp, ksyncp, confine_to, cursor; {
|
|
|
|
Check_Type (win, T_Window);
|
|
|
|
Check_Type (ownerp, T_Boolean);
|
|
|
|
XGrabButton (WINDOW(win)->dpy, Symbols_To_Bits (button, 0, Button_Syms),
|
|
|
|
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win,
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_EQ_P(ownerp, S48_TRUE), Symbols_To_Bits (events, 1, Event_Syms),
|
2001-05-08 10:21:00 -04:00
|
|
|
Get_Mode (psyncp), Get_Mode (ksyncp),
|
|
|
|
Get_Window (confine_to), Get_Cursor (cursor));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Ungrab_Button (win, button, mods) s48_value win, button, mods; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (win, T_Window);
|
|
|
|
XUngrabButton (WINDOW(win)->dpy, Symbols_To_Bits (button, 0, Button_Syms),
|
|
|
|
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Change_Active_Pointer_Grab (d, events, cursor, time)
|
|
|
|
s48_value d, events, cursor, time; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XChangeActivePointerGrab (DISPLAY(d)->dpy, Symbols_To_Bits (events, 1,
|
|
|
|
Event_Syms), Get_Cursor (cursor), Get_Time (time));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Grab_Keyboard (win, ownerp, psyncp, ksyncp, time) s48_value win,
|
2001-05-08 10:21:00 -04:00
|
|
|
ownerp, psyncp, ksyncp, time; {
|
|
|
|
Check_Type (win, T_Window);
|
|
|
|
Check_Type (ownerp, T_Boolean);
|
|
|
|
return Bits_To_Symbols ((unsigned long)XGrabKeyboard (WINDOW(win)->dpy,
|
2001-05-14 09:48:37 -04:00
|
|
|
WINDOW(win)->win, S48_EQ_P(ownerp, S48_TRUE), Get_Mode (psyncp),
|
2001-05-08 10:21:00 -04:00
|
|
|
Get_Mode (ksyncp), Get_Time (time)),
|
|
|
|
0, Grabstatus_Syms);
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Ungrab_Keyboard (d, time) s48_value d, time; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XUngrabKeyboard (DISPLAY(d)->dpy, Get_Time (time));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Grab_Key (win, key, mods, ownerp, psyncp, ksyncp) s48_value win,
|
2001-05-08 10:21:00 -04:00
|
|
|
key, mods, ownerp, psyncp, ksyncp; {
|
|
|
|
int keycode = AnyKey;
|
|
|
|
|
|
|
|
Check_Type (win, T_Window);
|
2001-05-14 09:48:37 -04:00
|
|
|
if (!S48_EQ_P(key, Sym_Any))
|
|
|
|
keycode = (int)s48_extract_integer (key);
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (ownerp, T_Boolean);
|
|
|
|
XGrabKey (WINDOW(win)->dpy, keycode, Symbols_To_Bits (mods, 1, State_Syms),
|
2001-05-14 09:48:37 -04:00
|
|
|
WINDOW(win)->win, S48_EQ_P(ownerp, S48_TRUE), Get_Mode (psyncp),
|
2001-05-08 10:21:00 -04:00
|
|
|
Get_Mode (ksyncp));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Ungrab_Key (win, key, mods) s48_value win, key, mods; {
|
2001-05-08 10:21:00 -04:00
|
|
|
int keycode = AnyKey;
|
|
|
|
|
|
|
|
Check_Type (win, T_Window);
|
2001-05-14 09:48:37 -04:00
|
|
|
if (!S48_EQ_P(key, Sym_Any))
|
|
|
|
keycode = (int)s48_extract_integer (key);
|
2001-05-08 10:21:00 -04:00
|
|
|
XUngrabKey (WINDOW(win)->dpy, keycode,
|
|
|
|
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Allow_Events (d, mode, time) s48_value d, mode, time; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XAllowEvents (DISPLAY(d)->dpy, Symbols_To_Bits (mode, 0,
|
|
|
|
Allow_Events_Syms), Get_Time (time));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Grab_Server (d) s48_value d; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XGrabServer (DISPLAY(d)->dpy);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Ungrab_Server (d) s48_value d; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XUngrabServer (DISPLAY(d)->dpy);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
|
|
|
elk_init_xlib_grab () {
|
|
|
|
Define_Primitive (P_Grab_Pointer, "grab-pointer", 8, 8, EVAL);
|
|
|
|
Define_Primitive (P_Ungrab_Pointer, "ungrab-pointer", 2, 2, EVAL);
|
|
|
|
Define_Primitive (P_Grab_Button, "grab-button", 9, 9, EVAL);
|
|
|
|
Define_Primitive (P_Ungrab_Button, "ungrab-button", 3, 3, EVAL);
|
|
|
|
Define_Primitive (P_Change_Active_Pointer_Grab,
|
|
|
|
"change-active-pointer-grab", 4, 4, EVAL);
|
|
|
|
Define_Primitive (P_Grab_Keyboard, "grab-keyboard", 5, 5, EVAL);
|
|
|
|
Define_Primitive (P_Ungrab_Keyboard, "ungrab-keyboard", 2, 2, EVAL);
|
|
|
|
Define_Primitive (P_Grab_Key, "grab-key", 6, 6, EVAL);
|
|
|
|
Define_Primitive (P_Ungrab_Key, "ungrab-key", 3, 3, EVAL);
|
|
|
|
Define_Primitive (P_Allow_Events, "allow-events", 3, 3, EVAL);
|
|
|
|
Define_Primitive (P_Grab_Server, "grab-server", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Ungrab_Server, "ungrab-server", 1, 1, EVAL);
|
|
|
|
Define_Symbol (&Sym_Any, "any");
|
|
|
|
}
|