2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
12 #include <Ecore_Input.h>
13 #include <Ecore_Input_Evas.h>
14 #ifdef BUILD_ECORE_EVAS_X11
16 # include <Ecore_X_Atoms.h>
19 #include "ecore_evas_private.h"
20 #include "Ecore_Evas.h"
22 #ifdef BUILD_ECORE_EVAS_X11
23 static int _ecore_evas_init_count = 0;
25 static Ecore_Event_Handler *ecore_evas_event_handlers[12];
27 #ifdef HAVE_ECORE_X_XCB
28 static xcb_visualtype_t *
29 xcb_visualtype_get(xcb_screen_t *screen, xcb_visualid_t visual)
31 xcb_depth_iterator_t iter_depth;
33 if (!screen) return NULL;
35 iter_depth = xcb_screen_allowed_depths_iterator(screen);
36 for (; iter_depth.rem; xcb_depth_next (&iter_depth))
38 xcb_visualtype_iterator_t iter_vis;
40 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
41 for (; iter_vis.rem; --screen, xcb_visualtype_next (&iter_vis))
43 if (visual == iter_vis.data->visual_id)
50 #endif /* HAVE_ECORE_X_XCB */
52 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
53 # ifdef HAVE_ECORE_X_XCB
57 _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, int w, int h, int override)
59 Evas_Engine_Info_GL_X11 *einfo;
62 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
65 XSetWindowAttributes attr;
68 /* FIXME: this is inefficient as its a round trip */
69 screen = DefaultScreen(ecore_x_display_get());
70 if (ScreenCount(ecore_x_display_get()) > 1)
72 Ecore_X_Window *roots;
76 roots = ecore_x_window_root_list(&num);
81 if (XGetWindowAttributes(ecore_x_display_get(),
84 for (i = 0; i < num; i++)
86 if (at.root == roots[i])
96 attr.backing_store = NotUseful;
97 attr.override_redirect = override;
98 attr.colormap = einfo->func.best_colormap_get(ecore_x_display_get(), screen);
99 attr.border_pixel = 0;
100 attr.background_pixmap = None;
102 KeyPressMask | KeyReleaseMask |
103 ExposureMask | ButtonPressMask | ButtonReleaseMask |
104 EnterWindowMask | LeaveWindowMask |
105 PointerMotionMask | StructureNotifyMask | VisibilityChangeMask |
106 FocusChangeMask | PropertyChangeMask | ColormapChangeMask;
107 attr.bit_gravity = ForgetGravity;
110 XCreateWindow(ecore_x_display_get(),
114 einfo->func.best_depth_get(ecore_x_display_get(), screen),
116 einfo->func.best_visual_get(ecore_x_display_get(), screen),
117 CWBackingStore | CWColormap |
118 CWBackPixmap | CWBorderPixel |
119 CWBitGravity | CWEventMask |
122 einfo->info.display = ecore_x_display_get();
123 einfo->info.visual = einfo->func.best_visual_get(ecore_x_display_get(), screen);
124 einfo->info.colormap = einfo->func.best_colormap_get(ecore_x_display_get(), screen);
125 einfo->info.drawable = win;
126 einfo->info.depth = einfo->func.best_depth_get(ecore_x_display_get(), screen);
127 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
135 #endif /* HAVE_ECORE_X_XCB */
139 _ecore_evas_x_render(Ecore_Evas *ee)
142 Eina_List *updates, *l;
144 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
148 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
150 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
151 rend |= _ecore_evas_buffer_render(ee2);
152 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
155 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
156 if (ee->prop.avoid_damage)
158 updates = evas_render_updates(ee->evas);
159 if (ee->engine.x.using_bg_pixmap)
163 EINA_LIST_FOREACH(updates, l, r)
164 ecore_x_window_area_clear(ee->prop.window, r->x, r->y, r->w, r->h);
165 if ((ee->shaped) && (updates))
166 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
167 if ((ee->alpha) && (updates))
168 ecore_x_window_shape_input_mask_set(ee->prop.window, ee->engine.x.mask);
169 evas_render_updates_free(updates);
170 _ecore_evas_idle_timeout_update(ee);
176 EINA_LIST_FOREACH(updates, l, r)
178 Ecore_X_Rectangle rect;
179 Ecore_X_XRegion *tmpr;
181 if (!ee->engine.x.damages)
182 ee->engine.x.damages = ecore_x_xregion_new();
183 tmpr = ecore_x_xregion_new();
184 if (ee->rotation == 0)
191 else if (ee->rotation == 90)
194 rect.y = ee->h - r->x - r->w;
198 else if (ee->rotation == 180)
200 rect.x = ee->w - r->x - r->w;
201 rect.y = ee->h - r->y - r->h;
205 else if (ee->rotation == 270)
207 rect.x = ee->w - r->y - r->h;
212 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
213 ecore_x_xregion_free(ee->engine.x.damages);
214 ee->engine.x.damages = tmpr;
216 if (ee->engine.x.damages)
218 /* if we have a damage pixmap - we can avoid exposures by
219 * disabling them just for setting the mask */
220 ecore_x_event_mask_set(ee->prop.window,
221 ECORE_X_EVENT_MASK_KEY_DOWN |
222 ECORE_X_EVENT_MASK_KEY_UP |
223 ECORE_X_EVENT_MASK_MOUSE_DOWN |
224 ECORE_X_EVENT_MASK_MOUSE_UP |
225 ECORE_X_EVENT_MASK_MOUSE_IN |
226 ECORE_X_EVENT_MASK_MOUSE_OUT |
227 ECORE_X_EVENT_MASK_MOUSE_MOVE |
228 // ECORE_X_EVENT_MASK_WINDOW_DAMAGE |
229 ECORE_X_EVENT_MASK_WINDOW_VISIBILITY |
230 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE |
231 ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE |
232 ECORE_X_EVENT_MASK_WINDOW_PROPERTY |
233 ECORE_X_EVENT_MASK_WINDOW_COLORMAP
235 if ((ee->shaped) && (updates))
236 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
237 /* and re-enable them again */
238 ecore_x_event_mask_set(ee->prop.window,
239 ECORE_X_EVENT_MASK_KEY_DOWN |
240 ECORE_X_EVENT_MASK_KEY_UP |
241 ECORE_X_EVENT_MASK_MOUSE_DOWN |
242 ECORE_X_EVENT_MASK_MOUSE_UP |
243 ECORE_X_EVENT_MASK_MOUSE_IN |
244 ECORE_X_EVENT_MASK_MOUSE_OUT |
245 ECORE_X_EVENT_MASK_MOUSE_MOVE |
246 ECORE_X_EVENT_MASK_WINDOW_DAMAGE |
247 ECORE_X_EVENT_MASK_WINDOW_VISIBILITY |
248 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE |
249 ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE |
250 ECORE_X_EVENT_MASK_WINDOW_PROPERTY |
251 ECORE_X_EVENT_MASK_WINDOW_COLORMAP
253 ecore_x_xregion_set(ee->engine.x.damages, ee->engine.x.gc);
254 /* debug rendering */
256 XSetForeground(ecore_x_display_get(), ee->engine.x.gc, rand());
257 XFillRectangle(ecore_x_display_get(), ee->prop.window, ee->engine.x.gc,
259 XSync(ecore_x_display_get(), False);
261 XSync(ecore_x_display_get(), False);
263 ecore_x_pixmap_paste(ee->engine.x.pmap, ee->prop.window, ee->engine.x.gc,
264 0, 0, ee->w, ee->h, 0, 0);
265 ecore_x_xregion_free(ee->engine.x.damages);
266 ee->engine.x.damages = NULL;
270 evas_render_updates_free(updates);
271 _ecore_evas_idle_timeout_update(ee);
276 else if (((ee->visible) && (ee->draw_ok)) ||
277 ((ee->should_be_visible) && (ee->prop.fullscreen)) ||
278 ((ee->should_be_visible) && (ee->prop.override)))
282 updates = evas_render_updates(ee->evas);
285 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
286 evas_render_updates_free(updates);
287 _ecore_evas_idle_timeout_update(ee);
293 updates = evas_render_updates(ee->evas);
296 evas_render_updates_free(updates);
298 ecore_x_window_shape_input_mask_set(ee->prop.window, ee->engine.x.mask);
299 _ecore_evas_idle_timeout_update(ee);
305 evas_norender(ee->evas);
306 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
311 _ecore_evas_x_resize_shape(Ecore_Evas *ee)
313 if (!strcmp(ee->driver, "software_x11"))
315 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
316 Evas_Engine_Info_Software_X11 *einfo;
318 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
321 unsigned int foreground;
324 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
325 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
327 gc = ecore_x_gc_new(ee->engine.x.mask,
328 ECORE_X_GC_VALUE_MASK_FOREGROUND,
330 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
333 einfo->info.mask = ee->engine.x.mask;
334 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
335 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
337 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
339 else if (!strcmp(ee->driver, "xrender_x11"))
341 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
342 Evas_Engine_Info_XRender_X11 *einfo;
344 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
347 unsigned int foreground;
350 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
351 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
353 gc = ecore_x_gc_new(ee->engine.x.mask,
354 ECORE_X_GC_VALUE_MASK_FOREGROUND,
356 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
359 einfo->info.mask = ee->engine.x.mask;
360 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
361 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
364 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
366 else if (!strcmp(ee->driver, "software_16_x11"))
368 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
369 # if 0 /* XXX no shaped window support for software_16_x11 */
370 Evas_Engine_Info_Software_16_X11 *einfo;
372 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
375 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
376 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
377 einfo->info.mask = ee->engine.x.mask;
378 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
379 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
381 # endif /* XXX no shaped window support for software_16_x11 */
382 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
386 /* TODO: we need to make this work for all the states, not just sticky */
388 _ecore_evas_x_event_property_change(void *data __UNUSED__, int type __UNUSED__, void *event)
391 Ecore_X_Event_Window_Property *e;
394 ee = ecore_event_window_match(e->win);
395 if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
396 if (e->win != ee->prop.window) return 1;
397 if (e->atom == ECORE_X_ATOM_NET_WM_STATE)
400 Ecore_X_Window_State *state;
403 #ifdef HAVE_ECORE_X_XCB
404 ecore_x_netwm_window_state_get_prefetch(e->win);
405 #endif /* HAVE_ECORE_X_XCB */
408 /* TODO: we need to move those to the end, with if statements */
409 ee->engine.x.state.modal = 0;
410 ee->engine.x.state.maximized_v = 0;
411 ee->engine.x.state.maximized_h = 0;
412 ee->engine.x.state.shaded = 0;
413 ee->engine.x.state.skip_taskbar = 0;
414 ee->engine.x.state.skip_pager = 0;
415 ee->prop.fullscreen = 0;
416 ee->engine.x.state.fullscreen = 0;
417 ee->engine.x.state.above = 0;
418 ee->engine.x.state.below = 0;
420 #ifdef HAVE_ECORE_X_XCB
421 ecore_x_netwm_window_state_get_fetch();
422 #endif /* HAVE_ECORE_X_XCB */
423 ecore_x_netwm_window_state_get(e->win, &state, &num);
426 for (i = 0; i < num; i++)
430 case ECORE_X_WINDOW_STATE_MODAL:
431 ee->engine.x.state.modal = 1;
433 case ECORE_X_WINDOW_STATE_STICKY:
434 if (ee->prop.sticky && ee->engine.x.state.sticky)
439 ee->engine.x.state.sticky = 1;
440 if (ee->func.fn_sticky) ee->func.fn_sticky(ee);
442 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
443 ee->engine.x.state.maximized_v = 1;
445 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
446 ee->engine.x.state.maximized_h = 1;
448 case ECORE_X_WINDOW_STATE_SHADED:
449 ee->engine.x.state.shaded = 1;
451 case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
452 ee->engine.x.state.skip_taskbar = 1;
454 case ECORE_X_WINDOW_STATE_SKIP_PAGER:
455 ee->engine.x.state.skip_pager = 1;
457 case ECORE_X_WINDOW_STATE_FULLSCREEN:
458 ee->prop.fullscreen = 1;
459 ee->engine.x.state.fullscreen = 1;
461 case ECORE_X_WINDOW_STATE_ABOVE:
462 ee->engine.x.state.above = 1;
464 case ECORE_X_WINDOW_STATE_BELOW:
465 ee->engine.x.state.below = 1;
473 #ifdef HAVE_ECORE_X_XCB
474 ecore_xcb_reply_free();
475 #endif /* HAVE_ECORE_X_XCB */
477 if (ee->prop.sticky && !sticky)
480 ee->engine.x.state.sticky = 0;
481 if (ee->func.fn_unsticky) ee->func.fn_unsticky(ee);
489 _ecore_evas_x_event_visibility_change(void *data __UNUSED__, int type __UNUSED__, void *event)
492 Ecore_X_Event_Window_Visibility_Change *e;
495 ee = ecore_event_window_match(e->win);
496 if (!ee) return 1; /* pass on event */
497 if (e->win != ee->prop.window) return 1;
498 // printf("VIS CHANGE OBSCURED: %p %i\n", ee, e->fully_obscured);
499 if (e->fully_obscured)
501 /* FIXME: round trip */
502 if (!ecore_x_screen_is_composited(ee->engine.x.screen_num))
505 else ee->draw_ok = 1;
510 _ecore_evas_x_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
513 Ecore_X_Event_Mouse_In *e;
516 ee = ecore_event_window_match(e->win);
517 if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
518 if (e->win != ee->prop.window) return 1;
523 /* const char *modes[] = { */
525 /* "MODE_WHILE_GRABBED", */
529 /* const char *details[] = { */
530 /* "DETAIL_ANCESTOR", */
531 /* "DETAIL_VIRTUAL", */
532 /* "DETAIL_INFERIOR", */
533 /* "DETAIL_NON_LINEAR", */
534 /* "DETAIL_NON_LINEAR_VIRTUAL", */
535 /* "DETAIL_POINTER", */
536 /* "DETAIL_POINTER_ROOT", */
537 /* "DETAIL_DETAIL_NONE" */
539 /* t = time(NULL); */
540 /* ct = ctime(&t); */
541 /* ct[strlen(ct) - 1] = 0; */
542 /* printf("@@ ->IN 0x%x 0x%x %s md=%s dt=%s\n", */
543 /* e->win, e->event_win, */
545 /* modes[e->mode], */
546 /* details[e->detail]); */
548 // disable. causes mroe problems than it fixes
549 // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) ||
550 // (e->mode == ECORE_X_EVENT_MODE_UNGRAB))
552 /* if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0; */
553 if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
554 ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
555 evas_event_feed_mouse_in(ee->evas, e->time, NULL);
556 _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
561 _ecore_evas_x_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
564 Ecore_X_Event_Mouse_Out *e;
567 ee = ecore_event_window_match(e->win);
568 if ((!ee) || (ee->ignore_events)) return 1;
570 if (e->win != ee->prop.window) return 1;
575 /* const char *modes[] = { */
577 /* "MODE_WHILE_GRABBED", */
581 /* const char *details[] = { */
582 /* "DETAIL_ANCESTOR", */
583 /* "DETAIL_VIRTUAL", */
584 /* "DETAIL_INFERIOR", */
585 /* "DETAIL_NON_LINEAR", */
586 /* "DETAIL_NON_LINEAR_VIRTUAL", */
587 /* "DETAIL_POINTER", */
588 /* "DETAIL_POINTER_ROOT", */
589 /* "DETAIL_DETAIL_NONE" */
591 /* t = time(NULL); */
592 /* ct = ctime(&t); */
593 /* ct[strlen(ct) - 1] = 0; */
594 /* printf("@@ ->OUT 0x%x 0x%x %s md=%s dt=%s\n", */
595 /* e->win, e->event_win, */
597 /* modes[e->mode], */
598 /* details[e->detail]); */
600 // disable. causes more problems than it fixes
601 // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) ||
602 // (e->mode == ECORE_X_EVENT_MODE_UNGRAB))
604 /* if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0; */
605 ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
606 _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
607 if (e->mode == ECORE_X_EVENT_MODE_GRAB)
608 evas_event_feed_mouse_cancel(ee->evas, e->time, NULL);
609 evas_event_feed_mouse_out(ee->evas, e->time, NULL);
610 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
611 if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
616 _ecore_evas_x_event_window_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
619 Ecore_X_Event_Window_Focus_In *e;
622 ee = ecore_event_window_match(e->win);
623 if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
624 if (e->win != ee->prop.window) return 1;
625 ee->prop.focused = 1;
626 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
631 _ecore_evas_x_event_window_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
634 Ecore_X_Event_Window_Focus_Out *e;
637 ee = ecore_event_window_match(e->win);
638 if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
639 if (e->win != ee->prop.window) return 1;
640 if (ee->prop.fullscreen)
641 ecore_x_window_focus(ee->prop.window);
642 ee->prop.focused = 0;
643 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
648 _ecore_evas_x_event_window_damage(void *data __UNUSED__, int type __UNUSED__, void *event)
651 Ecore_X_Event_Window_Damage *e;
654 ee = ecore_event_window_match(e->win);
655 if (!ee) return 1; /* pass on event */
656 if (e->win != ee->prop.window) return 1;
657 if (ee->engine.x.using_bg_pixmap) return 1;
658 // printf("EXPOSE %p [%i] %i %i %ix%i\n", ee, ee->prop.avoid_damage, e->x, e->y, e->w, e->h);
659 if (ee->prop.avoid_damage)
661 Ecore_X_Rectangle rect;
662 Ecore_X_XRegion *tmpr;
664 if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new();
665 tmpr = ecore_x_xregion_new();
670 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
671 ecore_x_xregion_free(ee->engine.x.damages);
672 ee->engine.x.damages = tmpr;
673 /* no - this breaks things badly. disable. Ecore_X_Rectangle != XRectangle - see
674 * the typedefs in x's headers and ecore_x's. also same with Region - it's a pointer in x - not an X ID
675 Ecore_X_Rectangle rect;
676 Ecore_X_XRegion *tmpr;
678 if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new();
679 tmpr = ecore_x_xregion_new();
684 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
685 ecore_x_xregion_free(ee->engine.x.damages);
686 ee->engine.x.damages = tmpr;
691 if (ee->rotation == 0)
692 evas_damage_rectangle_add(ee->evas,
696 else if (ee->rotation == 90)
697 evas_damage_rectangle_add(ee->evas,
701 else if (ee->rotation == 180)
702 evas_damage_rectangle_add(ee->evas,
706 else if (ee->rotation == 270)
707 evas_damage_rectangle_add(ee->evas,
716 _ecore_evas_x_event_window_destroy(void *data __UNUSED__, int type __UNUSED__, void *event)
719 Ecore_X_Event_Window_Destroy *e;
722 ee = ecore_event_window_match(e->win);
723 if (!ee) return 1; /* pass on event */
724 if (e->win != ee->prop.window) return 1;
725 if (ee->func.fn_destroy) ee->func.fn_destroy(ee);
731 _ecore_evas_x_event_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event)
734 Ecore_X_Event_Window_Configure *e;
737 ee = ecore_event_window_match(e->win);
738 if (!ee) return 1; /* pass on event */
739 if (e->win != ee->prop.window) return 1;
740 if (ee->engine.x.direct_resize) return 1;
742 if ((e->from_wm) || (ee->prop.override))
744 if ((ee->x != e->x) || (ee->y != e->y))
748 if (ee->func.fn_move) ee->func.fn_move(ee);
751 if ((ee->w != e->w) || (ee->h != e->h))
755 if ((ee->rotation == 90) || (ee->rotation == 270))
757 evas_output_size_set(ee->evas, ee->h, ee->w);
758 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
762 evas_output_size_set(ee->evas, ee->w, ee->h);
763 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
765 if (ee->prop.avoid_damage)
769 pdam = ecore_evas_avoid_damage_get(ee);
770 ecore_evas_avoid_damage_set(ee, 0);
771 ecore_evas_avoid_damage_set(ee, pdam);
773 if ((ee->shaped) || (ee->alpha))
774 _ecore_evas_x_resize_shape(ee);
775 if ((ee->expecting_resize.w > 0) &&
776 (ee->expecting_resize.h > 0))
778 if ((ee->expecting_resize.w == ee->w) &&
779 (ee->expecting_resize.h == ee->h))
780 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
781 ecore_x_current_time_get());
782 ee->expecting_resize.w = 0;
783 ee->expecting_resize.h = 0;
785 if (ee->func.fn_resize) ee->func.fn_resize(ee);
791 _ecore_evas_x_event_window_delete_request(void *data __UNUSED__, int type __UNUSED__, void *event)
794 Ecore_X_Event_Window_Delete_Request *e;
797 ee = ecore_event_window_match(e->win);
798 if (!ee) return 1; /* pass on event */
799 if (e->win != ee->prop.window) return 1;
800 if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee);
805 _ecore_evas_x_event_window_show(void *data __UNUSED__, int type __UNUSED__, void *event)
808 Ecore_X_Event_Window_Show *e;
811 ee = ecore_event_window_match(e->win);
812 if (!ee) return 1; /* pass on event */
813 if (e->win != ee->prop.window) return 1;
814 if (ee->visible) return 0; /* dont pass it on */
815 // printf("SHOW EVENT %p\n", ee);
817 if (ee->func.fn_show) ee->func.fn_show(ee);
822 _ecore_evas_x_event_window_hide(void *data __UNUSED__, int type __UNUSED__, void *event)
825 Ecore_X_Event_Window_Hide *e;
828 ee = ecore_event_window_match(e->win);
829 if (!ee) return 1; /* pass on event */
830 if (e->win != ee->prop.window) return 1;
831 if (!ee->visible) return 0; /* dont pass it on */
832 // printf("HIDE EVENT %p\n", ee);
834 if (ee->func.fn_hide) ee->func.fn_hide(ee);
838 /* FIXME, should be in idler */
839 /* FIXME, round trip */
841 _ecore_evas_x_size_pos_hints_update(Ecore_Evas *ee)
843 # ifdef HAVE_ECORE_X_XCB
844 ecore_x_icccm_size_pos_hints_get_prefetch(ee->prop.window);
845 ecore_x_icccm_size_pos_hints_get_fetch();
846 # endif /* HAVE_ECORE_X_XCB */
847 ecore_x_icccm_size_pos_hints_set(ee->prop.window,
848 ee->prop.request_pos /*request_pos */,
849 ECORE_X_GRAVITY_NW /* gravity */,
850 ee->prop.min.w /* min_w */,
851 ee->prop.min.h /* min_h */,
852 ee->prop.max.w /* max_w */,
853 ee->prop.max.h /* max_h */,
854 ee->prop.base.w /* base_w */,
855 ee->prop.base.h /* base_h */,
856 ee->prop.step.w /* step_x */,
857 ee->prop.step.h /* step_y */,
860 # ifdef HAVE_ECORE_X_XCB
861 ecore_xcb_reply_free();
862 # endif /* HAVE_ECORE_X_XCB */
865 /* FIXME, should be in idler */
867 _ecore_evas_x_state_update(Ecore_Evas *ee)
869 Ecore_X_Window_State state[10];
875 if (bd->client.netwm.state.modal)
876 state[num++] = ECORE_X_WINDOW_STATE_MODAL;
878 if (ee->engine.x.state.sticky)
879 state[num++] = ECORE_X_WINDOW_STATE_STICKY;
881 if (bd->client.netwm.state.maximized_v)
882 state[num++] = ECORE_X_WINDOW_STATE_MAXIMIZED_VERT;
883 if (bd->client.netwm.state.maximized_h)
884 state[num++] = ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ;
885 if (bd->client.netwm.state.shaded)
886 state[num++] = ECORE_X_WINDOW_STATE_SHADED;
887 if (bd->client.netwm.state.skip_taskbar)
888 state[num++] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
889 if (bd->client.netwm.state.skip_pager)
890 state[num++] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
891 if (bd->client.netwm.state.hidden)
892 state[num++] = ECORE_X_WINDOW_STATE_HIDDEN;
894 if (ee->engine.x.state.fullscreen)
895 state[num++] = ECORE_X_WINDOW_STATE_FULLSCREEN;
896 if (ee->engine.x.state.above)
897 state[num++] = ECORE_X_WINDOW_STATE_ABOVE;
898 if (ee->engine.x.state.below)
899 state[num++] = ECORE_X_WINDOW_STATE_BELOW;
901 ecore_x_netwm_window_state_set(ee->prop.window, state, num);
905 _ecore_evas_x_layer_update(Ecore_Evas *ee)
907 if (ee->should_be_visible)
909 /* We need to send a netwm request to the wm */
910 /* FIXME: Do we have to remove old state before adding new? */
911 if (ee->prop.layer < 3)
913 if (ee->engine.x.state.above)
915 ee->engine.x.state.above = 0;
916 ecore_x_netwm_state_request_send(ee->prop.window,
917 ee->engine.x.win_root,
918 ECORE_X_WINDOW_STATE_ABOVE, -1, 0);
920 if (!ee->engine.x.state.below)
922 ee->engine.x.state.below = 1;
923 ecore_x_netwm_state_request_send(ee->prop.window,
924 ee->engine.x.win_root,
925 ECORE_X_WINDOW_STATE_BELOW, -1, 1);
928 else if (ee->prop.layer > 5)
930 if (ee->engine.x.state.below)
932 ee->engine.x.state.below = 0;
933 ecore_x_netwm_state_request_send(ee->prop.window,
934 ee->engine.x.win_root,
935 ECORE_X_WINDOW_STATE_BELOW, -1, 0);
937 if (!ee->engine.x.state.above)
939 ee->engine.x.state.above = 1;
940 ecore_x_netwm_state_request_send(ee->prop.window,
941 ee->engine.x.win_root,
942 ECORE_X_WINDOW_STATE_ABOVE, -1, 1);
947 if (ee->engine.x.state.below)
949 ee->engine.x.state.below = 0;
950 ecore_x_netwm_state_request_send(ee->prop.window,
951 ee->engine.x.win_root,
952 ECORE_X_WINDOW_STATE_BELOW, -1, 0);
954 if (ee->engine.x.state.above)
956 ee->engine.x.state.above = 0;
957 ecore_x_netwm_state_request_send(ee->prop.window,
958 ee->engine.x.win_root,
959 ECORE_X_WINDOW_STATE_ABOVE, -1, 0);
965 /* Just set the state */
966 if (ee->prop.layer < 3)
968 if ((ee->engine.x.state.above) || (!ee->engine.x.state.below))
970 ee->engine.x.state.above = 0;
971 ee->engine.x.state.below = 1;
972 _ecore_evas_x_state_update(ee);
975 else if (ee->prop.layer > 5)
977 if ((!ee->engine.x.state.above) || (ee->engine.x.state.below))
979 ee->engine.x.state.above = 1;
980 ee->engine.x.state.below = 0;
981 _ecore_evas_x_state_update(ee);
986 if ((ee->engine.x.state.above) || (ee->engine.x.state.below))
988 ee->engine.x.state.above = 0;
989 ee->engine.x.state.below = 0;
990 _ecore_evas_x_state_update(ee);
994 /* FIXME: Set gnome layer */
998 _ecore_evas_x_init(void)
1000 _ecore_evas_init_count++;
1001 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
1002 ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_IN, _ecore_evas_x_event_mouse_in, NULL);
1003 ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT, _ecore_evas_x_event_mouse_out, NULL);
1004 ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, _ecore_evas_x_event_window_focus_in, NULL);
1005 ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, _ecore_evas_x_event_window_focus_out, NULL);
1006 ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DAMAGE, _ecore_evas_x_event_window_damage, NULL);
1007 ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _ecore_evas_x_event_window_destroy, NULL);
1008 ecore_evas_event_handlers[6] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, _ecore_evas_x_event_window_configure, NULL);
1009 ecore_evas_event_handlers[7] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, _ecore_evas_x_event_window_delete_request, NULL);
1010 ecore_evas_event_handlers[8] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, _ecore_evas_x_event_window_show, NULL);
1011 ecore_evas_event_handlers[9] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, _ecore_evas_x_event_window_hide, NULL);
1012 ecore_evas_event_handlers[10] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _ecore_evas_x_event_property_change, NULL);
1013 ecore_evas_event_handlers[11] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, _ecore_evas_x_event_visibility_change, NULL);
1014 ecore_event_evas_init();
1015 return _ecore_evas_init_count;
1019 _ecore_evas_x_free(Ecore_Evas *ee)
1021 ecore_x_window_free(ee->prop.window);
1022 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
1023 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1024 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
1025 if (ee->engine.x.damages) ecore_x_xregion_free(ee->engine.x.damages);
1026 ee->engine.x.pmap = 0;
1027 ee->engine.x.mask = 0;
1028 ee->engine.x.gc = 0;
1029 ee->engine.x.damages = NULL;
1030 ecore_event_window_unregister(ee->prop.window);
1031 while (ee->engine.x.win_extra)
1033 Ecore_X_Window *winp;
1035 winp = ee->engine.x.win_extra->data;
1036 ee->engine.x.win_extra = eina_list_remove_list(ee->engine.x.win_extra, ee->engine.x.win_extra);
1037 ecore_event_window_unregister(*winp);
1040 _ecore_evas_x_shutdown();
1044 /* FIXME: round trip */
1046 _ecore_evas_x_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1048 #ifdef HAVE_ECORE_X_XCB
1049 ecore_x_icccm_protocol_get_prefetch(ee->prop.window);
1050 ecore_x_icccm_protocol_get_fetch();
1051 #endif /* HAVE_ECORE_X_XCB */
1053 ecore_x_icccm_protocol_set(ee->prop.window, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 1);
1055 ecore_x_icccm_protocol_set(ee->prop.window, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 0);
1056 ee->func.fn_delete_request = func;
1057 #ifdef HAVE_ECORE_X_XCB
1058 ecore_xcb_reply_free();
1059 #endif /* HAVE_ECORE_X_XCB */
1063 _ecore_evas_x_move(Ecore_Evas *ee, int x, int y)
1065 if (ee->engine.x.direct_resize)
1067 if (!ee->engine.x.managed)
1069 if ((x != ee->x) || (y != ee->y))
1073 ecore_x_window_move(ee->prop.window, x, y);
1074 if (!ee->should_be_visible)
1076 /* We need to request pos */
1077 ee->prop.request_pos = 1;
1078 _ecore_evas_x_size_pos_hints_update(ee);
1080 if (ee->func.fn_move) ee->func.fn_move(ee);
1086 ecore_x_window_move(ee->prop.window, x, y);
1087 if (!ee->should_be_visible)
1089 /* We need to request pos */
1090 ee->prop.request_pos = 1;
1091 _ecore_evas_x_size_pos_hints_update(ee);
1093 if (!ee->engine.x.managed)
1102 _ecore_evas_x_managed_move(Ecore_Evas *ee, int x, int y)
1104 if (ee->engine.x.direct_resize)
1106 ee->engine.x.managed = 1;
1107 if ((x != ee->x) || (y != ee->y))
1111 if (ee->func.fn_move) ee->func.fn_move(ee);
1117 _ecore_evas_x_resize(Ecore_Evas *ee, int w, int h)
1119 if (ee->engine.x.direct_resize)
1121 if ((ee->w != w) || (ee->h != h))
1123 ecore_x_window_resize(ee->prop.window, w, h);
1126 if ((ee->rotation == 90) || (ee->rotation == 270))
1128 evas_output_size_set(ee->evas, ee->h, ee->w);
1129 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1133 evas_output_size_set(ee->evas, ee->w, ee->h);
1134 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1136 if (ee->prop.avoid_damage)
1140 pdam = ecore_evas_avoid_damage_get(ee);
1141 ecore_evas_avoid_damage_set(ee, 0);
1142 ecore_evas_avoid_damage_set(ee, pdam);
1144 if ((ee->shaped) || (ee->alpha))
1145 _ecore_evas_x_resize_shape(ee);
1146 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1150 ecore_x_window_resize(ee->prop.window, w, h);
1154 _ecore_evas_x_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
1156 if (ee->engine.x.direct_resize)
1158 if ((ee->w != w) || (ee->h != h) || (x != ee->x) || (y != ee->y))
1160 int change_size = 0, change_pos = 0;
1162 if ((ee->w != w) || (ee->h != h)) change_size = 1;
1163 if (!ee->engine.x.managed)
1165 if ((x != ee->x) || (y != ee->y)) change_pos = 1;
1167 ecore_x_window_move_resize(ee->prop.window, x, y, w, h);
1168 if (!ee->engine.x.managed)
1175 if ((ee->rotation == 90) || (ee->rotation == 270))
1177 evas_output_size_set(ee->evas, ee->h, ee->w);
1178 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1182 evas_output_size_set(ee->evas, ee->w, ee->h);
1183 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1185 if (ee->prop.avoid_damage)
1189 pdam = ecore_evas_avoid_damage_get(ee);
1190 ecore_evas_avoid_damage_set(ee, 0);
1191 ecore_evas_avoid_damage_set(ee, pdam);
1193 if ((ee->shaped) || (ee->alpha))
1194 _ecore_evas_x_resize_shape(ee);
1197 if (ee->func.fn_move) ee->func.fn_move(ee);
1201 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1207 ecore_x_window_move_resize(ee->prop.window, x, y, w, h);
1208 if (!ee->engine.x.managed)
1217 _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation,
1218 Evas_Engine_Info *einfo)
1222 rot_dif = ee->rotation - rotation;
1223 if (rot_dif < 0) rot_dif = -rot_dif;
1227 int minw, minh, maxw, maxh, basew, baseh, stepw, steph;
1229 evas_engine_info_set(ee->evas, einfo);
1230 if (!ee->prop.fullscreen)
1232 ecore_x_window_resize(ee->prop.window, ee->h, ee->w);
1233 ee->expecting_resize.w = ee->h;
1234 ee->expecting_resize.h = ee->w;
1240 ecore_x_window_size_get(ee->prop.window, &w, &h);
1241 ecore_x_window_resize(ee->prop.window, h, w);
1242 if ((rotation == 0) || (rotation == 180))
1244 evas_output_size_set(ee->evas, ee->w, ee->h);
1245 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1249 evas_output_size_set(ee->evas, ee->h, ee->w);
1250 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1252 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1254 ecore_evas_size_min_get(ee, &minw, &minh);
1255 ecore_evas_size_max_get(ee, &maxw, &maxh);
1256 ecore_evas_size_base_get(ee, &basew, &baseh);
1257 ecore_evas_size_step_get(ee, &stepw, &steph);
1258 ee->rotation = rotation;
1259 ecore_evas_size_min_set(ee, minh, minw);
1260 ecore_evas_size_max_set(ee, maxh, maxw);
1261 ecore_evas_size_base_set(ee, baseh, basew);
1262 ecore_evas_size_step_set(ee, steph, stepw);
1263 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
1264 ecore_x_current_time_get());
1268 evas_engine_info_set(ee->evas, einfo);
1269 ee->rotation = rotation;
1270 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
1271 ecore_x_current_time_get());
1272 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1275 if ((ee->rotation == 90) || (ee->rotation == 270))
1276 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
1278 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1282 _ecore_evas_x_rotation_set(Ecore_Evas *ee, int rotation)
1284 if (ee->rotation == rotation) return;
1285 if (!strcmp(ee->driver, "opengl_x11")) return;
1286 if (!strcmp(ee->driver, "xrender_x11")) return;
1287 if (!strcmp(ee->driver, "software_x11"))
1289 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1290 Evas_Engine_Info_Software_X11 *einfo;
1292 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1294 einfo->info.rotation = rotation;
1295 _ecore_evas_x_rotation_set_internal
1296 (ee, rotation, (Evas_Engine_Info *)einfo);
1297 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1299 else if (!strcmp(ee->driver, "software_16_x11"))
1301 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
1302 Evas_Engine_Info_Software_16_X11 *einfo;
1304 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
1306 einfo->info.rotation = rotation;
1307 _ecore_evas_x_rotation_set_internal
1308 (ee, rotation, (Evas_Engine_Info *)einfo);
1309 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
1314 _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped)
1316 if (((ee->shaped) && (shaped)) || ((!ee->shaped) && (!shaped)))
1318 if (!strcmp(ee->driver, "opengl_x11")) return;
1319 if (!strcmp(ee->driver, "software_x11"))
1321 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1322 Evas_Engine_Info_Software_X11 *einfo;
1324 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1325 ee->shaped = shaped;
1330 unsigned int foreground;
1333 if (!ee->engine.x.mask)
1334 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1336 gc = ecore_x_gc_new(ee->engine.x.mask,
1337 ECORE_X_GC_VALUE_MASK_FOREGROUND,
1339 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
1340 0, 0, ee->w, ee->h);
1341 ecore_x_gc_free(gc);
1342 einfo->info.mask = ee->engine.x.mask;
1343 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1344 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1345 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1349 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1350 ee->engine.x.mask = 0;
1351 einfo->info.mask = 0;
1352 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1353 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1354 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1357 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1359 else if (!strcmp(ee->driver, "xrender_x11"))
1361 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
1362 Evas_Engine_Info_XRender_X11 *einfo;
1364 ee->shaped = shaped;
1365 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
1370 unsigned int foreground;
1373 if (!ee->engine.x.mask)
1374 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1376 gc = ecore_x_gc_new(ee->engine.x.mask,
1377 ECORE_X_GC_VALUE_MASK_FOREGROUND,
1379 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
1380 0, 0, ee->w, ee->h);
1381 ecore_x_gc_free(gc);
1382 einfo->info.mask = ee->engine.x.mask;
1383 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1384 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1385 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1389 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1390 ee->engine.x.mask = 0;
1391 einfo->info.mask = 0;
1392 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1393 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1394 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1397 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
1399 else if (!strcmp(ee->driver, "software_16_x11"))
1401 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
1402 # if 0 /* XXX no shaped window support for software_16_x11 */
1403 Evas_Engine_Info_Software_16_X11 *einfo;
1405 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
1406 ee->shaped = shaped;
1414 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1415 einfo->info.mask = ee->engine.x.mask;
1416 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1417 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1421 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1422 ee->engine.x.mask = 0;
1423 einfo->info.mask = 0;
1424 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1425 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1428 # endif /* XXX no shaped window support for software_16_x11 */
1429 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
1434 /* FIXME, round trip */
1436 _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha)
1438 # ifdef HAVE_ECORE_X_XCB
1439 xcb_get_geometry_cookie_t cookie_geom;
1440 xcb_get_window_attributes_cookie_t cookie_attr;
1441 xcb_get_geometry_reply_t *reply_geom;
1442 xcb_get_window_attributes_reply_t *reply_attr;
1444 XWindowAttributes att;
1445 #endif /* ! HAVE_ECORE_X_XCB */
1447 if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha)))
1450 if (!strcmp(ee->driver, "software_x11"))
1452 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1453 Evas_Engine_Info_Software_X11 *einfo;
1455 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1458 if (!ecore_x_composite_query()) return;
1462 ecore_x_window_free(ee->prop.window);
1463 ecore_event_window_unregister(ee->prop.window);
1466 if (ee->prop.override)
1467 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1469 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1470 if (!ee->engine.x.mask)
1471 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1475 if (ee->prop.override)
1476 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1478 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1479 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1480 ee->engine.x.mask = 0;
1481 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1484 einfo->info.destination_alpha = alpha;
1486 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
1487 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
1488 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
1490 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
1491 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
1492 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
1493 einfo->info.colormap = reply_attr->colormap;
1494 einfo->info.depth = reply_geom->depth;
1498 XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att);
1499 einfo->info.visual = att.visual;
1500 einfo->info.colormap = att.colormap;
1501 einfo->info.depth = att.depth;
1502 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
1504 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1505 // ee->engine.x.mask = 0;
1506 einfo->info.mask = ee->engine.x.mask;
1507 einfo->info.drawable = ee->prop.window;
1508 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1509 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1510 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1511 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
1512 if (ee->prop.borderless)
1513 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
1514 if (ee->visible) ecore_x_window_show(ee->prop.window);
1515 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
1518 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
1519 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
1521 ecore_x_icccm_hints_set(ee->prop.window,
1522 1 /* accepts_focus */,
1523 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
1524 0 /* icon_pixmap */,
1526 0 /* icon_window */,
1527 0 /* window_group */,
1529 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1531 else if (!strcmp(ee->driver, "xrender_x11"))
1533 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
1534 Evas_Engine_Info_XRender_X11 *einfo;
1536 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
1538 if (!ecore_x_composite_query()) return;
1542 ecore_x_window_free(ee->prop.window);
1543 ecore_event_window_unregister(ee->prop.window);
1546 if (ee->prop.override)
1547 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1549 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1550 if (!ee->engine.x.mask)
1551 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1555 if (ee->prop.override)
1556 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1558 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1559 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1560 ee->engine.x.mask = 0;
1561 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1564 einfo->info.destination_alpha = alpha;
1566 # ifdef BUILD_ECORE_EVAS_XRENDER_XCB
1567 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
1568 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
1570 einfo->info.visual = reply_attr->visual;
1573 XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att);
1574 einfo->info.visual = att.visual;
1575 # endif /* ! BUILD_ECORE_EVAS_XRENDER_XCB */
1577 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1578 // ee->engine.x.mask = 0;
1579 einfo->info.mask = ee->engine.x.mask;
1580 einfo->info.drawable = ee->prop.window;
1581 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1582 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1583 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1584 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
1585 if (ee->prop.borderless)
1586 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
1587 if (ee->visible) ecore_x_window_show(ee->prop.window);
1588 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
1591 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
1592 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
1594 ecore_x_icccm_hints_set(ee->prop.window,
1595 1 /* accepts_focus */,
1596 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
1597 0 /* icon_pixmap */,
1599 0 /* icon_window */,
1600 0 /* window_group */,
1602 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
1604 else if (!strcmp(ee->driver, "software_16_x11"))
1606 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
1607 Evas_Engine_Info_Software_16_X11 *einfo;
1609 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
1614 ecore_x_window_free(ee->prop.window);
1615 ecore_event_window_unregister(ee->prop.window);
1618 if (ee->prop.override)
1619 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1621 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1622 if (!ee->engine.x.mask)
1623 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1627 if (ee->prop.override)
1628 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1630 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->x, ee->y, ee->w, ee->h);
1631 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1632 ee->engine.x.mask = 0;
1633 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1636 # if 0 /* XXX no alpha window support for software_16_x11 */
1637 einfo->info.destination_alpha = alpha;
1638 # endif /* XXX no alpha window support for software_16_x11 */
1640 # if 0 /* XXX no shaped window support for software_16_x11 */
1641 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1642 // ee->engine.x.mask = 0;
1643 einfo->info.mask = ee->engine.x.mask;
1644 # endif /* XXX no shaped window support for software_16_x11 */
1646 einfo->info.drawable = ee->prop.window;
1647 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1648 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1649 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1650 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
1651 if (ee->prop.borderless)
1652 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
1653 if (ee->visible) ecore_x_window_show(ee->prop.window);
1654 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
1657 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
1658 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
1660 ecore_x_icccm_hints_set(ee->prop.window,
1661 1 /* accepts_focus */,
1662 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
1663 0 /* icon_pixmap */,
1665 0 /* icon_window */,
1666 0 /* window_group */,
1668 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
1671 #endif /* BUILD_ECORE_EVAS_X11 */
1673 #ifdef BUILD_ECORE_EVAS_X11
1675 _ecore_evas_x_show(Ecore_Evas *ee)
1677 ee->should_be_visible = 1;
1678 if (ee->prop.avoid_damage)
1679 _ecore_evas_x_render(ee);
1680 ecore_x_window_show(ee->prop.window);
1681 if (ee->prop.fullscreen)
1682 ecore_x_window_focus(ee->prop.window);
1686 _ecore_evas_x_hide(Ecore_Evas *ee)
1688 ecore_x_window_hide(ee->prop.window);
1689 ee->should_be_visible = 0;
1693 _ecore_evas_x_raise(Ecore_Evas *ee)
1695 if (!ee->prop.fullscreen)
1696 ecore_x_window_raise(ee->prop.window);
1698 ecore_x_window_raise(ee->prop.window);
1702 _ecore_evas_x_lower(Ecore_Evas *ee)
1704 if (!ee->prop.fullscreen)
1705 ecore_x_window_lower(ee->prop.window);
1707 ecore_x_window_lower(ee->prop.window);
1711 _ecore_evas_x_activate(Ecore_Evas *ee)
1713 ecore_x_netwm_client_active_request(ee->engine.x.win_root,
1714 ee->prop.window, 2, 0);
1718 _ecore_evas_x_title_set(Ecore_Evas *ee, const char *t)
1720 if (ee->prop.title) free(ee->prop.title);
1721 ee->prop.title = NULL;
1722 if (t) ee->prop.title = strdup(t);
1723 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
1724 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
1728 _ecore_evas_x_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
1730 if (ee->prop.name) free(ee->prop.name);
1731 if (ee->prop.clas) free(ee->prop.clas);
1732 ee->prop.name = NULL;
1733 ee->prop.clas = NULL;
1734 if (n) ee->prop.name = strdup(n);
1735 if (c) ee->prop.clas = strdup(c);
1736 ecore_x_icccm_name_class_set(ee->prop.window, ee->prop.name, ee->prop.clas);
1740 _ecore_evas_x_size_min_set(Ecore_Evas *ee, int w, int h)
1744 if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return;
1747 _ecore_evas_x_size_pos_hints_update(ee);
1751 _ecore_evas_x_size_max_set(Ecore_Evas *ee, int w, int h)
1755 if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return;
1758 _ecore_evas_x_size_pos_hints_update(ee);
1762 _ecore_evas_x_size_base_set(Ecore_Evas *ee, int w, int h)
1766 if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return;
1767 ee->prop.base.w = w;
1768 ee->prop.base.h = h;
1769 _ecore_evas_x_size_pos_hints_update(ee);
1773 _ecore_evas_x_size_step_set(Ecore_Evas *ee, int w, int h)
1777 if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return;
1778 ee->prop.step.w = w;
1779 ee->prop.step.h = h;
1780 _ecore_evas_x_size_pos_hints_update(ee);
1784 _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1790 ee->prop.cursor.object = NULL;
1794 _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
1798 if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
1802 ee->prop.cursor.object = NULL;
1803 ee->prop.cursor.layer = 0;
1804 ee->prop.cursor.hot.x = 0;
1805 ee->prop.cursor.hot.y = 0;
1806 ecore_x_window_cursor_show(ee->prop.window, 1);
1810 ee->prop.cursor.object = obj;
1811 ee->prop.cursor.layer = layer;
1812 ee->prop.cursor.hot.x = hot_x;
1813 ee->prop.cursor.hot.y = hot_y;
1815 ecore_x_window_cursor_show(ee->prop.window, 0);
1817 evas_pointer_output_xy_get(ee->evas, &x, &y);
1818 evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
1819 evas_object_move(ee->prop.cursor.object,
1820 x - ee->prop.cursor.hot.x,
1821 y - ee->prop.cursor.hot.y);
1822 evas_object_pass_events_set(ee->prop.cursor.object, 1);
1823 if (evas_pointer_inside_get(ee->evas))
1824 evas_object_show(ee->prop.cursor.object);
1826 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
1831 * @param layer If < 3, @a ee will be put below all other windows.
1832 * If > 5, @a ee will be "always-on-top"
1833 * If = 4, @a ee will be put in the default layer.
1834 * Acceptable values range from 1 to 255 (0 reserved for
1838 _ecore_evas_x_layer_set(Ecore_Evas *ee, int layer)
1840 if (ee->prop.layer == layer) return;
1842 /* FIXME: Should this logic be here? */
1845 else if (layer > 255)
1848 ee->prop.layer = layer;
1849 _ecore_evas_x_layer_update(ee);
1853 _ecore_evas_x_focus_set(Ecore_Evas *ee, int on __UNUSED__)
1855 ecore_x_window_focus(ee->prop.window);
1859 _ecore_evas_x_iconified_set(Ecore_Evas *ee, int on)
1861 // if (((ee->prop.iconified) && (on)) ||
1862 // ((!ee->prop.iconified) && (!on))) return;
1863 ee->prop.iconified = on;
1866 ecore_x_icccm_hints_set(ee->prop.window,
1867 1 /* accepts_focus */,
1868 ECORE_X_WINDOW_STATE_HINT_ICONIC /* initial_state */,
1869 0 /* icon_pixmap */,
1871 0 /* icon_window */,
1872 0 /* window_group */,
1874 ecore_x_icccm_iconic_request_send(ee->prop.window, ee->engine.x.win_root);
1878 ecore_x_icccm_hints_set(ee->prop.window,
1879 1 /* accepts_focus */,
1880 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
1881 0 /* icon_pixmap */,
1883 0 /* icon_window */,
1884 0 /* window_group */,
1886 ecore_evas_show(ee);
1891 _ecore_evas_x_borderless_set(Ecore_Evas *ee, int on)
1893 if (((ee->prop.borderless) && (on)) ||
1894 ((!ee->prop.borderless) && (!on))) return;
1895 ee->prop.borderless = on;
1896 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
1899 /* FIXME: This function changes the initial state of the ee
1900 * whilest the iconic function changes the current state! */
1902 _ecore_evas_x_withdrawn_set(Ecore_Evas *ee, int withdrawn)
1904 Ecore_X_Window_State_Hint hint;
1906 if ((ee->prop.withdrawn && withdrawn) ||
1907 (!ee->prop.withdrawn && !withdrawn)) return;
1909 ee->prop.withdrawn = withdrawn;
1911 hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
1913 hint = ECORE_X_WINDOW_STATE_HINT_NORMAL;
1915 ecore_x_icccm_hints_set(ee->prop.window,
1916 1 /* accepts_focus */,
1917 hint /* initial_state */,
1918 0 /* icon_pixmap */,
1920 0 /* icon_window */,
1921 0 /* window_group */,
1926 _ecore_evas_x_sticky_set(Ecore_Evas *ee, int sticky)
1928 if ((ee->prop.sticky && sticky) ||
1929 (!ee->prop.sticky && !sticky)) return;
1931 /* We dont want to set prop.sticky here as it will cause
1932 * the sticky callback not to get called. Its set on the
1933 * property change event.
1934 * ee->prop.sticky = sticky;
1936 ee->engine.x.state.sticky = sticky;
1937 if (ee->should_be_visible)
1938 ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root,
1939 ECORE_X_WINDOW_STATE_STICKY, -1, sticky);
1941 _ecore_evas_x_state_update(ee);
1945 _ecore_evas_x_ignore_events_set(Ecore_Evas *ee, int ignore)
1947 if ((ee->ignore_events && ignore) ||
1948 (!ee->ignore_events && !ignore)) return;
1952 ee->ignore_events = 1;
1953 if (ee->prop.window)
1954 ecore_x_window_ignore_set(ee->prop.window, 1);
1958 ee->ignore_events = 0;
1959 if (ee->prop.window)
1960 ecore_x_window_ignore_set(ee->prop.window, 0);
1966 _ecore_evas_x_reinit_win(Ecore_Evas *ee)
1968 if (!strcmp(ee->driver, "software_x11"))
1970 #ifdef BUILD_ECORE_EVAS_X11
1971 Evas_Engine_Info_Software_X11 *einfo;
1973 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1976 einfo->info.drawable = ee->prop.window;
1977 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1981 else if (!strcmp(ee->driver, "xrender_x11"))
1983 #ifdef BUILD_ECORE_EVAS_XRENDER_X11
1984 Evas_Engine_Info_XRender_X11 *einfo;
1986 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
1989 einfo->info.drawable = ee->prop.window;
1990 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1994 else if (!strcmp(ee->driver, "opengl_x11"))
1996 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
1997 Evas_Engine_Info_GL_X11 *einfo;
1999 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
2002 einfo->info.drawable = ee->prop.window;
2003 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2011 _ecore_evas_x_override_set(Ecore_Evas *ee, int on)
2013 if (((ee->prop.override) && (on)) ||
2014 ((!ee->prop.override) && (!on))) return;
2015 ecore_x_window_hide(ee->prop.window);
2016 ecore_x_window_override_set(ee->prop.window, on);
2017 if (ee->visible) ecore_x_window_show(ee->prop.window);
2018 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2019 ee->prop.override = on;
2023 _ecore_evas_x_fullscreen_set(Ecore_Evas *ee, int on)
2025 if ((ee->prop.fullscreen && on) ||
2026 (!ee->prop.fullscreen && !on)) return;
2028 /* FIXME: Detect if WM is EWMH compliant and handle properly if not,
2029 * i.e. reposition, resize, and change borderless hint */
2030 ee->engine.x.state.fullscreen = on;
2031 if (ee->should_be_visible)
2032 ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root,
2033 ECORE_X_WINDOW_STATE_FULLSCREEN, -1, on);
2035 _ecore_evas_x_state_update(ee);
2039 _ecore_evas_x_avoid_damage_set(Ecore_Evas *ee, int on)
2041 if (ee->prop.avoid_damage == on) return;
2042 if (!strcmp(ee->driver, "opengl_x11")) return;
2043 if (!strcmp(ee->driver, "xrender_x11")) return;
2045 if (!strcmp(ee->driver, "software_x11"))
2047 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2048 Evas_Engine_Info_Software_X11 *einfo;
2050 ee->prop.avoid_damage = on;
2051 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
2054 if (ee->prop.avoid_damage)
2056 ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth);
2057 ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL);
2058 einfo->info.drawable = ee->engine.x.pmap;
2059 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2060 if ((ee->rotation == 90) || (ee->rotation == 270))
2061 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
2063 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2064 if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN)
2066 ee->engine.x.using_bg_pixmap = 1;
2067 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2068 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2070 if (ee->engine.x.direct_resize)
2072 /* Turn this off for now
2073 ee->engine.x.using_bg_pixmap = 1;
2074 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2080 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
2081 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
2082 if (ee->engine.x.using_bg_pixmap)
2084 ecore_x_window_pixmap_set(ee->prop.window, 0);
2085 ee->engine.x.using_bg_pixmap = 0;
2086 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2088 ee->engine.x.pmap = 0;
2089 ee->engine.x.gc = 0;
2090 einfo->info.drawable = ee->prop.window;
2091 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2094 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
2096 else if (!strcmp(ee->driver, "software_16_x11"))
2098 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
2099 Evas_Engine_Info_Software_16_X11 *einfo;
2100 ee->prop.avoid_damage = on;
2102 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
2105 if (ee->prop.avoid_damage)
2107 ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 16);
2108 ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL);
2109 einfo->info.drawable = ee->engine.x.pmap;
2110 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2111 if ((ee->rotation == 90) || (ee->rotation == 270))
2112 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
2114 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2115 if (ee->engine.x.direct_resize)
2117 /* Turn this off for now
2118 ee->engine.x.using_bg_pixmap = 1;
2119 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2125 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
2126 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
2127 if (ee->engine.x.using_bg_pixmap)
2129 ecore_x_window_pixmap_set(ee->prop.window, 0);
2130 ee->engine.x.using_bg_pixmap = 0;
2132 ee->engine.x.pmap = 0;
2133 ee->engine.x.gc = 0;
2134 einfo->info.drawable = ee->prop.window;
2135 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2138 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
2143 _ecore_evas_x_shutdown(void)
2145 _ecore_evas_init_count--;
2146 if (_ecore_evas_init_count == 0)
2150 for (i = 0; i < sizeof(ecore_evas_event_handlers) / sizeof(Ecore_Event_Handler*); i++)
2151 ecore_event_handler_del(ecore_evas_event_handlers[i]);
2152 ecore_event_evas_shutdown();
2154 if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
2155 return _ecore_evas_init_count;
2158 static Ecore_Evas_Engine_Func _ecore_x_engine_func =
2165 _ecore_evas_x_callback_delete_request_set,
2176 _ecore_evas_x_managed_move,
2177 _ecore_evas_x_resize,
2178 _ecore_evas_x_move_resize,
2179 _ecore_evas_x_rotation_set,
2180 _ecore_evas_x_shaped_set,
2183 _ecore_evas_x_raise,
2184 _ecore_evas_x_lower,
2185 _ecore_evas_x_activate,
2186 _ecore_evas_x_title_set,
2187 _ecore_evas_x_name_class_set,
2188 _ecore_evas_x_size_min_set,
2189 _ecore_evas_x_size_max_set,
2190 _ecore_evas_x_size_base_set,
2191 _ecore_evas_x_size_step_set,
2192 _ecore_evas_x_object_cursor_set,
2193 _ecore_evas_x_layer_set,
2194 _ecore_evas_x_focus_set,
2195 _ecore_evas_x_iconified_set,
2196 _ecore_evas_x_borderless_set,
2197 _ecore_evas_x_override_set,
2199 _ecore_evas_x_fullscreen_set,
2200 _ecore_evas_x_avoid_damage_set,
2201 _ecore_evas_x_withdrawn_set,
2202 _ecore_evas_x_sticky_set,
2203 _ecore_evas_x_ignore_events_set,
2204 _ecore_evas_x_alpha_set,
2208 #endif /* BUILD_ECORE_EVAS_X11 */
2211 * FIXME: there are some round trips. Especially, we can split
2212 * ecore_x_init in 2 functions and supress some round trips.
2218 * FIXME: To be fixed.
2220 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2222 ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent,
2223 int x, int y, int w, int h)
2225 Evas_Engine_Info_Software_X11 *einfo;
2229 static int redraw_debug = -1;
2231 rmethod = evas_render_method_lookup("software_x11");
2232 if (!rmethod) return NULL;
2233 if (!ecore_x_init(disp_name)) return NULL;
2234 ee = calloc(1, sizeof(Ecore_Evas));
2235 if (!ee) return NULL;
2237 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
2239 _ecore_evas_x_init();
2241 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
2243 ee->driver = "software_x11";
2244 if (disp_name) ee->name = strdup(disp_name);
2253 ee->prop.max.w = 32767;
2254 ee->prop.max.h = 32767;
2256 ee->prop.request_pos = 0;
2257 ee->prop.sticky = 0;
2258 ee->engine.x.state.sticky = 0;
2260 /* init evas here */
2261 ee->evas = evas_new();
2262 evas_data_attach_set(ee->evas, ee);
2263 evas_output_method_set(ee->evas, rmethod);
2264 evas_output_size_set(ee->evas, w, h);
2265 evas_output_viewport_set(ee->evas, 0, 0, w, h);
2267 ee->engine.x.win_root = parent;
2268 ee->engine.x.screen_num = 0;
2272 ee->engine.x.screen_num = 1; /* FIXME: get real scren # */
2273 /* FIXME: round trip in ecore_x_window_argb_get */
2274 if (ecore_x_window_argb_get(parent))
2276 ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h);
2280 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
2283 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
2284 if (getenv("DESKTOP_STARTUP_ID"))
2286 ecore_x_netwm_startup_id_set(ee->prop.window,
2287 getenv("DESKTOP_STARTUP_ID"));
2288 /* NB: on linux this may simply empty the env as opposed to completely
2289 * unset it to being empty - unsure as solartis libc crashes looking
2290 * for the '=' char */
2291 // putenv((char*)"DESKTOP_STARTUP_ID=");
2293 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
2296 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
2297 xcb_screen_iterator_t iter;
2298 xcb_screen_t *screen;
2301 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
2303 /* FIXME: this is inefficient as its a round trip */
2304 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
2305 screen = ecore_x_default_screen_get();
2306 iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get()));
2309 xcb_get_geometry_cookie_t cookie;
2310 xcb_get_geometry_reply_t *reply;
2311 Ecore_X_Window *roots;
2316 cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent);
2317 roots = ecore_x_window_root_list(&num);
2320 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
2324 for (i = 0; i < num; xcb_screen_next (&iter), i++)
2326 if (reply->root == roots[i])
2338 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
2339 if (reply) free(reply);
2343 screen = DefaultScreen(ecore_x_display_get());
2344 if (ScreenCount(ecore_x_display_get()) > 1)
2346 Ecore_X_Window *roots;
2350 roots = ecore_x_window_root_list(&num);
2353 XWindowAttributes at;
2355 if (XGetWindowAttributes(ecore_x_display_get(),
2358 for (i = 0; i < num; i++)
2360 if (at.root == roots[i])
2370 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
2372 if (redraw_debug < 0)
2374 if (getenv("REDRAW_DEBUG"))
2375 redraw_debug = atoi(getenv("REDRAW_DEBUG"));
2379 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
2380 einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB;
2381 einfo->info.connection = ecore_x_connection_get();
2382 einfo->info.screen = screen;
2384 einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB;
2385 einfo->info.connection = ecore_x_display_get();
2386 einfo->info.screen = NULL;
2387 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
2388 einfo->info.drawable = ee->prop.window;
2391 /* FIXME: round trip */
2392 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
2393 xcb_get_geometry_cookie_t cookie_geom;
2394 xcb_get_window_attributes_cookie_t cookie_attr;
2395 xcb_get_geometry_reply_t *reply_geom;
2396 xcb_get_window_attributes_reply_t *reply_attr;
2398 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
2399 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
2401 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
2402 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
2403 if (reply_attr && reply_geom)
2405 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
2406 einfo->info.colormap = reply_attr->colormap;
2407 einfo->info.depth = reply_geom->depth;
2408 einfo->info.destination_alpha = 1;
2413 XWindowAttributes at;
2415 if (XGetWindowAttributes(ecore_x_display_get(), ee->prop.window,
2418 einfo->info.visual = at.visual;
2419 einfo->info.colormap = at.colormap;
2420 einfo->info.depth = at.depth;
2421 einfo->info.destination_alpha = 1;
2423 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
2427 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
2428 xcb_screen_t *screen;
2430 screen = ecore_x_default_screen_get();
2431 einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual);
2432 einfo->info.colormap = screen->default_colormap;
2433 einfo->info.depth = screen->root_depth;
2435 einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen);
2436 einfo->info.colormap = DefaultColormap(ecore_x_display_get(), screen);
2437 einfo->info.depth = DefaultDepth(ecore_x_display_get(), screen);
2438 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
2439 einfo->info.destination_alpha = 0;
2441 einfo->info.rotation = 0;
2442 einfo->info.debug = redraw_debug;
2443 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2445 ecore_x_icccm_hints_set(ee->prop.window,
2446 1 /* accepts_focus */,
2447 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2448 0 /* icon_pixmap */,
2450 0 /* icon_window */,
2451 0 /* window_group */,
2454 ee->engine.func->fn_render = _ecore_evas_x_render;
2455 _ecore_evas_register(ee);
2456 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
2461 ecore_evas_software_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
2462 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
2471 * FIXME: To be fixed.
2473 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2475 ecore_evas_software_x11_window_get(const Ecore_Evas *ee)
2477 return (Ecore_X_Window) ecore_evas_window_get(ee);
2481 ecore_evas_software_x11_window_get(const Ecore_Evas *ee __UNUSED__)
2490 * FIXME: To be fixed.
2492 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2494 ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, int on)
2496 ee->engine.x.direct_resize = on;
2497 if (ee->prop.avoid_damage)
2499 if (ee->engine.x.direct_resize)
2501 /* turn this off for now
2502 ee->engine.x.using_bg_pixmap = 1;
2503 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2508 /* turn this off too- bg pixmap is controlled by avoid damage directly
2509 ee->engine.x.using_bg_pixmap = 0;
2510 ecore_x_window_pixmap_set(ee->prop.window, 0);
2511 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2518 ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__)
2526 * FIXME: To be fixed.
2528 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2530 ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee)
2532 return ee->engine.x.direct_resize;
2536 ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
2545 * FIXME: To be fixed.
2547 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2549 ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
2551 Ecore_X_Window *winp;
2553 winp = malloc(sizeof(Ecore_X_Window));
2557 ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp);
2558 ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
2563 ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
2571 * FIXME: To be fixed.
2573 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2575 ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent,
2576 int x, int y, int w, int h)
2578 # ifdef HAVE_ECORE_X_XCB
2579 Ecore_Evas *ee = NULL;
2584 rmethod = evas_render_method_lookup("gl_x11");
2585 if (!rmethod) return NULL;
2586 if (!ecore_x_init(disp_name)) return NULL;
2587 ee = calloc(1, sizeof(Ecore_Evas));
2588 if (!ee) return NULL;
2590 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
2592 _ecore_evas_x_init();
2594 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
2596 ee->driver = "opengl_x11";
2597 if (disp_name) ee->name = strdup(disp_name);
2606 ee->prop.max.w = 32767;
2607 ee->prop.max.h = 32767;
2609 ee->prop.request_pos = 0;
2610 ee->prop.sticky = 0;
2611 ee->engine.x.state.sticky = 0;
2613 /* init evas here */
2614 ee->evas = evas_new();
2615 evas_data_attach_set(ee->evas, ee);
2616 evas_output_method_set(ee->evas, rmethod);
2617 evas_output_size_set(ee->evas, w, h);
2618 evas_output_viewport_set(ee->evas, 0, 0, w, h);
2620 if (parent == 0) parent = DefaultRootWindow(ecore_x_display_get());
2621 ee->engine.x.win_root = parent;
2623 ee->prop.window = _ecore_evas_x_gl_window_new(ee, ee->engine.x.win_root, x, y, w, h, 0);
2625 if (getenv("DESKTOP_STARTUP_ID"))
2627 ecore_x_netwm_startup_id_set(ee->prop.window,
2628 getenv("DESKTOP_STARTUP_ID"));
2629 /* NB: on linux this may simply empty the env as opposed to completely
2630 * unset it to being empty - unsure as solartis libc crashes looking
2631 * for the '=' char */
2632 // putenv((char*)"DESKTOP_STARTUP_ID=");
2635 ecore_x_icccm_hints_set(ee->prop.window,
2636 1 /* accepts_focus */,
2637 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2638 0 /* icon_pixmap */,
2640 0 /* icon_window */,
2641 0 /* window_group */,
2644 ee->engine.func->fn_render = _ecore_evas_x_render;
2645 _ecore_evas_register(ee);
2646 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
2647 # endif /* HAVE_ECORE_X_XCB */
2653 ecore_evas_gl_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
2654 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
2658 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
2663 * FIXME: To be fixed.
2665 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2667 ecore_evas_gl_x11_window_get(const Ecore_Evas *ee)
2669 return (Ecore_X_Window) ecore_evas_window_get(ee);
2673 ecore_evas_gl_x11_window_get(const Ecore_Evas *ee __UNUSED__)
2677 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
2682 * FIXME: To be fixed.
2684 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2686 ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, int on)
2688 ee->engine.x.direct_resize = on;
2692 ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__)
2695 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
2700 * FIXME: To be fixed.
2702 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2704 ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee)
2706 return ee->engine.x.direct_resize;
2710 ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
2714 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
2719 * FIXME: To be fixed.
2721 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2723 ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
2725 ecore_evas_software_x11_extra_event_window_add(ee, win);
2729 ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
2732 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
2737 * FIXME: To be fixed.
2739 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2741 ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent,
2742 int x, int y, int w, int h)
2744 Evas_Engine_Info_XRender_X11 *einfo;
2748 rmethod = evas_render_method_lookup("xrender_x11");
2749 if (!rmethod) return NULL;
2750 if (!ecore_x_init(disp_name)) return NULL;
2751 ee = calloc(1, sizeof(Ecore_Evas));
2752 if (!ee) return NULL;
2754 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
2756 _ecore_evas_x_init();
2758 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
2760 ee->driver = "xrender_x11";
2761 if (disp_name) ee->name = strdup(disp_name);
2770 ee->prop.max.w = 32767;
2771 ee->prop.max.h = 32767;
2773 ee->prop.request_pos = 0;
2774 ee->prop.sticky = 0;
2775 ee->engine.x.state.sticky = 0;
2777 /* init evas here */
2778 ee->evas = evas_new();
2779 evas_data_attach_set(ee->evas, ee);
2780 evas_output_method_set(ee->evas, rmethod);
2781 evas_output_size_set(ee->evas, w, h);
2782 evas_output_viewport_set(ee->evas, 0, 0, w, h);
2784 ee->engine.x.win_root = parent;
2785 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
2786 if (getenv("DESKTOP_STARTUP_ID"))
2788 ecore_x_netwm_startup_id_set(ee->prop.window,
2789 getenv("DESKTOP_STARTUP_ID"));
2790 /* NB: on linux this may simply empty the env as opposed to completely
2791 * unset it to being empty - unsure as solartis libc crashes looking
2792 * for the '=' char */
2793 // putenv((char*)"DESKTOP_STARTUP_ID=");
2795 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
2798 # ifdef BUILD_ECORE_EVAS_XRENDER_XCB
2799 xcb_screen_iterator_t iter;
2800 xcb_screen_t *screen;
2802 /* FIXME: this is inefficient as its a round trip */
2803 screen = ecore_x_default_screen_get();
2804 iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get()));
2807 xcb_get_geometry_cookie_t cookie;
2808 xcb_get_geometry_reply_t *reply;
2809 Ecore_X_Window *roots;
2814 cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent);
2815 roots = ecore_x_window_root_list(&num);
2818 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
2822 for (i = 0; i < num; xcb_screen_next (&iter), i++)
2824 if (reply->root == roots[i])
2836 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
2837 if (reply) free(reply);
2840 einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XCB;
2841 einfo->info.connection = ecore_x_connection_get();
2842 einfo->info.screen = screen;
2843 einfo->info.visual = screen->root_visual;
2844 # elif BUILD_ECORE_EVAS_XRENDER_X11
2847 /* FIXME: this is inefficient as its a round trip */
2848 screen = DefaultScreen(ecore_x_display_get());
2849 if (ScreenCount(ecore_x_display_get()) > 1)
2851 Ecore_X_Window *roots;
2855 roots = ecore_x_window_root_list(&num);
2858 XWindowAttributes at;
2860 if (XGetWindowAttributes(ecore_x_display_get(),
2863 for (i = 0; i < num; i++)
2865 if (at.root == roots[i])
2875 einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XLIB;
2876 einfo->info.connection = ecore_x_display_get();
2877 einfo->info.screen = NULL;
2878 einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen);
2879 # endif /* BUILD_ECORE_EVAS_XRENDER_(XCB|X11) */
2880 einfo->info.drawable = ee->prop.window;
2881 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2884 ecore_x_icccm_hints_set(ee->prop.window,
2885 1 /* accepts_focus */,
2886 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2887 0 /* icon_pixmap */,
2889 0 /* icon_window */,
2890 0 /* window_group */,
2893 ee->engine.func->fn_render = _ecore_evas_x_render;
2894 _ecore_evas_register(ee);
2895 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
2900 ecore_evas_xrender_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
2901 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
2905 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
2910 * FIXME: To be fixed.
2912 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2914 ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee)
2916 return (Ecore_X_Window) ecore_evas_window_get(ee);
2920 ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee __UNUSED__)
2924 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
2929 * FIXME: To be fixed.
2931 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2933 ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, int on)
2935 ee->engine.x.direct_resize = on;
2939 ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__)
2942 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
2947 * FIXME: To be fixed.
2949 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2951 ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee)
2953 return ee->engine.x.direct_resize;
2957 ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
2961 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
2966 * FIXME: To be fixed.
2968 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2970 ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
2972 ecore_evas_software_x11_extra_event_window_add(ee, win);
2976 ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
2979 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
2984 * FIXME: To be fixed.
2986 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
2988 ecore_evas_software_x11_16_new(const char *disp_name, Ecore_X_Window parent,
2989 int x, int y, int w, int h)
2991 Evas_Engine_Info_Software_16_X11 *einfo;
2994 static int redraw_debug = -1;
2996 rmethod = evas_render_method_lookup("software_16_x11");
2997 if (!rmethod) return NULL;
2998 if (!ecore_x_init(disp_name)) return NULL;
2999 ee = calloc(1, sizeof(Ecore_Evas));
3000 if (!ee) return NULL;
3002 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
3004 _ecore_evas_x_init();
3006 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
3008 ee->driver = "software_16_x11";
3009 if (disp_name) ee->name = strdup(disp_name);
3018 ee->prop.max.w = 32767;
3019 ee->prop.max.h = 32767;
3021 ee->prop.request_pos = 0;
3022 ee->prop.sticky = 0;
3023 ee->engine.x.state.sticky = 0;
3025 /* init evas here */
3026 ee->evas = evas_new();
3027 evas_data_attach_set(ee->evas, ee);
3028 evas_output_method_set(ee->evas, rmethod);
3029 evas_output_size_set(ee->evas, w, h);
3030 evas_output_viewport_set(ee->evas, 0, 0, w, h);
3032 ee->engine.x.win_root = parent;
3035 /* FIXME: round trip in ecore_x_window_argb_get */
3036 if (ecore_x_window_argb_get(parent))
3038 ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h);
3041 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
3044 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
3045 if (getenv("DESKTOP_STARTUP_ID"))
3047 ecore_x_netwm_startup_id_set(ee->prop.window,
3048 getenv("DESKTOP_STARTUP_ID"));
3049 /* NB: on linux this may simply empty the env as opposed to completely
3050 * unset it to being empty - unsure as solartis libc crashes looking
3051 * for the '=' char */
3052 // putenv((char*)"DESKTOP_STARTUP_ID=");
3054 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
3058 if (ScreenCount(ecore_x_display_get()) > 1)
3060 Ecore_X_Window *roots;
3064 roots = ecore_x_window_root_list(&num);
3067 XWindowAttributes at;
3069 if (XGetWindowAttributes(ecore_x_display_get(),
3072 for (i = 0; i < num; i++)
3074 if (at.root == roots[i])
3082 if (redraw_debug < 0)
3084 if (getenv("REDRAW_DEBUG"))
3085 redraw_debug = atoi(getenv("REDRAW_DEBUG"));
3089 einfo->info.display = ecore_x_display_get();
3090 einfo->info.drawable = ee->prop.window;
3092 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
3095 ecore_x_icccm_hints_set(ee->prop.window,
3096 1 /* accepts_focus */,
3097 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
3098 0 /* icon_pixmap */,
3100 0 /* icon_window */,
3101 0 /* window_group */,
3104 ee->engine.func->fn_render = _ecore_evas_x_render;
3105 _ecore_evas_register(ee);
3106 ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
3111 ecore_evas_software_x11_16_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
3112 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
3116 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
3121 * FIXME: To be fixed.
3123 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
3125 ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee)
3127 return (Ecore_X_Window) ecore_evas_window_get(ee);
3131 ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee __UNUSED__)
3135 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
3140 * FIXME: To be fixed.
3142 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
3144 ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, int on)
3146 ee->engine.x.direct_resize = on;
3147 if (ee->prop.avoid_damage)
3149 if (ee->engine.x.direct_resize)
3151 /* turn this off for now
3152 ee->engine.x.using_bg_pixmap = 1;
3153 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
3158 /* turn this off too- bg pixmap is controlled by avoid damage directly
3159 ee->engine.x.using_bg_pixmap = 0;
3160 ecore_x_window_pixmap_set(ee->prop.window, 0);
3161 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
3168 ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__)
3171 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
3176 * FIXME: To be fixed.
3178 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
3180 ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee)
3182 return ee->engine.x.direct_resize;
3186 ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
3190 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
3195 * FIXME: To be fixed.
3197 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
3199 ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
3201 Ecore_X_Window *winp;
3203 winp = malloc(sizeof(Ecore_X_Window));
3207 ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp);
3208 ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process);
3213 ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
3216 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */