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 "xlib.h"
#include "scheme48.h"
static s48_value Sym_Any;
Time Get_Time (time) s48_value time; {
if (S48_EQ_P(time, Sym_Now)) int Get_Mode (s48_value m){
return CurrentTime; return S48_EXTRACT_BOOLEAN(m) ? GrabModeSync :GrabModeAsync;
return (Time)s48_extract_integer (time);
} }
static Get_Mode (m) s48_value m; {
Check_Type (m, T_Boolean); s48_value scx_Grab_Pointer (s48_value dpy, s48_value win,
return S48_EQ_P(m, S48_TRUE) ? GrabModeSync : GrabModeAsync; 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, s48_value scx_Ungrab_Pointer (s48_value dpy, s48_value time) {
cursor, time; { XUngrabPointer (SCX_EXTRACT_DISPLAY(dpy), SCX_EXTRACT_TIME(time));
Check_Type (win, T_Window); return S48_UNSPECIFIC;
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), 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), Get_Mode(psyncp), Get_Mode(ksyncp),
Get_Window (confine_to), Get_Cursor (cursor), Get_Time (time)), SCX_EXTRACT_WINDOW(confine_to),
0, Grabstatus_Syms); SCX_EXTRACT_CURSOR(cursor));
return S48_UNSPECIFIC;
} }
static s48_value P_Ungrab_Pointer (d, time) s48_value d, time; {
Check_Type (d, T_Display); s48_value scx_Ungrab_Button (s48_value Xdpy, s48_value Xwin,
XUngrabPointer (DISPLAY(d)->dpy, Get_Time (time)); s48_value button, s48_value mods){
return Void; 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_Grab_Button (win, button, mods, ownerp, events, psyncp, ksyncp,
confine_to, cursor) s48_value win, button, mods, ownerp, events, s48_value scx_Change_Active_Pointer_Grab (s48_value Xdpy, s48_value events,
psyncp, ksyncp, confine_to, cursor; { s48_value cursor, s48_value time){
Check_Type (win, T_Window); XChangeActivePointerGrab (SCX_EXTRACT_DISPLAY(Xdpy),
Check_Type (ownerp, T_Boolean); Symbols_To_Bits(events, Event_Syms),
XGrabButton (WINDOW(win)->dpy, Symbols_To_Bits (button, 0, Button_Syms), SCX_EXTRACT_CURSOR(cursor),
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win, SCX_EXTRACT_TIME(time));
S48_EQ_P(ownerp, S48_TRUE), Symbols_To_Bits (events, 1, Event_Syms), return S48_UNSPECIFIC;
Get_Mode (psyncp), Get_Mode (ksyncp),
Get_Window (confine_to), Get_Cursor (cursor));
return Void;
} }
static s48_value P_Ungrab_Button (win, button, mods) s48_value win, button, mods; {
Check_Type (win, T_Window); s48_value scx_Grab_Keyboard (s48_value Xdpy, s48_value Xwin, s48_value ownerp,
XUngrabButton (WINDOW(win)->dpy, Symbols_To_Bits (button, 0, Button_Syms), s48_value psyncp, s48_value ksyncp,
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win); s48_value time){
return Void; 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_Change_Active_Pointer_Grab (d, events, cursor, time)
s48_value d, events, cursor, time; { s48_value scx_Ungrab_Keyboard (s48_value Xdpy, s48_value time){
Check_Type (d, T_Display); XUngrabKeyboard (SCX_EXTRACT_DISPLAY(Xdpy),
XChangeActivePointerGrab (DISPLAY(d)->dpy, Symbols_To_Bits (events, 1, SCX_EXTRACT_TIME(time));
Event_Syms), Get_Cursor (cursor), Get_Time (time)); return S48_UNSPECIFIC;
return Void;
} }
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);
}
static s48_value P_Ungrab_Keyboard (d, time) s48_value d, time; { s48_value scx_Grab_Key (s48_value Xdpy, s48_value Xwin, s48_value key,
Check_Type (d, T_Display); s48_value mods, s48_value ownerp, s48_value psyncp,
XUngrabKeyboard (DISPLAY(d)->dpy, Get_Time (time)); s48_value ksyncp, s48_value flag){
return Void;
}
static s48_value P_Grab_Key (win, key, mods, ownerp, psyncp, ksyncp) s48_value win,
key, mods, ownerp, psyncp, ksyncp; {
int keycode = AnyKey; int keycode = AnyKey;
if (!S48_EXTRACT_BOOLEAN(flag))
Check_Type (win, T_Window);
if (!S48_EQ_P(key, Sym_Any))
keycode = (int)s48_extract_integer(key); keycode = (int)s48_extract_integer(key);
Check_Type (ownerp, T_Boolean); XGrabKey (SCX_EXTRACT_DISPLAY(Xdpy),
XGrabKey (WINDOW(win)->dpy, keycode, Symbols_To_Bits (mods, 1, State_Syms), keycode,
WINDOW(win)->win, S48_EQ_P(ownerp, S48_TRUE), Get_Mode (psyncp), Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(Xwin),
S48_EXTRACT_BOOLEAN(ownerp),
Get_Mode(psyncp),
Get_Mode (ksyncp)); Get_Mode (ksyncp));
return Void; return S48_UNSPECIFIC;
} }
static s48_value P_Ungrab_Key (win, key, mods) s48_value win, key, mods; {
s48_value scx_Ungrab_Key (s48_value Xdpy, s48_value Xwin, s48_value key,
s48_value mods, s48_value flag){
int keycode = AnyKey; int keycode = AnyKey;
if (!S48_EXTRACT_BOOLEAN(flag))
Check_Type (win, T_Window);
if (!S48_EQ_P(key, Sym_Any))
keycode = (int)s48_extract_integer(key); keycode = (int)s48_extract_integer(key);
XUngrabKey (WINDOW(win)->dpy, keycode, XUngrabKey (SCX_EXTRACT_DISPLAY(Xdpy),
Symbols_To_Bits (mods, 1, State_Syms), WINDOW(win)->win); keycode,
return Void; Symbols_To_Bits (mods, State_Syms),
SCX_EXTRACT_WINDOW(Xwin));
return S48_UNSPECIFIC;
} }
static s48_value P_Allow_Events (d, mode, time) s48_value d, mode, time; {
Check_Type (d, T_Display); s48_value scx_Allow_Events (s48_value Xdpy, s48_value mode, s48_value time){
XAllowEvents (DISPLAY(d)->dpy, Symbols_To_Bits (mode, 0, XAllowEvents (SCX_EXTRACT_DISPLAY(Xdpy),
Allow_Events_Syms), Get_Time (time)); Symbol_To_Bit (mode, Allow_Events_Syms),
return Void; SCX_EXTRACT_TIME(time));
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_Grab_Server (s48_value Xdpy){
XGravServer(SCX_EXTRACT_DISPLAY(Xdpy));
return S48_UNSPECIFIC;
} }
static s48_value P_Ungrab_Server (d) s48_value d; {
Check_Type (d, T_Display); s48_value scx_Ungrab_Server (s48_value Xdpy){
XUngrabServer (DISPLAY(d)->dpy); XUngrabServer (SCX_EXTRACT_DISPLAY(Xdpy));
return Void; return S48_UNSPECIFIC;
} }
elk_init_xlib_grab () {
Define_Primitive (P_Grab_Pointer, "grab-pointer", 8, 8, EVAL); void scx_init_grab(void) {
Define_Primitive (P_Ungrab_Pointer, "ungrab-pointer", 2, 2, EVAL); S48_EXPORT_FUNCTION(scx_Grab_Pointer);
Define_Primitive (P_Grab_Button, "grab-button", 9, 9, EVAL); S48_EXPORT_FUNCTION(scx_Ungrab_Pointer);
Define_Primitive (P_Ungrab_Button, "ungrab-button", 3, 3, EVAL); S48_EXPORT_FUNCTION(scx_Grab_Button);
Define_Primitive (P_Change_Active_Pointer_Grab, S48_EXPORT_FUNCTION(scx_Ungrab_Button);
"change-active-pointer-grab", 4, 4, EVAL); S48_EXPORT_FUNCTION(scx_Change_Active_Pointer_Grab);
Define_Primitive (P_Grab_Keyboard, "grab-keyboard", 5, 5, EVAL); S48_EXPORT_FUNCTION(scx_Grab_Keyboard);
Define_Primitive (P_Ungrab_Keyboard, "ungrab-keyboard", 2, 2, EVAL); S48_EXPORT_FUNCTION(scx_Ungrab_Keyboard);
Define_Primitive (P_Grab_Key, "grab-key", 6, 6, EVAL); S48_EXPORT_FUNCITON(scx_Grab_Key);
Define_Primitive (P_Ungrab_Key, "ungrab-key", 3, 3, EVAL); S48_EXPORT_FUNCTION(scx_Ungrab_Key);
Define_Primitive (P_Allow_Events, "allow-events", 3, 3, EVAL); S48_EXPORT_FUNCTION(scx_Allow_Events);
Define_Primitive (P_Grab_Server, "grab-server", 1, 1, EVAL); S48_EXPORT_FUNCTION(scx_Grab_Server);
Define_Primitive (P_Ungrab_Server, "ungrab-server", 1, 1, EVAL); S48_EXPORT_FUNCTION(scx_Ungrab_Server);
Define_Symbol (&Sym_Any, "any");
} }