From 8ea4e2267ac3d9fae0dd8fe8e952ca298e97f6a6 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Sat, 31 Oct 2009 02:50:15 +0300 Subject: [PATCH] Add GdkDisplay --- gdk/cl-gtk2-gdk.asd | 3 +- gdk/gdk.display.lisp | 143 ++++++++++++++++++++++++++++++++++++++++++++++++ gdk/gdk.functions.lisp | 3 - gdk/gdk.objects.lisp | 24 +++++++- 4 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 gdk/gdk.display.lisp diff --git a/gdk/cl-gtk2-gdk.asd b/gdk/cl-gtk2-gdk.asd index ca8cc25..4dfee67 100644 --- a/gdk/cl-gtk2-gdk.asd +++ b/gdk/cl-gtk2-gdk.asd @@ -7,5 +7,6 @@ :components ((:file "gdk.package") (:file "gdk.objects") (:file "gdk.functions") - (:file "gdk.general")) + (:file "gdk.general") + (:file "gdk.display")) :depends-on (:cl-gtk2-glib :cffi :cl-gtk2-pango)) \ No newline at end of file diff --git a/gdk/gdk.display.lisp b/gdk/gdk.display.lisp new file mode 100644 index 0000000..47bf45b --- /dev/null +++ b/gdk/gdk.display.lisp @@ -0,0 +1,143 @@ +(in-package :gdk) + +(defcfun (display-open "gdk_display_open") (g-object display) + (display-name :string)) +(export 'display-open) + +(defcfun (default-display "gdk_display_get_default") (g-object display)) +(export 'default-display) + +(defcfun (display-get-screen "gdk_display_get_screen") (g-object screen) + (display (g-object display)) + (screen-num :int)) +(export 'display-get-screen) + +(defcfun (display-pointer-ungrab "gdk_display_pointer_ungrab") :void + (display (g-object display)) + (time :uint32)) +(export 'display-pointer-ungrab) + +(defcfun (display-keyboard-ungrab "gdk_display_keyboard_ungrab") :void + (display (g-object display)) + (time :uint32)) +(export 'display-keyboard-ungrab) + +(defcfun (display-pointer-is-grabbed "gdk_display_pointer_is_grabbed") :boolean + (display (g-object display))) +(export 'display-pointer-is-grabbed) + +(defcfun (display-beep "gdk_display_beep") :void + (display (g-object display))) +(export 'display-beep) + +(defcfun (display-sync "gdk_display_sync") :void + (display (g-object display))) +(export 'display-sync) + +(defcfun (display-flush "gdk_display_flush") :void + (display (g-object display))) +(export 'display-flush) + +(defcfun (display-close "gdk_display_close") :void + (display (g-object display))) +(export 'display-close) + +(defcfun (display-get-event "gdk_display_get_event") (g-boxed-foreign event :return) + (display (g-object display))) +(export 'display-get-event) + +(defcfun (display-peek-event "gdk_display_peek_event") (g-boxed-foreign event :return) + (display (g-object display))) +(export 'display-peek-event) + +(defcfun (display-put-event "gdk_display_put_event") :void + (display (g-object display)) + (event (g-boxed-foreign event))) +(export 'display-put-event) + +;void gdk_display_add_client_message_filter +; (GdkDisplay *display, +; GdkAtom message_type, +; GdkFilterFunc func, +; gpointer data); + +(defcfun (display-set-double-click-time "gdk_display_set_double_click_time") :void + (display (g-object display)) + (msec :uint)) +(export 'display-set-double-click-time) + +(defcfun (display-set-double-click-distance "gdk_display_set_double_click_distance") :void + (display (g-object display)) + (distance :uint)) +(export 'display-set-double-click-distance) + +(defcfun gdk-display-get-pointer :void + (display (g-object display)) + (screen :pointer) + (x :pointer) + (y :pointer) + (mask :pointer)) + +(defun display-get-pointer (display) + (with-foreign-objects ((screen :pointer) (x :int) (y :int) (mask 'modifier-type)) + (gdk-display-get-pointer display screen x y mask) + (values (mem-ref screen '(g-object screen)) + (mem-ref x :int) + (mem-ref y :int) + (mem-ref mask :int)))) +(export 'display-get-pointer) + +(defcfun gdk-display-get-window-at-pointer (g-object gdk-window) + (display (g-object display)) + (win-x :pointer) + (win-y :pointer)) + +(defun display-get-window-at-pointer (display) + (with-foreign-objects ((win-x :int) (win-y :int)) + (let ((win (gdk-display-get-window-at-pointer display win-x win-y))) + (values win (mem-ref win-x :int) (mem-ref win-y :int))))) + +(export 'display-get-window-at-pointer) + +;GdkDisplayPointerHooks * gdk_display_set_pointer_hooks (GdkDisplay *display, +; const GdkDisplayPointerHooks *new_hooks); + +(defcfun (display-warp-pointer "gdk_display_warp_pointer") :void + (display (g-object display)) + (screen (g-object screen)) + (x :int) + (y :int)) +(export 'display-warp-pointer) + +(defcfun gdk-display-get-maximal-cursor-size :void + (display (g-object display)) + (width :pointer) + (height :pointer)) + +(defun display-get-maximal-cursor-size (display) + (with-foreign-objects ((width :uint) (height :uint)) + (gdk-display-get-maximal-cursor-size display width height) + (values (mem-ref width :uint) (mem-ref height :uint)))) +(export 'display-get-maximal-cursor-size) + +(defcfun (display-request-selection-notification "gdk_display_request_selection_notification") :boolean + (display (g-object display)) + (selection gdk-atom-as-string)) +(export 'display-request-selection-notification) + +(defcfun gdk-display-store-clipboard :void + (display (g-object display)) + (clipboard-window (g-object gdk-window)) + (time :uint32) + (targets :pointer) + (n-targets :int)) + +(defun display-store-clipboard (display clipboard-window time targets) + (let ((n-targets (length targets))) + (with-foreign-object (targets-ptr 'gdk-atom-as-string n-targets) + (loop + for str in targets + for i from 0 + do (setf (mem-aref targets-ptr 'gdk-atom-as-string i) str)) + (gdk-display-store-clipboard display clipboard-window time targets-ptr n-targets)))) +(export 'display-store-clipboard) diff --git a/gdk/gdk.functions.lisp b/gdk/gdk.functions.lisp index d97ea7a..88bbc1e 100644 --- a/gdk/gdk.functions.lisp +++ b/gdk/gdk.functions.lisp @@ -3,9 +3,6 @@ (defcfun (default-screen "gdk_screen_get_default") (g-object gdk-screen)) (export 'default-screen) -(defcfun (default-display "gdk_display_get_default") (g-object display)) -(export 'default-display) - (defcfun gdk-window-get-events event-mask (window (g-object gdk-window))) diff --git a/gdk/gdk.objects.lisp b/gdk/gdk.objects.lisp index 5881e3b..b3bebfc 100644 --- a/gdk/gdk.objects.lisp +++ b/gdk/gdk.objects.lisp @@ -14,7 +14,29 @@ (:cffi n-screens display-n-screens :int "gdk_display_get_n_screens" nil) (:cffi default-screen display-default-screen (g-object screen) - "gdk_display_get_default_screen" nil))) + "gdk_display_get_default_screen" nil) + (:cffi devices display-devices (glib:glist g-object :free-from-foreign nil) + "gdk_display_list_devices" nil) + (:cffi supports-cursor-color display-supports-cursor-color :boolean + "gdk_display_supports_cursor_color" nil) + (:cffi supports-cursor-alpha display-supports-color-alpha :boolean + "gdk_display_supports_cursor_alpha" nil) + (:cffi default-cursor-size display-default-cursor-size :uint + "gdk_display_get_default_cursor_size" nil) + (:cffi default-group display-default-group (g-object gdk-window) + "gdk_display_get_default_group" nil) + (:cffi supports-selection-notification display-supports-selection-notification :boolean + "gdk_display_supports_selection_notification" nil) + (:cffi supports-clipboard-persistence display-supports-clipboard-persistence :boolean + "gdk_display_supports_clipboard_persistence" nil) + (:cffi supports-shapes display-supports-shapes :boolean + "gdk_display_supports_shapes" nil) + (:cffi supports-input-shapes display-supports-input-shapes :boolean + "gdk_display_supports_input_shapes" nil) + (:cffi supports-composite display-supports-composite :boolean + "gdk_display_supports_composite" nil) + (:cffi core-pointer display-core-pointer g-object + "gdk_display_get_core_pointer" nil))) ;gdk_display_get_screen -- 1.7.10.4