#include "xlib.h" #include "scheme48.h" int Get_Mode (s48_value m){ return S48_EXTRACT_BOOLEAN(m) ? 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); } s48_value scx_Ungrab_Pointer (s48_value dpy, s48_value time) { XUngrabPointer (SCX_EXTRACT_DISPLAY(dpy), SCX_EXTRACT_TIME(time)); return S48_UNSPECIFIC; } 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; } 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; } 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; } 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); } s48_value scx_Ungrab_Keyboard (s48_value Xdpy, s48_value time){ XUngrabKeyboard (SCX_EXTRACT_DISPLAY(Xdpy), SCX_EXTRACT_TIME(time)); return S48_UNSPECIFIC; } 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; } 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; } 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; } s48_value scx_Grab_Server (s48_value Xdpy){ XGrabServer(SCX_EXTRACT_DISPLAY(Xdpy)); return S48_UNSPECIFIC; } s48_value scx_Ungrab_Server (s48_value Xdpy){ XUngrabServer (SCX_EXTRACT_DISPLAY(Xdpy)); return S48_UNSPECIFIC; } 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_FUNCTION(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); }