1 # Copyright (C) 2008, Parrot Foundation.
6 xlibtest.pl - A test of Xlib.pir usage from nqp
10 This is an initial version, be careful and not expect too much.
12 Compile Xlib.pir to Xlib.pbc before usage:
14 ../../parrot -o Xlib.pbc Xlib.pir
16 To run this file, execute the following command from the
19 ../../parrot ../../compilers/nqp/nqp.pbc xlibtest.nqp
21 Press any key to exit.
25 PIR q< load_bytecode 'Xlib.pbc' >;
27 my $a := Xlib::DisplayName();
28 say("Display: ", Xlib::DisplayName());
30 my $display := Xlib::OpenDisplay('');
32 say("Default screen: ", $display.DefaultScreen());
36 my $white := $display.WhitePixel(0);
37 my $root := $display.RootWindow();
38 my $window := $display.CreateSimpleWindow($root, 0, 0, 600, 400, 0, 0, $white);
39 $window.StoreName("Hello, nqp");
40 $window.SelectInput(163919);
43 my $event := Xlib::newEvent();
57 $display.NextEvent($event);
58 $type := $event.type();
62 $window.DrawPoint($x, $y);
72 elsif ($type == 6 && $pressed) {
75 $window.DrawLine($lastx, $lasty, $x, $y);
94 while ($i < @points) {
95 $window.DrawPoint(@points[$i], @points[$i+1]);
100 $window.DrawLine(@lines[$i], @lines[$i+1],
101 @lines[$i+2], @lines[$i+3]);
112 # vim: expandtab shiftwidth=4 ft=perl6: