From: Grégoire Jadi Date: Tue, 11 Jun 2013 13:12:58 +0000 (+0200) Subject: Small fixes X-Git-Tag: emacs-25.0.90~2903^2~8 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8847f1116c0a29899c742805ccabb7604f08a52c;p=emacs.git Small fixes * lisp/xwidget.el: Do some cosmetic changes. Align expressions, remove some whitespaces, remove duplicated provide, replace (if foo foo bar) by (or foo bar) * src/xwidget.c (Fmake_xwidget): Cosmetic changes and fix a comment. * README.xwidget: Fix some typos. --- diff --git a/README.xwidget b/README.xwidget index d4ed54549e0..71e4e5f743b 100644 --- a/README.xwidget +++ b/README.xwidget @@ -121,7 +121,7 @@ we provide proper sizes and so on back to the redisplay engine. The problem is that Emacs cant actually draw the widgets, as it can with images. Emacs must notify GTK about where the widgets should be, and how they should be clipped and so on, and this information must be given to GTK -synchonous with Emacs display changes. Ok, so why is that difficult then? +synchronous with Emacs display changes. Ok, so why is that difficult then? - How do we know when a widget is NOT to be drawn? The only way I found so far is having a flag for each xwdiget, that is reset before a redisplay. When an @@ -198,9 +198,9 @@ xembed host widget that allows for embedding other applications inside an Emacs window, the story gets more complex. The problem is that xembed is designed to plug an application window -inside a a secket and thats it. You can't move a plug between +inside a socket and thats it. You can't move a plug between sockets. I tried numerous hacks to get around this but there is -nothing that works realy well. +nothing that works really well. Therefore the Emacs part of the code will only expose well-defined interfaces. cooperating applications will be able to use the interface @@ -215,14 +215,14 @@ multi view xembed function. That way Emacs is sane and the insanity contained. This app will work by providing a socket that an app plugs into. The -socket window is copied efficientlp by means of composition to a -number of other windows, that then are plugged into the different +socket window is copied efficiently by means of composition to a +number of other windows, that are then plugged into the different Emacs sockets. ** old notes from x_draw_xwidget_glyph_string BUG it seems this method for some reason is called with bad s->x and s->y sometimes. When this happens the xwidget doesnt move on screen as it should. - This mightbe because of x_scroll_run. Emacs decides to scroll the screen by blitting sometimes. + This might be because of x_scroll_run. Emacs decides to scroll the screen by blitting sometimes. then emacs doesnt try to actualy call the paint routines, which means this here code will never run so the xwidget wont know it has been moved. @@ -233,7 +233,7 @@ Emacs sockets. always available in an off-screen buffer. My current attempt at composition doesnt work properly however. //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok - // this is because we dont know when the container gets around to doing layout + // this is because we dont know when the container gets around to do layout //GtkAllocation galloc; //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc); //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height); @@ -242,7 +242,7 @@ Emacs sockets. *** old notes about the old live/phantom scheme //TODO: - // 1) always draw live xwidget in slected window + // 1) always draw live xwidget in selected window // (2) if there were no live instances of the xwidget in selected window, also draw it live) // 3) if there was a live xwidget previously, now phantom it. @@ -547,7 +547,7 @@ hangs. http://kegel.com/gtk/button.c -*** TODO examine some library to synthesise events +*** TODO examine some library to synthesize events xdotool xte xautomation crikey @@ -641,7 +641,7 @@ the other aproach would be to work more like images: xwidget. - retrieve the xwidget objet from the spec with an xwidget-at-point function. It can be uninitalized which client code must handle. Unlike - assynchronous process creation we dont get back a handle, because + asynchronous process creation we dont get back a handle, because there is none yet. - emitted event on initialization, when needed. Many widgets don't need this. for instance, a button sends an event when pressed. but @@ -831,7 +831,7 @@ anyway clipping is rather complicated but seems to finally work okay. CLOSED: [2011-07-04 Mon 16:55] http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window mentions that it has_window can only be called inside a widget -impementation. +implementation. this wasnt really the issue. allocation was the problem *** DONE try scrolled window @@ -922,7 +922,7 @@ see: I returned to using a simple gtkfixed for the widgetwindow. with allocation hack and set_has_window it works. Idea prefer not to have the allocatien hack and it wasnt needed it gtk3 only gtk2. needs -furthi investigation, +further investigation. ** various code cleanups There are many cleanups necessary before any hope of inclusion in @@ -1013,9 +1013,9 @@ crash in gtk_window_get_size instead. great. http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html -after many atempts, the basic issue remains. for some reason the +after many attempts, the basic issue remains. for some reason the offscreen widget isnt ok when I want to snapshot it, so i simply get -emptiness. the surface is only ok someimes. +emptiness. the surface is only ok sometimes. here is a useful debugging snippets: #+begin_src C @@ -1060,7 +1060,7 @@ seems to be severly bitrotted heres a newer aproach http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp -while webkit clearly has the best traction as an embeddee, the +while webkit clearly has the best traction as an embedded, the offscreen rendering issues makes it interesting to see what ff brings to the table. @@ -1100,7 +1100,7 @@ maybe https://launchpad.net/gnome-seed or this funny hack: - im trying to understanh how to interact via javascript to an embedded + im trying to understand how to interact via javascript to an embedded webkit gtk instance [23:38] i use webkit_web_view_execute_script() which is nice but doesnt return a value, by design aparently [23:39] @@ -1139,7 +1139,7 @@ easy. ** webkit related *** TODO webkit support webkit signals -**** DONE particularily document-load-finished +**** DONE particularly document-load-finished CLOSED: [2011-08-01 Mon 22:34] http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished because one might need tell set a title and sizes and things when it loads. @@ -1375,7 +1375,7 @@ Maybe a new image type could be added that was a wraper on an xwidget. Then image mode could be reused for webkit mode. I tried some adaptor code in xwidget.el so webkit mode now delegates -to image mode buh its a kludge. +to image mode but its a kludge. ** socket related *** TODO some flickering during redisplay of sockets @@ -1385,13 +1385,13 @@ xwidget socket type. The webkit xwidget doesn't seem similarily afflicted. the size allocation workaround works by 1st running the ordinary -allocation then modifying the results. its done this way to minimise +allocation then modifying the results. its done this way to minimize the copy paste index from the base class. it might be that the original allocation has a brief time window to show itself. tried to modify the allocation hack so it doesn't call allocate twice. this doesn't seem to help flicker at all aparently so the -hypothesis falls. Maybe then a socket simply doesn't lke being clipped +hypothesis falls. Maybe then a socket simply doesn't like being clipped by gtkfixed. *** TODO xwidget view reaping too agressive @@ -1434,7 +1434,7 @@ suspects: - XCopyArea - x_shift_glyphs_for_insert - x_scroll_run. this is run by the try_window* functions, and - inhibiting them dösnt help. but also callid in scrolling_window. + inhibiting them doesnt help. but also callid in scrolling_window. - try_window_reusing_current_matrix @@ -1452,7 +1452,7 @@ workaround: (run-with-timer 1 1 'redraw-display) seems to work: -inhibiting scrolling_window(). and this seem to be enaugh to restore +inhibiting scrolling_window(). and this seem to be enough to restore the old behaviour, GLYPH_DEBUG doesn't seem needed. diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 8af8d47c00d..00f1ca9b87e 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -3,7 +3,7 @@ ;;; Commentary: -;; +;; ;;TODO this breaks compilation when we dont have xwidgets ;;(require 'xwidget-internal) @@ -17,13 +17,12 @@ Return ID see xwidget.c for types suitable for TYPE." (goto-char pos) - (let ((id (make-xwidget (point) (point) type title width height nil))) - (put-text-property (point) - (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) - + (let ((id (make-xwidget (point) (point) + type title width height nil))) + (put-text-property (point) (+ 1 (point)) + 'display (list 'xwidget ':xwidget id)) id)) - (defun xwidget-at (pos) "Return xwidget at POS." ;;TODO this function is a bit tedious because the C layer isnt well protected yet and @@ -31,10 +30,7 @@ see xwidget.c for types suitable for TYPE." (let* ((disp (get-text-property pos 'display)) (xw (car (cdr (cdr disp))))) ;;(if ( xwidgetp xw) xw nil) - (if (equal 'xwidget (car disp)) xw) - )) - - + (if (equal 'xwidget (car disp)) xw))) ;; (defun xwidget-socket-handler () @@ -63,7 +59,7 @@ see xwidget.c for types suitable for TYPE." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; webkit support (require 'browse-url) -(require 'image-mode);;for some image-mode alike functinoality +(require 'image-mode);;for some image-mode alike functionality (require 'cl-macs);;for flet ;;;###autoload @@ -72,14 +68,14 @@ see xwidget.c for types suitable for TYPE." NEW-SESSION specifies whether to create a new xwidget-webkit session. URL defaults to the string looking like a url around the cursor position." (interactive (progn - (require 'browse-url) - (browse-url-interactive-arg "xwidget-webkit URL: " + (require 'browse-url) + (browse-url-interactive-arg "xwidget-webkit URL: " ;;( xwidget-webkit-current-url) ))) (when (stringp url) (setq url (url-tidy url)) (if new-session - (xwidget-webkit-new-session url) + (xwidget-webkit-new-session url) (xwidget-webkit-goto-url url)))) @@ -97,7 +93,7 @@ defaults to the string looking like a url around the cursor position." (funcall ,fn )))) (defmacro xwidget-image-mode-navigation-adaptor-p (fn) - "Image code adaptor. `image-mode' FN is called with interactive arg." + "Image code adaptor. `image-mode' FN is called with interactive arg." `(lambda (n) (interactive "p") (cl-flet ((image-display-size (spec) (xwidget-image-display-size spec))) (funcall ,fn n)))) @@ -116,26 +112,26 @@ defaults to the string looking like a url around the cursor position." (define-key map "w" 'xwidget-webkit-current-url) ;;similar to image mode bindings - (define-key map (kbd "SPC") (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) - (define-key map (kbd "DEL") (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) - - (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) - (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) - - (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) - (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) - - (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) - (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) - (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) - (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) - (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor-p 'image-previous-line)) - (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor-p 'image-next-line)) - - (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-bol)) - (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-eol)) - (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) - (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) + (define-key map (kbd "SPC") (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) + (define-key map (kbd "DEL") (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) + + (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) + (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) + + (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) + (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) + + (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) + (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) + (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) + (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) + (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor-p 'image-previous-line)) + (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor-p 'image-next-line)) + + (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-bol)) + (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-eol)) + (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) + (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) map) "Keymap for `xwidget-webkit-mode'.") @@ -162,34 +158,29 @@ defaults to the string looking like a url around the cursor position." ) ;(funcall xwidget-callback xwidget xwidget-event-type) (message "xw callback %s" xwidget) - (funcall 'xwidget-webkit-callback xwidget xwidget-event-type) - )) + (funcall 'xwidget-webkit-callback xwidget xwidget-event-type))) (defun xwidget-webkit-callback (xwidget xwidget-event-type) (save-excursion - (cond ( (buffer-live-p (xwidget-buffer xwidget)) - (set-buffer (xwidget-buffer xwidget)) - (let* ( (strarg (nth 3 last-input-event))) - (cond ((eq xwidget-event-type 'document-load-finished) - (xwidget-log "webkit finished loading: '%s'" (xwidget-webkit-get-title xwidget)) - (xwidget-adjust-size-to-content xwidget) - (rename-buffer (format "*xwidget webkit: %s *" (xwidget-webkit-get-title xwidget))) - (pop-to-buffer (current-buffer)) - ) - - ((eq xwidget-event-type 'navigation-policy-decision-requested) - (if (string-match ".*#\\(.*\\)" strarg) - (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg)))) - (t (xwidget-log "unhandled event:%s" xwidget-event-type))))) + (cond ((buffer-live-p (xwidget-buffer xwidget)) + (set-buffer (xwidget-buffer xwidget)) + (let* ((strarg (nth 3 last-input-event))) + (cond ((eq xwidget-event-type 'document-load-finished) + (xwidget-log "webkit finished loading: '%s'" (xwidget-webkit-get-title xwidget)) + (xwidget-adjust-size-to-content xwidget) + (rename-buffer (format "*xwidget webkit: %s *" (xwidget-webkit-get-title xwidget))) + (pop-to-buffer (current-buffer))) + ((eq xwidget-event-type 'navigation-policy-decision-requested) + (if (string-match ".*#\\(.*\\)" strarg) + (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg)))) + (t (xwidget-log "unhandled event:%s" xwidget-event-type))))) (t (xwidget-log "error: callback called for xwidget with dead buffer"))))) (define-derived-mode xwidget-webkit-mode special-mode "xwidget-webkit" "xwidget webkit view mode" (setq buffer-read-only t) ;; Keep track of [vh]scroll when switching buffers - (image-mode-setup-winprops) - - ) + (image-mode-setup-winprops)) (defvar xwidget-webkit-last-session-buffer nil) @@ -238,13 +229,13 @@ function findactiveelement(doc){ " -"javascript that finds the active element." -;;yes its ugly. because: -;; - there is aparently no way to find the active frame other than recursion -;; - the js "for each" construct missbehaved on the "frames" collection -;; - a window with no frameset still has frames.length == 1, but frames[0].document.activeElement != document.activeElement -;;TODO the activeelement type needs to be examined, for iframe, etc. sucks. -) + "javascript that finds the active element." + ;;yes its ugly. because: + ;; - there is aparently no way to find the active frame other than recursion + ;; - the js "for each" construct missbehaved on the "frames" collection + ;; - a window with no frameset still has frames.length == 1, but frames[0].document.activeElement != document.activeElement + ;;TODO the activeelement type needs to be examined, for iframe, etc. sucks. + ) (defun xwidget-webkit-insert-string (xw str) "Insert string in the active field in the webkit. @@ -258,22 +249,23 @@ Argument STR string." (progn (xwidget-webkit-execute-script xww xwidget-webkit-activeelement-js) (xwidget-webkit-execute-script-rv xww "findactiveelement(document).value;" ))) - (field-type (xwidget-webkit-execute-script-rv xww "findactiveelement(document).type;" ))) + (field-type (xwidget-webkit-execute-script-rv xww "findactiveelement(document).type;" ))) (list xww - (cond ( (equal "text" field-type) (read-string "text:" field-value)) - ( (equal "password" field-type) (read-passwd "password:" nil field-value)) - ( (equal "textarea" field-type) (xwidget-webkit-begin-edit-textarea xww field-value)) - )))) + (cond ((equal "text" field-type) + (read-string "text:" field-value)) + ((equal "password" field-type) + (read-passwd "password:" nil field-value)) + ((equal "textarea" field-type) + (xwidget-webkit-begin-edit-textarea xww field-value)))))) (xwidget-webkit-execute-script xw (format "findactiveelement(document).value='%s'" str))) (defun xwidget-webkit-begin-edit-textarea (xw text) - (switch-to-buffer + (switch-to-buffer (generate-new-buffer "textarea")) - + (set (make-local-variable 'xwbl) xw) - (insert text) - ) + (insert text)) (defun xwidget-webkit-end-edit-textarea () (interactive) @@ -295,42 +287,49 @@ Argument STR string." ;; - the selected window is scrolled but this is not always correct ;; - this needs to be interfaced into browse-url somehow. the tricky part is that we need to do this in two steps: ;; A: load the base url, wait for load signal to arrive B: navigate to the anchor when the base url is finished rendering - + ;;this part figures out the Y coordinate of the element - (let ((y - (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-name) 0)))) - ;;now we need to tell emacs to scroll the element into view. + (let ((y (string-to-number + (xwidget-webkit-execute-script-rv xw + (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-name) + 0)))) + ;;now we need to tell emacs to scroll the element into view. (xwidget-log "scroll: %d" y) - (set-window-vscroll (selected-window) y t)) - ) + (set-window-vscroll (selected-window) y t))) (defun xwidget-webkit-show-id-element (xw element-id) "make id-element show. for instance an anchor." - (interactive (list (xwidget-webkit-current-session) (read-string "element id:"))) - (let ((y - (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementById('%s').getBoundingClientRect().top" element-id) 0)))) - ;;now we need to tell emacs to scroll the element into view. + (interactive (list (xwidget-webkit-current-session) + (read-string "element id:"))) + (let ((y (string-to-number + (xwidget-webkit-execute-script-rv xw + (format "document.getElementById('%s').getBoundingClientRect().top" element-id) + 0)))) + ;;now we need to tell emacs to scroll the element into view. (xwidget-log "scroll: %d" y) - (set-window-vscroll (selected-window) y t)) - ) + (set-window-vscroll (selected-window) y t))) (defun xwidget-webkit-show-id-or-named-element (xw element-id) "make id-element show. for instance an anchor." - (interactive (list (xwidget-webkit-current-session) (read-string "element id:"))) - (let* ((y1 - (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-id) "0"))) - (y2 - (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementById('%s').getBoundingClientRect().top" element-id) "0"))) - (y3 (max y1 y2))) - ;;now we need to tell emacs to scroll the element into view. + (interactive (list (xwidget-webkit-current-session) + (read-string "element id:"))) + (let* ((y1 (string-to-number + (xwidget-webkit-execute-script-rv xw + (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-id) + "0"))) + (y2 (string-to-number + (xwidget-webkit-execute-script-rv xw + (format "document.getElementById('%s').getBoundingClientRect().top" element-id) + "0"))) + (y3 (max y1 y2))) + ;;now we need to tell emacs to scroll the element into view. (xwidget-log "scroll: %d" y3) - (set-window-vscroll (selected-window) y3 t)) - ) + (set-window-vscroll (selected-window) y3 t))) (defun xwidget-webkit-adjust-size-to-content () "Adjust webkit to content size." (interactive) - ( xwidget-adjust-size-to-content ( xwidget-webkit-current-session))) + (xwidget-adjust-size-to-content (xwidget-webkit-current-session))) (defun xwidget-webkit-adjust-size (w h) "Manualy set webkit size. @@ -338,16 +337,16 @@ Argument W width. Argument H height." ;;TODO shouldnt be tied to the webkit xwidget (interactive "nWidth:\nnHeight:\n") - ( xwidget-resize ( xwidget-webkit-current-session) w h)) + (xwidget-resize ( xwidget-webkit-current-session) w h)) (defun xwidget-webkit-fit-width () (interactive) - (xwidget-webkit-adjust-size - (- (caddr (window-inside-pixel-edges)) (car (window-inside-pixel-edges))) - 1000)) + (xwidget-webkit-adjust-size (- (caddr (window-inside-pixel-edges)) + (car (window-inside-pixel-edges))) + 1000)) (defun xwidget-webkit-new-session (url) -"Create a new webkit session buffer with URL." + "Create a new webkit session buffer with URL." (let* ((bufname (generate-new-buffer-name "*xwidget-webkit*")) xw) @@ -356,31 +355,32 @@ Argument H height." (setq xw (xwidget-insert 1 'webkit-osr bufname 1000 1000)) (xwidget-put xw 'callback 'xwidget-webkit-callback) (xwidget-webkit-mode) - (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url ))) + (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url ))) (defun xwidget-webkit-goto-url (url) "Goto URL." - (if ( xwidget-webkit-current-session) + (if (xwidget-webkit-current-session) (progn - (xwidget-webkit-goto-uri ( xwidget-webkit-current-session) url)) - ( xwidget-webkit-new-session url))) + (xwidget-webkit-goto-uri (xwidget-webkit-current-session) url)) + (xwidget-webkit-new-session url))) (defun xwidget-webkit-back () "Back in history." (interactive) - (xwidget-webkit-execute-script ( xwidget-webkit-current-session) "history.go(-1);")) + (xwidget-webkit-execute-script (xwidget-webkit-current-session) "history.go(-1);")) (defun xwidget-webkit-reload () "Reload current url." (interactive) - (xwidget-webkit-execute-script ( xwidget-webkit-current-session) "history.go(0);")) + (xwidget-webkit-execute-script (xwidget-webkit-current-session) "history.go(0);")) (defun xwidget-webkit-current-url () "Get the webkit url. place it on kill ring." (interactive) - (let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) "document.URL")) - (url (kill-new (if rv rv "")))) + (let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) + "document.URL")) + (url (kill-new (or rv "")))) (message "url: %s" url ) url)) @@ -391,13 +391,15 @@ Argument H height." ;;or we find some other way to access the DOM ;;reset webkit title. fugly. - (let* ( (emptytag "titlecantbewhitespaceohthehorror") - title) - (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" (if default default emptytag))) + (let* ((emptytag "titlecantbewhitespaceohthehorror") + title) + (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" (or default emptytag))) (xwidget-webkit-execute-script xw (format "document.title=%s;" script)) (setq title (xwidget-webkit-get-title xw)) - (if (equal emptytag title) (setq title "")) - (unless title (setq title default)) + (if (equal emptytag title) + (setq title "")) + (unless title + (setq title default)) title)) @@ -427,7 +429,7 @@ This is the last value stored with `(xwidget-put XWIDGET PROPNAME VALUE)'." "Change XWIDGET' PROPNAME property to VALUE. It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." (set-xwidget-plist xwidget - (plist-put (xwidget-plist xwidget) propname value))) + (plist-put (xwidget-plist xwidget) propname value))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -463,6 +465,4 @@ yet, so deinstall Flash instead for now." (provide 'xwidget) -(provide 'xwidget) - ;;; xwidget.el ends here diff --git a/src/xwidget.c b/src/xwidget.c index 42659723a4b..9c9e8169790 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -208,11 +208,11 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, XSETSYMBOL(xw->type, type); XSETSTRING(xw->title, title); //TODO buffer should be an optional argument not just assumed to be the current buffer - XSETBUFFER(xw->buffer, Fcurrent_buffer()); // conservatively gcpro xw since we call lisp + XSETBUFFER(xw->buffer, Fcurrent_buffer()); // conservatively gcpro xw since we call lisp xw->height = XFASTINT(height); xw->width = XFASTINT(width); - XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); //?? dunno why i need this - Vxwidget_alist = Fcons ( val, Vxwidget_alist); + XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); // set the vectorlike_header of VAL with the correct value + Vxwidget_alist = Fcons (val, Vxwidget_alist); xw->widgetwindow_osr = NULL; xw->widget_osr = NULL; xw->plist = Qnil; @@ -224,73 +224,73 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, */ if (EQ(xw->type, Qwebkit_osr)|| EQ(xw->type, Qsocket_osr)|| - (Fget(xw->type, Qcxwgir_class) != Qnil)){ - printf("init osr widget\n"); - block_input(); - xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); - gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); - - if (EQ(xw->type, Qwebkit_osr)) - xw->widget_osr = webkit_web_view_new(); - if(EQ(xw->type, Qsocket_osr)) - xw->widget_osr = gtk_socket_new(); - if(Fget(xw->type, Qcxwgir_class) != Qnil) - xw->widget_osr = xwgir_create( SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))), + (Fget(xw->type, Qcxwgir_class) != Qnil)) { + printf("init osr widget\n"); + block_input(); + xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); + gtk_window_resize(GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); + + if (EQ(xw->type, Qwebkit_osr)) + xw->widget_osr = webkit_web_view_new(); + if(EQ(xw->type, Qsocket_osr)) + xw->widget_osr = gtk_socket_new(); + if(Fget(xw->type, Qcxwgir_class) != Qnil) + xw->widget_osr = xwgir_create(SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))), SDATA(Fcar(Fget(xw->type, Qcxwgir_class)))); - gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); - gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); + gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); + gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); - gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); + gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); - /* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */ - g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); - g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); - /* signals */ - g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); + /* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */ + g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); + g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); + /* signals */ + g_signal_connect (G_OBJECT (xw->widgetwindow_osr), "damage-event", + G_CALLBACK (xwidget_osr_damage_event_callback), NULL); - if (EQ(xw->type, Qwebkit_osr)){ - g_signal_connect (G_OBJECT ( xw->widget_osr), - "document-load-finished", - G_CALLBACK (webkit_osr_document_load_finished_callback), - xw); + if (EQ(xw->type, Qwebkit_osr)) { + g_signal_connect (G_OBJECT (xw->widget_osr), + "document-load-finished", + G_CALLBACK (webkit_osr_document_load_finished_callback), + xw); - g_signal_connect (G_OBJECT ( xw->widget_osr), - "download-requested", - G_CALLBACK (webkit_osr_download_callback), - xw); - - g_signal_connect (G_OBJECT ( xw->widget_osr), - "mime-type-policy-decision-requested", - G_CALLBACK (webkit_osr_mime_type_policy_typedecision_requested_callback), - xw); - - g_signal_connect (G_OBJECT ( xw->widget_osr), - "new-window-policy-decision-requested", - G_CALLBACK (webkit_osr_new_window_policy_decision_requested_callback), - xw); - - g_signal_connect (G_OBJECT ( xw->widget_osr), - "navigation-policy-decision-requested", - G_CALLBACK (webkit_osr_navigation_policy_decision_requested_callback), - xw); - //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); + g_signal_connect (G_OBJECT (xw->widget_osr), + "download-requested", + G_CALLBACK (webkit_osr_download_callback), + xw); + + g_signal_connect (G_OBJECT (xw->widget_osr), + "mime-type-policy-decision-requested", + G_CALLBACK (webkit_osr_mime_type_policy_typedecision_requested_callback), + xw); + + g_signal_connect (G_OBJECT (xw->widget_osr), + "new-window-policy-decision-requested", + G_CALLBACK (webkit_osr_new_window_policy_decision_requested_callback), + xw); + + g_signal_connect (G_OBJECT (xw->widget_osr), + "navigation-policy-decision-requested", + G_CALLBACK (webkit_osr_navigation_policy_decision_requested_callback), + xw); + //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); - } + } - if (EQ(xw->type, Qsocket_osr)) { - printf ("xwid:%d socket id:%x %d\n", - xw, - gtk_socket_get_id (GTK_SOCKET (xw->widget_osr)), - gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); - send_xembed_ready_event (xw, - gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); - //gtk_widget_realize(xw->widget); - } + if (EQ(xw->type, Qsocket_osr)) { + printf ("xwid:%d socket id:%x %d\n", + xw, + gtk_socket_get_id (GTK_SOCKET (xw->widget_osr)), + gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); + send_xembed_ready_event (xw, gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); + //gtk_widget_realize(xw->widget); + } - unblock_input(); + unblock_input(); } #endif /* HAVE_WEBKIT_OSR */