diff options
| author | Joakim Verona | 2010-09-15 13:56:58 +0200 |
|---|---|---|
| committer | Joakim Verona | 2010-09-15 13:56:58 +0200 |
| commit | f5f038d96e72f1fcf827db572c56c935f606c9b7 (patch) | |
| tree | 96b04da08999998234ec23f28c820beb43d6ef3e | |
| parent | 0699485f1c0f0fef9983e9f12e48036ddba5dc16 (diff) | |
| download | emacs-f5f038d96e72f1fcf827db572c56c935f606c9b7.tar.gz emacs-f5f038d96e72f1fcf827db572c56c935f606c9b7.zip | |
still doesnt actually work, but at least you get to see the widgets on screen randomly from time to time
| -rw-r--r-- | src/xwidget.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index acfe3450b2c..1afbb9bdbaa 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -57,7 +57,7 @@ | |||
| 57 | #endif | 57 | #endif |
| 58 | #include <X11/extensions/Xcomposite.h> | 58 | #include <X11/extensions/Xcomposite.h> |
| 59 | #include <X11/extensions/Xrender.h> | 59 | #include <X11/extensions/Xrender.h> |
| 60 | 60 | #include <cairo.h> | |
| 61 | #ifdef HAVE_SYS_TIME_H | 61 | #ifdef HAVE_SYS_TIME_H |
| 62 | #include <sys/time.h> | 62 | #include <sys/time.h> |
| 63 | #endif | 63 | #endif |
| @@ -183,12 +183,14 @@ xwidget_show (struct xwidget *xw) | |||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | 185 | ||
| 186 | |||
| 186 | static gboolean | 187 | static gboolean |
| 187 | xwidget_composite_draw(GtkWidget *widget, | 188 | xwidget_composite_draw_2(GtkWidget *widget, |
| 188 | GdkEventExpose *event, | 189 | GdkEventExpose *event, |
| 189 | gpointer data) | 190 | gpointer data, |
| 190 | { | 191 | int x, int y) |
| 191 | //FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA); | 192 | { |
| 193 | FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA); | ||
| 192 | struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); | 194 | struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); |
| 193 | //////////////////////////////////////////////////////////////// | 195 | //////////////////////////////////////////////////////////////// |
| 194 | //Example 7. Composited windows | 196 | //Example 7. Composited windows |
| @@ -197,12 +199,17 @@ xwidget_composite_draw(GtkWidget *widget, | |||
| 197 | cairo_t *cr; | 199 | cairo_t *cr; |
| 198 | /* get our child (in this case, the event box) */ | 200 | /* get our child (in this case, the event box) */ |
| 199 | child = widget; //gtk_bin_get_child (GTK_BIN (widget)); | 201 | child = widget; //gtk_bin_get_child (GTK_BIN (widget)); |
| 200 | /* create a cairo context to draw to the window */ | 202 | /* create a cairo context to draw to the emacs window */ |
| 201 | cr = gdk_cairo_create (gtk_widget_get_window(xw->widgetwindow));//widget->window); | 203 | cr = gdk_cairo_create (gtk_widget_get_window (f->gwfixed));//GTK_WIDGET(xw->emacswindow));//xw->widgetwindow));//widget->window); |
| 202 | /* the source data is the (composited) event box */ | 204 | /* the source data is the (composited) xwidget */ |
| 205 | //cairo_move_to(cr, xw->x, xw->y); | ||
| 206 | cairo_set_source_rgb(cr,1.0,0,0); | ||
| 207 | cairo_rectangle(cr,x,y,xw->width,xw->height); | ||
| 208 | cairo_fill(cr); | ||
| 203 | gdk_cairo_set_source_pixmap (cr, child->window, | 209 | gdk_cairo_set_source_pixmap (cr, child->window, |
| 204 | child->allocation.x, | 210 | x,//child->allocation.x, |
| 205 | child->allocation.y); | 211 | y//child->allocation.y |
| 212 | ); | ||
| 206 | /* draw no more than our expose event intersects our child */ | 213 | /* draw no more than our expose event intersects our child */ |
| 207 | /* region = gdk_region_rectangle (&child->allocation); | 214 | /* region = gdk_region_rectangle (&child->allocation); |
| 208 | gdk_region_intersect (region, event->region); | 215 | gdk_region_intersect (region, event->region); |
| @@ -210,12 +217,26 @@ xwidget_composite_draw(GtkWidget *widget, | |||
| 210 | cairo_clip (cr); */ | 217 | cairo_clip (cr); */ |
| 211 | /* composite, with a 50% opacity */ | 218 | /* composite, with a 50% opacity */ |
| 212 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | 219 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
| 213 | cairo_paint_with_alpha (cr, 0.5);//transparency); | 220 | //cairo_paint_with_alpha (cr, 0.5);//transparency); |
| 221 | cairo_paint(cr);//transparency); | ||
| 214 | /* we're done */ | 222 | /* we're done */ |
| 215 | cairo_destroy (cr); | 223 | cairo_destroy (cr); |
| 216 | // return FALSE; | 224 | return FALSE; |
| 217 | } | 225 | } |
| 218 | 226 | ||
| 227 | static gboolean | ||
| 228 | xwidget_composite_draw(GtkWidget *widget, | ||
| 229 | GdkEventExpose *event, | ||
| 230 | gpointer data) | ||
| 231 | { | ||
| 232 | struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); | ||
| 233 | xwidget_composite_draw_2(widget, | ||
| 234 | event, | ||
| 235 | data, | ||
| 236 | xw->x, xw->y); | ||
| 237 | |||
| 238 | } | ||
| 239 | |||
| 219 | void | 240 | void |
| 220 | xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) | 241 | xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) |
| 221 | { | 242 | { |
| @@ -253,8 +274,8 @@ xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) | |||
| 253 | gtk_container_add (xw->widgetwindow, xw->widget); | 274 | gtk_container_add (xw->widgetwindow, xw->widget); |
| 254 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget), xw->width, | 275 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget), xw->width, |
| 255 | xw->height); | 276 | xw->height); |
| 256 | gtk_fixed_put (GTK_FIXED (s->f->gwfixed), GTK_WIDGET (xw->widgetwindow), x, | 277 | gtk_fixed_put (GTK_FIXED (s->f->gwfixed), GTK_WIDGET (xw->widgetwindow), |
| 257 | y); | 278 | x, y); |
| 258 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow)); | 279 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow)); |
| 259 | 280 | ||
| 260 | //store some xwidget data in the gtk widgets | 281 | //store some xwidget data in the gtk widgets |
| @@ -336,7 +357,7 @@ xwidget_draw_phantom (struct xwidget *xw, | |||
| 336 | gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy); | 357 | gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy); |
| 337 | #else | 358 | #else |
| 338 | 359 | ||
| 339 | xwidget_composite_draw(xw->widget, NULL, NULL); | 360 | xwidget_composite_draw_2(xw->widget, NULL, NULL,x,y); |
| 340 | #endif | 361 | #endif |
| 341 | //////////////////////////////////////////////////////////////// | 362 | //////////////////////////////////////////////////////////////// |
| 342 | 363 | ||
| @@ -423,8 +444,8 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) | |||
| 423 | GTK_WIDGET (xw->widgetwindow), x, y); | 444 | GTK_WIDGET (xw->widgetwindow), x, y); |
| 424 | //clip the widget window if some parts happen to be outside drawable area | 445 | //clip the widget window if some parts happen to be outside drawable area |
| 425 | //an emacs window is not a gtk window, a gtk window covers the entire frame | 446 | //an emacs window is not a gtk window, a gtk window covers the entire frame |
| 426 | gtk_widget_set_size_request (GTK_WIDGET (xw->widgetwindow), clipx, | 447 | gtk_widget_set_size_request (GTK_WIDGET (xw->widgetwindow), |
| 427 | clipy); | 448 | clipx, clipy); |
| 428 | 449 | ||
| 429 | //if we are using compositing, we are always responsible for drawing the widget on the screen | 450 | //if we are using compositing, we are always responsible for drawing the widget on the screen |
| 430 | //just reuse the phantom routine for now | 451 | //just reuse the phantom routine for now |