Window creation/X11: Difference between revisions
→{{header|Perl 6}}: Minimal changes to make runnable
No edit summary |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Minimal changes to make runnable) |
||
Line 824:
=={{header|Perl 6}}==
{{trans|C}}
There is not yet a X11 library in Perl 6 but we can write the minimal C mappings for this task.
<lang perl6>use NativeCall;
class Display is repr('CStruct') {
has int32 $!screen;
class GC is repr('CStruct') {}▼
has int32 $!window;
}
has int32 $!context;
}
class XEvent is repr('CStruct') {
has int32 $.type;
method init { $!type = 0 }
}
sub XOpenDisplay(Str $name = ':0') returns Display is native('
sub XDefaultScreen(Display $) returns
sub XRootWindow(Display $,
sub XBlackPixel(Display $,
sub XWhitePixel(Display $,
sub XCreateSimpleWindow(
Display $,
) returns
sub XMapWindow(Display $,
sub XSelectInput(Display $,
sub XFillRectangle(
Display $,
) is native('
sub XDrawString(
Display $,
) is native('
sub XDefaultGC(Display $,
sub XNextEvent(Display $, XEvent $e) is native('
sub XCloseDisplay(Display $) is native('
my Display $display = XOpenDisplay()
Line 879 ⟶ 881:
XNextEvent($display, $e);
if $e.type == 12 {
}
elsif $e.type == 2 {
}
}
|