first implementation for s48

This commit is contained in:
nofreude 2001-08-22 12:09:56 +00:00
parent 814296eb3d
commit a61c257d4e
1 changed files with 126 additions and 105 deletions

View File

@ -1,138 +1,159 @@
#include "xlib.h"
#include "scheme48.h"
static s48_value Sym_Any;
Time Get_Time (time) s48_value time; {
if (S48_EQ_P(time, Sym_Now))
return CurrentTime;
return (Time)s48_extract_integer (time);
int Get_Mode (s48_value m){
return S48_EXTRACT_BOOLEAN(m) ? GrabModeSync :GrabModeAsync;
}
static Get_Mode (m) s48_value m; {
Check_Type (m, T_Boolean);
return S48_EQ_P(m, S48_TRUE) ? GrabModeSync : GrabModeAsync;
s48_value scx_Grab_Pointer (s48_value dpy, s48_value win,
s48_value ownerp, s48_value events,
s48_value psyncp, s48_value ksyncp,
s48_value confine_to, s48_value cursor,
s48_value time) {
int res = XGrabPointer(SCX_EXTRACT_DISPLAY(dpy),
SCX_EXTRACT_WINDOW(win),
S48_EXTRACT_BOOLEAN(ownerp),
Symbols_To_Bits(events, Event_Syms),
Get_Mode(psyncp),
Get_Mode(ksyncp),
SCX_EXTRACT_WINDOW(confine_to),
SCX_EXTRACT_CURSOR(cursor),
SCX_EXTRACT_TIME(time));
return Bit_To_Symbol(res, Grabstatus_Syms);
}
static s48_value P_Grab_Pointer (win, ownerp, events, psyncp, ksyncp, confine_to,
cursor, time) s48_value win, ownerp, events, psyncp, ksyncp, confine_to,
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,
S48_EQ_P(ownerp, S48_TRUE), Symbols_To_Bits (events, 1, Event_Syms),
Get_Mode (psyncp), Get_Mode (ksyncp),
Get_Window (confine_to), Get_Cursor (cursor), Get_Time (time)),
0, Grabstatus_Syms);
s48_value scx_Ungrab_Pointer (s48_value dpy, s48_value time) {
XUngrabPointer (SCX_EXTRACT_DISPLAY(dpy), SCX_EXTRACT_TIME(time));
return S48_UNSPECIFIC;
}
static s48_value P_Ungrab_Pointer (d, time) s48_value d, time; {
Check_Type (d, T_Display);
XUngrabPointer (DISPLAY(d)->dpy, Get_Time (time));
return Void;
s48_value scx_Grab_Button (s48_value dpy, s48_value win, s48_value button,
s48_value mods, s48_value ownerp, s48_value events,
s48_value psyncp, s48_value ksyncp,
s48_value confine_to, s48_value cursor){
XGrabButton(SCX_EXTRACT_DISPLAY(dpy),
Symbol_To_Bit(button, Button_Syms),
Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(win),
S48_EXTRACT_BOOLEAN(ownerp),
Symbols_To_Bits(events, Event_Syms),
Get_Mode(psyncp), Get_Mode(ksyncp),
SCX_EXTRACT_WINDOW(confine_to),
SCX_EXTRACT_CURSOR(cursor));
return S48_UNSPECIFIC;
}
static s48_value P_Grab_Button (win, button, mods, ownerp, events, psyncp, ksyncp,
confine_to, cursor) s48_value win, button, mods, ownerp, events,
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,
S48_EQ_P(ownerp, S48_TRUE), Symbols_To_Bits (events, 1, Event_Syms),
Get_Mode (psyncp), Get_Mode (ksyncp),
Get_Window (confine_to), Get_Cursor (cursor));
return Void;
s48_value scx_Ungrab_Button (s48_value Xdpy, s48_value Xwin,
s48_value button, s48_value mods){
XUngrabButton(SCX_EXTRACT_DISPLAY(Xdpy),
Symbol_To_Bit(button, Button_Syms),
Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(Xwin));
return S48_UNSPECIFIC;
}
static s48_value P_Ungrab_Button (win, button, mods) s48_value win, button, mods; {
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;
s48_value scx_Change_Active_Pointer_Grab (s48_value Xdpy, s48_value events,
s48_value cursor, s48_value time){
XChangeActivePointerGrab (SCX_EXTRACT_DISPLAY(Xdpy),
Symbols_To_Bits(events, Event_Syms),
SCX_EXTRACT_CURSOR(cursor),
SCX_EXTRACT_TIME(time));
return S48_UNSPECIFIC;
}
static s48_value P_Change_Active_Pointer_Grab (d, events, cursor, time)
s48_value d, events, cursor, time; {
Check_Type (d, T_Display);
XChangeActivePointerGrab (DISPLAY(d)->dpy, Symbols_To_Bits (events, 1,
Event_Syms), Get_Cursor (cursor), Get_Time (time));
return Void;
s48_value scx_Grab_Keyboard (s48_value Xdpy, s48_value Xwin, s48_value ownerp,
s48_value psyncp, s48_value ksyncp,
s48_value time){
return Bit_To_Symbol((unsigned long)XGrabKeyboard (
SCX_EXTRACT_DISPLAY(Xdpy),
SCX_EXTRACT_WINDOW(Xwin),
S48_EXTRACT_BOOLEAN(ownerp),
Get_Mode(psyncp),
Get_Mode (ksyncp),
SCX_EXTRACT_TIME(time)),
Grabstatus_Syms);
}
static s48_value P_Grab_Keyboard (win, ownerp, psyncp, ksyncp, time) s48_value win,
ownerp, psyncp, ksyncp, time; {
Check_Type (win, T_Window);
Check_Type (ownerp, T_Boolean);
return Bits_To_Symbols ((unsigned long)XGrabKeyboard (WINDOW(win)->dpy,
WINDOW(win)->win, S48_EQ_P(ownerp, S48_TRUE), Get_Mode (psyncp),
Get_Mode (ksyncp), Get_Time (time)),
0, Grabstatus_Syms);
s48_value scx_Ungrab_Keyboard (s48_value Xdpy, s48_value time){
XUngrabKeyboard (SCX_EXTRACT_DISPLAY(Xdpy),
SCX_EXTRACT_TIME(time));
return S48_UNSPECIFIC;
}
static s48_value P_Ungrab_Keyboard (d, time) s48_value d, time; {
Check_Type (d, T_Display);
XUngrabKeyboard (DISPLAY(d)->dpy, Get_Time (time));
return Void;
s48_value scx_Grab_Key (s48_value Xdpy, s48_value Xwin, s48_value key,
s48_value mods, s48_value ownerp, s48_value psyncp,
s48_value ksyncp, s48_value flag){
int keycode = AnyKey;
if (!S48_EXTRACT_BOOLEAN(flag))
keycode = (int)s48_extract_integer(key);
XGrabKey (SCX_EXTRACT_DISPLAY(Xdpy),
keycode,
Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(Xwin),
S48_EXTRACT_BOOLEAN(ownerp),
Get_Mode(psyncp),
Get_Mode (ksyncp));
return S48_UNSPECIFIC;
}
static s48_value P_Grab_Key (win, key, mods, ownerp, psyncp, ksyncp) s48_value win,
key, mods, ownerp, psyncp, ksyncp; {
int keycode = AnyKey;
Check_Type (win, T_Window);
if (!S48_EQ_P(key, Sym_Any))
keycode = (int)s48_extract_integer (key);
Check_Type (ownerp, T_Boolean);
XGrabKey (WINDOW(win)->dpy, keycode, Symbols_To_Bits (mods, 1, State_Syms),
WINDOW(win)->win, S48_EQ_P(ownerp, S48_TRUE), Get_Mode (psyncp),
Get_Mode (ksyncp));
return Void;
s48_value scx_Ungrab_Key (s48_value Xdpy, s48_value Xwin, s48_value key,
s48_value mods, s48_value flag){
int keycode = AnyKey;
if (!S48_EXTRACT_BOOLEAN(flag))
keycode = (int)s48_extract_integer(key);
XUngrabKey (SCX_EXTRACT_DISPLAY(Xdpy),
keycode,
Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(Xwin));
return S48_UNSPECIFIC;
}
static s48_value P_Ungrab_Key (win, key, mods) s48_value win, key, mods; {
int keycode = AnyKey;
Check_Type (win, T_Window);
if (!S48_EQ_P(key, Sym_Any))
keycode = (int)s48_extract_integer (key);
XUngrabKey (WINDOW(win)->dpy, keycode,
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win);
return Void;
s48_value scx_Allow_Events (s48_value Xdpy, s48_value mode, s48_value time){
XAllowEvents (SCX_EXTRACT_DISPLAY(Xdpy),
Symbol_To_Bit (mode, Allow_Events_Syms),
SCX_EXTRACT_TIME(time));
return S48_UNSPECIFIC;
}
static s48_value P_Allow_Events (d, mode, time) s48_value d, mode, time; {
Check_Type (d, T_Display);
XAllowEvents (DISPLAY(d)->dpy, Symbols_To_Bits (mode, 0,
Allow_Events_Syms), Get_Time (time));
return Void;
s48_value scx_Grab_Server (s48_value Xdpy){
XGravServer(SCX_EXTRACT_DISPLAY(Xdpy));
return S48_UNSPECIFIC;
}
static s48_value P_Grab_Server (d) s48_value d; {
Check_Type (d, T_Display);
XGrabServer (DISPLAY(d)->dpy);
return Void;
s48_value scx_Ungrab_Server (s48_value Xdpy){
XUngrabServer (SCX_EXTRACT_DISPLAY(Xdpy));
return S48_UNSPECIFIC;
}
static s48_value P_Ungrab_Server (d) s48_value d; {
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");
void scx_init_grab(void) {
S48_EXPORT_FUNCTION(scx_Grab_Pointer);
S48_EXPORT_FUNCTION(scx_Ungrab_Pointer);
S48_EXPORT_FUNCTION(scx_Grab_Button);
S48_EXPORT_FUNCTION(scx_Ungrab_Button);
S48_EXPORT_FUNCTION(scx_Change_Active_Pointer_Grab);
S48_EXPORT_FUNCTION(scx_Grab_Keyboard);
S48_EXPORT_FUNCTION(scx_Ungrab_Keyboard);
S48_EXPORT_FUNCITON(scx_Grab_Key);
S48_EXPORT_FUNCTION(scx_Ungrab_Key);
S48_EXPORT_FUNCTION(scx_Allow_Events);
S48_EXPORT_FUNCTION(scx_Grab_Server);
S48_EXPORT_FUNCTION(scx_Ungrab_Server);
}