From 72485f5fcba4c761b8c72d22564705df4489c852 Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 3 Jun 2006 21:42:01 +0000 Subject: [PATCH] xlib cleanups and start of clipboard code (untested) --- TODO.FACTOR.txt | 1 - library/ui/x11/clipboard.factor | 25 +++++++++++++++++++++++++ library/ui/x11/xlib.factor | 24 ++++++++++++------------ 3 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 library/ui/x11/clipboard.factor diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 713635cbe8..9021e583aa 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -5,7 +5,6 @@ ] - x11 title bars are funny -- x11: when starting with restored windows, caret invisible + httpd: - outliners don't work - browser responder doesn't work diff --git a/library/ui/x11/clipboard.factor b/library/ui/x11/clipboard.factor new file mode 100644 index 0000000000..d6c575bcca --- /dev/null +++ b/library/ui/x11/clipboard.factor @@ -0,0 +1,25 @@ +! Copyright (C) 2006 Slava Pestov +! See http://factorcode.org/license.txt for BSD license. +USING: alien kernel math namespaces ; +IN: x11 + +! This code was inspired by McCLIM's Backends/CLX/port.lisp. + +: selection-property ( -- n ) + dpy get "org.factorcode.Factor.SELECTION" f XInternAtom ; + +: convert-selection ( win -- n ) + >r dpy get XA_PRIMARY XA_STRING selection-property r> + CurrentTime XConvertSelection ; + +: snarf-property ( length-return prop-return -- string ) + swap *ulong zero? [ drop f ] [ *char* ] if ; + +: window-property ( win prop delete? -- string ) + >r >r >r dpy get r> r> 0 -1 r> AnyProperty + 0 0 0 0 f + [ XGetWindowProperty drop ] 2keep snarf-property ; + +: selection-from-event ( event -- string ) + dup XSelectionEvent-property zero? + [ drop f ] [ selection-property t window-property ] if ; diff --git a/library/ui/x11/xlib.factor b/library/ui/x11/xlib.factor index c89279fa2e..122a86d25b 100644 --- a/library/ui/x11/xlib.factor +++ b/library/ui/x11/xlib.factor @@ -47,19 +47,17 @@ TYPEDEF: ulong Time TYPEDEF: void* Window** TYPEDEF: void* Atom** -: ; -: ; -: ; -: ; -: ; -: ; +: ; inline +: ; inline +: ; inline +: ; inline +: ; inline -: *ulong *uint ; -: *XID *ulong ; -: *Window *XID ; -: *Drawable *XID ; -: *KeySym *XID ; -: *Atom *ulong ; +: *XID *ulong ; inline +: *Window *XID ; inline +: *Drawable *XID ; inline +: *KeySym *XID ; inline +: *Atom *ulong ; inline ! ! 2 - Display Functions ! @@ -261,6 +259,8 @@ FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ; ! 4.4 - Obtaining and Changing Window Properties +: AnyPropertyType 0 ; inline + FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, char** prop_return ) ; FUNCTION: int XChangeProperty ( Display* display, Window w, Atom property, Atom type, int format, int mode, char* data, int nelements ) ;