comp.lang.ada
 help / color / mirror / Atom feed
* XGrab Pointer does work...why???
@ 2003-05-01  1:11 VNCoder
  2003-05-01  2:34 ` Rick Stikkers
  0 siblings, 1 reply; 2+ messages in thread
From: VNCoder @ 2003-05-01  1:11 UTC (permalink / 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;



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: XGrab Pointer does work...why???
  2003-05-01  1:11 XGrab Pointer does work...why??? VNCoder
@ 2003-05-01  2:34 ` Rick Stikkers
  0 siblings, 0 replies; 2+ messages in thread
From: Rick Stikkers @ 2003-05-01  2:34 UTC (permalink / raw)




VNCoder wrote:

>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??
>
>    
>
>
>  
>
<snip>

You don't say what GUI builder, compiler, and platform you are using, 
but I have noticed similar behavior on a Rational VADS Ada 83 compiler 
under Solaris 2.6 using BXAda as a GUI builder.  I'm not too sure if I'm 
correct, but it almost seems that the combined implementation for 
XWindows puts some of the X processing into a task.  If you don't break 
out of the main processing, sometimes the additional background 
processing does not seem to have completed.  I have also noticed 
problems when you attempt to put the X processing routines into a 
separate task.  I've tried to do stuff that does not work when put into 
a task but the exact same code works in the main body of the program.  I 
pretty much gave up on trying to figure that one out a long time ago. 
 From my experience, you don't need a 5 second delay.  As long as you 
put some kind of delay it will allow the other code to finish processing 
and it should run.  I normally put a 0.01 second delay in and that seems 
to work fine for my applications.

    Rick




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-01  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-01  1:11 XGrab Pointer does work...why??? VNCoder
2003-05-01  2:34 ` Rick Stikkers

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