diff options
| author | Joakim Verona | 2011-07-17 23:53:27 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-07-17 23:53:27 +0200 |
| commit | 32b1b66b26662eb2dd46657cbd292063691bfc79 (patch) | |
| tree | 4b4302b917d5049cdb1cf4a4e0dcb3f129744761 | |
| parent | b9cc0253ffe73b2c5c2cf4dddd65786a2d03d8c2 (diff) | |
| download | emacs-32b1b66b26662eb2dd46657cbd292063691bfc79.tar.gz emacs-32b1b66b26662eb2dd46657cbd292063691bfc79.zip | |
some attempts at real-world usefulness
| -rw-r--r-- | README.xwidget | 59 | ||||
| -rw-r--r-- | lisp/xwidget.el | 43 | ||||
| -rw-r--r-- | src/xdisp.c | 15 | ||||
| -rw-r--r-- | src/xwidget.c | 30 |
4 files changed, 125 insertions, 22 deletions
diff --git a/README.xwidget b/README.xwidget index 89c07127b5c..6ac7469fd08 100644 --- a/README.xwidget +++ b/README.xwidget | |||
| @@ -24,8 +24,10 @@ The xwidget code attempts to keep the visual appearance of the views | |||
| 24 | in sync with through an Observer pattern implementation. | 24 | in sync with through an Observer pattern implementation. |
| 25 | 25 | ||
| 26 | ** building | 26 | ** building |
| 27 | export CFLAGS="-g" | 27 | export CFLAGS=" -g -DGLYPH_DEBUG=1" |
| 28 | #export CFLAGS="-g" | ||
| 28 | ./configure --with-x-toolkit=gtk3 --with-xwidgets | 29 | ./configure --with-x-toolkit=gtk3 --with-xwidgets |
| 30 | make -j4 | ||
| 29 | 31 | ||
| 30 | ** MVC and Xembedd | 32 | ** MVC and Xembedd |
| 31 | The MVC approach appears to be at least in principle robust for plain gtk | 33 | The MVC approach appears to be at least in principle robust for plain gtk |
| @@ -138,6 +140,61 @@ this is aproach worked so-so. | |||
| 138 | 140 | ||
| 139 | * ToDo:s | 141 | * ToDo:s |
| 140 | 142 | ||
| 143 | ** TODO annoying backtrace | ||
| 144 | sadly happens a lot. | ||
| 145 | - happens even with no initialized xwidgets | ||
| 146 | - + row->glyphs[area][i].face_id | ||
| 147 | or similar code, so row is invalid for some reason. | ||
| 148 | xwidgets currently disable some redisplay opimizations so it might be | ||
| 149 | an actual emacs bug manifesting without optimizations. | ||
| 150 | |||
| 151 | *** bt 1 | ||
| 152 | /* Compute the width of this line. */ | ||
| 153 | row->pixel_width = row->x; | ||
| 154 | for (i = 0; i < row->used[TEXT_AREA]; ++i) | ||
| 155 | row->pixel_width += row->glyphs[TEXT_AREA][i].pixel_width; | ||
| 156 | |||
| 157 | (gdb) bt | ||
| 158 | #0 0x000000000045c340 in compute_line_metrics (it=0x7fffffff8a20) | ||
| 159 | at xdisp.c:17549 | ||
| 160 | #1 0x00000000004603da in display_line (it=0x7fffffff8a20) at xdisp.c:18792 | ||
| 161 | #2 0x0000000000457646 in try_window (window=23403045, pos=..., flags=1) | ||
| 162 | at xdisp.c:15399 | ||
| 163 | #3 0x00000000004559c9 in redisplay_window (window=23403045, just_this_one_p=0) | ||
| 164 | at xdisp.c:14944 | ||
| 165 | #4 0x0000000000450247 in redisplay_window_0 (window=23403045) at xdisp.c:13152 | ||
| 166 | #5 0x00000000005fdcd9 in internal_condition_case_1 (bfun= | ||
| 167 | 0x450208 <redisplay_window_0>, arg=23403045, handlers=12691046, hfun= | ||
| 168 | 0x4501d9 <redisplay_window_error>) at eval.c:1538 | ||
| 169 | #6 0x00000000004501ba in redisplay_windows (window=23403045) at xdisp.c:13132 | ||
| 170 | #7 0x000000000044f19c in redisplay_internal () at xdisp.c:12706 | ||
| 171 | #8 0x000000000044f9f2 in redisplay_preserve_echo_area (from_where=7) | ||
| 172 | at xdisp.c:12964 | ||
| 173 | #9 0x0000000000568525 in swallow_events (do_display=1) at keyboard.c:4197 | ||
| 174 | #10 0x0000000000422554 in sit_for (timeout=40, reading=1, do_display=1) | ||
| 175 | at dispnew.c:5963 | ||
| 176 | #11 0x000000000056512c in read_char (commandflag=1, nmaps=8, maps= | ||
| 177 | 0x7fffffffd3f0, prev_event=12720514, used_mouse_menu=0x7fffffffd604, | ||
| 178 | end_time=0x0) at keyboard.c:2689 | ||
| 179 | #12 0x0000000000572c59 in read_key_sequence (keybuf=0x7fffffffd850, bufsize= | ||
| 180 | 30, prompt=12720514, dont_downcase_last=0, can_return_switch_frame=1, | ||
| 181 | ---Type <return> to continue, or q <return> to quit--- | ||
| 182 | fix_current_buffer=1) at keyboard.c:9291 | ||
| 183 | #13 0x0000000000562897 in command_loop_1 () at keyboard.c:1446 | ||
| 184 | #14 0x00000000005fdb52 in internal_condition_case (bfun= | ||
| 185 | 0x5624b4 <command_loop_1>, handlers=12772898, hfun=0x561dab <cmd_error>) | ||
| 186 | at eval.c:1493 | ||
| 187 | #15 0x00000000005621ab in command_loop_2 (ignore=12720514) at keyboard.c:1157 | ||
| 188 | #16 0x00000000005fd4ce in internal_catch (tag=12768770, func= | ||
| 189 | 0x562185 <command_loop_2>, arg=12720514) at eval.c:1247 | ||
| 190 | #17 0x000000000056215e in command_loop () at keyboard.c:1136 | ||
| 191 | #18 0x00000000005618f9 in recursive_edit_1 () at keyboard.c:757 | ||
| 192 | #19 0x0000000000561a95 in Frecursive_edit () at keyboard.c:821 | ||
| 193 | #20 0x000000000055fba2 in main (argc=1, argv=0x7fffffffe188) at emacs.c:1704 | ||
| 194 | |||
| 195 | |||
| 196 | *** bt 2 | ||
| 197 | |||
| 141 | ** DONE Examine using XComposite rather than GTK off-screen | 198 | ** DONE Examine using XComposite rather than GTK off-screen |
| 142 | rendering. This would make xembed widgets work much better. This | 199 | rendering. This would make xembed widgets work much better. This |
| 143 | would probably be rathter difficult, but could open up other | 200 | would probably be rathter difficult, but could open up other |
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 4c94b7e291c..3ef379c4ffe 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -15,8 +15,10 @@ see xwidget.c for types suitable for TYPE. | |||
| 15 | (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) | 15 | (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) |
| 16 | id)) | 16 | id)) |
| 17 | 17 | ||
| 18 | 18 | (defun xwidget-at (pos) | |
| 19 | 19 | (caddr (get-text-property pos 'display) | |
| 20 | )) | ||
| 21 | |||
| 20 | (defun xwidget-socket-handler () | 22 | (defun xwidget-socket-handler () |
| 21 | "creates plug for socket. TODO" | 23 | "creates plug for socket. TODO" |
| 22 | (interactive) | 24 | (interactive) |
| @@ -60,25 +62,34 @@ defaults to the string looking like a url around the cursor position." | |||
| 60 | ;;todo. | 62 | ;;todo. |
| 61 | ;; - support browse-url with xwidget-webkit | 63 | ;; - support browse-url with xwidget-webkit |
| 62 | ;; - check that the webkit support is compiled in | 64 | ;; - check that the webkit support is compiled in |
| 63 | (define-derived-mode xwidget-webkit-mode special-mode "xwidget-webkit" "xwidget webkit special mode" ) | 65 | (define-derived-mode xwidget-webkit-mode view-mode "xwidget-webkit" "xwidget webkit view mode" ) |
| 64 | (defvar xwidget-webkit-last-session nil) | 66 | |
| 67 | (defvar xwidget-webkit-last-session-buffer nil) | ||
| 68 | |||
| 69 | (defun xwidget-webkit-last-session () | ||
| 70 | (if (buffer-live-p xwidget-webkit-last-session-buffer) | ||
| 71 | (save-excursion | ||
| 72 | (switch-to-buffer xwidget-webkit-last-session-buffer) | ||
| 73 | (xwidget-at 1)) | ||
| 74 | nil)) | ||
| 75 | |||
| 65 | (defun xwidget-webkit-new-session (url) | 76 | (defun xwidget-webkit-new-session (url) |
| 66 | (save-excursion | 77 | |
| 67 | (let* | 78 | (let* |
| 68 | ((bufname (generate-new-buffer-name "*xwidget-webkit*")) | 79 | ((bufname (generate-new-buffer-name "*xwidget-webkit*")) |
| 69 | ) | 80 | ) |
| 70 | (set-buffer (get-buffer-create bufname)) | 81 | (setq xwidget-webkit-last-session-buffer (switch-to-buffer (get-buffer-create bufname))) |
| 71 | (insert " ") | 82 | (insert " ") |
| 72 | (setq xwidget-webkit-last-session (xwidget-insert 1 'webkit-osr bufname 1000 1000)) | 83 | (xwidget-insert 1 'webkit-osr bufname 1000 1000) |
| 73 | (xwidget-webkit-mode) | 84 | (xwidget-webkit-mode) |
| 74 | (xwidget-webkit-goto-uri xwidget-webkit-last-session url )) | 85 | (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url )) |
| 75 | ) | 86 | |
| 76 | 87 | ||
| 77 | ) | 88 | ) |
| 78 | 89 | ||
| 79 | (defun xwidget-webkit-goto-url (url) | 90 | (defun xwidget-webkit-goto-url (url) |
| 80 | (if xwidget-webkit-last-session | 91 | (if ( xwidget-webkit-last-session) |
| 81 | (xwidget-webkit-goto-uri xwidget-webkit-last-session url) | 92 | (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url) |
| 82 | ( xwidget-webkit-new-session url))) | 93 | ( xwidget-webkit-new-session url))) |
| 83 | 94 | ||
| 84 | 95 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index c02de7225e1..67cbfaa76f6 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -12209,7 +12209,7 @@ redisplay_internal (void) | |||
| 12209 | frames. Zero means, only selected_window is considered. */ | 12209 | frames. Zero means, only selected_window is considered. */ |
| 12210 | int consider_all_windows_p; | 12210 | int consider_all_windows_p; |
| 12211 | 12211 | ||
| 12212 | printf(">>>>redisplay\n"); | 12212 | //printf(">>>>redisplay\n"); |
| 12213 | // xwidget_start_redisplay(); | 12213 | // xwidget_start_redisplay(); |
| 12214 | 12214 | ||
| 12215 | TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); | 12215 | TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); |
| @@ -12932,7 +12932,7 @@ redisplay_internal (void) | |||
| 12932 | RESUME_POLLING; | 12932 | RESUME_POLLING; |
| 12933 | //xwidget_end_redisplay(); | 12933 | //xwidget_end_redisplay(); |
| 12934 | 12934 | ||
| 12935 | printf("<<<<redisplay\n"); | 12935 | //printf("<<<<redisplay\n"); |
| 12936 | } | 12936 | } |
| 12937 | 12937 | ||
| 12938 | 12938 | ||
| @@ -15383,6 +15383,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 15383 | struct glyph_row *last_text_row = NULL; | 15383 | struct glyph_row *last_text_row = NULL; |
| 15384 | struct frame *f = XFRAME (w->frame); | 15384 | struct frame *f = XFRAME (w->frame); |
| 15385 | 15385 | ||
| 15386 | |||
| 15386 | /* Make POS the new window start. */ | 15387 | /* Make POS the new window start. */ |
| 15387 | set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); | 15388 | set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); |
| 15388 | 15389 | ||
| @@ -15393,6 +15394,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 15393 | /* Initialize iterator and info to start at POS. */ | 15394 | /* Initialize iterator and info to start at POS. */ |
| 15394 | start_display (&it, w, pos); | 15395 | start_display (&it, w, pos); |
| 15395 | 15396 | ||
| 15397 | |||
| 15396 | /* Display all lines of W. */ | 15398 | /* Display all lines of W. */ |
| 15397 | while (it.current_y < it.last_visible_y) | 15399 | while (it.current_y < it.last_visible_y) |
| 15398 | { | 15400 | { |
| @@ -15489,10 +15491,11 @@ try_window_reusing_current_matrix (struct window *w) | |||
| 15489 | struct glyph_row *start_row; | 15491 | struct glyph_row *start_row; |
| 15490 | int start_vpos, min_y, max_y; | 15492 | int start_vpos, min_y, max_y; |
| 15491 | 15493 | ||
| 15494 | #if HAVE_XWIDGETS_hhh | ||
| 15492 | return 0; | 15495 | return 0; |
| 15493 | //xwidgets doesnt like blit scrolling and stuff, try this for now | 15496 | //xwidgets doesnt like blit scrolling and stuff, try this for now |
| 15494 | //should be optimized, perhaps by just inhibiting optimizations of windows containing xwidgets. | 15497 | //should be optimized, perhaps by just inhibiting optimizations of windows containing xwidgets. |
| 15495 | 15498 | #endif | |
| 15496 | 15499 | ||
| 15497 | #if GLYPH_DEBUG | 15500 | #if GLYPH_DEBUG |
| 15498 | if (inhibit_try_window_reusing) | 15501 | if (inhibit_try_window_reusing) |
| @@ -17476,7 +17479,11 @@ static void | |||
| 17476 | compute_line_metrics (struct it *it) | 17479 | compute_line_metrics (struct it *it) |
| 17477 | { | 17480 | { |
| 17478 | struct glyph_row *row = it->glyph_row; | 17481 | struct glyph_row *row = it->glyph_row; |
| 17479 | 17482 | if(row->used[TEXT_AREA] > 1000){ | |
| 17483 | printf("compute_line_metrics %d %d %d\n", row->used[TEXT_AREA], it->f->text_cols, row->end.pos.charpos); | ||
| 17484 | printf("row->used[TEXT_AREA] seems weirdly big! therefore dont compute_line_metrics\n"); | ||
| 17485 | return; | ||
| 17486 | } | ||
| 17480 | if (FRAME_WINDOW_P (it->f)) | 17487 | if (FRAME_WINDOW_P (it->f)) |
| 17481 | { | 17488 | { |
| 17482 | int i, min_y, max_y; | 17489 | int i, min_y, max_y; |
diff --git a/src/xwidget.c b/src/xwidget.c index 2ea88a22279..44e1d327729 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -783,6 +783,33 @@ DEFUN("xwidget-view-info", Fxwidget_view_info , Sxwidget_view_info, 2,2,0, doc: | |||
| 783 | return info; | 783 | return info; |
| 784 | } | 784 | } |
| 785 | 785 | ||
| 786 | |||
| 787 | DEFUN("xwidget-delete-zombies", Fxwidget_delete_zombies , Sxwidget_delete_zombies, 0,0,0, doc: /* */) | ||
| 788 | (void) | ||
| 789 | { | ||
| 790 | /* | ||
| 791 | - remove all views with window gone | ||
| 792 | |||
| 793 | TODO | ||
| 794 | - remove all xwidgets with buffer gone | ||
| 795 | - remove all views with xw gone | ||
| 796 | |||
| 797 | */ | ||
| 798 | struct xwidget_view* xv = NULL; | ||
| 799 | Lisp_Object w; | ||
| 800 | for (int i = 0; i < MAX_XWIDGETS; i++){ | ||
| 801 | xv = &xwidget_views[i]; | ||
| 802 | XSETWINDOW(w, xv->w); | ||
| 803 | if(xv->initialized && (! (WINDOW_LIVE_P(w)))){ | ||
| 804 | |||
| 805 | gtk_widget_destroy(GTK_WIDGET(xv->widgetwindow)); | ||
| 806 | xv->initialized = 0; | ||
| 807 | } | ||
| 808 | } | ||
| 809 | } | ||
| 810 | |||
| 811 | |||
| 812 | |||
| 786 | void | 813 | void |
| 787 | syms_of_xwidget (void) | 814 | syms_of_xwidget (void) |
| 788 | { | 815 | { |
| @@ -799,7 +826,7 @@ syms_of_xwidget (void) | |||
| 799 | defsubr (&Sxwidget_webkit_execute_script); | 826 | defsubr (&Sxwidget_webkit_execute_script); |
| 800 | defsubr (&Sxwidget_webkit_get_title); | 827 | defsubr (&Sxwidget_webkit_get_title); |
| 801 | defsubr (&Sxwidget_size_request ); | 828 | defsubr (&Sxwidget_size_request ); |
| 802 | 829 | defsubr (&Sxwidget_delete_zombies); | |
| 803 | DEFSYM (Qxwidget ,"xwidget"); | 830 | DEFSYM (Qxwidget ,"xwidget"); |
| 804 | 831 | ||
| 805 | DEFSYM (Qcxwidget ,":xwidget"); | 832 | DEFSYM (Qcxwidget ,":xwidget"); |
| @@ -904,6 +931,7 @@ void xwidget_view_delete_all_in_window( struct window *w ) | |||
| 904 | } | 931 | } |
| 905 | 932 | ||
| 906 | 933 | ||
| 934 | |||
| 907 | struct xwidget_view* xwidget_view_lookup(struct xwidget* xw, struct window *w){ | 935 | struct xwidget_view* xwidget_view_lookup(struct xwidget* xw, struct window *w){ |
| 908 | struct xwidget_view* xv = NULL; | 936 | struct xwidget_view* xv = NULL; |
| 909 | for (int i = 0; i < MAX_XWIDGETS; i++) | 937 | for (int i = 0; i < MAX_XWIDGETS; i++) |