From 71cd1a6f6a5e7728944baed951252300b82adf16 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Mon, 4 Jul 2011 15:47:40 -0700 Subject: [PATCH] Add bindings to allow for grabbing key presses --- src/xlib-keys.ads | 8 ++++++++ src/xlib.ads | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/xlib-keys.ads b/src/xlib-keys.ads index 9d91b6c..5ff0019 100644 --- a/src/xlib-keys.ads +++ b/src/xlib-keys.ads @@ -1,3 +1,4 @@ +with Interfaces.C.Strings; package Xlib.Keys is pragma Linker_Options ("-lX11"); @@ -10,4 +11,11 @@ package Xlib.Keys is Mod3Mask : constant := (2**5); Mod4Mask : constant := (2**6); Mod5Mask : constant := (2**7); + + function Symbol_To_Code (Display : Display_Type; + Key_Symbol : Key_Symbol_Type) return Key_Code_Type; + pragma Import (C, Symbol_To_Code, "XKeysymToKeycode"); + + function String_To_Symbol (Str : Interfaces.C.Strings.Chars_Ptr) return Key_Symbol_Type; + pragma Import (C, String_To_Symbol, "XStringToKeysym"); end Xlib.Keys; diff --git a/src/xlib.ads b/src/xlib.ads index b29a90b..309621d 100644 --- a/src/xlib.ads +++ b/src/xlib.ads @@ -33,6 +33,9 @@ package Xlib is subtype Colormap_Type is Xid_Type; subtype Cursor_Type is Xid_Type; subtype VisualId_Type is Xid_Type; + subtype Key_Symbol_Type is Xid_Type; + + subtype Key_Code_Type is Unsigned_Char; CurrentTime : constant Time_Type := 0; @@ -42,6 +45,16 @@ package Xlib is function Default_Root_Window (D : Display_Type) return Window_Type; pragma Import (C, Default_Root_Window, "XDefaultRootWindow"); + + function Grab_Key (Display : Display_Type; + Key_Code : Key_Code_Type; + Modifiers : Unsigned; + Window : Window_Type; + Owner_Events : Int; + Pointer_Mode : Int; + Keyboard_Mode : Int) return Return_Code_Type; + pragma Import (C, Grab_Key, "XGrabKey"); + function Grab_Button (Display : Display_Type; Button : Unsigned; Modifiers : Unsigned; @@ -77,6 +90,11 @@ package Xlib is Height : Unsigned) return Return_Code_Type; pragma Import (C, Move_Resize_Window, "XMoveResizeWindow"); + + function Raise_Window (Display : Display_Type; + Window : Window_Type) return Return_Code_Type; + pragma Import (C, Raise_Window, "XRaiseWindow"); + type XPointer is new Interfaces.C.Strings.Chars_Ptr; type u_XExtData is record number : aliased Int;