Kevin Cheng | 757c264 | 2019-04-18 11:31:16 -0700 | [diff] [blame] | 1 | import sys, os |
| 2 | |
| 3 | # run xclient_build first, then make sure the shared object is on sys.path |
| 4 | from _xclient_cffi import ffi, lib |
| 5 | |
| 6 | |
| 7 | # ffi "knows" about the declared variables and functions from the |
| 8 | # cdef parts of the module xclient_build created, |
| 9 | # lib "knows" how to call the functions from the set_source parts |
| 10 | # of the module. |
| 11 | |
| 12 | |
| 13 | class XError(Exception): |
| 14 | pass |
| 15 | |
| 16 | def main(): |
| 17 | display = lib.XOpenDisplay(ffi.NULL) |
| 18 | if display == ffi.NULL: |
| 19 | raise XError("cannot open display") |
| 20 | w = lib.XCreateSimpleWindow(display, lib.DefaultRootWindow(display), |
| 21 | 10, 10, 500, 350, 0, 0, 0) |
| 22 | lib.XMapRaised(display, w) |
| 23 | event = ffi.new("XEvent *") |
| 24 | lib.XNextEvent(display, event) |
| 25 | |
| 26 | if __name__ == '__main__': |
| 27 | main() |