8 #include <Ecore_Input.h>
9 #include <Ecore_Input_Evas.h>
10 #ifdef BUILD_ECORE_EVAS_X11
12 # include <Ecore_X_Atoms.h>
14 # undef BUILD_ECORE_EVAS_OPENGL_X11
15 # undef BUILD_ECORE_EVAS_SOFTWARE_X11
16 # undef BUILD_ECORE_EVAS_XRENDER_X11
19 #ifndef HAVE_ECORE_X_XCB
20 # undef BUILD_ECORE_EVAS_XRENDER_XCB
21 # undef BUILD_ECORE_EVAS_SOFTWARE_XCB
24 #include "ecore_evas_private.h"
25 #include "Ecore_Evas.h"
27 #ifdef BUILD_ECORE_EVAS_X11
28 static int _ecore_evas_init_count = 0;
30 static Ecore_Event_Handler *ecore_evas_event_handlers[13];
32 static int leader_ref = 0;
33 static Ecore_X_Window leader_win = 0;
36 _ecore_evas_x_group_leader_set(Ecore_Evas *ee)
41 leader_win = ecore_x_window_override_new(ee->engine.x.win_root, 1234, 5678, 1, 2);
42 ecore_x_window_defaults_set(leader_win);
43 if (getenv("DESKTOP_STARTUP_ID"))
44 ecore_x_netwm_startup_id_set(leader_win,
45 getenv("DESKTOP_STARTUP_ID"));
46 ecore_x_icccm_client_leader_set(leader_win, leader_win);
48 ee->engine.x.leader = leader_win;
49 ecore_x_icccm_client_leader_set(ee->prop.window, leader_win);
53 _ecore_evas_x_group_leader_unset(Ecore_Evas *ee)
55 ecore_x_window_prop_property_del(ee->prop.window, ECORE_X_ATOM_WM_CLIENT_LEADER);
56 if (ee->engine.x.leader == leader_win)
61 ecore_x_window_free(leader_win);
64 ee->engine.x.leader = 0;
69 _ecore_evas_x_group_leader_update(Ecore_Evas *ee)
71 if (ee->engine.x.leader)
72 ecore_x_icccm_client_leader_set(ee->prop.window, ee->engine.x.leader);
76 _ecore_evas_x_protocols_set(Ecore_Evas *ee)
78 Ecore_X_Atom protos[10];
81 if (ee->func.fn_delete_request)
82 protos[num++] = ECORE_X_ATOM_WM_DELETE_WINDOW;
83 protos[num++] = ECORE_X_ATOM_NET_WM_PING;
84 protos[num++] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
85 ecore_x_icccm_protocol_atoms_set(ee->prop.window, protos, num);
87 if (!ee->engine.x.netwm_sync_counter)
88 ee->engine.x.netwm_sync_counter = ecore_x_sync_counter_new(0);
91 unsigned int tmp = ee->engine.x.netwm_sync_counter;
92 ecore_x_window_prop_card32_set(ee->prop.window,
93 ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER,
99 _ecore_evas_x_sync_set(Ecore_Evas *ee)
101 if (((ee->should_be_visible) || (ee->visible)) &&
102 ((ecore_x_e_comp_sync_supported_get(ee->engine.x.win_root)) &&
103 (!ee->no_comp_sync) && (_ecore_evas_app_comp_sync)))
105 if (!ee->engine.x.sync_counter)
106 ee->engine.x.sync_counter = ecore_x_sync_counter_new(0);
110 if (ee->engine.x.sync_counter)
111 ecore_x_sync_counter_free(ee->engine.x.sync_counter);
112 ee->engine.x.sync_counter = 0;
114 ecore_x_e_comp_sync_counter_set(ee->prop.window, ee->engine.x.sync_counter);
118 _ecore_evas_x_sync_clear(Ecore_Evas *ee)
120 if (!ee->engine.x.sync_counter) return;
121 ecore_x_sync_counter_free(ee->engine.x.sync_counter);
122 ee->engine.x.sync_counter = 0;
125 #ifdef HAVE_ECORE_X_XCB
126 static xcb_visualtype_t *
127 xcb_visualtype_get(xcb_screen_t *screen, xcb_visualid_t visual)
129 xcb_depth_iterator_t iter_depth;
131 if (!screen) return NULL;
133 iter_depth = xcb_screen_allowed_depths_iterator(screen);
134 for (; iter_depth.rem; xcb_depth_next (&iter_depth))
136 xcb_visualtype_iterator_t iter_vis;
138 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
139 for (; iter_vis.rem; --screen, xcb_visualtype_next (&iter_vis))
141 if (visual == iter_vis.data->visual_id)
142 return iter_vis.data;
148 #endif /* HAVE_ECORE_X_XCB */
150 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
151 # ifdef HAVE_ECORE_X_XCB
154 static Ecore_X_Window
155 _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, int w, int h, int override, int argb, const int *opt)
157 Evas_Engine_Info_GL_X11 *einfo;
160 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
163 XSetWindowAttributes attr;
170 for (op = 0; opt[op]; op++)
172 if (opt[op] == ECORE_EVAS_GL_X11_OPT_INDIRECT)
175 einfo->indirect = opt[op];
177 else if (opt[op] == ECORE_EVAS_GL_X11_OPT_VSYNC)
180 einfo->vsync = opt[op];
185 /* FIXME: this is inefficient as its 1 or more round trips */
186 screen = DefaultScreen(ecore_x_display_get());
187 if (ScreenCount(ecore_x_display_get()) > 1)
189 Ecore_X_Window *roots;
193 roots = ecore_x_window_root_list(&num);
196 XWindowAttributes at;
198 if (XGetWindowAttributes(ecore_x_display_get(),
201 for (i = 0; i < num; i++)
203 if (at.root == roots[i])
213 einfo->info.display = ecore_x_display_get();
214 einfo->info.screen = screen;
216 einfo->info.destination_alpha = argb;
218 einfo->info.visual = einfo->func.best_visual_get(einfo);
219 einfo->info.colormap = einfo->func.best_colormap_get(einfo);
220 einfo->info.depth = einfo->func.best_depth_get(einfo);
223 if ((!einfo->info.visual) ||
224 (!einfo->info.colormap) ||
225 (!einfo->info.depth))
227 WRN("OpenGL X11 init engine '%s' failed - no visual, colormap or depth.", ee->driver);
228 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
230 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
235 attr.backing_store = NotUseful;
236 attr.override_redirect = override;
237 attr.colormap = einfo->info.colormap;
238 attr.border_pixel = 0;
239 attr.background_pixmap = None;
241 KeyPressMask | KeyReleaseMask |
242 ExposureMask | ButtonPressMask | ButtonReleaseMask |
243 EnterWindowMask | LeaveWindowMask |
244 PointerMotionMask | StructureNotifyMask | VisibilityChangeMask |
245 FocusChangeMask | PropertyChangeMask | ColormapChangeMask;
246 attr.bit_gravity = ForgetGravity;
249 XCreateWindow(einfo->info.display, parent, x, y, w, h, 0,
250 einfo->info.depth, InputOutput, einfo->info.visual,
251 CWBackingStore | CWColormap | CWBackPixmap |
252 CWBorderPixel | CWBitGravity | CWEventMask |
253 CWOverrideRedirect, &attr);
254 einfo->info.drawable = win;
256 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
258 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
259 XDestroyWindow(einfo->info.display, win);
269 #endif /* HAVE_ECORE_X_XCB */
273 _ecore_evas_x_render(Ecore_Evas *ee)
276 Eina_List *updates, *l;
278 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
282 if ((!ee->no_comp_sync) && (_ecore_evas_app_comp_sync) &&
283 (ee->engine.x.sync_counter) && (!ee->engine.x.sync_began) &&
284 (!ee->engine.x.sync_cancel))
287 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
289 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
290 rend |= _ecore_evas_buffer_render(ee2);
291 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
294 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
295 if (ee->prop.avoid_damage)
297 updates = evas_render_updates(ee->evas);
298 if (ee->engine.x.using_bg_pixmap)
302 EINA_LIST_FOREACH(updates, l, r)
303 ecore_x_window_area_clear(ee->prop.window, r->x, r->y, r->w, r->h);
304 if ((ee->shaped) && (updates))
306 #ifdef EVAS_FRAME_QUEUING
307 /* wait until ee->engine.x.mask being updated */
310 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
312 if ((ee->alpha) && (updates))
314 #ifdef EVAS_FRAME_QUEUING
315 /* wait until ee->engine.x.mask being updated */
316 // evas_sync(ee->evas);
318 // ecore_x_window_shape_input_mask_set(ee->prop.window, ee->engine.x.mask);
320 evas_render_updates_free(updates);
321 _ecore_evas_idle_timeout_update(ee);
327 EINA_LIST_FOREACH(updates, l, r)
329 Ecore_X_Rectangle rect;
330 Ecore_X_XRegion *tmpr;
332 if (!ee->engine.x.damages)
333 ee->engine.x.damages = ecore_x_xregion_new();
334 tmpr = ecore_x_xregion_new();
335 if (ee->rotation == 0)
342 else if (ee->rotation == 90)
345 rect.y = ee->h - r->x - r->w;
349 else if (ee->rotation == 180)
351 rect.x = ee->w - r->x - r->w;
352 rect.y = ee->h - r->y - r->h;
356 else if (ee->rotation == 270)
358 rect.x = ee->w - r->y - r->h;
363 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
364 ecore_x_xregion_free(ee->engine.x.damages);
365 ee->engine.x.damages = tmpr;
367 if (ee->engine.x.damages)
369 /* if we have a damage pixmap - we can avoid exposures by
370 * disabling them just for setting the mask */
371 ecore_x_event_mask_set(ee->prop.window,
372 ECORE_X_EVENT_MASK_KEY_DOWN |
373 ECORE_X_EVENT_MASK_KEY_UP |
374 ECORE_X_EVENT_MASK_MOUSE_DOWN |
375 ECORE_X_EVENT_MASK_MOUSE_UP |
376 ECORE_X_EVENT_MASK_MOUSE_IN |
377 ECORE_X_EVENT_MASK_MOUSE_OUT |
378 ECORE_X_EVENT_MASK_MOUSE_MOVE |
379 // ECORE_X_EVENT_MASK_WINDOW_DAMAGE |
380 ECORE_X_EVENT_MASK_WINDOW_VISIBILITY |
381 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE |
382 ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE |
383 ECORE_X_EVENT_MASK_WINDOW_PROPERTY |
384 ECORE_X_EVENT_MASK_WINDOW_COLORMAP
386 if ((ee->shaped) && (updates))
387 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
388 /* and re-enable them again */
389 ecore_x_event_mask_set(ee->prop.window,
390 ECORE_X_EVENT_MASK_KEY_DOWN |
391 ECORE_X_EVENT_MASK_KEY_UP |
392 ECORE_X_EVENT_MASK_MOUSE_DOWN |
393 ECORE_X_EVENT_MASK_MOUSE_UP |
394 ECORE_X_EVENT_MASK_MOUSE_IN |
395 ECORE_X_EVENT_MASK_MOUSE_OUT |
396 ECORE_X_EVENT_MASK_MOUSE_MOVE |
397 ECORE_X_EVENT_MASK_WINDOW_DAMAGE |
398 ECORE_X_EVENT_MASK_WINDOW_VISIBILITY |
399 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE |
400 ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE |
401 ECORE_X_EVENT_MASK_WINDOW_PROPERTY |
402 ECORE_X_EVENT_MASK_WINDOW_COLORMAP
404 ecore_x_xregion_set(ee->engine.x.damages, ee->engine.x.gc);
405 /* debug rendering */
407 XSetForeground(ecore_x_display_get(), ee->engine.x.gc, rand());
408 XFillRectangle(ecore_x_display_get(), ee->prop.window, ee->engine.x.gc,
410 XSync(ecore_x_display_get(), False);
412 XSync(ecore_x_display_get(), False);
414 ecore_x_pixmap_paste(ee->engine.x.pmap, ee->prop.window, ee->engine.x.gc,
415 0, 0, ee->w, ee->h, 0, 0);
416 ecore_x_xregion_free(ee->engine.x.damages);
417 ee->engine.x.damages = NULL;
421 evas_render_updates_free(updates);
422 _ecore_evas_idle_timeout_update(ee);
427 else if (((ee->visible) && (ee->draw_ok)) ||
428 ((ee->should_be_visible) && (ee->prop.fullscreen)) ||
429 ((ee->should_be_visible) && (ee->prop.override)))
431 updates = evas_render_updates(ee->evas);
436 #ifdef EVAS_FRAME_QUEUING
437 /* wait until ee->engine.x.mask being updated */
440 ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask);
444 #ifdef EVAS_FRAME_QUEUING
445 /* wait until ee->engine.x.mask being updated */
446 // evas_sync(ee->evas);
448 // ecore_x_window_shape_input_mask_set(ee->prop.window, ee->engine.x.mask);
450 evas_render_updates_free(updates);
451 _ecore_evas_idle_timeout_update(ee);
456 evas_norender(ee->evas);
457 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
461 static int frames = 0;
462 static double t0 = 0.0;
465 t = ecore_time_get();
470 printf("FPS: %3.3f\n", (double)frames / td);
480 _ecore_evas_x_resize_shape(Ecore_Evas *ee)
482 if (!strcmp(ee->driver, "software_x11"))
484 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
485 Evas_Engine_Info_Software_X11 *einfo;
487 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
490 unsigned int foreground;
493 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
494 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
496 gc = ecore_x_gc_new(ee->engine.x.mask,
497 ECORE_X_GC_VALUE_MASK_FOREGROUND,
499 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
502 einfo->info.mask = ee->engine.x.mask;
503 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
505 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
507 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
509 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
511 else if (!strcmp(ee->driver, "xrender_x11"))
513 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
514 Evas_Engine_Info_XRender_X11 *einfo;
516 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
519 unsigned int foreground;
522 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
523 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
525 gc = ecore_x_gc_new(ee->engine.x.mask,
526 ECORE_X_GC_VALUE_MASK_FOREGROUND,
528 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
531 einfo->info.mask = ee->engine.x.mask;
532 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
534 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
536 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
539 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
541 else if (!strcmp(ee->driver, "software_16_x11"))
543 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
544 # if 0 /* XXX no shaped window support for software_16_x11 */
545 Evas_Engine_Info_Software_16_X11 *einfo;
547 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
550 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
551 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
552 einfo->info.mask = ee->engine.x.mask;
553 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
555 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
557 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
559 # endif /* XXX no shaped window support for software_16_x11 */
560 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
562 if (!strcmp(ee->driver, "software_8_x11"))
564 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
565 Evas_Engine_Info_Software_8_X11 *einfo;
567 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
570 unsigned int foreground;
573 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
574 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
576 gc = ecore_x_gc_new(ee->engine.x.mask,
577 ECORE_X_GC_VALUE_MASK_FOREGROUND,
579 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
582 einfo->info.mask = ee->engine.x.mask;
583 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
585 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
587 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
589 #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
593 /* TODO: we need to make this work for all the states, not just sticky */
595 _ecore_evas_x_event_property_change(void *data __UNUSED__, int type __UNUSED__, void *event)
598 Ecore_X_Event_Window_Property *e;
601 ee = ecore_event_window_match(e->win);
602 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; /* pass on event */
603 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
604 if (e->atom == ECORE_X_ATOM_NET_WM_STATE)
607 Ecore_X_Window_State *state;
610 #ifdef HAVE_ECORE_X_XCB
611 ecore_x_netwm_window_state_get_prefetch(e->win);
612 #endif /* HAVE_ECORE_X_XCB */
615 /* TODO: we need to move those to the end, with if statements */
616 ee->engine.x.state.modal = 0;
617 ee->engine.x.state.maximized_v = 0;
618 ee->engine.x.state.maximized_h = 0;
619 ee->engine.x.state.shaded = 0;
620 ee->engine.x.state.skip_taskbar = 0;
621 ee->engine.x.state.skip_pager = 0;
622 ee->prop.fullscreen = 0;
623 ee->engine.x.state.fullscreen = 0;
624 ee->engine.x.state.above = 0;
625 ee->engine.x.state.below = 0;
627 #ifdef HAVE_ECORE_X_XCB
628 ecore_x_netwm_window_state_get_fetch();
629 #endif /* HAVE_ECORE_X_XCB */
630 ecore_x_netwm_window_state_get(e->win, &state, &num);
633 for (i = 0; i < num; i++)
637 case ECORE_X_WINDOW_STATE_MODAL:
638 ee->engine.x.state.modal = 1;
640 case ECORE_X_WINDOW_STATE_STICKY:
641 if (ee->prop.sticky && ee->engine.x.state.sticky)
646 ee->engine.x.state.sticky = 1;
647 if (ee->func.fn_sticky) ee->func.fn_sticky(ee);
649 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
650 ee->engine.x.state.maximized_v = 1;
652 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
653 ee->engine.x.state.maximized_h = 1;
655 case ECORE_X_WINDOW_STATE_SHADED:
656 ee->engine.x.state.shaded = 1;
658 case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
659 ee->engine.x.state.skip_taskbar = 1;
661 case ECORE_X_WINDOW_STATE_SKIP_PAGER:
662 ee->engine.x.state.skip_pager = 1;
664 case ECORE_X_WINDOW_STATE_FULLSCREEN:
665 ee->prop.fullscreen = 1;
666 ee->engine.x.state.fullscreen = 1;
668 case ECORE_X_WINDOW_STATE_ABOVE:
669 ee->engine.x.state.above = 1;
671 case ECORE_X_WINDOW_STATE_BELOW:
672 ee->engine.x.state.below = 1;
680 #ifdef HAVE_ECORE_X_XCB
681 ecore_xcb_reply_free();
682 #endif /* HAVE_ECORE_X_XCB */
684 if (ee->prop.sticky && !sticky)
687 ee->engine.x.state.sticky = 0;
688 if (ee->func.fn_unsticky) ee->func.fn_unsticky(ee);
692 return ECORE_CALLBACK_PASS_ON;
696 _ecore_evas_x_event_visibility_change(void *data __UNUSED__, int type __UNUSED__, void *event)
699 Ecore_X_Event_Window_Visibility_Change *e;
702 ee = ecore_event_window_match(e->win);
703 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
704 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
705 // printf("VIS CHANGE OBSCURED: %p %i\n", ee, e->fully_obscured);
706 if (e->fully_obscured)
708 /* FIXME: round trip */
709 if (!ecore_x_screen_is_composited(ee->engine.x.screen_num))
712 else ee->draw_ok = 1;
713 return ECORE_CALLBACK_PASS_ON;
717 _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, void *event)
720 Ecore_X_Event_Client_Message *e;
723 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
724 if (e->message_type == ECORE_X_ATOM_E_COMP_SYNC_BEGIN)
726 ee = ecore_event_window_match(e->data.l[0]);
727 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
728 if (e->data.l[0] != (long)ee->prop.window) return ECORE_CALLBACK_PASS_ON;
729 if (!ee->engine.x.sync_began)
731 // qeue a damage + draw. work around an event re-ordering thing.
732 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
734 ee->engine.x.sync_began = 1;
735 ee->engine.x.sync_cancel = 0;
737 else if (e->message_type == ECORE_X_ATOM_E_COMP_SYNC_END)
739 ee = ecore_event_window_match(e->data.l[0]);
740 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
741 if (e->data.l[0] != (long)ee->prop.window) return ECORE_CALLBACK_PASS_ON;
742 ee->engine.x.sync_began = 0;
743 ee->engine.x.sync_cancel = 0;
745 else if (e->message_type == ECORE_X_ATOM_E_COMP_SYNC_CANCEL)
747 ee = ecore_event_window_match(e->data.l[0]);
748 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
749 if (e->data.l[0] != (long)ee->prop.window) return ECORE_CALLBACK_PASS_ON;
750 ee->engine.x.sync_began = 0;
751 ee->engine.x.sync_cancel = 1;
753 else if ((e->message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
754 (e->data.l[0] == (int)ECORE_X_ATOM_NET_WM_SYNC_REQUEST))
756 ee = ecore_event_window_match(e->win);
757 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
758 ee->engine.x.netwm_sync_val_lo = (unsigned int)e->data.l[2];
759 ee->engine.x.netwm_sync_val_hi = (int)e->data.l[3];
760 ee->engine.x.netwm_sync_set = 1;
762 return ECORE_CALLBACK_PASS_ON;
766 _ecore_evas_x_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
769 Ecore_X_Event_Mouse_In *e;
772 ee = ecore_event_window_match(e->win);
773 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; /* pass on event */
774 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
779 /* const char *modes[] = { */
781 /* "MODE_WHILE_GRABBED", */
785 /* const char *details[] = { */
786 /* "DETAIL_ANCESTOR", */
787 /* "DETAIL_VIRTUAL", */
788 /* "DETAIL_INFERIOR", */
789 /* "DETAIL_NON_LINEAR", */
790 /* "DETAIL_NON_LINEAR_VIRTUAL", */
791 /* "DETAIL_POINTER", */
792 /* "DETAIL_POINTER_ROOT", */
793 /* "DETAIL_DETAIL_NONE" */
795 /* t = time(NULL); */
796 /* ct = ctime(&t); */
797 /* ct[strlen(ct) - 1] = 0; */
798 /* printf("@@ ->IN 0x%x 0x%x %s md=%s dt=%s\n", */
799 /* e->win, e->event_win, */
801 /* modes[e->mode], */
802 /* details[e->detail]); */
804 // disable. causes more problems than it fixes
805 // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) ||
806 // (e->mode == ECORE_X_EVENT_MODE_UNGRAB))
808 /* if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0; */
809 if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
810 ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
811 evas_event_feed_mouse_in(ee->evas, e->time, NULL);
812 _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
813 return ECORE_CALLBACK_PASS_ON;
817 _ecore_evas_x_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
820 Ecore_X_Event_Mouse_Out *e;
823 ee = ecore_event_window_match(e->win);
824 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
826 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
831 /* const char *modes[] = { */
833 /* "MODE_WHILE_GRABBED", */
837 /* const char *details[] = { */
838 /* "DETAIL_ANCESTOR", */
839 /* "DETAIL_VIRTUAL", */
840 /* "DETAIL_INFERIOR", */
841 /* "DETAIL_NON_LINEAR", */
842 /* "DETAIL_NON_LINEAR_VIRTUAL", */
843 /* "DETAIL_POINTER", */
844 /* "DETAIL_POINTER_ROOT", */
845 /* "DETAIL_DETAIL_NONE" */
847 /* t = time(NULL); */
848 /* ct = ctime(&t); */
849 /* ct[strlen(ct) - 1] = 0; */
850 /* printf("@@ ->OUT 0x%x 0x%x %s md=%s dt=%s\n", */
851 /* e->win, e->event_win, */
853 /* modes[e->mode], */
854 /* details[e->detail]); */
856 // disable. causes more problems than it fixes
857 // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) ||
858 // (e->mode == ECORE_X_EVENT_MODE_UNGRAB))
860 /* if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0; */
861 ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
862 _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
863 if (e->mode == ECORE_X_EVENT_MODE_GRAB)
864 evas_event_feed_mouse_cancel(ee->evas, e->time, NULL);
865 evas_event_feed_mouse_out(ee->evas, e->time, NULL);
866 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
867 if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
868 return ECORE_CALLBACK_PASS_ON;
872 _ecore_evas_x_event_window_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
875 Ecore_X_Event_Window_Focus_In *e;
878 ee = ecore_event_window_match(e->win);
879 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; /* pass on event */
880 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
881 if (e->mode == ECORE_X_EVENT_MODE_UNGRAB) return ECORE_CALLBACK_PASS_ON;
882 ee->prop.focused = 1;
883 evas_focus_in(ee->evas);
884 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
885 return ECORE_CALLBACK_PASS_ON;
889 _ecore_evas_x_event_window_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
892 Ecore_X_Event_Window_Focus_Out *e;
895 ee = ecore_event_window_match(e->win);
896 if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; /* pass on event */
897 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
898 if (e->mode == ECORE_X_EVENT_MODE_GRAB) return ECORE_CALLBACK_PASS_ON;
899 // if (ee->prop.fullscreen)
900 // ecore_x_window_focus(ee->prop.window);
901 evas_focus_out(ee->evas);
902 ee->prop.focused = 0;
903 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
904 return ECORE_CALLBACK_PASS_ON;
908 _ecore_evas_x_event_window_damage(void *data __UNUSED__, int type __UNUSED__, void *event)
911 Ecore_X_Event_Window_Damage *e;
914 ee = ecore_event_window_match(e->win);
915 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
916 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
917 if (ee->engine.x.using_bg_pixmap) return ECORE_CALLBACK_PASS_ON;
918 // printf("EXPOSE %p [%i] %i %i %ix%i\n", ee, ee->prop.avoid_damage, e->x, e->y, e->w, e->h);
919 if (ee->prop.avoid_damage)
921 Ecore_X_Rectangle rect;
922 Ecore_X_XRegion *tmpr;
924 if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new();
925 tmpr = ecore_x_xregion_new();
930 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
931 ecore_x_xregion_free(ee->engine.x.damages);
932 ee->engine.x.damages = tmpr;
933 /* no - this breaks things badly. disable. Ecore_X_Rectangle != XRectangle - see
934 * the typedefs in x's headers and ecore_x's. also same with Region - it's a pointer in x - not an X ID
935 Ecore_X_Rectangle rect;
936 Ecore_X_XRegion *tmpr;
938 if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new();
939 tmpr = ecore_x_xregion_new();
944 ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect);
945 ecore_x_xregion_free(ee->engine.x.damages);
946 ee->engine.x.damages = tmpr;
951 if (ee->rotation == 0)
952 evas_damage_rectangle_add(ee->evas,
956 else if (ee->rotation == 90)
957 evas_damage_rectangle_add(ee->evas,
961 else if (ee->rotation == 180)
962 evas_damage_rectangle_add(ee->evas,
966 else if (ee->rotation == 270)
967 evas_damage_rectangle_add(ee->evas,
972 return ECORE_CALLBACK_PASS_ON;
976 _ecore_evas_x_event_window_destroy(void *data __UNUSED__, int type __UNUSED__, void *event)
979 Ecore_X_Event_Window_Destroy *e;
982 ee = ecore_event_window_match(e->win);
983 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
984 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
985 if (ee->func.fn_destroy) ee->func.fn_destroy(ee);
986 _ecore_evas_x_sync_clear(ee);
988 return ECORE_CALLBACK_PASS_ON;
992 _ecore_evas_x_event_window_configure(void *data __UNUSED__, int type __UNUSED__, void *event)
995 Ecore_X_Event_Window_Configure *e;
998 ee = ecore_event_window_match(e->win);
999 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
1000 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1001 if (ee->engine.x.direct_resize) return ECORE_CALLBACK_PASS_ON;
1003 if ((e->from_wm) || (ee->prop.override))
1005 if ((ee->x != e->x) || (ee->y != e->y))
1011 if (ee->func.fn_move) ee->func.fn_move(ee);
1014 if ((ee->w != e->w) || (ee->h != e->h))
1020 if ((ee->rotation == 90) || (ee->rotation == 270))
1022 evas_output_size_set(ee->evas, ee->h, ee->w);
1023 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1027 evas_output_size_set(ee->evas, ee->w, ee->h);
1028 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1030 if (ee->prop.avoid_damage)
1034 pdam = ecore_evas_avoid_damage_get(ee);
1035 ecore_evas_avoid_damage_set(ee, 0);
1036 ecore_evas_avoid_damage_set(ee, pdam);
1038 if ((ee->shaped) || (ee->alpha))
1039 _ecore_evas_x_resize_shape(ee);
1040 if ((ee->expecting_resize.w > 0) &&
1041 (ee->expecting_resize.h > 0))
1043 if ((ee->expecting_resize.w == ee->w) &&
1044 (ee->expecting_resize.h == ee->h))
1045 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
1046 ecore_x_current_time_get());
1047 ee->expecting_resize.w = 0;
1048 ee->expecting_resize.h = 0;
1050 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1052 return ECORE_CALLBACK_PASS_ON;
1056 _ecore_evas_x_event_window_delete_request(void *data __UNUSED__, int type __UNUSED__, void *event)
1059 Ecore_X_Event_Window_Delete_Request *e;
1062 ee = ecore_event_window_match(e->win);
1063 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
1064 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1065 if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee);
1066 return ECORE_CALLBACK_PASS_ON;
1070 _ecore_evas_x_event_window_show(void *data __UNUSED__, int type __UNUSED__, void *event)
1073 Ecore_X_Event_Window_Show *e;
1074 static int first_map_bug = -1;
1077 ee = ecore_event_window_match(e->win);
1078 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
1079 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1080 if (first_map_bug < 0)
1082 if (getenv("ECORE_EVAS_GL_FIRST_MAP_BUG"))
1083 first_map_bug = atoi(getenv("ECORE_EVAS_GL_FIRST_MAP_BUG"));
1087 if ((first_map_bug) &&
1088 (!strcmp(ee->driver, "opengl_x11")))
1089 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1090 if (ee->visible) return ECORE_CALLBACK_DONE;
1091 // printf("SHOW EVENT %p\n", ee);
1093 if (ee->func.fn_show) ee->func.fn_show(ee);
1094 return ECORE_CALLBACK_PASS_ON;
1098 _ecore_evas_x_event_window_hide(void *data __UNUSED__, int type __UNUSED__, void *event)
1101 Ecore_X_Event_Window_Hide *e;
1104 ee = ecore_event_window_match(e->win);
1105 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
1106 if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
1107 if (!ee->visible) return ECORE_CALLBACK_DONE;
1108 // printf("HIDE EVENT %p\n", ee);
1110 if (ee->func.fn_hide) ee->func.fn_hide(ee);
1111 return ECORE_CALLBACK_PASS_ON;
1114 /* FIXME, should be in idler */
1115 /* FIXME, round trip */
1117 _ecore_evas_x_size_pos_hints_update(Ecore_Evas *ee)
1119 # ifdef HAVE_ECORE_X_XCB
1120 ecore_x_icccm_size_pos_hints_get_prefetch(ee->prop.window);
1121 ecore_x_icccm_size_pos_hints_get_fetch();
1122 # endif /* HAVE_ECORE_X_XCB */
1123 ecore_x_icccm_size_pos_hints_set(ee->prop.window,
1124 ee->prop.request_pos /*request_pos */,
1125 ECORE_X_GRAVITY_NW /* gravity */,
1126 ee->prop.min.w /* min_w */,
1127 ee->prop.min.h /* min_h */,
1128 ee->prop.max.w /* max_w */,
1129 ee->prop.max.h /* max_h */,
1130 ee->prop.base.w /* base_w */,
1131 ee->prop.base.h /* base_h */,
1132 ee->prop.step.w /* step_x */,
1133 ee->prop.step.h /* step_y */,
1135 0 /* max_aspect */);
1136 # ifdef HAVE_ECORE_X_XCB
1137 ecore_xcb_reply_free();
1138 # endif /* HAVE_ECORE_X_XCB */
1141 /* FIXME, should be in idler */
1143 _ecore_evas_x_state_update(Ecore_Evas *ee)
1145 Ecore_X_Window_State state[10];
1151 if (bd->client.netwm.state.modal)
1152 state[num++] = ECORE_X_WINDOW_STATE_MODAL;
1154 if (ee->engine.x.state.sticky)
1155 state[num++] = ECORE_X_WINDOW_STATE_STICKY;
1157 if (bd->client.netwm.state.maximized_v)
1158 state[num++] = ECORE_X_WINDOW_STATE_MAXIMIZED_VERT;
1159 if (bd->client.netwm.state.maximized_h)
1160 state[num++] = ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ;
1161 if (bd->client.netwm.state.shaded)
1162 state[num++] = ECORE_X_WINDOW_STATE_SHADED;
1163 if (bd->client.netwm.state.skip_taskbar)
1164 state[num++] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1165 if (bd->client.netwm.state.skip_pager)
1166 state[num++] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
1167 if (bd->client.netwm.state.hidden)
1168 state[num++] = ECORE_X_WINDOW_STATE_HIDDEN;
1170 if (ee->engine.x.state.fullscreen)
1171 state[num++] = ECORE_X_WINDOW_STATE_FULLSCREEN;
1172 if (ee->engine.x.state.above)
1173 state[num++] = ECORE_X_WINDOW_STATE_ABOVE;
1174 if (ee->engine.x.state.below)
1175 state[num++] = ECORE_X_WINDOW_STATE_BELOW;
1177 ecore_x_netwm_window_state_set(ee->prop.window, state, num);
1181 _ecore_evas_x_layer_update(Ecore_Evas *ee)
1183 if (ee->should_be_visible)
1185 /* We need to send a netwm request to the wm */
1186 /* FIXME: Do we have to remove old state before adding new? */
1187 if (ee->prop.layer < 3)
1189 if (ee->engine.x.state.above)
1191 ee->engine.x.state.above = 0;
1192 ecore_x_netwm_state_request_send(ee->prop.window,
1193 ee->engine.x.win_root,
1194 ECORE_X_WINDOW_STATE_ABOVE, -1, 0);
1196 if (!ee->engine.x.state.below)
1198 ee->engine.x.state.below = 1;
1199 ecore_x_netwm_state_request_send(ee->prop.window,
1200 ee->engine.x.win_root,
1201 ECORE_X_WINDOW_STATE_BELOW, -1, 1);
1204 else if (ee->prop.layer > 5)
1206 if (ee->engine.x.state.below)
1208 ee->engine.x.state.below = 0;
1209 ecore_x_netwm_state_request_send(ee->prop.window,
1210 ee->engine.x.win_root,
1211 ECORE_X_WINDOW_STATE_BELOW, -1, 0);
1213 if (!ee->engine.x.state.above)
1215 ee->engine.x.state.above = 1;
1216 ecore_x_netwm_state_request_send(ee->prop.window,
1217 ee->engine.x.win_root,
1218 ECORE_X_WINDOW_STATE_ABOVE, -1, 1);
1223 if (ee->engine.x.state.below)
1225 ee->engine.x.state.below = 0;
1226 ecore_x_netwm_state_request_send(ee->prop.window,
1227 ee->engine.x.win_root,
1228 ECORE_X_WINDOW_STATE_BELOW, -1, 0);
1230 if (ee->engine.x.state.above)
1232 ee->engine.x.state.above = 0;
1233 ecore_x_netwm_state_request_send(ee->prop.window,
1234 ee->engine.x.win_root,
1235 ECORE_X_WINDOW_STATE_ABOVE, -1, 0);
1241 /* Just set the state */
1242 if (ee->prop.layer < 3)
1244 if ((ee->engine.x.state.above) || (!ee->engine.x.state.below))
1246 ee->engine.x.state.above = 0;
1247 ee->engine.x.state.below = 1;
1248 _ecore_evas_x_state_update(ee);
1251 else if (ee->prop.layer > 5)
1253 if ((!ee->engine.x.state.above) || (ee->engine.x.state.below))
1255 ee->engine.x.state.above = 1;
1256 ee->engine.x.state.below = 0;
1257 _ecore_evas_x_state_update(ee);
1262 if ((ee->engine.x.state.above) || (ee->engine.x.state.below))
1264 ee->engine.x.state.above = 0;
1265 ee->engine.x.state.below = 0;
1266 _ecore_evas_x_state_update(ee);
1270 /* FIXME: Set gnome layer */
1274 _ecore_evas_x_init(void)
1276 _ecore_evas_init_count++;
1277 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
1278 ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_IN, _ecore_evas_x_event_mouse_in, NULL);
1279 ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT, _ecore_evas_x_event_mouse_out, NULL);
1280 ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, _ecore_evas_x_event_window_focus_in, NULL);
1281 ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, _ecore_evas_x_event_window_focus_out, NULL);
1282 ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DAMAGE, _ecore_evas_x_event_window_damage, NULL);
1283 ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _ecore_evas_x_event_window_destroy, NULL);
1284 ecore_evas_event_handlers[6] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, _ecore_evas_x_event_window_configure, NULL);
1285 ecore_evas_event_handlers[7] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, _ecore_evas_x_event_window_delete_request, NULL);
1286 ecore_evas_event_handlers[8] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, _ecore_evas_x_event_window_show, NULL);
1287 ecore_evas_event_handlers[9] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, _ecore_evas_x_event_window_hide, NULL);
1288 ecore_evas_event_handlers[10] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _ecore_evas_x_event_property_change, NULL);
1289 ecore_evas_event_handlers[11] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, _ecore_evas_x_event_visibility_change, NULL);
1290 ecore_evas_event_handlers[12] = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_evas_x_event_client_message, NULL);
1291 ecore_event_evas_init();
1292 return _ecore_evas_init_count;
1296 _ecore_evas_x_free(Ecore_Evas *ee)
1298 _ecore_evas_x_group_leader_unset(ee);
1299 _ecore_evas_x_sync_set(ee);
1300 if (ee->engine.x.win_shaped_input) ecore_x_window_free(ee->engine.x.win_shaped_input);
1301 ecore_x_window_free(ee->prop.window);
1302 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
1303 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1304 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
1305 if (ee->engine.x.damages) ecore_x_xregion_free(ee->engine.x.damages);
1306 ee->engine.x.pmap = 0;
1307 ee->engine.x.mask = 0;
1308 ee->engine.x.gc = 0;
1309 ee->engine.x.damages = NULL;
1310 ecore_event_window_unregister(ee->prop.window);
1311 while (ee->engine.x.win_extra)
1313 Ecore_X_Window *winp;
1315 winp = ee->engine.x.win_extra->data;
1316 ee->engine.x.win_extra = eina_list_remove_list(ee->engine.x.win_extra, ee->engine.x.win_extra);
1317 ecore_event_window_unregister(*winp);
1320 _ecore_evas_x_shutdown();
1325 _ecore_evas_x_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1327 ee->func.fn_delete_request = func;
1328 _ecore_evas_x_protocols_set(ee);
1329 _ecore_evas_x_sync_set(ee);
1333 _ecore_evas_x_move(Ecore_Evas *ee, int x, int y)
1337 if (ee->engine.x.direct_resize)
1339 if (!ee->engine.x.managed)
1341 if ((x != ee->x) || (y != ee->y))
1345 ecore_x_window_move(ee->prop.window, x, y);
1346 if (!ee->should_be_visible)
1348 /* We need to request pos */
1349 ee->prop.request_pos = 1;
1350 _ecore_evas_x_size_pos_hints_update(ee);
1352 if (ee->func.fn_move) ee->func.fn_move(ee);
1358 ecore_x_window_move(ee->prop.window, x, y);
1359 if (!ee->should_be_visible)
1361 /* We need to request pos */
1362 ee->prop.request_pos = 1;
1363 _ecore_evas_x_size_pos_hints_update(ee);
1365 if (!ee->engine.x.managed)
1374 _ecore_evas_x_managed_move(Ecore_Evas *ee, int x, int y)
1378 if (ee->engine.x.direct_resize)
1380 ee->engine.x.managed = 1;
1381 if ((x != ee->x) || (y != ee->y))
1385 if (ee->func.fn_move) ee->func.fn_move(ee);
1391 _ecore_evas_x_resize(Ecore_Evas *ee, int w, int h)
1395 if (ee->engine.x.direct_resize)
1397 if ((ee->w != w) || (ee->h != h))
1399 ecore_x_window_resize(ee->prop.window, w, h);
1402 if ((ee->rotation == 90) || (ee->rotation == 270))
1404 evas_output_size_set(ee->evas, ee->h, ee->w);
1405 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1409 evas_output_size_set(ee->evas, ee->w, ee->h);
1410 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1412 if (ee->prop.avoid_damage)
1416 pdam = ecore_evas_avoid_damage_get(ee);
1417 ecore_evas_avoid_damage_set(ee, 0);
1418 ecore_evas_avoid_damage_set(ee, pdam);
1420 if ((ee->shaped) || (ee->alpha))
1421 _ecore_evas_x_resize_shape(ee);
1422 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1426 ecore_x_window_resize(ee->prop.window, w, h);
1430 _ecore_evas_x_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
1436 if (ee->engine.x.direct_resize)
1438 if ((ee->w != w) || (ee->h != h) || (x != ee->x) || (y != ee->y))
1440 int change_size = 0, change_pos = 0;
1442 if ((ee->w != w) || (ee->h != h)) change_size = 1;
1443 if (!ee->engine.x.managed)
1445 if ((x != ee->x) || (y != ee->y)) change_pos = 1;
1447 ecore_x_window_move_resize(ee->prop.window, x, y, w, h);
1448 if (!ee->engine.x.managed)
1455 if ((ee->rotation == 90) || (ee->rotation == 270))
1457 evas_output_size_set(ee->evas, ee->h, ee->w);
1458 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1462 evas_output_size_set(ee->evas, ee->w, ee->h);
1463 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1465 if (ee->prop.avoid_damage)
1469 pdam = ecore_evas_avoid_damage_get(ee);
1470 ecore_evas_avoid_damage_set(ee, 0);
1471 ecore_evas_avoid_damage_set(ee, pdam);
1473 if ((ee->shaped) || (ee->alpha))
1474 _ecore_evas_x_resize_shape(ee);
1477 if (ee->func.fn_move) ee->func.fn_move(ee);
1481 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1487 ecore_x_window_move_resize(ee->prop.window, x, y, w, h);
1488 if (!ee->engine.x.managed)
1497 _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize,
1498 Evas_Engine_Info *einfo)
1502 rot_dif = ee->rotation - rotation;
1503 if (rot_dif < 0) rot_dif = -rot_dif;
1507 int minw, minh, maxw, maxh, basew, baseh, stepw, steph;
1509 if (!evas_engine_info_set(ee->evas, einfo))
1511 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1516 if (!ee->prop.fullscreen)
1518 ecore_x_window_resize(ee->prop.window, ee->req.h, ee->req.w);
1519 ee->expecting_resize.w = ee->h;
1520 ee->expecting_resize.h = ee->w;
1526 ecore_x_window_size_get(ee->prop.window, &w, &h);
1527 ecore_x_window_resize(ee->prop.window, h, w);
1528 if ((rotation == 0) || (rotation == 180))
1530 evas_output_size_set(ee->evas, ee->req.w, ee->req.h);
1531 evas_output_viewport_set(ee->evas, 0, 0, ee->req.w, ee->req.h);
1535 evas_output_size_set(ee->evas, ee->req.h, ee->req.w);
1536 evas_output_viewport_set(ee->evas, 0, 0, ee->req.h, ee->req.w);
1538 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1540 if ((ee->rotation == 90) || (ee->rotation == 270))
1541 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.h, ee->req.w);
1543 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
1549 ecore_x_window_size_get(ee->prop.window, &w, &h);
1550 if ((rotation == 0) || (rotation == 180))
1552 evas_output_size_set(ee->evas, ee->w, ee->h);
1553 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1557 evas_output_size_set(ee->evas, ee->h, ee->w);
1558 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
1560 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1561 if ((ee->rotation == 90) || (ee->rotation == 270))
1562 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
1564 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1566 ecore_evas_size_min_get(ee, &minw, &minh);
1567 ecore_evas_size_max_get(ee, &maxw, &maxh);
1568 ecore_evas_size_base_get(ee, &basew, &baseh);
1569 ecore_evas_size_step_get(ee, &stepw, &steph);
1570 ee->rotation = rotation;
1571 ecore_evas_size_min_set(ee, minh, minw);
1572 ecore_evas_size_max_set(ee, maxh, maxw);
1573 ecore_evas_size_base_set(ee, baseh, basew);
1574 ecore_evas_size_step_set(ee, steph, stepw);
1575 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
1576 ecore_x_current_time_get());
1580 if (!evas_engine_info_set(ee->evas, einfo))
1582 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1584 ee->rotation = rotation;
1585 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
1586 ecore_x_current_time_get());
1587 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1589 if ((ee->rotation == 90) || (ee->rotation == 270))
1590 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
1592 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1597 _ecore_evas_x_rotation_set(Ecore_Evas *ee, int rotation, int resize)
1599 if (ee->rotation == rotation) return;
1600 if (!strcmp(ee->driver, "xrender_x11")) return;
1601 if (!strcmp(ee->driver, "opengl_x11"))
1603 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
1604 Evas_Engine_Info_GL_X11 *einfo;
1606 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
1608 einfo->info.rotation = rotation;
1609 _ecore_evas_x_rotation_set_internal
1610 (ee, rotation, resize, (Evas_Engine_Info *)einfo);
1611 #endif /* BUILD_ECORE_EVAS_OPENGL_X11 */
1613 else if (!strcmp(ee->driver, "software_x11"))
1615 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1616 Evas_Engine_Info_Software_X11 *einfo;
1618 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1620 einfo->info.rotation = rotation;
1621 _ecore_evas_x_rotation_set_internal
1622 (ee, rotation, resize, (Evas_Engine_Info *)einfo);
1623 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1625 else if (!strcmp(ee->driver, "software_16_x11"))
1627 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
1628 Evas_Engine_Info_Software_16_X11 *einfo;
1630 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
1632 einfo->info.rotation = rotation;
1633 _ecore_evas_x_rotation_set_internal
1634 (ee, rotation, resize, (Evas_Engine_Info *)einfo);
1635 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
1637 else if (!strcmp(ee->driver, "software_8_x11"))
1639 #if BUILD_ECORE_EVAS_SOFTWARE_8_X11
1640 Evas_Engine_Info_Software_8_X11 *einfo;
1642 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
1644 einfo->info.rotation = rotation;
1645 _ecore_evas_x_rotation_set_internal
1646 (ee, rotation, resize, (Evas_Engine_Info *)einfo);
1647 #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
1652 _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped)
1654 if (((ee->shaped) && (shaped)) || ((!ee->shaped) && (!shaped)))
1656 if (!strcmp(ee->driver, "opengl_x11")) return;
1657 if (!strcmp(ee->driver, "software_x11"))
1659 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1660 Evas_Engine_Info_Software_X11 *einfo;
1662 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1663 ee->shaped = shaped;
1668 unsigned int foreground;
1671 if (!ee->engine.x.mask)
1672 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1674 gc = ecore_x_gc_new(ee->engine.x.mask,
1675 ECORE_X_GC_VALUE_MASK_FOREGROUND,
1677 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
1678 0, 0, ee->w, ee->h);
1679 ecore_x_gc_free(gc);
1680 einfo->info.mask = ee->engine.x.mask;
1681 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1683 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1685 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1686 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1690 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1691 ee->engine.x.mask = 0;
1692 einfo->info.mask = 0;
1693 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1695 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1697 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1698 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1701 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1703 else if (!strcmp(ee->driver, "xrender_x11"))
1705 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
1706 Evas_Engine_Info_XRender_X11 *einfo;
1708 ee->shaped = shaped;
1709 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
1714 unsigned int foreground;
1717 if (!ee->engine.x.mask)
1718 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1720 gc = ecore_x_gc_new(ee->engine.x.mask,
1721 ECORE_X_GC_VALUE_MASK_FOREGROUND,
1723 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
1724 0, 0, ee->w, ee->h);
1725 ecore_x_gc_free(gc);
1726 einfo->info.mask = ee->engine.x.mask;
1727 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1729 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1731 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1732 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1736 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1737 ee->engine.x.mask = 0;
1738 einfo->info.mask = 0;
1739 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1741 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1743 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1744 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1747 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
1749 else if (!strcmp(ee->driver, "software_16_x11"))
1751 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
1752 # if 0 /* XXX no shaped window support for software_16_x11 */
1753 Evas_Engine_Info_Software_16_X11 *einfo;
1755 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
1756 ee->shaped = shaped;
1764 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1765 einfo->info.mask = ee->engine.x.mask;
1766 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1768 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1770 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1774 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1775 ee->engine.x.mask = 0;
1776 einfo->info.mask = 0;
1777 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1779 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1781 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1784 # endif /* XXX no shaped window support for software_16_x11 */
1785 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
1787 if (!strcmp(ee->driver, "software_8_x11"))
1789 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
1790 Evas_Engine_Info_Software_8_X11 *einfo;
1792 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
1793 ee->shaped = shaped;
1798 unsigned int foreground;
1801 if (!ee->engine.x.mask)
1802 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1);
1804 gc = ecore_x_gc_new(ee->engine.x.mask,
1805 ECORE_X_GC_VALUE_MASK_FOREGROUND,
1807 ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc,
1808 0, 0, ee->w, ee->h);
1809 ecore_x_gc_free(gc);
1810 einfo->info.mask = ee->engine.x.mask;
1811 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1813 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1815 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1816 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1820 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1821 ee->engine.x.mask = 0;
1822 einfo->info.mask = 0;
1823 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1825 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1827 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1828 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1831 #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
1835 /* FIXME, round trip */
1837 _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha)
1839 # ifdef HAVE_ECORE_X_XCB
1840 xcb_get_geometry_cookie_t cookie_geom;
1841 xcb_get_window_attributes_cookie_t cookie_attr;
1842 xcb_get_geometry_reply_t *reply_geom;
1843 xcb_get_window_attributes_reply_t *reply_attr;
1845 XWindowAttributes att;
1846 #endif /* ! HAVE_ECORE_X_XCB */
1848 if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha)))
1851 if (!strcmp(ee->driver, "software_x11"))
1853 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
1854 Evas_Engine_Info_Software_X11 *einfo;
1856 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
1859 if (!ecore_x_composite_query()) return;
1863 ecore_x_window_free(ee->prop.window);
1864 ecore_event_window_unregister(ee->prop.window);
1867 if (ee->prop.override)
1868 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
1870 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
1871 if (!ee->engine.x.mask)
1872 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1);
1876 if (ee->prop.override)
1877 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
1879 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
1880 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1881 ee->engine.x.mask = 0;
1882 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
1885 einfo->info.destination_alpha = alpha;
1887 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
1888 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
1889 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
1891 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
1892 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
1893 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
1894 einfo->info.colormap = reply_attr->colormap;
1895 einfo->info.depth = reply_geom->depth;
1899 XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att);
1900 einfo->info.visual = att.visual;
1901 einfo->info.colormap = att.colormap;
1902 einfo->info.depth = att.depth;
1903 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
1905 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
1906 // ee->engine.x.mask = 0;
1907 einfo->info.mask = ee->engine.x.mask;
1908 einfo->info.drawable = ee->prop.window;
1909 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1911 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1913 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
1914 ecore_x_window_shape_mask_set(ee->prop.window, 0);
1915 ecore_x_input_multi_select(ee->prop.window);
1916 ecore_event_window_register(ee->prop.window, ee, ee->evas,
1917 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
1918 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
1919 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
1920 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
1921 if (ee->prop.borderless)
1922 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
1923 if (ee->visible) ecore_x_window_show(ee->prop.window);
1924 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
1927 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
1928 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
1930 ecore_x_icccm_hints_set(ee->prop.window,
1931 1 /* accepts_focus */,
1932 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
1933 0 /* icon_pixmap */,
1935 0 /* icon_window */,
1936 0 /* window_group */,
1938 _ecore_evas_x_group_leader_update(ee);
1939 ecore_x_window_defaults_set(ee->prop.window);
1940 _ecore_evas_x_protocols_set(ee);
1941 _ecore_evas_x_sync_set(ee);
1942 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
1943 if (getenv("DESKTOP_STARTUP_ID"))
1945 ecore_x_netwm_startup_id_set(ee->prop.window,
1946 getenv("DESKTOP_STARTUP_ID"));
1947 /* NB: on linux this may simply empty the env as opposed to completely
1948 * unset it to being empty - unsure as solartis libc crashes looking
1949 * for the '=' char */
1950 // putenv((char*)"DESKTOP_STARTUP_ID=");
1953 else if (!strcmp(ee->driver, "opengl_x11"))
1955 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
1956 Evas_Engine_Info_GL_X11 *einfo;
1958 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
1961 if (!ecore_x_composite_query()) return;
1965 ecore_x_window_free(ee->prop.window);
1966 ecore_event_window_unregister(ee->prop.window);
1967 ee->prop.window = 0;
1969 einfo->info.destination_alpha = alpha;
1971 if (ee->engine.x.win_root != 0)
1973 /* FIXME: round trip in ecore_x_window_argb_get */
1974 if (ecore_x_window_argb_get(ee->engine.x.win_root))
1976 ee->prop.window = _ecore_evas_x_gl_window_new
1977 (ee, ee->engine.x.win_root,
1978 ee->req.x, ee->req.y, ee->req.w, ee->req.h,
1979 ee->prop.override, 1, NULL);
1982 ee->prop.window = _ecore_evas_x_gl_window_new
1983 (ee, ee->engine.x.win_root,
1984 ee->req.x, ee->req.y, ee->req.w, ee->req.h,
1985 ee->prop.override, ee->alpha, NULL);
1988 ee->prop.window = _ecore_evas_x_gl_window_new
1989 (ee, ee->engine.x.win_root,
1990 ee->req.x, ee->req.y, ee->req.w, ee->req.h,
1991 ee->prop.override, ee->alpha, NULL);
1992 if (!ee->prop.window)
1999 if (ee->prop.override)
2000 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2002 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2003 if (!ee->engine.x.mask)
2004 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1);
2008 if (ee->prop.override)
2009 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2011 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2012 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2013 ee->engine.x.mask = 0;
2014 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
2018 XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att);
2019 einfo->info.visual = att.visual;
2020 einfo->info.colormap = att.colormap;
2021 einfo->info.depth = att.depth;
2023 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2024 // ee->engine.x.mask = 0;
2025 // einfo->info.mask = ee->engine.x.mask;
2026 einfo->info.drawable = ee->prop.window;
2027 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2029 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2031 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
2032 // ecore_x_window_shape_mask_set(ee->prop.window, 0);
2033 ecore_x_input_multi_select(ee->prop.window);
2034 ecore_event_window_register(ee->prop.window, ee, ee->evas,
2035 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
2036 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
2037 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
2038 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
2039 if (ee->prop.borderless)
2040 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
2041 if (ee->visible) ecore_x_window_show(ee->prop.window);
2042 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2045 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
2046 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
2048 ecore_x_icccm_hints_set(ee->prop.window,
2049 1 /* accepts_focus */,
2050 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2051 0 /* icon_pixmap */,
2053 0 /* icon_window */,
2054 0 /* window_group */,
2056 _ecore_evas_x_group_leader_update(ee);
2057 ecore_x_window_defaults_set(ee->prop.window);
2058 _ecore_evas_x_protocols_set(ee);
2059 _ecore_evas_x_sync_set(ee);
2060 #endif /* BUILD_ECORE_EVAS_OPENGL_X11 */
2061 if (getenv("DESKTOP_STARTUP_ID"))
2063 ecore_x_netwm_startup_id_set(ee->prop.window,
2064 getenv("DESKTOP_STARTUP_ID"));
2065 /* NB: on linux this may simply empty the env as opposed to completely
2066 * unset it to being empty - unsure as solartis libc crashes looking
2067 * for the '=' char */
2068 // putenv((char*)"DESKTOP_STARTUP_ID=");
2071 else if (!strcmp(ee->driver, "xrender_x11"))
2073 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
2074 Evas_Engine_Info_XRender_X11 *einfo;
2076 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
2078 if (!ecore_x_composite_query()) return;
2082 ecore_x_window_free(ee->prop.window);
2083 ecore_event_window_unregister(ee->prop.window);
2086 if (ee->prop.override)
2087 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2089 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2090 if (!ee->engine.x.mask)
2091 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1);
2095 if (ee->prop.override)
2096 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2098 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2099 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2100 ee->engine.x.mask = 0;
2101 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
2104 einfo->info.destination_alpha = alpha;
2106 # ifdef BUILD_ECORE_EVAS_XRENDER_XCB
2107 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
2108 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
2110 einfo->info.visual = reply_attr->visual;
2113 XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att);
2114 einfo->info.visual = att.visual;
2115 # endif /* ! BUILD_ECORE_EVAS_XRENDER_XCB */
2117 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2118 // ee->engine.x.mask = 0;
2119 einfo->info.mask = ee->engine.x.mask;
2120 einfo->info.drawable = ee->prop.window;
2121 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2123 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2125 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
2126 ecore_x_window_shape_mask_set(ee->prop.window, 0);
2127 ecore_x_input_multi_select(ee->prop.window);
2128 ecore_event_window_register(ee->prop.window, ee, ee->evas,
2129 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
2130 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
2131 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
2132 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
2133 if (ee->prop.borderless)
2134 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
2135 if (ee->visible) ecore_x_window_show(ee->prop.window);
2136 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2139 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
2140 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
2142 ecore_x_icccm_hints_set(ee->prop.window,
2143 1 /* accepts_focus */,
2144 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2145 0 /* icon_pixmap */,
2147 0 /* icon_window */,
2148 0 /* window_group */,
2150 _ecore_evas_x_group_leader_update(ee);
2151 ecore_x_window_defaults_set(ee->prop.window);
2152 _ecore_evas_x_protocols_set(ee);
2153 _ecore_evas_x_sync_set(ee);
2154 #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
2155 if (getenv("DESKTOP_STARTUP_ID"))
2157 ecore_x_netwm_startup_id_set(ee->prop.window,
2158 getenv("DESKTOP_STARTUP_ID"));
2159 /* NB: on linux this may simply empty the env as opposed to completely
2160 * unset it to being empty - unsure as solartis libc crashes looking
2161 * for the '=' char */
2162 // putenv((char*)"DESKTOP_STARTUP_ID=");
2165 else if (!strcmp(ee->driver, "software_16_x11"))
2167 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
2168 Evas_Engine_Info_Software_16_X11 *einfo;
2170 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
2175 ecore_x_window_free(ee->prop.window);
2176 ecore_event_window_unregister(ee->prop.window);
2179 if (ee->prop.override)
2180 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2182 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2183 if (!ee->engine.x.mask)
2184 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1);
2188 if (ee->prop.override)
2189 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2191 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2192 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2193 ee->engine.x.mask = 0;
2194 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
2197 # if 0 /* XXX no alpha window support for software_16_x11 */
2198 einfo->info.destination_alpha = alpha;
2199 # endif /* XXX no alpha window support for software_16_x11 */
2201 # if 0 /* XXX no shaped window support for software_16_x11 */
2202 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2203 // ee->engine.x.mask = 0;
2204 einfo->info.mask = ee->engine.x.mask;
2205 # endif /* XXX no shaped window support for software_16_x11 */
2207 einfo->info.drawable = ee->prop.window;
2208 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2210 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2212 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
2213 ecore_x_window_shape_mask_set(ee->prop.window, 0);
2214 ecore_x_input_multi_select(ee->prop.window);
2215 ecore_event_window_register(ee->prop.window, ee, ee->evas,
2216 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
2217 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
2218 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
2219 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
2220 if (ee->prop.borderless)
2221 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
2222 if (ee->visible) ecore_x_window_show(ee->prop.window);
2223 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2226 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
2227 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
2229 ecore_x_icccm_hints_set(ee->prop.window,
2230 1 /* accepts_focus */,
2231 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2232 0 /* icon_pixmap */,
2234 0 /* icon_window */,
2235 0 /* window_group */,
2237 _ecore_evas_x_group_leader_update(ee);
2238 ecore_x_window_defaults_set(ee->prop.window);
2239 _ecore_evas_x_protocols_set(ee);
2240 _ecore_evas_x_sync_set(ee);
2241 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
2242 if (getenv("DESKTOP_STARTUP_ID"))
2244 ecore_x_netwm_startup_id_set(ee->prop.window,
2245 getenv("DESKTOP_STARTUP_ID"));
2246 /* NB: on linux this may simply empty the env as opposed to completely
2247 * unset it to being empty - unsure as solartis libc crashes looking
2248 * for the '=' char */
2249 // putenv((char*)"DESKTOP_STARTUP_ID=");
2252 else if (!strcmp(ee->driver, "software_8_x11"))
2254 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
2255 Evas_Engine_Info_Software_8_X11 *einfo;
2257 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
2262 ecore_x_window_free(ee->prop.window);
2263 ecore_event_window_unregister(ee->prop.window);
2266 if (ee->prop.override)
2267 ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2269 ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2270 if (!ee->engine.x.mask)
2271 ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1);
2275 if (ee->prop.override)
2276 ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2278 ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h);
2279 if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2280 ee->engine.x.mask = 0;
2281 ecore_x_window_shape_input_mask_set(ee->prop.window, 0);
2284 einfo->info.destination_alpha = alpha;
2286 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
2287 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
2289 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
2290 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
2291 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
2292 einfo->info.colormap = reply_attr->colormap;
2293 einfo->info.depth = reply_geom->depth;
2297 // if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
2298 // ee->engine.x.mask = 0;
2299 einfo->info.mask = ee->engine.x.mask;
2300 einfo->info.drawable = ee->prop.window;
2301 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2303 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2305 evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
2306 ecore_x_window_shape_mask_set(ee->prop.window, 0);
2307 ecore_x_input_multi_select(ee->prop.window);
2308 ecore_event_window_register(ee->prop.window, ee, ee->evas,
2309 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
2310 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
2311 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
2312 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
2313 if (ee->prop.borderless)
2314 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
2315 if (ee->visible) ecore_x_window_show(ee->prop.window);
2316 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2319 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
2320 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
2322 ecore_x_icccm_hints_set(ee->prop.window,
2323 1 /* accepts_focus */,
2324 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2325 0 /* icon_pixmap */,
2327 0 /* icon_window */,
2328 0 /* window_group */,
2330 _ecore_evas_x_group_leader_update(ee);
2331 ecore_x_window_defaults_set(ee->prop.window);
2332 _ecore_evas_x_protocols_set(ee);
2333 _ecore_evas_x_sync_set(ee);
2335 if (getenv("DESKTOP_STARTUP_ID"))
2337 ecore_x_netwm_startup_id_set(ee->prop.window,
2338 getenv("DESKTOP_STARTUP_ID"));
2339 /* NB: on linux this may simply empty the env as opposed to completely
2340 * unset it to being empty - unsure as solartis libc crashes looking
2341 * for the '=' char */
2342 // putenv((char*)"DESKTOP_STARTUP_ID=");
2344 #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
2349 _ecore_evas_x_transparent_set(Ecore_Evas *ee, int transparent)
2351 if (((ee->transparent) && (transparent)) ||
2352 ((!ee->transparent) && (!transparent)))
2355 if (!strcmp(ee->driver, "software_x11"))
2357 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2358 Evas_Engine_Info_Software_X11 *einfo;
2360 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
2363 ee->transparent = transparent;
2364 einfo->info.destination_alpha = transparent;
2365 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2367 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2369 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2373 #endif /* BUILD_ECORE_EVAS_X11 */
2375 #ifdef BUILD_ECORE_EVAS_X11
2377 _ecore_evas_x_show(Ecore_Evas *ee)
2379 ee->should_be_visible = 1;
2380 if (ee->prop.avoid_damage)
2381 _ecore_evas_x_render(ee);
2382 _ecore_evas_x_sync_set(ee);
2383 ecore_x_window_show(ee->prop.window);
2384 if (ee->prop.fullscreen)
2385 ecore_x_window_focus(ee->prop.window);
2389 _ecore_evas_x_hide(Ecore_Evas *ee)
2391 ecore_x_window_hide(ee->prop.window);
2392 ee->should_be_visible = 0;
2393 _ecore_evas_x_sync_set(ee);
2397 _ecore_evas_x_raise(Ecore_Evas *ee)
2399 if (!ee->prop.fullscreen)
2400 ecore_x_window_raise(ee->prop.window);
2402 ecore_x_window_raise(ee->prop.window);
2406 _ecore_evas_x_lower(Ecore_Evas *ee)
2408 if (!ee->prop.fullscreen)
2409 ecore_x_window_lower(ee->prop.window);
2411 ecore_x_window_lower(ee->prop.window);
2415 _ecore_evas_x_activate(Ecore_Evas *ee)
2417 ecore_x_netwm_client_active_request(ee->engine.x.win_root,
2418 ee->prop.window, 2, 0);
2422 _ecore_evas_x_title_set(Ecore_Evas *ee, const char *t)
2424 if (ee->prop.title) free(ee->prop.title);
2425 ee->prop.title = NULL;
2426 if (t) ee->prop.title = strdup(t);
2427 ecore_x_icccm_title_set(ee->prop.window, ee->prop.title);
2428 ecore_x_netwm_name_set(ee->prop.window, ee->prop.title);
2432 _ecore_evas_x_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
2434 if (ee->prop.name) free(ee->prop.name);
2435 if (ee->prop.clas) free(ee->prop.clas);
2436 ee->prop.name = NULL;
2437 ee->prop.clas = NULL;
2438 if (n) ee->prop.name = strdup(n);
2439 if (c) ee->prop.clas = strdup(c);
2440 ecore_x_icccm_name_class_set(ee->prop.window, ee->prop.name, ee->prop.clas);
2444 _ecore_evas_x_size_min_set(Ecore_Evas *ee, int w, int h)
2448 if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return;
2451 _ecore_evas_x_size_pos_hints_update(ee);
2455 _ecore_evas_x_size_max_set(Ecore_Evas *ee, int w, int h)
2459 if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return;
2462 _ecore_evas_x_size_pos_hints_update(ee);
2466 _ecore_evas_x_size_base_set(Ecore_Evas *ee, int w, int h)
2470 if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return;
2471 ee->prop.base.w = w;
2472 ee->prop.base.h = h;
2473 _ecore_evas_x_size_pos_hints_update(ee);
2477 _ecore_evas_x_size_step_set(Ecore_Evas *ee, int w, int h)
2481 if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return;
2482 ee->prop.step.w = w;
2483 ee->prop.step.h = h;
2484 _ecore_evas_x_size_pos_hints_update(ee);
2488 _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2494 ee->prop.cursor.object = NULL;
2498 _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
2502 if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
2506 ee->prop.cursor.object = NULL;
2507 ee->prop.cursor.layer = 0;
2508 ee->prop.cursor.hot.x = 0;
2509 ee->prop.cursor.hot.y = 0;
2510 ecore_x_window_cursor_show(ee->prop.window, 1);
2514 ee->prop.cursor.object = obj;
2515 ee->prop.cursor.layer = layer;
2516 ee->prop.cursor.hot.x = hot_x;
2517 ee->prop.cursor.hot.y = hot_y;
2519 ecore_x_window_cursor_show(ee->prop.window, 0);
2521 evas_pointer_output_xy_get(ee->evas, &x, &y);
2522 evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
2523 evas_object_move(ee->prop.cursor.object,
2524 x - ee->prop.cursor.hot.x,
2525 y - ee->prop.cursor.hot.y);
2526 evas_object_pass_events_set(ee->prop.cursor.object, 1);
2527 if (evas_pointer_inside_get(ee->evas))
2528 evas_object_show(ee->prop.cursor.object);
2530 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
2535 * @param layer If < 3, @a ee will be put below all other windows.
2536 * If > 5, @a ee will be "always-on-top"
2537 * If = 4, @a ee will be put in the default layer.
2538 * Acceptable values range from 1 to 255 (0 reserved for
2542 _ecore_evas_x_layer_set(Ecore_Evas *ee, int layer)
2544 if (ee->prop.layer == layer) return;
2546 /* FIXME: Should this logic be here? */
2549 else if (layer > 255)
2552 ee->prop.layer = layer;
2553 _ecore_evas_x_layer_update(ee);
2557 _ecore_evas_x_focus_set(Ecore_Evas *ee, int on __UNUSED__)
2559 ecore_x_window_focus(ee->prop.window);
2563 _ecore_evas_x_iconified_set(Ecore_Evas *ee, int on)
2565 // if (((ee->prop.iconified) && (on)) ||
2566 // ((!ee->prop.iconified) && (!on))) return;
2567 ee->prop.iconified = on;
2570 ecore_x_icccm_hints_set(ee->prop.window,
2571 1 /* accepts_focus */,
2572 ECORE_X_WINDOW_STATE_HINT_ICONIC /* initial_state */,
2573 0 /* icon_pixmap */,
2575 0 /* icon_window */,
2576 0 /* window_group */,
2578 ecore_x_icccm_iconic_request_send(ee->prop.window, ee->engine.x.win_root);
2582 ecore_x_icccm_hints_set(ee->prop.window,
2583 1 /* accepts_focus */,
2584 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
2585 0 /* icon_pixmap */,
2587 0 /* icon_window */,
2588 0 /* window_group */,
2590 ecore_evas_show(ee);
2595 _ecore_evas_x_borderless_set(Ecore_Evas *ee, int on)
2597 if (((ee->prop.borderless) && (on)) ||
2598 ((!ee->prop.borderless) && (!on))) return;
2599 ee->prop.borderless = on;
2600 ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless);
2603 /* FIXME: This function changes the initial state of the ee
2604 * whilest the iconic function changes the current state! */
2606 _ecore_evas_x_withdrawn_set(Ecore_Evas *ee, int withdrawn)
2608 Ecore_X_Window_State_Hint hint;
2610 if ((ee->prop.withdrawn && withdrawn) ||
2611 (!ee->prop.withdrawn && !withdrawn)) return;
2613 ee->prop.withdrawn = withdrawn;
2615 hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
2617 hint = ECORE_X_WINDOW_STATE_HINT_NORMAL;
2619 ecore_x_icccm_hints_set(ee->prop.window,
2620 1 /* accepts_focus */,
2621 hint /* initial_state */,
2622 0 /* icon_pixmap */,
2624 0 /* icon_window */,
2625 0 /* window_group */,
2630 _ecore_evas_x_sticky_set(Ecore_Evas *ee, int sticky)
2632 if ((ee->prop.sticky && sticky) ||
2633 (!ee->prop.sticky && !sticky)) return;
2635 /* We dont want to set prop.sticky here as it will cause
2636 * the sticky callback not to get called. Its set on the
2637 * property change event.
2638 * ee->prop.sticky = sticky;
2640 ee->engine.x.state.sticky = sticky;
2641 if (ee->should_be_visible)
2642 ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root,
2643 ECORE_X_WINDOW_STATE_STICKY, -1, sticky);
2645 _ecore_evas_x_state_update(ee);
2649 _ecore_evas_x_ignore_events_set(Ecore_Evas *ee, int ignore)
2651 if ((ee->ignore_events && ignore) ||
2652 (!ee->ignore_events && !ignore)) return;
2656 ee->ignore_events = 1;
2657 if (ee->prop.window)
2658 ecore_x_window_ignore_set(ee->prop.window, 1);
2662 ee->ignore_events = 0;
2663 if (ee->prop.window)
2664 ecore_x_window_ignore_set(ee->prop.window, 0);
2670 _ecore_evas_x_reinit_win(Ecore_Evas *ee)
2672 if (!strcmp(ee->driver, "software_x11"))
2674 #ifdef BUILD_ECORE_EVAS_X11
2675 Evas_Engine_Info_Software_X11 *einfo;
2677 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
2680 einfo->info.drawable = ee->prop.window;
2681 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2685 else if (!strcmp(ee->driver, "xrender_x11"))
2687 #ifdef BUILD_ECORE_EVAS_XRENDER_X11
2688 Evas_Engine_Info_XRender_X11 *einfo;
2690 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
2693 einfo->info.drawable = ee->prop.window;
2694 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2698 else if (!strcmp(ee->driver, "opengl_x11"))
2700 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
2701 Evas_Engine_Info_GL_X11 *einfo;
2703 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
2706 einfo->info.drawable = ee->prop.window;
2707 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
2715 _ecore_evas_x_override_set(Ecore_Evas *ee, int on)
2717 if (((ee->prop.override) && (on)) ||
2718 ((!ee->prop.override) && (!on))) return;
2719 ecore_x_window_hide(ee->prop.window);
2720 ecore_x_window_override_set(ee->prop.window, on);
2721 if (ee->visible) ecore_x_window_show(ee->prop.window);
2722 if (ee->prop.focused) ecore_x_window_focus(ee->prop.window);
2723 ee->prop.override = on;
2727 _ecore_evas_x_fullscreen_set(Ecore_Evas *ee, int on)
2729 if ((ee->prop.fullscreen && on) ||
2730 (!ee->prop.fullscreen && !on)) return;
2732 /* FIXME: Detect if WM is EWMH compliant and handle properly if not,
2733 * i.e. reposition, resize, and change borderless hint */
2734 ee->engine.x.state.fullscreen = on;
2735 if (ee->should_be_visible)
2736 ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root,
2737 ECORE_X_WINDOW_STATE_FULLSCREEN, -1, on);
2739 _ecore_evas_x_state_update(ee);
2743 _ecore_evas_x_avoid_damage_set(Ecore_Evas *ee, int on)
2745 if (ee->prop.avoid_damage == on) return;
2746 if (!strcmp(ee->driver, "opengl_x11")) return;
2747 if (!strcmp(ee->driver, "xrender_x11")) return;
2749 if (!strcmp(ee->driver, "software_x11"))
2751 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
2752 Evas_Engine_Info_Software_X11 *einfo;
2754 ee->prop.avoid_damage = on;
2755 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
2758 if (ee->prop.avoid_damage)
2760 ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth);
2761 ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL);
2762 einfo->info.drawable = ee->engine.x.pmap;
2763 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2765 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2767 if ((ee->rotation == 90) || (ee->rotation == 270))
2768 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
2770 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2771 if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN)
2773 ee->engine.x.using_bg_pixmap = 1;
2774 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2775 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2777 if (ee->engine.x.direct_resize)
2779 /* Turn this off for now
2780 ee->engine.x.using_bg_pixmap = 1;
2781 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2787 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
2788 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
2789 if (ee->engine.x.using_bg_pixmap)
2791 ecore_x_window_pixmap_set(ee->prop.window, 0);
2792 ee->engine.x.using_bg_pixmap = 0;
2793 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2795 ee->engine.x.pmap = 0;
2796 ee->engine.x.gc = 0;
2797 einfo->info.drawable = ee->prop.window;
2798 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2800 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2804 #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
2806 else if (!strcmp(ee->driver, "software_16_x11"))
2808 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
2809 Evas_Engine_Info_Software_16_X11 *einfo;
2810 ee->prop.avoid_damage = on;
2812 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
2815 if (ee->prop.avoid_damage)
2817 ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 16);
2818 ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL);
2819 einfo->info.drawable = ee->engine.x.pmap;
2820 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2822 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2824 if ((ee->rotation == 90) || (ee->rotation == 270))
2825 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
2827 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2828 if (ee->engine.x.direct_resize)
2830 /* Turn this off for now
2831 ee->engine.x.using_bg_pixmap = 1;
2832 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2838 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
2839 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
2840 if (ee->engine.x.using_bg_pixmap)
2842 ecore_x_window_pixmap_set(ee->prop.window, 0);
2843 ee->engine.x.using_bg_pixmap = 0;
2845 ee->engine.x.pmap = 0;
2846 ee->engine.x.gc = 0;
2847 einfo->info.drawable = ee->prop.window;
2848 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2850 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2854 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
2856 else if (!strcmp(ee->driver, "software_8_x11"))
2858 #if BUILD_ECORE_EVAS_SOFTWARE_8_X11
2859 Evas_Engine_Info_Software_8_X11 *einfo;
2861 ee->prop.avoid_damage = on;
2862 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
2865 if (ee->prop.avoid_damage)
2867 ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth);
2868 ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL);
2869 einfo->info.drawable = ee->engine.x.pmap;
2870 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2872 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2874 if ((ee->rotation == 90) || (ee->rotation == 270))
2875 evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
2877 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
2878 if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN)
2880 ee->engine.x.using_bg_pixmap = 1;
2881 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2882 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2884 if (ee->engine.x.direct_resize)
2886 /* Turn this off for now
2887 ee->engine.x.using_bg_pixmap = 1;
2888 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
2894 if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
2895 if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc);
2896 if (ee->engine.x.using_bg_pixmap)
2898 ecore_x_window_pixmap_set(ee->prop.window, 0);
2899 ee->engine.x.using_bg_pixmap = 0;
2900 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
2902 ee->engine.x.pmap = 0;
2903 ee->engine.x.gc = 0;
2904 einfo->info.drawable = ee->prop.window;
2905 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2907 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2911 #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
2916 _ecore_evas_x_shutdown(void)
2918 _ecore_evas_init_count--;
2919 if (_ecore_evas_init_count == 0)
2923 for (i = 0; i < sizeof(ecore_evas_event_handlers) / sizeof(Ecore_Event_Handler*); i++)
2925 if (ecore_evas_event_handlers[i])
2926 ecore_event_handler_del(ecore_evas_event_handlers[i]);
2928 ecore_event_evas_shutdown();
2930 if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
2931 return _ecore_evas_init_count;
2934 static Ecore_Evas_Engine_Func _ecore_x_engine_func =
2941 _ecore_evas_x_callback_delete_request_set,
2952 _ecore_evas_x_managed_move,
2953 _ecore_evas_x_resize,
2954 _ecore_evas_x_move_resize,
2955 _ecore_evas_x_rotation_set,
2956 _ecore_evas_x_shaped_set,
2959 _ecore_evas_x_raise,
2960 _ecore_evas_x_lower,
2961 _ecore_evas_x_activate,
2962 _ecore_evas_x_title_set,
2963 _ecore_evas_x_name_class_set,
2964 _ecore_evas_x_size_min_set,
2965 _ecore_evas_x_size_max_set,
2966 _ecore_evas_x_size_base_set,
2967 _ecore_evas_x_size_step_set,
2968 _ecore_evas_x_object_cursor_set,
2969 _ecore_evas_x_layer_set,
2970 _ecore_evas_x_focus_set,
2971 _ecore_evas_x_iconified_set,
2972 _ecore_evas_x_borderless_set,
2973 _ecore_evas_x_override_set,
2975 _ecore_evas_x_fullscreen_set,
2976 _ecore_evas_x_avoid_damage_set,
2977 _ecore_evas_x_withdrawn_set,
2978 _ecore_evas_x_sticky_set,
2979 _ecore_evas_x_ignore_events_set,
2980 _ecore_evas_x_alpha_set,
2981 _ecore_evas_x_transparent_set,
2985 #endif /* BUILD_ECORE_EVAS_X11 */
2988 * FIXME: there are some round trips. Especially, we can split
2989 * ecore_x_init in 2 functions and suppress some round trips.
2992 #if defined (BUILD_ECORE_EVAS_SOFTWARE_X11) || defined (BUILD_ECORE_EVAS_OPENGL_X11) || defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) || defined (BUILD_ECORE_EVAS_SOFTWARE_16_X11) || defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
2994 _ecore_evas_x_flush_pre(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
2996 Ecore_Evas *ee = data;
2998 if (ee->no_comp_sync) return;
2999 if (!_ecore_evas_app_comp_sync) return;
3000 if (ee->engine.x.sync_counter)
3002 if (ee->engine.x.sync_began)
3004 ee->engine.x.sync_val++;
3005 if (!ee->engine.x.sync_cancel)
3008 ecore_x_sync_counter_val_wait(ee->engine.x.sync_counter,
3009 ee->engine.x.sync_val);
3016 _ecore_evas_x_flush_post(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
3018 Ecore_Evas *ee = data;
3020 if ((!ee->no_comp_sync) &&
3021 (_ecore_evas_app_comp_sync))
3023 if (ee->engine.x.sync_counter)
3025 if (ee->engine.x.sync_began)
3027 if (!ee->engine.x.sync_cancel)
3029 ecore_x_e_comp_sync_draw_size_done_send
3030 (ee->engine.x.win_root, ee->prop.window, ee->w, ee->h);
3035 if (ee->engine.x.netwm_sync_set)
3037 ecore_x_sync_counter_2_set(ee->engine.x.netwm_sync_counter,
3038 ee->engine.x.netwm_sync_val_hi,
3039 ee->engine.x.netwm_sync_val_lo);
3040 ee->engine.x.netwm_sync_set = 0;
3048 * FIXME: To be fixed.
3050 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
3052 ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent,
3053 int x, int y, int w, int h)
3055 Evas_Engine_Info_Software_X11 *einfo;
3059 static int redraw_debug = -1;
3061 rmethod = evas_render_method_lookup("software_x11");
3062 if (!rmethod) return NULL;
3063 if (!ecore_x_init(disp_name)) return NULL;
3064 ee = calloc(1, sizeof(Ecore_Evas));
3065 if (!ee) return NULL;
3067 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
3069 _ecore_evas_x_init();
3071 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
3073 ee->driver = "software_x11";
3074 if (disp_name) ee->name = strdup(disp_name);
3087 ee->prop.max.w = 32767;
3088 ee->prop.max.h = 32767;
3090 ee->prop.request_pos = 0;
3091 ee->prop.sticky = 0;
3092 ee->engine.x.state.sticky = 0;
3094 /* init evas here */
3095 ee->evas = evas_new();
3096 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _ecore_evas_x_flush_pre, ee);
3097 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_POST, _ecore_evas_x_flush_post, ee);
3098 evas_data_attach_set(ee->evas, ee);
3099 evas_output_method_set(ee->evas, rmethod);
3100 evas_output_size_set(ee->evas, w, h);
3101 evas_output_viewport_set(ee->evas, 0, 0, w, h);
3103 ee->engine.x.win_root = parent;
3104 ee->engine.x.screen_num = 0;
3108 ee->engine.x.screen_num = 1; /* FIXME: get real scren # */
3109 /* FIXME: round trip in ecore_x_window_argb_get */
3110 if (ecore_x_window_argb_get(parent))
3112 ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h);
3116 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
3119 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
3120 if (getenv("DESKTOP_STARTUP_ID"))
3122 ecore_x_netwm_startup_id_set(ee->prop.window,
3123 getenv("DESKTOP_STARTUP_ID"));
3124 /* NB: on linux this may simply empty the env as opposed to completely
3125 * unset it to being empty - unsure as solartis libc crashes looking
3126 * for the '=' char */
3127 // putenv((char*)"DESKTOP_STARTUP_ID=");
3129 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas);
3132 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
3133 xcb_screen_iterator_t iter;
3134 xcb_screen_t *screen;
3137 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
3139 /* FIXME: this is inefficient as its a round trip */
3140 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
3141 screen = ecore_x_default_screen_get();
3142 iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get()));
3145 xcb_get_geometry_cookie_t cookie;
3146 xcb_get_geometry_reply_t *reply;
3147 Ecore_X_Window *roots;
3152 cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent);
3153 roots = ecore_x_window_root_list(&num);
3156 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
3160 for (i = 0; i < num; xcb_screen_next (&iter), i++)
3162 if (reply->root == roots[i])
3174 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
3175 if (reply) free(reply);
3179 screen = DefaultScreen(ecore_x_display_get());
3180 if (ScreenCount(ecore_x_display_get()) > 1)
3182 Ecore_X_Window *roots;
3186 roots = ecore_x_window_root_list(&num);
3189 XWindowAttributes at;
3191 if (XGetWindowAttributes(ecore_x_display_get(),
3194 for (i = 0; i < num; i++)
3196 if (at.root == roots[i])
3206 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
3208 if (redraw_debug < 0)
3210 if (getenv("REDRAW_DEBUG"))
3211 redraw_debug = atoi(getenv("REDRAW_DEBUG"));
3215 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
3216 einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB;
3217 einfo->info.connection = ecore_x_connection_get();
3218 einfo->info.screen = screen;
3220 einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB;
3221 einfo->info.connection = ecore_x_display_get();
3222 einfo->info.screen = NULL;
3223 #ifdef EVAS_FRAME_QUEUING
3226 render_mode = getenv("EVAS_RENDER_MODE");
3227 if (render_mode && !strcmp(render_mode, "non-blocking"))
3229 einfo->render_mode = EVAS_RENDER_MODE_NONBLOCKING;
3234 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
3235 einfo->info.drawable = ee->prop.window;
3238 /* FIXME: round trip */
3239 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
3240 xcb_get_geometry_cookie_t cookie_geom;
3241 xcb_get_window_attributes_cookie_t cookie_attr;
3242 xcb_get_geometry_reply_t *reply_geom;
3243 xcb_get_window_attributes_reply_t *reply_attr;
3245 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
3246 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
3248 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
3249 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
3250 if (reply_attr && reply_geom)
3252 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
3253 einfo->info.colormap = reply_attr->colormap;
3254 einfo->info.depth = reply_geom->depth;
3255 einfo->info.destination_alpha = 1;
3260 XWindowAttributes at;
3262 if (XGetWindowAttributes(ecore_x_display_get(), ee->prop.window,
3265 einfo->info.visual = at.visual;
3266 einfo->info.colormap = at.colormap;
3267 einfo->info.depth = at.depth;
3268 einfo->info.destination_alpha = 1;
3270 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
3274 # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
3275 xcb_screen_t *screen;
3277 screen = ecore_x_default_screen_get();
3278 einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual);
3279 einfo->info.colormap = screen->default_colormap;
3280 einfo->info.depth = screen->root_depth;
3282 einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen);
3283 einfo->info.colormap = DefaultColormap(ecore_x_display_get(), screen);
3284 einfo->info.depth = DefaultDepth(ecore_x_display_get(), screen);
3285 # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */
3286 einfo->info.destination_alpha = 0;
3288 einfo->info.rotation = 0;
3289 einfo->info.debug = redraw_debug;
3290 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
3292 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
3293 ecore_evas_free(ee);
3298 ecore_x_icccm_hints_set(ee->prop.window,
3299 1 /* accepts_focus */,
3300 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
3301 0 /* icon_pixmap */,
3303 0 /* icon_window */,
3304 0 /* window_group */,
3306 _ecore_evas_x_group_leader_set(ee);
3307 ecore_x_window_defaults_set(ee->prop.window);
3308 _ecore_evas_x_protocols_set(ee);
3309 _ecore_evas_x_sync_set(ee);
3311 ee->engine.func->fn_render = _ecore_evas_x_render;
3312 _ecore_evas_register(ee);
3313 ecore_x_input_multi_select(ee->prop.window);
3314 ecore_event_window_register(ee->prop.window, ee, ee->evas,
3315 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
3316 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
3317 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
3318 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
3323 ecore_evas_software_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
3324 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
3333 * FIXME: To be fixed.
3335 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
3337 ecore_evas_software_x11_window_get(const Ecore_Evas *ee)
3339 return (Ecore_X_Window) ecore_evas_window_get(ee);
3343 ecore_evas_software_x11_window_get(const Ecore_Evas *ee __UNUSED__)
3352 * FIXME: To be fixed.
3354 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
3356 ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on)
3358 ee->engine.x.direct_resize = on;
3359 if (ee->prop.avoid_damage)
3361 if (ee->engine.x.direct_resize)
3363 /* turn this off for now
3364 ee->engine.x.using_bg_pixmap = 1;
3365 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
3370 /* turn this off too- bg pixmap is controlled by avoid damage directly
3371 ee->engine.x.using_bg_pixmap = 0;
3372 ecore_x_window_pixmap_set(ee->prop.window, 0);
3373 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
3380 ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__)
3388 * FIXME: To be fixed.
3390 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
3392 ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee)
3394 return ee->engine.x.direct_resize;
3398 ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
3407 * FIXME: To be fixed.
3409 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
3411 ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
3413 Ecore_X_Window *winp;
3415 winp = malloc(sizeof(Ecore_X_Window));
3419 ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp);
3420 ecore_x_input_multi_select(win);
3421 ecore_event_window_register(win, ee, ee->evas,
3422 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
3423 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
3424 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
3425 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
3430 ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
3438 * FIXME: To be fixed.
3440 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3442 ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent,
3443 int x, int y, int w, int h)
3445 return ecore_evas_gl_x11_options_new(disp_name, parent, x, y, w, h, NULL);
3448 ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent,
3449 int x, int y, int w, int h, const int *opt)
3451 # ifdef HAVE_ECORE_X_XCB
3452 Ecore_Evas *ee = NULL;
3457 rmethod = evas_render_method_lookup("gl_x11");
3458 if (!rmethod) return NULL;
3459 if (!ecore_x_init(disp_name)) return NULL;
3460 ee = calloc(1, sizeof(Ecore_Evas));
3461 if (!ee) return NULL;
3463 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
3465 _ecore_evas_x_init();
3467 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
3469 ee->driver = "opengl_x11";
3470 ee->semi_sync = 1; // gl engine doesnt need to sync - its whole swaps
3471 // ee->no_comp_sync = 1; // gl engine doesnt need to sync - its whole swaps
3472 if (disp_name) ee->name = strdup(disp_name);
3485 ee->prop.max.w = 32767;
3486 ee->prop.max.h = 32767;
3488 ee->prop.request_pos = 0;
3489 ee->prop.sticky = 0;
3490 ee->engine.x.state.sticky = 0;
3492 /* init evas here */
3493 ee->evas = evas_new();
3494 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _ecore_evas_x_flush_pre, ee);
3495 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_POST, _ecore_evas_x_flush_post, ee);
3496 evas_data_attach_set(ee->evas, ee);
3497 evas_output_method_set(ee->evas, rmethod);
3498 evas_output_size_set(ee->evas, w, h);
3499 evas_output_viewport_set(ee->evas, 0, 0, w, h);
3501 if (parent == 0) parent = DefaultRootWindow(ecore_x_display_get());
3502 ee->engine.x.win_root = parent;
3504 if (ee->engine.x.win_root != 0)
3506 ee->engine.x.screen_num = 1; /* FIXME: get real scren # */
3507 /* FIXME: round trip in ecore_x_window_argb_get */
3508 if (ecore_x_window_argb_get(ee->engine.x.win_root))
3510 ee->prop.window = _ecore_evas_x_gl_window_new
3511 (ee, ee->engine.x.win_root, x, y, w, h, 0, 1, opt);
3514 ee->prop.window = _ecore_evas_x_gl_window_new
3515 (ee, ee->engine.x.win_root, x, y, w, h, 0, 0, opt);
3518 ee->prop.window = _ecore_evas_x_gl_window_new
3519 (ee, ee->engine.x.win_root, x, y, w, h, 0, 0, opt);
3520 if (!ee->prop.window)
3522 ecore_evas_free(ee);
3525 if (getenv("DESKTOP_STARTUP_ID"))
3527 ecore_x_netwm_startup_id_set(ee->prop.window,
3528 getenv("DESKTOP_STARTUP_ID"));
3529 /* NB: on linux this may simply empty the env as opposed to completely
3530 * unset it to being empty - unsure as solartis libc crashes looking
3531 * for the '=' char */
3532 // putenv((char*)"DESKTOP_STARTUP_ID=");
3535 ecore_x_icccm_hints_set(ee->prop.window,
3536 1 /* accepts_focus */,
3537 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
3538 0 /* icon_pixmap */,
3540 0 /* icon_window */,
3541 0 /* window_group */,
3543 _ecore_evas_x_group_leader_set(ee);
3544 ecore_x_window_defaults_set(ee->prop.window);
3545 _ecore_evas_x_protocols_set(ee);
3546 _ecore_evas_x_sync_set(ee);
3548 ee->engine.func->fn_render = _ecore_evas_x_render;
3549 _ecore_evas_register(ee);
3550 ecore_x_input_multi_select(ee->prop.window);
3551 ecore_event_window_register(ee->prop.window, ee, ee->evas,
3552 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
3553 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
3554 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
3555 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
3556 # endif /* HAVE_ECORE_X_XCB */
3562 ecore_evas_gl_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
3563 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
3568 ecore_evas_gl_x11_options_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
3569 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__, const int *opt __UNUSED__)
3573 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3578 * FIXME: To be fixed.
3580 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3582 ecore_evas_gl_x11_window_get(const Ecore_Evas *ee)
3584 return (Ecore_X_Window) ecore_evas_window_get(ee);
3588 ecore_evas_gl_x11_window_get(const Ecore_Evas *ee __UNUSED__)
3592 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3597 * FIXME: To be fixed.
3599 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3601 ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on)
3603 ee->engine.x.direct_resize = on;
3607 ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__)
3610 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3615 * FIXME: To be fixed.
3617 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3619 ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee)
3621 return ee->engine.x.direct_resize;
3625 ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
3629 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3634 * FIXME: To be fixed.
3636 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3638 ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
3640 ecore_evas_software_x11_extra_event_window_add(ee, win);
3644 ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
3647 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3652 * FIXME: To be fixed.
3654 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
3656 ecore_evas_gl_x11_pre_post_swap_callback_set(const Ecore_Evas *ee, void *data, void (*pre_cb) (void *data, Evas *e), void (*post_cb) (void *data, Evas *e))
3658 Evas_Engine_Info_GL_X11 *einfo;
3660 if (!(!strcmp(ee->driver, "opengl_x11"))) return;
3662 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas);
3665 einfo->callback.pre_swap = pre_cb;
3666 einfo->callback.pre_swap = post_cb;
3667 einfo->callback.data = data;
3668 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
3670 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
3676 ecore_evas_gl_x11_pre_post_swap_callback_set(const Ecore_Evas *ee __UNUSED__, void *data __UNUSED__, void (*pre_cb) (void *data, Evas *e) __UNUSED__, void (*post_cb) (void *data, Evas *e) __UNUSED__)
3680 #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */
3685 * FIXME: To be fixed.
3687 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
3689 ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent,
3690 int x, int y, int w, int h)
3692 Evas_Engine_Info_XRender_X11 *einfo;
3696 rmethod = evas_render_method_lookup("xrender_x11");
3697 if (!rmethod) return NULL;
3698 if (!ecore_x_init(disp_name)) return NULL;
3699 ee = calloc(1, sizeof(Ecore_Evas));
3700 if (!ee) return NULL;
3702 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
3704 _ecore_evas_x_init();
3706 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
3708 ee->driver = "xrender_x11";
3709 if (disp_name) ee->name = strdup(disp_name);
3722 ee->prop.max.w = 32767;
3723 ee->prop.max.h = 32767;
3725 ee->prop.request_pos = 0;
3726 ee->prop.sticky = 0;
3727 ee->engine.x.state.sticky = 0;
3729 /* init evas here */
3730 ee->evas = evas_new();
3731 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _ecore_evas_x_flush_pre, ee);
3732 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_POST, _ecore_evas_x_flush_post, ee);
3733 evas_data_attach_set(ee->evas, ee);
3734 evas_output_method_set(ee->evas, rmethod);
3735 evas_output_size_set(ee->evas, w, h);
3736 evas_output_viewport_set(ee->evas, 0, 0, w, h);
3738 ee->engine.x.win_root = parent;
3739 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
3740 if (getenv("DESKTOP_STARTUP_ID"))
3742 ecore_x_netwm_startup_id_set(ee->prop.window,
3743 getenv("DESKTOP_STARTUP_ID"));
3744 /* NB: on linux this may simply empty the env as opposed to completely
3745 * unset it to being empty - unsure as solartis libc crashes looking
3746 * for the '=' char */
3747 // putenv((char*)"DESKTOP_STARTUP_ID=");
3749 einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas);
3752 # ifdef BUILD_ECORE_EVAS_XRENDER_XCB
3753 xcb_screen_iterator_t iter;
3754 xcb_screen_t *screen;
3756 /* FIXME: this is inefficient as its a round trip */
3757 screen = ecore_x_default_screen_get();
3758 iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get()));
3761 xcb_get_geometry_cookie_t cookie;
3762 xcb_get_geometry_reply_t *reply;
3763 Ecore_X_Window *roots;
3768 cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent);
3769 roots = ecore_x_window_root_list(&num);
3772 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
3776 for (i = 0; i < num; xcb_screen_next (&iter), i++)
3778 if (reply->root == roots[i])
3790 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
3791 if (reply) free(reply);
3794 einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XCB;
3795 einfo->info.connection = ecore_x_connection_get();
3796 einfo->info.screen = screen;
3797 einfo->info.visual = screen->root_visual;
3798 # elif BUILD_ECORE_EVAS_XRENDER_X11
3801 /* FIXME: this is inefficient as its a round trip */
3802 screen = DefaultScreen(ecore_x_display_get());
3803 if (ScreenCount(ecore_x_display_get()) > 1)
3805 Ecore_X_Window *roots;
3809 roots = ecore_x_window_root_list(&num);
3812 XWindowAttributes at;
3814 if (XGetWindowAttributes(ecore_x_display_get(),
3817 for (i = 0; i < num; i++)
3819 if (at.root == roots[i])
3829 einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XLIB;
3830 einfo->info.connection = ecore_x_display_get();
3831 einfo->info.screen = NULL;
3832 einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen);
3833 # endif /* BUILD_ECORE_EVAS_XRENDER_(XCB|X11) */
3834 einfo->info.drawable = ee->prop.window;
3835 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
3837 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
3838 ecore_evas_free(ee);
3843 ecore_x_icccm_hints_set(ee->prop.window,
3844 1 /* accepts_focus */,
3845 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
3846 0 /* icon_pixmap */,
3848 0 /* icon_window */,
3849 0 /* window_group */,
3851 _ecore_evas_x_group_leader_set(ee);
3852 ecore_x_window_defaults_set(ee->prop.window);
3853 _ecore_evas_x_protocols_set(ee);
3854 _ecore_evas_x_sync_set(ee);
3856 ee->engine.func->fn_render = _ecore_evas_x_render;
3857 _ecore_evas_register(ee);
3858 ecore_x_input_multi_select(ee->prop.window);
3859 ecore_event_window_register(ee->prop.window, ee, ee->evas,
3860 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
3861 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
3862 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
3863 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
3868 ecore_evas_xrender_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
3869 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
3873 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
3878 * FIXME: To be fixed.
3880 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
3882 ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee)
3884 return (Ecore_X_Window) ecore_evas_window_get(ee);
3888 ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee __UNUSED__)
3892 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
3897 * FIXME: To be fixed.
3899 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
3901 ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on)
3903 ee->engine.x.direct_resize = on;
3907 ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__)
3910 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
3915 * FIXME: To be fixed.
3917 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
3919 ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee)
3921 return ee->engine.x.direct_resize;
3925 ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
3929 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
3934 * FIXME: To be fixed.
3936 #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB)
3938 ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
3940 ecore_evas_software_x11_extra_event_window_add(ee, win);
3944 ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
3947 #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */
3952 * FIXME: To be fixed.
3954 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
3956 ecore_evas_software_x11_16_new(const char *disp_name, Ecore_X_Window parent,
3957 int x, int y, int w, int h)
3959 Evas_Engine_Info_Software_16_X11 *einfo;
3962 static int redraw_debug = -1;
3964 rmethod = evas_render_method_lookup("software_16_x11");
3965 if (!rmethod) return NULL;
3966 if (!ecore_x_init(disp_name)) return NULL;
3967 ee = calloc(1, sizeof(Ecore_Evas));
3968 if (!ee) return NULL;
3970 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
3972 _ecore_evas_x_init();
3974 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
3976 ee->driver = "software_16_x11";
3977 if (disp_name) ee->name = strdup(disp_name);
3990 ee->prop.max.w = 32767;
3991 ee->prop.max.h = 32767;
3993 ee->prop.request_pos = 0;
3994 ee->prop.sticky = 0;
3995 ee->engine.x.state.sticky = 0;
3997 /* init evas here */
3998 ee->evas = evas_new();
3999 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _ecore_evas_x_flush_pre, ee);
4000 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_POST, _ecore_evas_x_flush_post, ee);
4001 evas_data_attach_set(ee->evas, ee);
4002 evas_output_method_set(ee->evas, rmethod);
4003 evas_output_size_set(ee->evas, w, h);
4004 evas_output_viewport_set(ee->evas, 0, 0, w, h);
4006 ee->engine.x.win_root = parent;
4009 /* FIXME: round trip in ecore_x_window_argb_get */
4010 if (ecore_x_window_argb_get(parent))
4012 ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h);
4015 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
4018 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
4019 if (getenv("DESKTOP_STARTUP_ID"))
4021 ecore_x_netwm_startup_id_set(ee->prop.window,
4022 getenv("DESKTOP_STARTUP_ID"));
4023 /* NB: on linux this may simply empty the env as opposed to completely
4024 * unset it to being empty - unsure as solartis libc crashes looking
4025 * for the '=' char */
4026 // putenv((char*)"DESKTOP_STARTUP_ID=");
4028 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas);
4032 if (ScreenCount(ecore_x_display_get()) > 1)
4034 Ecore_X_Window *roots;
4038 roots = ecore_x_window_root_list(&num);
4041 XWindowAttributes at;
4043 if (XGetWindowAttributes(ecore_x_display_get(),
4046 for (i = 0; i < num; i++)
4048 if (at.root == roots[i])
4056 if (redraw_debug < 0)
4058 if (getenv("REDRAW_DEBUG"))
4059 redraw_debug = atoi(getenv("REDRAW_DEBUG"));
4063 einfo->info.display = ecore_x_display_get();
4064 einfo->info.drawable = ee->prop.window;
4066 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
4068 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
4069 ecore_evas_free(ee);
4074 ecore_x_icccm_hints_set(ee->prop.window,
4075 1 /* accepts_focus */,
4076 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
4077 0 /* icon_pixmap */,
4079 0 /* icon_window */,
4080 0 /* window_group */,
4082 _ecore_evas_x_group_leader_set(ee);
4083 ecore_x_window_defaults_set(ee->prop.window);
4084 _ecore_evas_x_protocols_set(ee);
4085 _ecore_evas_x_sync_set(ee);
4087 ee->engine.func->fn_render = _ecore_evas_x_render;
4088 _ecore_evas_register(ee);
4089 ecore_x_input_multi_select(ee->prop.window);
4090 ecore_event_window_register(ee->prop.window, ee, ee->evas,
4091 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
4092 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
4093 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
4094 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
4099 ecore_evas_software_x11_16_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__,
4100 int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
4104 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
4109 * FIXME: To be fixed.
4111 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
4113 ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee)
4115 return (Ecore_X_Window) ecore_evas_window_get(ee);
4119 ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee __UNUSED__)
4123 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
4128 * FIXME: To be fixed.
4130 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
4132 ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, Eina_Bool on)
4134 ee->engine.x.direct_resize = on;
4135 if (ee->prop.avoid_damage)
4137 if (ee->engine.x.direct_resize)
4139 /* turn this off for now
4140 ee->engine.x.using_bg_pixmap = 1;
4141 ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap);
4146 /* turn this off too- bg pixmap is controlled by avoid damage directly
4147 ee->engine.x.using_bg_pixmap = 0;
4148 ecore_x_window_pixmap_set(ee->prop.window, 0);
4149 ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h);
4156 ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__)
4159 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
4164 * FIXME: To be fixed.
4166 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
4168 ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee)
4170 return ee->engine.x.direct_resize;
4174 ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee __UNUSED__)
4178 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
4183 * FIXME: To be fixed.
4185 #if BUILD_ECORE_EVAS_SOFTWARE_16_X11
4187 ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
4189 Ecore_X_Window *winp;
4191 winp = malloc(sizeof(Ecore_X_Window));
4195 ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp);
4196 ecore_x_input_multi_select(win);
4197 ecore_event_window_register(win, ee, ee->evas,
4198 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
4199 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
4200 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
4201 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
4206 ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_X_Window win __UNUSED__)
4209 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
4215 * FIXME: To be fixed.
4218 ecore_evas_software_x11_8_new(const char *disp_name, Ecore_X_Window parent,
4219 int x, int y, int w, int h)
4221 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4222 Evas_Engine_Info_Software_8_X11 *einfo;
4226 static int redraw_debug = -1;
4228 rmethod = evas_render_method_lookup("software_8_x11");
4229 if (!rmethod) return NULL;
4230 if (!ecore_x_init(disp_name)) return NULL;
4231 ee = calloc(1, sizeof(Ecore_Evas));
4232 if (!ee) return NULL;
4234 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
4236 _ecore_evas_x_init();
4238 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_x_engine_func;
4240 ee->driver = "software_8_x11";
4241 if (disp_name) ee->name = strdup(disp_name);
4254 ee->prop.max.w = 32767;
4255 ee->prop.max.h = 32767;
4257 ee->prop.request_pos = 0;
4258 ee->prop.sticky = 0;
4259 ee->engine.x.state.sticky = 0;
4261 /* init evas here */
4262 ee->evas = evas_new();
4263 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_PRE, _ecore_evas_x_flush_pre, ee);
4264 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_FLUSH_POST, _ecore_evas_x_flush_post, ee);
4265 evas_data_attach_set(ee->evas, ee);
4266 evas_output_method_set(ee->evas, rmethod);
4267 evas_output_size_set(ee->evas, w, h);
4268 evas_output_viewport_set(ee->evas, 0, 0, w, h);
4270 ee->engine.x.win_root = parent;
4273 // /* FIXME: round trip in ecore_x_window_argb_get */
4274 // if (ecore_x_window_argb_get(parent))
4276 // ee->engine.x.win = ecore_x_window_argb_new(parent, x, y, w, h);
4280 // ee->engine.x.win = ecore_x_window_new(parent, x, y, w, h);
4283 ee->prop.window = ecore_x_window_new(parent, x, y, w, h);
4284 if (getenv("DESKTOP_STARTUP_ID"))
4286 ecore_x_netwm_startup_id_set(ee->prop.window,
4287 getenv("DESKTOP_STARTUP_ID"));
4288 /* NB: on linux this may simply empty the env as opposed to completely
4289 * unset it to being empty - unsure as solartis libc crashes looking
4290 * for the '=' char */
4291 // putenv((char*)"DESKTOP_STARTUP_ID=");
4293 einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas);
4296 xcb_screen_iterator_t iter;
4297 xcb_screen_t *screen;
4299 /* FIXME: this is inefficient as its a round trip */
4300 //einfo->info.backend = 1;
4301 screen = ecore_x_default_screen_get();
4302 iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get()));
4305 xcb_get_geometry_cookie_t cookie;
4306 xcb_get_geometry_reply_t *reply;
4307 Ecore_X_Window *roots;
4312 cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent);
4313 roots = ecore_x_window_root_list(&num);
4316 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
4320 for (i = 0; i < num; xcb_screen_next (&iter), i++)
4322 if (reply->root == roots[i])
4334 reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL);
4335 if (reply) free(reply);
4339 if (redraw_debug < 0)
4341 if (getenv("REDRAW_DEBUG"))
4342 redraw_debug = atoi(getenv("REDRAW_DEBUG"));
4346 einfo->info.connection = ecore_x_connection_get();
4347 einfo->info.screen = screen;
4348 einfo->info.drawable = ee->prop.window;
4351 /* FIXME: round trip */
4352 xcb_get_geometry_cookie_t cookie_geom;
4353 xcb_get_window_attributes_cookie_t cookie_attr;
4354 xcb_get_geometry_reply_t *reply_geom;
4355 xcb_get_window_attributes_reply_t *reply_attr;
4357 cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window);
4358 cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window);
4360 reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL);
4361 reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL);
4362 if (reply_attr && reply_geom)
4364 einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual);
4365 einfo->info.colormap = reply_attr->colormap;
4366 einfo->info.depth = reply_geom->depth;
4367 einfo->info.destination_alpha = 1;
4374 xcb_screen_t *screen;
4376 screen = ecore_x_default_screen_get();
4377 einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual);
4378 einfo->info.colormap = screen->default_colormap;
4379 einfo->info.depth = screen->root_depth;
4380 einfo->info.destination_alpha = 0;
4382 einfo->info.rotation = 0;
4383 einfo->info.debug = redraw_debug;
4384 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
4386 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
4387 ecore_evas_free(ee);
4392 ecore_x_icccm_hints_set(ee->prop.window,
4393 1 /* accepts_focus */,
4394 ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */,
4395 0 /* icon_pixmap */,
4397 0 /* icon_window */,
4398 0 /* window_group */,
4400 _ecore_evas_x_group_leader_set(ee);
4401 ecore_x_window_defaults_set(ee->prop.window);
4402 _ecore_evas_x_protocols_set(ee);
4403 _ecore_evas_x_sync_set(ee);
4405 ee->engine.func->fn_render = _ecore_evas_x_render;
4406 _ecore_evas_register(ee);
4407 ecore_x_input_multi_select(ee->prop.window);
4408 ecore_event_window_register(ee->prop.window, ee, ee->evas,
4409 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
4410 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
4411 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
4412 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
4423 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_8_X11 */
4429 * FIXME: To be fixed.
4432 ecore_evas_software_x11_8_window_get(const Ecore_Evas *ee)
4434 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4435 return (Ecore_X_Window) ecore_evas_window_get(ee);
4445 * FIXME: To be fixed.
4448 ecore_evas_software_x11_8_subwindow_get(const Ecore_Evas *ee)
4450 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4451 return (Ecore_X_Window) ecore_evas_window_get(ee);
4461 * FIXME: To be fixed.
4464 ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, Eina_Bool on)
4466 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4467 ee->engine.x.direct_resize = on;
4468 if (ee->prop.avoid_damage)
4470 if (ee->engine.x.direct_resize)
4472 /* turn this off for now
4473 ee->engine.x.using_bg_pixmap = 1;
4474 ecore_x_window_pixmap_set(ee->engine.x.win, ee->engine.x.pmap);
4479 /* turn this off too- bg pixmap is controlled by avoid damage directly
4480 ee->engine.x.using_bg_pixmap = 0;
4481 ecore_x_window_pixmap_set(ee->engine.x.win, 0);
4482 ecore_x_window_area_expose(ee->engine.x.win, 0, 0, ee->w, ee->h);
4496 * FIXME: To be fixed.
4499 ecore_evas_software_x11_8_direct_resize_get(const Ecore_Evas *ee)
4501 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4502 return ee->engine.x.direct_resize;
4512 * FIXME: To be fixed.
4515 ecore_evas_software_x11_8_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win)
4517 #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11)
4518 Ecore_X_Window *winp;
4520 winp = malloc(sizeof(Ecore_X_Window));
4524 ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp);
4525 ecore_x_input_multi_select(win);
4526 ecore_event_window_register(win, ee, ee->evas,
4527 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
4528 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
4529 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
4530 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
4540 ecore_evas_x11_leader_set(Ecore_Evas *ee, Ecore_X_Window win)
4542 #ifdef BUILD_ECORE_EVAS_X11
4543 _ecore_evas_x_group_leader_unset(ee);
4544 ee->engine.x.leader = win;
4545 _ecore_evas_x_group_leader_update(ee);
4554 ecore_evas_x11_leader_get(Ecore_Evas *ee)
4556 #ifdef BUILD_ECORE_EVAS_X11
4557 return ee->engine.x.leader;
4565 ecore_evas_x11_leader_default_set(Ecore_Evas *ee)
4567 #ifdef BUILD_ECORE_EVAS_X11
4568 _ecore_evas_x_group_leader_unset(ee);
4569 _ecore_evas_x_group_leader_set(ee);
4576 #ifdef BUILD_ECORE_EVAS_X11
4578 _ecore_evas_x11_convert_rectangle_with_angle(Ecore_Evas *ee, Ecore_X_Rectangle *dst_rect, Ecore_X_Rectangle *src_rect)
4580 if (!src_rect || !dst_rect) return 0;
4582 if (ee->rotation == 0)
4584 dst_rect->x = src_rect->x;
4585 dst_rect->y = src_rect->y;
4586 dst_rect->width = src_rect->width;
4587 dst_rect->height = src_rect->height;
4589 else if (ee->rotation == 90)
4591 dst_rect->x = src_rect->y;
4592 dst_rect->y = ee->req.h - src_rect->x - src_rect->width;
4593 dst_rect->width = src_rect->height;
4594 dst_rect->height = src_rect->width;
4596 else if (ee->rotation == 180)
4598 dst_rect->x = ee->req.w - src_rect->x - src_rect->width;
4599 dst_rect->y = ee->req.h - src_rect->y - src_rect->height;
4600 dst_rect->width = src_rect->width;
4601 dst_rect->height = src_rect->height;
4603 else if (ee->rotation == 270)
4605 dst_rect->x = ee->req.w - src_rect->y - src_rect->height;
4606 dst_rect->y = src_rect->x;
4607 dst_rect->width = src_rect->height;
4608 dst_rect->height = src_rect->width;
4620 ecore_evas_x11_shape_input_rectangle_set(Ecore_Evas *ee, int x, int y, int w, int h)
4622 #ifdef BUILD_ECORE_EVAS_X11
4624 Ecore_X_Rectangle src_rect;
4625 Ecore_X_Rectangle dst_rect;
4627 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4629 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4630 "ecore_evas_x11_shape_input_rectangle_set");
4637 src_rect.height = h;
4639 ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect);
4641 if (!ee->engine.x.win_shaped_input)
4642 ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1);
4645 ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height);
4657 ecore_evas_x11_shape_input_rectangle_add(Ecore_Evas *ee, int x, int y, int w, int h)
4659 #ifdef BUILD_ECORE_EVAS_X11
4661 Ecore_X_Rectangle src_rect;
4662 Ecore_X_Rectangle dst_rect;
4664 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4666 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4667 "ecore_evas_x11_shape_input_rectangle_add");
4674 src_rect.height = h;
4676 ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect);
4678 if (!ee->engine.x.win_shaped_input)
4679 ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1);
4682 ecore_x_window_shape_input_rectangle_add(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height);
4694 ecore_evas_x11_shape_input_rectangle_subtract(Ecore_Evas *ee, int x, int y, int w, int h)
4696 #ifdef BUILD_ECORE_EVAS_X11
4698 Ecore_X_Rectangle src_rect;
4699 Ecore_X_Rectangle dst_rect;
4701 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4703 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4704 "ecore_evas_x11_shape_input_rectangle_subtract");
4711 src_rect.height = h;
4713 ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect);
4715 if (!ee->engine.x.win_shaped_input)
4716 ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1);
4719 ecore_x_window_shape_input_rectangle_subtract(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height);
4731 ecore_evas_x11_shape_input_empty(Ecore_Evas *ee)
4733 #ifdef BUILD_ECORE_EVAS_X11
4734 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4736 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4737 "ecore_evas_x11_shape_input_empty");
4741 if (!ee->engine.x.win_shaped_input)
4742 ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1);
4744 ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, 0, 0, 0, 0);
4752 ecore_evas_x11_shape_input_reset(Ecore_Evas *ee)
4754 #ifdef BUILD_ECORE_EVAS_X11
4755 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4757 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4758 "ecore_evas_x11_shape_input_reset");
4762 if (!ee->engine.x.win_shaped_input)
4763 ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1);
4765 ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, 0, 0, 65535, 65535);
4773 ecore_evas_x11_shape_input_apply(Ecore_Evas *ee)
4775 #ifdef BUILD_ECORE_EVAS_X11
4776 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
4778 ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
4779 "ecore_evas_x11_shape_input_apply");
4783 if (!ee->engine.x.win_shaped_input) return;
4785 ecore_x_window_shape_input_window_set(ee->prop.window, ee->engine.x.win_shaped_input);