#include "xlib.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), s48_extract_integer(events), Get_Mode(psyncp), Get_Mode(ksyncp), SCX_EXTRACT_WINDOW(confine_to), SCX_EXTRACT_CURSOR(cursor), SCX_EXTRACT_TIME(time)); return s48_enter_integer(res); } 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), s48_extract_integer(button), s48_extract_integer(mods), SCX_EXTRACT_WINDOW(win), S48_EXTRACT_BOOLEAN(ownerp), s48_extract_integer(events), 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), s48_extract_integer(button), s48_extract_integer(mods), 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), s48_extract_integer(events), 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){ int res = XGrabKeyboard( SCX_EXTRACT_DISPLAY(Xdpy), SCX_EXTRACT_WINDOW(Xwin), S48_EXTRACT_BOOLEAN(ownerp), Get_Mode(psyncp), Get_Mode (ksyncp), SCX_EXTRACT_TIME(time)); return s48_enter_integer(res); } 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, s48_extract_integer(mods), 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, s48_extract_integer(mods), 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), s48_extract_integer(mode), 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); }