comp.lang.ada
 help / color / mirror / Atom feed
From: astrolove@hotmail.com (VNCoder)
Subject: XGrab Pointer does work...why???
Date: 30 Apr 2003 18:11:24 -0700
Date: 2003-05-01T01:11:25+00:00	[thread overview]
Message-ID: <6091ca88.0304301711.61d724df@posting.google.com> (raw)

G'day all,
   Using the Ada C-binding for Xlib (see below). After create a
window, I tried to grab the pointer immediately but it doesn't seem to
grab at all.
   Only if I put a delay (sleep for few seconds) before I grab then it
works.
   Anyone know what's happening??

    

----CODE ----------------


procedure Test_Grab_Pointer is
   pragma Link_With
      ("-L/usr/openwin/lib/ -R/usr/openwin/lib
/apex_repos/DISPLAY/oper/x11_support/c_lib/var.o -Bdynamic -lX11
-Bdynamic -lm -lc");

begin
   Test_Window_Grab_Pointer.Start;
   delay 5.0;

   Test_Window_Grab_Pointer.Bound_Pointer;
   delay 5.0;
   Test_Window_Grab_Pointer.Unbound_Pointer;
   delay 5.0;

end Test_Grab_Pointer;



package body Test_Window_Grab_Pointer is
   Display : X.Xlib.Xdisplay_Access;

   Window : X.Window;
   Screen_Number : X.Signed_Int;
   Attributes : aliased X.Xlib.Xsetwindowattributes;
   Attribute_Mask : X.Unsigned_Long;

   procedure Start is
   begin

      Display := X.Xlib.Xopendisplay (Interfaces.C.To_C (""));
      Attributes.Background_Pixel := 255;
      Attributes.Border_Pixel := 0;
      Attributes.Colormap := X.Xlib.Xdefaultcolormapofscreen
                                (X.Xlib.Xscreenofdisplay
                                    (Display, X.Xlib.Xdefaultscreen
(Display)));
      Attribute_Mask := X.Unsigned_Long
                           (X.Cwbackpixel + X.Cwborderpixel +
X.Cwcolormap);
      Window := X.Xlib.Xcreatewindow
                   (Display, X.Xlib.Rootwindow
                                (Display, X.Xlib.Xdefaultscreen
(Display)),
                    0, 0, 200, 200, 1,
                    X.Xlib.Xdefaultdepthofscreen
                       (X.Xlib.Xscreenofdisplay
                           (Display, X.Xlib.Xdefaultscreen
(Display))),
                    X.Inputoutput,
                    X.Xlib.Xdefaultvisualofscreen
                       (X.Xlib.Xscreenofdisplay
                           (Display, X.Xlib.Xdefaultscreen
(Display))),
                    Attribute_Mask,
                    Attributes'Access);
      X.Xlib.Xmapwindow (Display, Window);
      X.Xlib.Xflush (Display);
   end Start;

   procedure Bound_Pointer is
      Result : X.Signed_Int;
   begin
      Result := X.Xlib.Xgrabpointer
                   (Display, Window, X.Xlib.False,
                    X.Unsigned_Int (X.Buttonreleasemask +
X.Buttonpressmask +
                                    X.Pointermotionmask),
                    X.Grabmodeasync, X.Grabmodeasync,
                    Window, X.None, X.Currenttime);
   end Bound_Pointer;

   procedure Unbound_Pointer is
   begin
      X.Xlib.Xungrabpointer (Display, X.Currenttime);
   end Unbound_Pointer;
end Test_Window_Grab_Pointer;



             reply	other threads:[~2003-05-01  1:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-01  1:11 VNCoder [this message]
2003-05-01  2:34 ` XGrab Pointer does work...why??? Rick Stikkers
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox