aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2010-08-31 08:50:57 +0200
committerJoakim Verona2010-08-31 08:50:57 +0200
commit4c264afb06bb10ef5a80f62b3ffcb98192fe06ec (patch)
tree4a4acd86658148871a392565c427d0e7a5d052cc /src
parent8f7457f9179314ea534f188bc880652d68f0f846 (diff)
downloademacs-4c264afb06bb10ef5a80f62b3ffcb98192fe06ec.tar.gz
emacs-4c264afb06bb10ef5a80f62b3ffcb98192fe06ec.zip
fixed a lot of warnings, also made some xcomposite preparations
Diffstat (limited to 'src')
-rw-r--r--src/xwidget.c130
1 files changed, 81 insertions, 49 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index a67480b85f8..dc103601e5c 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -55,6 +55,7 @@
55#ifdef USE_X_TOOLKIT 55#ifdef USE_X_TOOLKIT
56#include <X11/Shell.h> 56#include <X11/Shell.h>
57#endif 57#endif
58#include <X11/extensions/Xcomposite.h>
58 59
59#ifdef HAVE_SYS_TIME_H 60#ifdef HAVE_SYS_TIME_H
60#include <sys/time.h> 61#include <sys/time.h>
@@ -99,15 +100,14 @@ static void
99buttonclick_handler (GtkWidget * widget, gpointer data) 100buttonclick_handler (GtkWidget * widget, gpointer data)
100{ 101{
101 struct xwidget *xw = (struct xwidget *) data; 102 struct xwidget *xw = (struct xwidget *) data;
103 struct input_event event;
102 Lisp_Object frame; 104 Lisp_Object frame;
105 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
103 printf ("button clicked xw:%d id:%d\n", xw, xw->id); 106 printf ("button clicked xw:%d id:%d\n", xw, xw->id);
104 107
105 struct input_event event;
106 EVENT_INIT (event); 108 EVENT_INIT (event);
107 event.kind = XWIDGET_EVENT; 109 event.kind = XWIDGET_EVENT;
108 110
109 FRAME_PTR f =
110 (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
111 XSETFRAME (frame, f); 111 XSETFRAME (frame, f);
112 112
113 event.frame_or_window = Qnil; //frame; //how to get the frame here? 113 event.frame_or_window = Qnil; //frame; //how to get the frame here?
@@ -213,12 +213,40 @@ xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy,
213 //but XCopyArea() might be sufficient for our needs here 213 //but XCopyArea() might be sufficient for our needs here
214 214
215 215
216 GdkPixmap *xw_snapshot = gtk_widget_get_snapshot (xw->widget, NULL); 216 GdkPixmap *xw_snapshot = NULL;
217 GdkGC *gdkgc = gdk_gc_new (xw_snapshot); 217 GdkGC *gdkgc = NULL;
218 GdkNativeWindow p_xid;
219 GdkNativeWindow xid;
220
221 if (0
222 //xw->type == 3 //this doesnt work atm
223 ) {
224 //its a gtk_socket, get_snapshot() doesnt work so try using composition methods
225 xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget));
226 p_xid = XCompositeNameWindowPixmap( GDK_DISPLAY (), GDK_WINDOW_XID(xid)) ;
227 //xw_snapshot = gdk_pixmap_foreign_new_for_display(GDK_DISPLAY(), p_xid);
228 printf("phantom socket 1: %d %d\n", xid, p_xid);
229 xw_snapshot = gdk_pixmap_foreign_new(p_xid); //wraps the native window in a gdk windw, but it crashes!
230 printf("2\n");
231 }else {
232 //if its not a socket, its got a snapshot method that works
233 printf("phantom other\n");
234 xw_snapshot = gtk_widget_get_snapshot (xw->widget, NULL);
235 }
236
237 if(xw_snapshot==NULL){
238 printf(" xw_snapshot null for some reason ... \n");
239 return;
240 }
241
242 printf("3\n");
243 gdkgc = gdk_gc_new (xw_snapshot);
218 244
219 //currently a phanotm gets a line drawn across it to denote phantomness 245 //currently a phanotm gets a line drawn across it to denote phantomness
220 //dimming or such would be more elegant 246 //dimming or such would be more elegant
247 printf("4\n");
221 gdk_draw_line (xw_snapshot, gdkgc, 0, 0, xw->width, xw->height); 248 gdk_draw_line (xw_snapshot, gdkgc, 0, 0, xw->width, xw->height);
249 printf("5\n");
222 gdk_draw_drawable (gtk_widget_get_window (s->f->gwfixed), //convert to GdkWindow from gtkWindow 250 gdk_draw_drawable (gtk_widget_get_window (s->f->gwfixed), //convert to GdkWindow from gtkWindow
223 gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy); 251 gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy);
224} 252}
@@ -226,8 +254,7 @@ xwidget_draw_phantom (struct xwidget *xw, int x, int y, int clipx, int clipy,
226 254
227 255
228void 256void
229x_draw_xwidget_glyph_string (s) 257x_draw_xwidget_glyph_string (struct glyph_string *s)
230 struct glyph_string *s;
231{ 258{
232 int box_line_hwidth = eabs (s->face->box_line_width); 259 int box_line_hwidth = eabs (s->face->box_line_width);
233 int box_line_vwidth = max (s->face->box_line_width, 0); 260 int box_line_vwidth = max (s->face->box_line_width, 0);
@@ -239,6 +266,9 @@ x_draw_xwidget_glyph_string (s)
239 // printf("x_draw_xwidget_glyph_string: id:%d %d %d (%d,%d,%d,%d) selected win:%d\n", 266 // printf("x_draw_xwidget_glyph_string: id:%d %d %d (%d,%d,%d,%d) selected win:%d\n",
240 // s->xwidget_id, box_line_hwidth, box_line_vwidth, s->x,s->y,s->height,s->width, drawing_in_selected_window); 267 // s->xwidget_id, box_line_hwidth, box_line_vwidth, s->x,s->y,s->height,s->width, drawing_in_selected_window);
241 struct xwidget *xw = &xwidgets[s->xwidget_id]; 268 struct xwidget *xw = &xwidgets[s->xwidget_id];
269 int clipx; int clipy;
270
271
242 272
243 int x = s->x; 273 int x = s->x;
244 int y = s->y + (s->height / 2) - (xw->height / 2); 274 int y = s->y + (s->height / 2) - (xw->height / 2);
@@ -250,9 +280,8 @@ x_draw_xwidget_glyph_string (s)
250 280
251 //calculate clip widht and height, which is used both for the xwidget 281 //calculate clip widht and height, which is used both for the xwidget
252 //and its phantom counterpart 282 //and its phantom counterpart
253 int clipx = min (xw->width, WINDOW_RIGHT_EDGE_X (s->w) - x); 283 clipx = min (xw->width, WINDOW_RIGHT_EDGE_X (s->w) - x);
254 int clipy = 284 clipy = min (xw->height,
255 min (xw->height,
256 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); 285 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
257 286
258 287
@@ -306,13 +335,12 @@ x_draw_xwidget_glyph_string (s)
306 335
307DEFUN ("xwidget-embed-steal-window", Fxwidget_embed_steal_window, Sxwidget_embed_steal_window, 2, 2, 0, doc: /* tell existing embed xwidget to steal other window id. */ 336DEFUN ("xwidget-embed-steal-window", Fxwidget_embed_steal_window, Sxwidget_embed_steal_window, 2, 2, 0, doc: /* tell existing embed xwidget to steal other window id. */
308 ) 337 )
309 (xwidget_id, window_id) 338 (Lisp_Object xwidget_id, Lisp_Object window_id)
310 Lisp_Object xwidget_id, window_id;
311{ 339{
312 struct xwidget *xw; 340 struct xwidget *xw;
313 int xid = XFASTINT (xwidget_id); 341 int xid = XFASTINT (xwidget_id);
314 xw = &xwidgets[xid];
315 int iwindow_id = XFASTINT (window_id); 342 int iwindow_id = XFASTINT (window_id);
343 xw = &xwidgets[xid];
316 printf (" gtk_socket_add_id: %d %d\n", xid, iwindow_id); 344 printf (" gtk_socket_add_id: %d %d\n", xid, iwindow_id);
317 // gtk_socket_steal(GTK_SOCKET(xw->widget),iwindow_id); 345 // gtk_socket_steal(GTK_SOCKET(xw->widget),iwindow_id);
318 //try adding proper gtk plugs instead, i never once had "steal" work 346 //try adding proper gtk plugs instead, i never once had "steal" work
@@ -327,14 +355,14 @@ DEFUN ("xwidget-embed-steal-window", Fxwidget_embed_steal_window, Sxwidget_embed
327DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_internal, 3, 3, 0, doc: 355DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_internal, 3, 3, 0, doc:
328 /* tell existing embed xwidget to steal other window id. */ 356 /* tell existing embed xwidget to steal other window id. */
329 ) 357 )
330 (xwidget_id, new_width, new_height) 358 (Lisp_Object xwidget_id, Lisp_Object new_width, Lisp_Object new_height)
331 Lisp_Object xwidget_id, new_width, new_height;
332{ 359{
333 struct xwidget *xw; 360 struct xwidget *xw;
334 int xid = XFASTINT (xwidget_id); 361 int xid = XFASTINT (xwidget_id);
335 xw = &xwidgets[xid];
336 int w = XFASTINT (new_width); 362 int w = XFASTINT (new_width);
337 int h = XFASTINT (new_height); 363 int h = XFASTINT (new_height);
364 xw = &xwidgets[xid];
365
338 printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h); 366 printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h);
339 xw->width=w; 367 xw->width=w;
340 xw->height=h; 368 xw->height=h;
@@ -350,13 +378,13 @@ DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_inte
350int xwidget_owns_kbd = 0; 378int xwidget_owns_kbd = 0;
351DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_keyboard_grab, 2, 2, 0, doc: /* set unset kbd grab for xwidget. */ 379DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_keyboard_grab, 2, 2, 0, doc: /* set unset kbd grab for xwidget. */
352 ) 380 )
353 (xwidget_id, kbd_grab) 381 (Lisp_Object xwidget_id, Lisp_Object kbd_grab)
354 Lisp_Object xwidget_id, kbd_grab;
355{ 382{
356 struct xwidget *xw; 383 struct xwidget *xw;
357 int xid = XFASTINT (xwidget_id); 384 int xid = XFASTINT (xwidget_id);
358 xw = &xwidgets[xid];
359 int kbd_flag = XFASTINT (kbd_grab); 385 int kbd_flag = XFASTINT (kbd_grab);
386 xw = &xwidgets[xid];
387
360 printf ("kbd grab: %d %d\n", xid, kbd_flag); 388 printf ("kbd grab: %d %d\n", xid, kbd_flag);
361 if (kbd_flag) 389 if (kbd_flag)
362 { 390 {
@@ -395,10 +423,9 @@ DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_key
395 423
396//lowlevel fn mostly cloned from xembed_send_message() 424//lowlevel fn mostly cloned from xembed_send_message()
397void 425void
398xwidget_key_send_message (f, destination_window, keycode, keypress, modifiers) 426xwidget_key_send_message (struct frame *f,
399 struct frame *f; 427 Window destination_window,
400 Window destination_window; 428 int keycode, int keypress, int modifiers)
401 int keypress;
402{ 429{
403 430
404 XKeyEvent event; 431 XKeyEvent event;
@@ -432,29 +459,30 @@ xwidget_key_send_message (f, destination_window, keycode, keypress, modifiers)
432 459
433DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_send_keyboard_event, 2, 2, 0, doc:/* synthesize a kbd event for a xwidget. */ 460DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_send_keyboard_event, 2, 2, 0, doc:/* synthesize a kbd event for a xwidget. */
434 ) 461 )
435 (xwidget_id, keydescriptor) 462 (Lisp_Object xwidget_id, Lisp_Object keydescriptor)
436 Lisp_Object xwidget_id, keydescriptor;
437{ 463{
438 int keyval; 464 int keyval;
439 char *keystring = ""; 465 char *keystring = "";
440 466 FRAME_PTR f;
441 struct xwidget *xw; 467 struct xwidget *xw;
468 GdkWindow *window;
442 int xwid = XFASTINT (xwidget_id); 469 int xwid = XFASTINT (xwidget_id);
470 XID xid;
471
443 xw = &xwidgets[xwid]; 472 xw = &xwidgets[xwid];
444 473
445 FRAME_PTR f = 474 f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
446 (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
447 475
448 //GdkWindow* window=gtk_widget_get_window(xw->widget); //event winds up in emacs 476 //GdkWindow* window=gtk_widget_get_window(xw->widget); //event winds up in emacs
449 477
450 //TODO assert xw is a gtk_socket or THIS WILL FAIL GLORIOUSLY 478 //TODO assert xw is a gtk_socket or THIS WILL FAIL GLORIOUSLY
451 GdkWindow *window = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); 479 window = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget));
452 //the event gets eaten somewhere. 480 //the event gets eaten somewhere.
453 //i suspect you just cant send an event to a child window and not have emacs eat it. 481 //i suspect you just cant send an event to a child window and not have emacs eat it.
454 //but if this were true the event should pop to emacs right? 482 //but if this were true the event should pop to emacs right?
455 483
456 484
457 XID xid = gdk_x11_drawable_get_xid (window); 485 xid = gdk_x11_drawable_get_xid (window);
458 486
459 printf ("xwidget-send-keyboard-event %d %d\n", window, xid); 487 printf ("xwidget-send-keyboard-event %d %d\n", window, xid);
460 488
@@ -465,7 +493,7 @@ DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_sen
465} 493}
466 494
467void 495void
468syms_of_xwidget () 496syms_of_xwidget (void)
469{ 497{
470 int i; 498 int i;
471 499
@@ -516,8 +544,7 @@ syms_of_xwidget ()
516 xwidget type. */ 544 xwidget type. */
517 545
518int 546int
519valid_xwidget_p (object) 547valid_xwidget_p (Lisp_Object object)
520 Lisp_Object object;
521{ 548{
522 int valid_p = 0; 549 int valid_p = 0;
523 550
@@ -592,9 +619,9 @@ xwidget_show (struct xwidget *xw)
592 619
593 620
594Lisp_Object 621Lisp_Object
595xwidget_spec_value (spec, key, found) 622xwidget_spec_value (
596 Lisp_Object spec, key; 623 Lisp_Object spec, Lisp_Object key,
597 int *found; 624 int *found)
598{ 625{
599 Lisp_Object tail; 626 Lisp_Object tail;
600 627
@@ -634,16 +661,18 @@ xwidget_from_id (int id)
634} 661}
635 662
636int 663int
637lookup_xwidget (spec) 664lookup_xwidget (Lisp_Object spec)
638 Lisp_Object spec;
639{ 665{
640 666
641 int found = 0, found1 = 0, found2 = 0; 667 int found = 0, found1 = 0, found2 = 0;
642 Lisp_Object value; 668 Lisp_Object value;
669 int id;
670 struct xwidget *xw;
671
643 value = xwidget_spec_value (spec, Qxwidget_id, &found1); 672 value = xwidget_spec_value (spec, Qxwidget_id, &found1);
644 int id = INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb 673 id = INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb
645 674
646 struct xwidget *xw = &xwidgets[id]; 675 xw = &xwidgets[id];
647 value = xwidget_spec_value (spec, QCtype, &found); 676 value = xwidget_spec_value (spec, QCtype, &found);
648 xw->type = INTEGERP (value) ? XFASTINT (value) : 1; //default to button 677 xw->type = INTEGERP (value) ? XFASTINT (value) : 1; //default to button
649 value = xwidget_spec_value (spec, Qtitle, &found2); 678 value = xwidget_spec_value (spec, Qtitle, &found2);
@@ -669,7 +698,7 @@ int region_modified = 0;
669 698
670/*set up detection of touched xwidget*/ 699/*set up detection of touched xwidget*/
671void 700void
672xwidget_start_redisplay () 701xwidget_start_redisplay (void)
673{ 702{
674 int i; 703 int i;
675 for (i = 0; i < MAX_XWIDGETS; i++) 704 for (i = 0; i < MAX_XWIDGETS; i++)
@@ -698,19 +727,22 @@ in that case not phantomed.
698void 727void
699xwidget_end_redisplay (struct glyph_matrix *matrix) 728xwidget_end_redisplay (struct glyph_matrix *matrix)
700{ 729{
730 int i;
731 struct xwidget *xw;
732 int area;
733
701 //dont change anything if minibuffer is selected this redisplay 734 //dont change anything if minibuffer is selected this redisplay
702 //this is mostly a workaround to reduce the phantoming of xwidgets 735 //this is mostly a workaround to reduce the phantoming of xwidgets
703 if( (XWINDOW (FRAME_MINIBUF_WINDOW (SELECTED_FRAME()))) == 736 // this is special case handling and it doesnt work too well.
704 (XWINDOW (FRAME_SELECTED_WINDOW (SELECTED_FRAME())))) 737 /* if( (XWINDOW (FRAME_MINIBUF_WINDOW (SELECTED_FRAME()))) == */
705 return; 738 /* (XWINDOW (FRAME_SELECTED_WINDOW (SELECTED_FRAME())))) */
739 /* return; */
706 740
707 int i;
708 struct xwidget *xw;
709 region_modified = 0; 741 region_modified = 0;
710 xwidget_start_redisplay (); 742 xwidget_start_redisplay ();
711 //iterate desired glyph matrix of "live" window here, hide gtk widgets 743 //iterate desired glyph matrix of "live" window here, hide gtk widgets
712 //not in the desired matrix. 744 //not in the desired matrix.
713 int area; 745
714 //the current scheme will fail on the case of several buffers showing xwidgets 746 //the current scheme will fail on the case of several buffers showing xwidgets
715 747
716 // dump_glyph_matrix(matrix, 2); 748 // dump_glyph_matrix(matrix, 2);
@@ -767,7 +799,7 @@ xwidget_end_redisplay (struct glyph_matrix *matrix)
767 799
768/* some type of modification was made to the buffers*/ 800/* some type of modification was made to the buffers*/
769void 801void
770xwidget_modify_region () 802xwidget_modify_region (void)
771{ 803{
772 region_modified = 1; 804 region_modified = 1;
773} 805}
@@ -789,7 +821,7 @@ xwidget_delete (struct xwidget *xw)
789 821
790/* redraw all xwidgets */ 822/* redraw all xwidgets */
791void 823void
792xwidget_invalidate () 824xwidget_invalidate (void)
793{ 825{
794 int i; 826 int i;
795 struct xwidget *xw; 827 struct xwidget *xw;