diff options
| author | Joakim Verona | 2010-09-10 07:27:36 +0200 |
|---|---|---|
| committer | Joakim Verona | 2010-09-10 07:27:36 +0200 |
| commit | 5d131913cfdb52afeec90b7bf37ba307e4d8b3b3 (patch) | |
| tree | e503f1b65cc25ebafb1d5cec9a53eba898c38a66 /src/xwidget.c | |
| parent | 8dfed77f7bdf7591d6daa705364db6ba0d872116 (diff) | |
| download | emacs-5d131913cfdb52afeec90b7bf37ba307e4d8b3b3.tar.gz emacs-5d131913cfdb52afeec90b7bf37ba307e4d8b3b3.zip | |
beginnings of a lisp interface to support debugging of xwidgets placements, which is hairy, and buggy.
Diffstat (limited to 'src/xwidget.c')
| -rw-r--r-- | src/xwidget.c | 140 |
1 files changed, 92 insertions, 48 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index 9d977ced256..78e2e718c0b 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -86,6 +86,7 @@ Lisp_Object Qxwidget_id; | |||
| 86 | Lisp_Object Qtitle; | 86 | Lisp_Object Qtitle; |
| 87 | Lisp_Object Qxwidget_set_keyboard_grab; | 87 | Lisp_Object Qxwidget_set_keyboard_grab; |
| 88 | Lisp_Object Qxwidget_embed_steal_window; | 88 | Lisp_Object Qxwidget_embed_steal_window; |
| 89 | Lisp_Object Qxwidget_info; | ||
| 89 | Lisp_Object Qxwidget_resize_internal; | 90 | Lisp_Object Qxwidget_resize_internal; |
| 90 | Lisp_Object Qxwidget_send_keyboard_event; | 91 | Lisp_Object Qxwidget_send_keyboard_event; |
| 91 | 92 | ||
| @@ -154,9 +155,9 @@ int i; | |||
| 154 | if(xwidget_query_composition_called) | 155 | if(xwidget_query_composition_called) |
| 155 | return hasNamePixmap; | 156 | return hasNamePixmap; |
| 156 | xwidget_query_composition_called = 1; | 157 | xwidget_query_composition_called = 1; |
| 157 | 158 | ||
| 158 | //do this once in an emacs session | 159 | //do this once in an emacs session |
| 159 | 160 | ||
| 160 | if(gdk_display_supports_composite(gdk_display_get_default ())){ | 161 | if(gdk_display_supports_composite(gdk_display_get_default ())){ |
| 161 | hasNamePixmap = 1; | 162 | hasNamePixmap = 1; |
| 162 | }else{ | 163 | }else{ |
| @@ -182,7 +183,7 @@ xwidget_setup_socket_composition(struct xwidget* xw) | |||
| 182 | //do this for every gtk_socket | 183 | //do this for every gtk_socket |
| 183 | //XCompositeRedirectWindow(); should probably replace the global backing request | 184 | //XCompositeRedirectWindow(); should probably replace the global backing request |
| 184 | //now residing in xwidget_has_composition() | 185 | //now residing in xwidget_has_composition() |
| 185 | 186 | ||
| 186 | // int xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); | 187 | // int xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); |
| 187 | // Display* dpy = GDK_DISPLAY (); | 188 | // Display* dpy = GDK_DISPLAY (); |
| 188 | 189 | ||
| @@ -216,11 +217,21 @@ xwidget_end_composition(struct xwidget* w){ | |||
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | void | 219 | void |
| 220 | xwidget_show (struct xwidget *xw) | ||
| 221 | { | ||
| 222 | //printf("xwidget %d shown\n",xw->id); | ||
| 223 | xw->hidden = 0; | ||
| 224 | //gtk_widget_show(GTK_WIDGET(xw->widgetwindow)); | ||
| 225 | gtk_fixed_move (GTK_FIXED (xw->emacswindow), GTK_WIDGET (xw->widgetwindow), | ||
| 226 | xw->x, xw->y); | ||
| 227 | } | ||
| 228 | |||
| 229 | void | ||
| 219 | xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) | 230 | xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) |
| 220 | { | 231 | { |
| 221 | xw->initialized = 1; | 232 | xw->initialized = 1; |
| 222 | xw->id = s->xwidget_id; | 233 | xw->id = s->xwidget_id; |
| 223 | xw->hidden = 0; | 234 | xwidget_show(xw); |
| 224 | 235 | ||
| 225 | //widget creation | 236 | //widget creation |
| 226 | switch (xw->type) | 237 | switch (xw->type) |
| @@ -278,7 +289,9 @@ xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) | |||
| 278 | 289 | ||
| 279 | 290 | ||
| 280 | void | 291 | void |
| 281 | xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy, | 292 | xwidget_draw_phantom (struct xwidget *xw, |
| 293 | int x, int y, | ||
| 294 | int clipx, int clipy, | ||
| 282 | struct glyph_string *s) | 295 | struct glyph_string *s) |
| 283 | { | 296 | { |
| 284 | //we cant always get real widgets, so here we try to fetch a snapshot of | 297 | //we cant always get real widgets, so here we try to fetch a snapshot of |
| @@ -294,21 +307,21 @@ xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy, | |||
| 294 | GdkGC *gdkgc = NULL; | 307 | GdkGC *gdkgc = NULL; |
| 295 | GdkNativeWindow p_xid; | 308 | GdkNativeWindow p_xid; |
| 296 | GdkWindow* xid; | 309 | GdkWindow* xid; |
| 297 | 310 | ||
| 298 | if (xw->type == 3 && xwidget_has_composition()){ | 311 | if (xw->type == 3 && xwidget_has_composition()){ |
| 299 | //its a gtk_socket, get_snapshot() doesnt work so try using composition methods | 312 | //its a gtk_socket, get_snapshot() doesnt work so try using composition methods |
| 300 | //xw_snapshot = gdk_pixmap_foreign_new_for_display(GDK_DISPLAY(), p_xid); | 313 | //xw_snapshot = gdk_pixmap_foreign_new_for_display(GDK_DISPLAY(), p_xid); |
| 301 | xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); | 314 | xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); |
| 302 | //should check the xid here, because it could be invalid | 315 | //should check the xid here, because it could be invalid |
| 303 | //p_xid = XCompositeNameWindowPixmap( GDK_DISPLAY (), GDK_WINDOW_XID(xid)) ; | 316 | //p_xid = XCompositeNameWindowPixmap( GDK_DISPLAY (), GDK_WINDOW_XID(xid)) ; |
| 304 | 317 | ||
| 305 | printf("phantom socket 1: %d %d\n", xid, p_xid); | 318 | printf("phantom socket 1: %d %d\n", xid, p_xid); |
| 306 | xw_snapshot = gdk_pixmap_foreign_new(GDK_WINDOW_XID(xid)); //wraps the native window in a gdk windw, but it crashes! | 319 | xw_snapshot = gdk_pixmap_foreign_new(GDK_WINDOW_XID(xid)); //wraps the native window in a gdk windw, but it crashes! |
| 307 | printf("2\n"); | 320 | printf("2\n"); |
| 308 | }else { | 321 | }else { |
| 309 | //if its not a socket, its got a snapshot method that works | 322 | //if its not a socket, its got a snapshot method that works |
| 310 | //or if we dont have composition well try for sockets, but probably get a grey rect | 323 | //or if we dont have composition well try for sockets, but probably get a grey rect |
| 311 | printf("phantom other\n"); | 324 | printf("phantom other\n"); |
| 312 | xw_snapshot = gtk_widget_get_snapshot (xw->widget, NULL); | 325 | xw_snapshot = gtk_widget_get_snapshot (xw->widget, NULL); |
| 313 | } | 326 | } |
| 314 | 327 | ||
| @@ -316,11 +329,11 @@ xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy, | |||
| 316 | printf(" xw_snapshot null for some reason ... \n"); | 329 | printf(" xw_snapshot null for some reason ... \n"); |
| 317 | return; | 330 | return; |
| 318 | } | 331 | } |
| 319 | 332 | ||
| 320 | printf("3\n"); | 333 | printf("3\n"); |
| 321 | gdkgc = gdk_gc_new (xw_snapshot); | 334 | gdkgc = gdk_gc_new (xw_snapshot); |
| 322 | 335 | ||
| 323 | //currently a phanotm gets a line drawn across it to denote phantomness | 336 | //currently a phantom gets a line drawn across it to denote phantomness |
| 324 | //dimming or such would be more elegant | 337 | //dimming or such would be more elegant |
| 325 | printf("4\n"); | 338 | printf("4\n"); |
| 326 | gdk_draw_line (xw_snapshot, gdkgc, 0, 0, xw->width, xw->height); | 339 | gdk_draw_line (xw_snapshot, gdkgc, 0, 0, xw->width, xw->height); |
| @@ -334,27 +347,37 @@ xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy, | |||
| 334 | void | 347 | void |
| 335 | x_draw_xwidget_glyph_string (struct glyph_string *s) | 348 | x_draw_xwidget_glyph_string (struct glyph_string *s) |
| 336 | { | 349 | { |
| 350 | /* | ||
| 351 | this method is called by the redisplay engine and is supposed to put the xwidget on screen. | ||
| 352 | |||
| 353 | must handle both live xwidgets, and phantom xwidgets. | ||
| 354 | |||
| 355 | BUG it seems this method for some reason is called with bad s->x and s->y sometimes. | ||
| 356 | When this happens the xwidget doesnt move on screen as it should. | ||
| 357 | |||
| 358 | BUG the phantoming code doesnt work very well when the live xwidget is off screen. | ||
| 359 | you will get weirdo display artefacts. Composition ought to solve this, since that means the live window is | ||
| 360 | always available in an off-screen buffer. My current attempt at composition doesnt work properly however. | ||
| 361 | |||
| 362 | */ | ||
| 337 | int box_line_hwidth = eabs (s->face->box_line_width); | 363 | int box_line_hwidth = eabs (s->face->box_line_width); |
| 338 | int box_line_vwidth = max (s->face->box_line_width, 0); | 364 | int box_line_vwidth = max (s->face->box_line_width, 0); |
| 339 | int height = s->height; | 365 | int height = s->height; |
| 340 | Pixmap pixmap = None; | ||
| 341 | 366 | ||
| 342 | int drawing_in_selected_window = (XWINDOW (FRAME_SELECTED_WINDOW (s->f))) == (s->w); | 367 | int drawing_in_selected_window = (XWINDOW (FRAME_SELECTED_WINDOW (s->f))) == (s->w); |
| 343 | |||
| 344 | // printf("x_draw_xwidget_glyph_string: id:%d %d %d (%d,%d,%d,%d) selected win:%d\n", | ||
| 345 | // s->xwidget_id, box_line_hwidth, box_line_vwidth, s->x,s->y,s->height,s->width, drawing_in_selected_window); | ||
| 346 | struct xwidget *xw = &xwidgets[s->xwidget_id]; | 368 | struct xwidget *xw = &xwidgets[s->xwidget_id]; |
| 347 | int clipx; int clipy; | 369 | int clipx; int clipy; |
| 348 | 370 | ||
| 349 | 371 | printf("x_draw_xwidget_glyph_string: id:%d %d %d (%d,%d,%d,%d) selected win:%d\n", | |
| 372 | s->xwidget_id, box_line_hwidth, box_line_vwidth, | ||
| 373 | s->x, s->y, s->height, s->width, | ||
| 374 | drawing_in_selected_window); | ||
| 350 | 375 | ||
| 351 | int x = s->x; | 376 | int x = s->x; |
| 352 | int y = s->y + (s->height / 2) - (xw->height / 2); | 377 | int y = s->y + (s->height / 2) - (xw->height / 2); |
| 353 | int doingsocket = 0; | 378 | int doingsocket = 0; |
| 354 | if (!xw->initialized) | 379 | if (!xw->initialized) |
| 355 | { | ||
| 356 | xwidget_init (xw, s, x, y); | 380 | xwidget_init (xw, s, x, y); |
| 357 | } | ||
| 358 | 381 | ||
| 359 | //calculate clip widht and height, which is used both for the xwidget | 382 | //calculate clip widht and height, which is used both for the xwidget |
| 360 | //and its phantom counterpart | 383 | //and its phantom counterpart |
| @@ -362,10 +385,9 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) | |||
| 362 | clipy = min (xw->height, | 385 | clipy = min (xw->height, |
| 363 | WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); | 386 | WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); |
| 364 | 387 | ||
| 365 | |||
| 366 | //TODO: | 388 | //TODO: |
| 367 | // 1) always draw live xwidget in slected window | 389 | // 1) always draw live xwidget in slected window |
| 368 | // 2) if there were no live instances of the xwidget in selected window, also draw it live | 390 | // (2) if there were no live instances of the xwidget in selected window, also draw it live) |
| 369 | // 3) if there was a live xwidget previously, now phantom it. | 391 | // 3) if there was a live xwidget previously, now phantom it. |
| 370 | if (drawing_in_selected_window) | 392 | if (drawing_in_selected_window) |
| 371 | { | 393 | { |
| @@ -376,12 +398,12 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) | |||
| 376 | else | 398 | else |
| 377 | { | 399 | { |
| 378 | } | 400 | } |
| 379 | if (xw->hidden == 0) //hidden equals not being seen in the live window | 401 | //TODO maybe theres a bug that the hidden flag sometimes dont get reset properly |
| 402 | if (!xwidget_hidden(xw)) //hidden equals not being seen in the live window | ||
| 380 | { | 403 | { |
| 381 | gtk_fixed_move (GTK_FIXED (s->f->gwfixed), | 404 | gtk_fixed_move (GTK_FIXED (s->f->gwfixed), |
| 382 | GTK_WIDGET (xw->widgetwindow), x, y); | 405 | GTK_WIDGET (xw->widgetwindow), x, y); |
| 383 | //adjust size of the widget window if some parts happen to be outside drawable area | 406 | //clip the widget window if some parts happen to be outside drawable area |
| 384 | //that is, we should clip | ||
| 385 | //an emacs window is not a gtk window, a gtk window covers the entire frame | 407 | //an emacs window is not a gtk window, a gtk window covers the entire frame |
| 386 | gtk_widget_set_size_request (GTK_WIDGET (xw->widgetwindow), clipx, | 408 | gtk_widget_set_size_request (GTK_WIDGET (xw->widgetwindow), clipx, |
| 387 | clipy); | 409 | clipy); |
| @@ -391,7 +413,7 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) | |||
| 391 | //xwidget is hidden, hide it offscreen somewhere, still realized, so we may snapshot it | 413 | //xwidget is hidden, hide it offscreen somewhere, still realized, so we may snapshot it |
| 392 | //gtk_fixed_move(GTK_FIXED(s->f->gwfixed),GTK_WIDGET(xw->widgetwindow) ,10000,10000); | 414 | //gtk_fixed_move(GTK_FIXED(s->f->gwfixed),GTK_WIDGET(xw->widgetwindow) ,10000,10000); |
| 393 | } | 415 | } |
| 394 | //xw is (aparently) supposed to refer to the *live* instance of the xwidget | 416 | //xw refers to the *live* instance of the xwidget |
| 395 | xw->x = x; | 417 | xw->x = x; |
| 396 | xw->y = y; | 418 | xw->y = y; |
| 397 | 419 | ||
| @@ -399,9 +421,7 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) | |||
| 399 | } | 421 | } |
| 400 | else | 422 | else |
| 401 | { | 423 | { |
| 402 | //ok, we are painting the xwidgets in non-selected window | 424 | //ok, we are painting the xwidgets in non-selected window, so draw a phantom |
| 403 | |||
| 404 | //so draw a phantom | ||
| 405 | xwidget_draw_phantom (xw, x, y, clipx, clipy, s); | 425 | xwidget_draw_phantom (xw, x, y, clipx, clipy, s); |
| 406 | 426 | ||
| 407 | } | 427 | } |
| @@ -439,18 +459,36 @@ DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_inte | |||
| 439 | int w = XFASTINT (new_width); | 459 | int w = XFASTINT (new_width); |
| 440 | int h = XFASTINT (new_height); | 460 | int h = XFASTINT (new_height); |
| 441 | xw = &xwidgets[xid]; | 461 | xw = &xwidgets[xid]; |
| 442 | 462 | ||
| 443 | printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h); | 463 | printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h); |
| 444 | xw->width=w; | 464 | xw->width=w; |
| 445 | xw->height=h; | 465 | xw->height=h; |
| 446 | gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height); | 466 | gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height); |
| 447 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget), xw->width, | 467 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget), xw->width, |
| 448 | xw->height); | 468 | xw->height); |
| 449 | return Qnil; | 469 | return Qnil; |
| 450 | } | 470 | } |
| 451 | 471 | ||
| 452 | 472 | ||
| 453 | 473 | ||
| 474 | DEFUN("xwidget-info", Fxwidget_info , Sxwidget_info, 1,1,0, doc: /* get xwidget props */) | ||
| 475 | (Lisp_Object xwidget_id) | ||
| 476 | { | ||
| 477 | struct xwidget *xw = &xwidgets[XFASTINT (xwidget_id)]; | ||
| 478 | Lisp_Object info; | ||
| 479 | |||
| 480 | info = Fmake_vector (make_number (7), Qnil); | ||
| 481 | XVECTOR (info)->contents[0] = make_number(xw->id); | ||
| 482 | XVECTOR (info)->contents[1] = make_number(xw->type); | ||
| 483 | XVECTOR (info)->contents[2] = make_number(xw->x); | ||
| 484 | XVECTOR (info)->contents[3] = make_number(xw->y); | ||
| 485 | XVECTOR (info)->contents[4] = make_number(xw->width); | ||
| 486 | XVECTOR (info)->contents[5] = make_number(xw->height); | ||
| 487 | XVECTOR (info)->contents[6] = make_number(xw->hidden); | ||
| 488 | |||
| 489 | return info; | ||
| 490 | } | ||
| 491 | |||
| 454 | //xterm.c listens to xwidget_owns_kbd and tries to not eat events when its set | 492 | //xterm.c listens to xwidget_owns_kbd and tries to not eat events when its set |
| 455 | int xwidget_owns_kbd = 0; | 493 | int xwidget_owns_kbd = 0; |
| 456 | DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_keyboard_grab, 2, 2, 0, doc: /* set unset kbd grab for xwidget. */ | 494 | DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_keyboard_grab, 2, 2, 0, doc: /* set unset kbd grab for xwidget. */ |
| @@ -461,7 +499,7 @@ DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_key | |||
| 461 | int xid = XFASTINT (xwidget_id); | 499 | int xid = XFASTINT (xwidget_id); |
| 462 | int kbd_flag = XFASTINT (kbd_grab); | 500 | int kbd_flag = XFASTINT (kbd_grab); |
| 463 | xw = &xwidgets[xid]; | 501 | xw = &xwidgets[xid]; |
| 464 | 502 | ||
| 465 | printf ("kbd grab: %d %d\n", xid, kbd_flag); | 503 | printf ("kbd grab: %d %d\n", xid, kbd_flag); |
| 466 | if (kbd_flag) | 504 | if (kbd_flag) |
| 467 | { | 505 | { |
| @@ -482,7 +520,7 @@ DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_key | |||
| 482 | /* gtk_container_set_focus_child (GTK_CONTAINER (lastparent), xw->widget); */ | 520 | /* gtk_container_set_focus_child (GTK_CONTAINER (lastparent), xw->widget); */ |
| 483 | 521 | ||
| 484 | gtk_container_set_focus_child (GTK_CONTAINER (xw->widgetwindow), xw->widget); | 522 | gtk_container_set_focus_child (GTK_CONTAINER (xw->widgetwindow), xw->widget); |
| 485 | 523 | ||
| 486 | xwidget_owns_kbd = TRUE; | 524 | xwidget_owns_kbd = TRUE; |
| 487 | } | 525 | } |
| 488 | else | 526 | else |
| @@ -545,7 +583,7 @@ DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_sen | |||
| 545 | GdkWindow *window; | 583 | GdkWindow *window; |
| 546 | int xwid = XFASTINT (xwidget_id); | 584 | int xwid = XFASTINT (xwidget_id); |
| 547 | XID xid; | 585 | XID xid; |
| 548 | 586 | ||
| 549 | xw = &xwidgets[xwid]; | 587 | xw = &xwidgets[xwid]; |
| 550 | 588 | ||
| 551 | f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA); | 589 | f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA); |
| @@ -586,17 +624,20 @@ syms_of_xwidget (void) | |||
| 586 | staticpro (&Qxwidget_embed_steal_window); | 624 | staticpro (&Qxwidget_embed_steal_window); |
| 587 | defsubr (&Sxwidget_embed_steal_window); | 625 | defsubr (&Sxwidget_embed_steal_window); |
| 588 | 626 | ||
| 589 | 627 | Qxwidget_info = intern ("xwidget-info"); | |
| 628 | staticpro (&Qxwidget_info); | ||
| 629 | defsubr (&Sxwidget_info); | ||
| 630 | |||
| 590 | Qxwidget_resize_internal = intern ("xwidget-resize-internal"); | 631 | Qxwidget_resize_internal = intern ("xwidget-resize-internal"); |
| 591 | staticpro (&Qxwidget_resize_internal); | 632 | staticpro (&Qxwidget_resize_internal); |
| 592 | defsubr (&Sxwidget_resize_internal); | 633 | defsubr (&Sxwidget_resize_internal); |
| 593 | 634 | ||
| 594 | 635 | ||
| 595 | Qxwidget_embed_steal_window = intern ("xwidget-embed-steal-window"); | 636 | Qxwidget_embed_steal_window = intern ("xwidget-embed-steal-window"); |
| 596 | staticpro (&Qxwidget_embed_steal_window); | 637 | staticpro (&Qxwidget_embed_steal_window); |
| 597 | defsubr (&Sxwidget_embed_steal_window); | 638 | defsubr (&Sxwidget_embed_steal_window); |
| 598 | 639 | ||
| 599 | 640 | ||
| 600 | Qxwidget = intern ("xwidget"); | 641 | Qxwidget = intern ("xwidget"); |
| 601 | staticpro (&Qxwidget); | 642 | staticpro (&Qxwidget); |
| 602 | 643 | ||
| @@ -606,7 +647,7 @@ syms_of_xwidget (void) | |||
| 606 | Qtitle = intern (":title"); | 647 | Qtitle = intern (":title"); |
| 607 | staticpro (&Qtitle); | 648 | staticpro (&Qtitle); |
| 608 | 649 | ||
| 609 | Fprovide (intern ("xwidget-internal"), Qnil); | 650 | Fprovide (intern ("xwidget-internal"), Qnil); |
| 610 | 651 | ||
| 611 | for (i = 0; i < MAX_XWIDGETS; i++) | 652 | for (i = 0; i < MAX_XWIDGETS; i++) |
| 612 | xwidgets[i].initialized = 0; | 653 | xwidgets[i].initialized = 0; |
| @@ -684,17 +725,14 @@ xwidget_hide (struct xwidget *xw) | |||
| 684 | 10000, 10000); | 725 | 10000, 10000); |
| 685 | } | 726 | } |
| 686 | 727 | ||
| 687 | void | 728 | |
| 688 | xwidget_show (struct xwidget *xw) | 729 | |
| 730 | int | ||
| 731 | xwidget_hidden(struct xwidget *xw) | ||
| 689 | { | 732 | { |
| 690 | //printf("xwidget %d shown\n",xw->id); | 733 | return xw->hidden; |
| 691 | xw->hidden = 0; | ||
| 692 | //gtk_widget_show(GTK_WIDGET(xw->widgetwindow)); | ||
| 693 | gtk_fixed_move (GTK_FIXED (xw->emacswindow), GTK_WIDGET (xw->widgetwindow), | ||
| 694 | xw->x, xw->y); | ||
| 695 | } | 734 | } |
| 696 | 735 | ||
| 697 | |||
| 698 | Lisp_Object | 736 | Lisp_Object |
| 699 | xwidget_spec_value ( | 737 | xwidget_spec_value ( |
| 700 | Lisp_Object spec, Lisp_Object key, | 738 | Lisp_Object spec, Lisp_Object key, |
| @@ -745,7 +783,7 @@ lookup_xwidget (Lisp_Object spec) | |||
| 745 | Lisp_Object value; | 783 | Lisp_Object value; |
| 746 | int id; | 784 | int id; |
| 747 | struct xwidget *xw; | 785 | struct xwidget *xw; |
| 748 | 786 | ||
| 749 | value = xwidget_spec_value (spec, Qxwidget_id, &found1); | 787 | value = xwidget_spec_value (spec, Qxwidget_id, &found1); |
| 750 | id = INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb | 788 | id = INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb |
| 751 | 789 | ||
| @@ -791,6 +829,12 @@ xwidget_touch (struct xwidget *xw) | |||
| 791 | xw->redisplayed = 1; | 829 | xw->redisplayed = 1; |
| 792 | } | 830 | } |
| 793 | 831 | ||
| 832 | int | ||
| 833 | xwidget_touched (struct xwidget *xw) | ||
| 834 | { | ||
| 835 | return xw->redisplayed; | ||
| 836 | } | ||
| 837 | |||
| 794 | /* redisplay has ended, now we should hide untouched xwidgets | 838 | /* redisplay has ended, now we should hide untouched xwidgets |
| 795 | 839 | ||
| 796 | atm this works as follows: only check if xwidgets are displayed in the | 840 | atm this works as follows: only check if xwidgets are displayed in the |
| @@ -807,7 +851,7 @@ xwidget_end_redisplay (struct glyph_matrix *matrix) | |||
| 807 | int i; | 851 | int i; |
| 808 | struct xwidget *xw; | 852 | struct xwidget *xw; |
| 809 | int area; | 853 | int area; |
| 810 | 854 | ||
| 811 | //dont change anything if minibuffer is selected this redisplay | 855 | //dont change anything if minibuffer is selected this redisplay |
| 812 | //this is mostly a workaround to reduce the phantoming of xwidgets | 856 | //this is mostly a workaround to reduce the phantoming of xwidgets |
| 813 | // this is special case handling and it doesnt work too well. | 857 | // this is special case handling and it doesnt work too well. |
| @@ -865,13 +909,13 @@ xwidget_end_redisplay (struct glyph_matrix *matrix) | |||
| 865 | xw = &xwidgets[i]; | 909 | xw = &xwidgets[i]; |
| 866 | if (xw->initialized) | 910 | if (xw->initialized) |
| 867 | { | 911 | { |
| 868 | if (xw->redisplayed) | 912 | if (xwidget_touched(xw)) |
| 869 | xwidget_show (xw); | 913 | xwidget_show (xw); |
| 870 | else | 914 | else |
| 871 | xwidget_hide (xw); | 915 | xwidget_hide (xw); |
| 872 | } | 916 | } |
| 873 | } | 917 | } |
| 874 | 918 | ||
| 875 | } | 919 | } |
| 876 | 920 | ||
| 877 | /* some type of modification was made to the buffers*/ | 921 | /* some type of modification was made to the buffers*/ |