June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
40
Task/Window-creation-X11/Julia/window-creation-x11.julia
Normal file
40
Task/Window-creation-X11/Julia/window-creation-x11.julia
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using Xlib
|
||||
|
||||
function x11demo()
|
||||
# Open connection to the server.
|
||||
dpy = XOpenDisplay(C_NULL)
|
||||
dpy == C_NULL && error("unable to open display")
|
||||
scr = DefaultScreen(dpy)
|
||||
|
||||
# Create a window.
|
||||
win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 10, 10, 300, 100, 1,
|
||||
BlackPixel(dpy, scr), WhitePixel(dpy, scr))
|
||||
|
||||
# Select the kind of events we are interested in.
|
||||
XSelectInput(dpy, win, ExposureMask | KeyPressMask)
|
||||
|
||||
# Show or in x11 terms map window.
|
||||
XMapWindow(dpy, win)
|
||||
|
||||
# Run event loop.
|
||||
evt = Ref(XEvent())
|
||||
while true
|
||||
XNextEvent(dpy, evt)
|
||||
|
||||
# Draw or redraw the window.
|
||||
if EventType(evt) == Expose
|
||||
XFillRectangle(dpy, win, DefaultGC(dpy, scr), 24, 24, 16, 16)
|
||||
XDrawString(dpy, win, DefaultGC(dpy, scr), 50, 50, "Hello, World! Press any key to exit.")
|
||||
end
|
||||
|
||||
# Exit whenever a key is pressed.
|
||||
if EventType(evt) == KeyPress
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
# Shutdown server connection
|
||||
XCloseDisplay(dpy)
|
||||
end
|
||||
|
||||
x11demo()
|
||||
Loading…
Add table
Add a link
Reference in a new issue