1c3cbb4dcb56dd22001a466b0cf63254c9be2f27
[profile/ivi/ecore.git] / src / lib / ecore_evas / ecore_evas_wince.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <stdlib.h> /* for NULL */
6
7 #include <Ecore.h>
8 #include "ecore_private.h"
9 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
10 # define WIN32_LEAN_AND_MEAN
11 # include <windows.h>
12 # undef WIN32_LEAN_AND_MEAN
13 # include <Ecore_WinCE.h>
14 # include <ecore_wince_private.h>
15 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_WINCE */
16
17 #include "ecore_evas_private.h"
18 #include "Ecore_Evas.h"
19
20 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
21
22 #define ECORE_EVAS_EVENT_COUNT 7
23
24 static int _ecore_evas_init_count = 0;
25
26 static Ecore_Event_Handler *ecore_evas_event_handlers[ECORE_EVAS_EVENT_COUNT];
27
28 static Eina_Bool _ecore_evas_wince_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
29
30 static Eina_Bool _ecore_evas_wince_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
31
32 static Eina_Bool _ecore_evas_wince_event_window_damage(void *data __UNUSED__, int type __UNUSED__, void *event);
33
34 static Eina_Bool _ecore_evas_wince_event_window_destroy(void *data __UNUSED__, int type __UNUSED__, void *event);
35
36 static Eina_Bool _ecore_evas_wince_event_window_show(void *data __UNUSED__, int type __UNUSED__, void *event);
37
38 static Eina_Bool _ecore_evas_wince_event_window_hide(void *data __UNUSED__, int type __UNUSED__, void *event);
39
40 static Eina_Bool _ecore_evas_wince_event_window_delete_request(void *data __UNUSED__, int type __UNUSED__, void *event);
41
42 /* Private functions */
43
44 static int
45 _ecore_evas_wince_render(Ecore_Evas *ee)
46 {
47    int rend = 0;
48    Eina_List *updates = NULL;
49 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
50    Eina_List *ll;
51    Ecore_Evas *ee2;
52
53    EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
54      {
55         if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
56         rend |= _ecore_evas_buffer_render(ee2);
57         if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
58      }
59 #endif
60    if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
61    if (ee->prop.avoid_damage)
62      {
63         updates = evas_render_updates(ee->evas);
64         if (updates) evas_render_updates_free(updates);
65      }
66    else if ((ee->visible) ||
67             ((ee->should_be_visible) && (ee->prop.fullscreen)) ||
68             ((ee->should_be_visible) && (ee->prop.override)))
69      {
70         if (ee->shaped)
71           {
72              updates = evas_render_updates(ee->evas);
73              if (updates) evas_render_updates_free(updates);
74           }
75         else
76           {
77              updates = evas_render_updates(ee->evas);
78              if (updates) evas_render_updates_free(updates);
79           }
80      }
81    else
82      evas_norender(ee->evas);
83    if (updates) rend = 1;
84    if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
85    return rend;
86 }
87
88 static int
89 _ecore_evas_wince_init(void)
90 {
91    _ecore_evas_init_count++;
92    if (_ecore_evas_init_count > 1)
93      return _ecore_evas_init_count;
94    
95    ecore_evas_event_handlers[0]  = ecore_event_handler_add(ECORE_WINCE_EVENT_MOUSE_IN, _ecore_evas_wince_event_mouse_in, NULL);
96    ecore_evas_event_handlers[1]  = ecore_event_handler_add(ECORE_WINCE_EVENT_MOUSE_OUT, _ecore_evas_wince_event_mouse_out, NULL);
97    ecore_evas_event_handlers[2]  = ecore_event_handler_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, _ecore_evas_wince_event_window_damage, NULL);
98    ecore_evas_event_handlers[3]  = ecore_event_handler_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, _ecore_evas_wince_event_window_destroy, NULL);
99    ecore_evas_event_handlers[4]  = ecore_event_handler_add(ECORE_WINCE_EVENT_WINDOW_SHOW, _ecore_evas_wince_event_window_show, NULL);
100    ecore_evas_event_handlers[5]  = ecore_event_handler_add(ECORE_WINCE_EVENT_WINDOW_HIDE, _ecore_evas_wince_event_window_hide, NULL);
101    ecore_evas_event_handlers[6]  = ecore_event_handler_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, _ecore_evas_wince_event_window_delete_request, NULL);
102
103    ecore_event_evas_init();
104    return _ecore_evas_init_count;
105 }
106
107 int
108 _ecore_evas_wince_shutdown(void)
109 {
110    _ecore_evas_init_count--;
111    if (_ecore_evas_init_count == 0)
112      {
113         int i;
114
115         for (i = 0; i < ECORE_EVAS_EVENT_COUNT; i++)
116           ecore_event_handler_del(ecore_evas_event_handlers[i]);
117         ecore_event_evas_shutdown();
118      }
119
120    if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
121
122    return _ecore_evas_init_count;
123 }
124
125 static Eina_Bool
126 _ecore_evas_wince_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
127 {
128    Ecore_Evas                 *ee;
129    Ecore_WinCE_Event_Mouse_In *e;
130
131    INF("mouse in");
132
133    e = event;
134    ee = ecore_event_window_match((Ecore_Window)e->window);
135    if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
136    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
137
138    if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
139    /* FIXME to do */
140 /*    _ecore_evas_x_modifier_locks_update(ee, e->modifiers); */
141    evas_event_feed_mouse_in(ee->evas, e->time, NULL);
142    _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
143
144    return 1;
145 }
146
147 static Eina_Bool
148 _ecore_evas_wince_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
149 {
150    Ecore_Evas                  *ee;
151    Ecore_WinCE_Event_Mouse_Out *e;
152
153    INF("mouse out");
154
155    e = event;
156    ee = ecore_event_window_match((Ecore_Window)e->window);
157    if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
158    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
159
160    /* FIXME to do */
161 /*    _ecore_evas_x_modifier_locks_update(ee, e->modifiers); */
162    _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
163
164    evas_event_feed_mouse_out(ee->evas, e->time, NULL);
165    if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
166    if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
167
168    return 1;
169 }
170
171 static Eina_Bool
172 _ecore_evas_wince_event_window_damage(void *data __UNUSED__, int type __UNUSED__, void *event)
173 {
174    Ecore_Evas                      *ee;
175    Ecore_WinCE_Event_Window_Damage *e;
176
177    INF("window damage");
178
179    e = event;
180    ee = ecore_event_window_match((Ecore_Window)e->window);
181    if (!ee) return 1; /* pass on event */
182    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
183
184    if (ee->prop.avoid_damage)
185      {
186 #warning [ECORE] [WINCE] No Region code
187      }
188    else
189      {
190         if (ee->rotation == 0)
191           evas_damage_rectangle_add(ee->evas,
192                                     e->x,
193                                     e->y,
194                                     e->width,
195                                     e->height);
196         else if (ee->rotation == 90)
197           evas_damage_rectangle_add(ee->evas,
198                                     ee->h - e->y - e->height,
199                                     e->x,
200                                     e->height,
201                                     e->width);
202         else if (ee->rotation == 180)
203           evas_damage_rectangle_add(ee->evas,
204                                     ee->w - e->x - e->width,
205                                     ee->h - e->y - e->height,
206                                     e->width,
207                                     e->height);
208         else if (ee->rotation == 270)
209           evas_damage_rectangle_add(ee->evas,
210                                     e->y,
211                                     ee->w - e->x - e->width,
212                                     e->height,
213                                     e->width);
214      }
215
216    return 1;
217 }
218
219 static Eina_Bool
220 _ecore_evas_wince_event_window_destroy(void *data __UNUSED__, int type __UNUSED__, void *event)
221 {
222    Ecore_Evas                       *ee;
223    Ecore_WinCE_Event_Window_Destroy *e;
224
225    INF("window destroy");
226
227    e = event;
228    ee = ecore_event_window_match((Ecore_Window)e->window);
229    if (!ee) return 1; /* pass on event */
230    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
231    if (ee->func.fn_destroy) ee->func.fn_destroy(ee);
232    ecore_evas_free(ee);
233
234    return 1;
235 }
236
237 static Eina_Bool
238 _ecore_evas_wince_event_window_show(void *data __UNUSED__, int type __UNUSED__, void *event)
239 {
240    Ecore_Evas                    *ee;
241    Ecore_WinCE_Event_Window_Show *e;
242
243    INF("window show");
244
245    e = event;
246    ee = ecore_event_window_match((Ecore_Window)e->window);
247    if (!ee) return 1; /* pass on event */
248    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
249    if (ee->visible) return 0; /* dont pass it on */
250    ee->visible = 1;
251    if (ee->func.fn_show) ee->func.fn_show(ee);
252
253    return 1;
254 }
255
256 static Eina_Bool
257 _ecore_evas_wince_event_window_hide(void *data __UNUSED__, int type __UNUSED__, void *event)
258 {
259    Ecore_Evas                    *ee;
260    Ecore_WinCE_Event_Window_Hide *e;
261
262    INF("window hide");
263
264    e = event;
265    ee = ecore_event_window_match((Ecore_Window)e->window);
266    if (!ee) return 1; /* pass on event */
267    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
268    if (!ee->visible) return 0; /* dont pass it on */
269    ee->visible = 0;
270    if (ee->func.fn_hide) ee->func.fn_hide(ee);
271
272    return 1;
273 }
274
275 static Eina_Bool
276 _ecore_evas_wince_event_window_delete_request(void *data __UNUSED__, int type __UNUSED__, void *event)
277 {
278    Ecore_Evas                              *ee;
279    Ecore_WinCE_Event_Window_Delete_Request *e;
280
281    INF("window delete request");
282
283    e = event;
284    ee = ecore_event_window_match((Ecore_Window)e->window);
285    if (!ee) return 1; /* pass on event */
286    if (e->window != (Ecore_WinCE_Window *)ee->prop.window) return 1;
287    if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee);
288
289    return 1;
290 }
291
292
293 /* Ecore_Evas interface */
294
295 static void
296 _ecore_evas_wince_free(Ecore_Evas *ee)
297 {
298    INF("ecore evas free");
299
300    ecore_wince_window_free((Ecore_WinCE_Window *)ee->prop.window);
301    ecore_event_window_unregister(ee->prop.window);
302    _ecore_evas_wince_shutdown();
303    ecore_wince_shutdown();
304 }
305
306 static void
307 _ecore_evas_wince_callback_delete_request_set(Ecore_Evas *ee,
308                                               void (*func) (Ecore_Evas *ee))
309 {
310    ee->func.fn_delete_request = func;
311 }
312
313 static void
314 _ecore_evas_wince_move(Ecore_Evas *ee, int x, int y)
315 {
316   INF("ecore evas move (%dx%d)", x, y);
317
318    if ((x != ee->x) || (y != ee->y))
319      {
320         ee->x = x;
321         ee->y = y;
322         ecore_wince_window_move((Ecore_WinCE_Window *)ee->prop.window, x, y);
323         if (ee->func.fn_move) ee->func.fn_move(ee);
324      }
325 }
326
327 static void
328 _ecore_evas_wince_resize(Ecore_Evas *ee, int width, int height)
329 {
330    INF("ecore evas resize (%dx%d)", width, height);
331
332    if ((ee->w != width) || (ee->h != height))
333      {
334         ee->w = width;
335         ee->h = height;
336         ecore_wince_window_resize((Ecore_WinCE_Window *)ee->prop.window, width, height);
337         if ((ee->rotation == 90) || (ee->rotation == 270))
338           {
339              evas_output_size_set(ee->evas, ee->h, ee->w);
340              evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
341           }
342         else
343           {
344              evas_output_size_set(ee->evas, ee->w, ee->h);
345              evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
346           }
347         /* FIXME: damage and shape */
348
349         if (ee->func.fn_resize) ee->func.fn_resize(ee);
350      }
351 }
352
353 static void
354 _ecore_evas_wince_move_resize(Ecore_Evas *ee, int x, int y, int width, int height)
355 {
356    INF("ecore evas resize (%dx%d %dx%d)", x, y, width, height);
357
358    if ((ee->w != width) || (ee->h != height) || (x != ee->x) || (y != ee->y))
359      {
360         int change_size = 0;
361         int change_pos = 0;
362
363         if ((ee->w != width) || (ee->h != height)) change_size = 1;
364         if ((x != ee->x) || (y != ee->y)) change_pos = 1;
365
366         ee->x = x;
367         ee->y = y;
368         ee->w = width;
369         ee->h = height;
370         ecore_wince_window_move_resize((Ecore_WinCE_Window *)ee->prop.window, x, y, width, height);
371         if ((ee->rotation == 90) || (ee->rotation == 270))
372           {
373              evas_output_size_set(ee->evas, ee->h, ee->w);
374              evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
375           }
376         else
377           {
378              evas_output_size_set(ee->evas, ee->w, ee->h);
379              evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
380           }
381         /* FIXME: damage and shape */
382         if (change_pos)
383           {
384              if (ee->func.fn_move) ee->func.fn_move(ee);
385           }
386         if (change_size)
387           {
388              if (ee->func.fn_resize) ee->func.fn_resize(ee);
389           }
390      }
391 }
392
393 /* static void */
394 /* _ecore_evas_wince_rotation_set(Ecore_Evas *ee, int rotation) */
395 /* { */
396 /*    int rot_dif; */
397
398 /*    if (ee->rotation == rotation) return; */
399 /*    rot_dif = ee->rotation - rotation; */
400 /*    if (rot_dif < 0) rot_dif = -rot_dif; */
401 /*    if (!strcmp(ee->driver, "software_ddraw")) */
402 /*      { */
403 /*      Evas_Engine_Info_Software_16_WinCE *einfo; */
404
405 /*      einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(ee->evas); */
406 /*      if (!einfo) return; */
407 /*      if (rot_dif != 180) */
408 /*        { */
409 /*           int minw, minh, maxw, maxh, basew, baseh, stepw, steph; */
410
411 /*           einfo->info.rotation = rotation; */
412 /*           evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */
413 /*           if (!ee->prop.fullscreen) */
414 /*             { */
415 /*                ecore_wince_window_resize(ee->prop.window, ee->h, ee->w); */
416 /*                ee->expecting_resize.w = ee->h; */
417 /*                ee->expecting_resize.h = ee->w; */
418 /*             } */
419 /*           else */
420 /*             { */
421 /*                int w, h; */
422
423 /*                ecore_wince_window_size_get(ee->prop.window, &w, &h); */
424 /*                ecore_wince_window_resize(ee->prop.window, h, w); */
425 /*                if ((rotation == 0) || (rotation == 180)) */
426 /*                  { */
427 /*                     evas_output_size_set(ee->evas, ee->w, ee->h); */
428 /*                     evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); */
429 /*                  } */
430 /*                else */
431 /*                  { */
432 /*                     evas_output_size_set(ee->evas, ee->h, ee->w); */
433 /*                     evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); */
434 /*                  } */
435 /*                if (ee->func.fn_resize) ee->func.fn_resize(ee); */
436 /*             } */
437 /*           ecore_evas_size_min_get(ee, &minw, &minh); */
438 /*           ecore_evas_size_max_get(ee, &maxw, &maxh); */
439 /*           ecore_evas_size_base_get(ee, &basew, &baseh); */
440 /*           ecore_evas_size_step_get(ee, &stepw, &steph); */
441 /*           ee->rotation = rotation; */
442 /*           ecore_evas_size_min_set(ee, minh, minw); */
443 /*           ecore_evas_size_max_set(ee, maxh, maxw); */
444 /*           ecore_evas_size_base_set(ee, baseh, basew); */
445 /*           ecore_evas_size_step_set(ee, steph, stepw); */
446 /*           _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */
447 /*                                                   ecore_wince_current_time_get()); */
448 /*        } */
449 /*      else */
450 /*        { */
451 /*           einfo->info.rotation = rotation; */
452 /*           evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */
453 /*           ee->rotation = rotation; */
454 /*           _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */
455 /*                                                   ecore_wince_current_time_get()); */
456 /*           if (ee->func.fn_resize) ee->func.fn_resize(ee); */
457 /*        } */
458 /*      if ((ee->rotation == 90) || (ee->rotation == 270)) */
459 /*        evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); */
460 /*      else */
461 /*        evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); */
462 /*      } */
463 /* } */
464
465 static void
466 _ecore_evas_wince_show(Ecore_Evas *ee)
467 {
468    INF("ecore evas show");
469
470    ee->should_be_visible = 1;
471    if (ee->prop.avoid_damage)
472      _ecore_evas_wince_render(ee);
473    ecore_wince_window_show((Ecore_WinCE_Window *)ee->prop.window);
474 /*    if (ee->prop.fullscreen) */
475 /*      ecore_wince_window_focus(ee->prop.window); */
476 }
477
478 static void
479 _ecore_evas_wince_hide(Ecore_Evas *ee)
480 {
481    INF("ecore evas hide");
482
483    ecore_wince_window_hide((Ecore_WinCE_Window *)ee->prop.window);
484    ee->should_be_visible = 0;
485 }
486
487 /* static void */
488 /* _ecore_evas_wince_raise(Ecore_Evas *ee) */
489 /* { */
490 /*    if (!ee->prop.fullscreen) */
491 /*      ecore_wince_window_raise(ee->prop.window); */
492 /*    else */
493 /*      ecore_wince_window_raise(ee->prop.window); */
494 /* } */
495
496 /* static void */
497 /* _ecore_evas_wince_lower(Ecore_Evas *ee) */
498 /* { */
499 /*    if (!ee->prop.fullscreen) */
500 /*      ecore_wince_window_lower(ee->prop.window); */
501 /*    else */
502 /*      ecore_wince_window_lower(ee->prop.window); */
503 /* } */
504
505 static void
506 _ecore_evas_wince_title_set(Ecore_Evas *ee, const char *title)
507 {
508    INF("ecore evas title set");
509
510    if (ee->prop.title) free(ee->prop.title);
511    ee->prop.title = NULL;
512    if (title) ee->prop.title = strdup(title);
513    ecore_wince_window_title_set((Ecore_WinCE_Window *)ee->prop.window, ee->prop.title);
514 }
515
516 /* static void */
517 /* _ecore_evas_wince_size_min_set(Ecore_Evas *ee, int width, int height) */
518 /* { */
519 /*    if (width < 0) width = 0; */
520 /*    if (height < 0) height = 0; */
521 /*    if ((ee->prop.min.w == width) && (ee->prop.min.h == height)) return; */
522 /*    ee->prop.min.w = width; */
523 /*    ee->prop.min.h = height; */
524 /*    ecore_wince_window_size_min_set(ee->prop.window, width, height); */
525 /* } */
526
527 /* static void */
528 /* _ecore_evas_wince_size_max_set(Ecore_Evas *ee, int width, int height) */
529 /* { */
530 /*    if (width < 0) width = 0; */
531 /*    if (height < 0) height = 0; */
532 /*    if ((ee->prop.max.w == width) && (ee->prop.max.h == height)) return; */
533 /*    ee->prop.max.w = width; */
534 /*    ee->prop.max.h = height; */
535 /*    ecore_wince_window_size_max_set(ee->prop.window, width, height); */
536 /* } */
537
538 /* static void */
539 /* _ecore_evas_wince_size_base_set(Ecore_Evas *ee, int width, int height) */
540 /* { */
541 /*    if (width < 0) width = 0; */
542 /*    if (height < 0) height = 0; */
543 /*    if ((ee->prop.base.w == width) && (ee->prop.base.h == height)) return; */
544 /*    ee->prop.base.w = width; */
545 /*    ee->prop.base.h = height; */
546 /*    ecore_wince_window_size_base_set(ee->prop.window, width, height); */
547 /* } */
548
549 /* static void */
550 /* _ecore_evas_wince_size_step_set(Ecore_Evas *ee, int width, int height) */
551 /* { */
552 /*    if (width < 1) width = 1; */
553 /*    if (height < 1) height = 1; */
554 /*    if ((ee->prop.step.w == width) && (ee->prop.step.h == height)) return; */
555 /*    ee->prop.step.w = width; */
556 /*    ee->prop.step.h = height; */
557 /*    ecore_wince_window_size_step_set(ee->prop.window, width, height); */
558 /* } */
559
560 static void
561 _ecore_evas_wince_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
562 {
563 #if 0
564    int x, y;
565
566    if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
567
568    if (obj == NULL)
569      {
570         ee->prop.cursor.object = NULL;
571         ee->prop.cursor.layer = 0;
572         ee->prop.cursor.hot.x = 0;
573         ee->prop.cursor.hot.y = 0;
574         ecore_wince_window_cursor_show(ee->prop.window, 1);
575         return;
576      }
577
578    ee->prop.cursor.object = obj;
579    ee->prop.cursor.layer = layer;
580    ee->prop.cursor.hot.x = hot_x;
581    ee->prop.cursor.hot.y = hot_y;
582
583    ecore_wince_window_cursor_show(ee->prop.window, 0);
584
585    evas_pointer_output_xy_get(ee->evas, &x, &y);
586    evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
587    evas_object_move(ee->prop.cursor.object,
588                     x - ee->prop.cursor.hot.x,
589                     y - ee->prop.cursor.hot.y);
590    evas_object_pass_events_set(ee->prop.cursor.object, 1);
591    if (evas_pointer_inside_get(ee->evas))
592      evas_object_show(ee->prop.cursor.object);
593 #endif
594 }
595
596 /* static void */
597 /* _ecore_evas_wince_focus_set(Ecore_Evas *ee, int on __UNUSED__) */
598 /* { */
599 /*    ecore_wince_window_focus_set(ee->prop.window); */
600 /* } */
601
602 /* static void */
603 /* _ecore_evas_wince_iconified_set(Ecore_Evas *ee, int on) */
604 /* { */
605 /* /\*    if (((ee->prop.borderless) && (on)) || *\/ */
606 /* /\*        ((!ee->prop.borderless) && (!on))) return; *\/ */
607 /*    ee->prop.iconified = on; */
608 /*    ecore_wince_window_iconified_set(ee->prop.window, ee->prop.iconified); */
609 /* } */
610
611 /* static void */
612 /* _ecore_evas_wince_borderless_set(Ecore_Evas *ee, int on) */
613 /* { */
614 /*    if (((ee->prop.borderless) && (on)) || */
615 /*        ((!ee->prop.borderless) && (!on))) return; */
616 /*    ee->prop.borderless = on; */
617 /*    ecore_wince_window_borderless_set(ee->prop.window, ee->prop.borderless); */
618 /* } */
619
620 static void
621 _ecore_evas_wince_fullscreen_set(Ecore_Evas *ee, int on)
622 {
623    Evas_Engine_Info_Software_16_WinCE *einfo;
624    struct _Ecore_WinCE_Window         *window;
625
626    INF("ecore evas fullscreen set");
627
628    if ((ee->engine.wince.state.fullscreen && on) ||
629       (!ee->engine.wince.state.fullscreen && !on))
630      return;
631
632    ee->engine.wince.state.fullscreen = on;
633    ee->prop.fullscreen = on;
634
635    window = (struct _Ecore_WinCE_Window *)ee->prop.window;
636
637    if (on != 0)
638    {
639 /*       ecore_win32_window_shape_set(ee->engine.win32.window, 0, 0, NULL); */
640       ecore_wince_window_fullscreen_set((Ecore_WinCE_Window *)ee->prop.window, on);
641       ee->w = GetSystemMetrics(SM_CXSCREEN);
642       ee->h = GetSystemMetrics(SM_CYSCREEN);
643       evas_output_size_set(ee->evas, ee->w, ee->h);
644       evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
645    }
646    else
647    {
648       int w;
649       int h;
650
651       ecore_wince_window_fullscreen_set((Ecore_WinCE_Window *)ee->prop.window, on);
652       ecore_wince_window_size_get((Ecore_WinCE_Window *)ee->prop.window, &w, &h);
653       ee->w = w;
654       ee->h = h;
655       evas_output_size_set(ee->evas, ee->w, ee->h);
656       evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
657 /*       ecore_win32_window_shape_set(window, */
658 /*                                    window->shape.width, */
659 /*                                    window->shape.height, */
660 /*                                    window->shape.mask); */
661    }
662
663    einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(ecore_evas_get(ee));
664    if (einfo)
665      {
666         einfo->info.fullscreen = !!on;
667 /*         einfo->info.layered = window->shape.layered; */
668         evas_engine_info_set(ecore_evas_get(ee), (Evas_Engine_Info *)einfo);
669      }
670 }
671
672 static Ecore_Evas_Engine_Func _ecore_wince_engine_func =
673 {
674    _ecore_evas_wince_free,
675    NULL,
676    NULL,
677    NULL,
678    NULL,
679    _ecore_evas_wince_callback_delete_request_set,
680    NULL,
681    NULL,
682    NULL,
683    NULL,
684    NULL,
685    NULL,
686    NULL,
687    NULL,
688    NULL,
689    _ecore_evas_wince_move,
690    NULL,
691    _ecore_evas_wince_resize,
692    _ecore_evas_wince_move_resize,
693    NULL, //_ecore_evas_wince_rotation_set,
694    NULL, /* _ecore_evas_x_shaped_set */
695    _ecore_evas_wince_show,
696    _ecore_evas_wince_hide,
697    NULL, //_ecore_evas_wince_raise,
698    NULL, //_ecore_evas_wince_lower,
699    NULL, //_ecore_evas_wince_activate,
700    _ecore_evas_wince_title_set,
701    NULL, /* _ecore_evas_x_name_class_set */
702    NULL, //_ecore_evas_wince_size_min_set,
703    NULL, //_ecore_evas_wince_size_max_set,
704    NULL, //_ecore_evas_wince_size_base_set,
705    NULL, //_ecore_evas_wince_size_step_set,
706    _ecore_evas_wince_cursor_set,
707    NULL, /* _ecore_evas_x_layer_set */
708    NULL, //_ecore_evas_wince_focus_set,
709    NULL, //_ecore_evas_wince_iconified_set,
710    NULL, //_ecore_evas_wince_borderless_set,
711    NULL, /* _ecore_evas_x_override_set */
712    NULL,
713    _ecore_evas_wince_fullscreen_set,
714    NULL, /* _ecore_evas_x_avoid_damage_set */
715    NULL, /* _ecore_evas_x_withdrawn_set */
716    NULL, /* _ecore_evas_x_sticky_set */
717    NULL, /* _ecore_evas_x_ignore_events_set */
718    NULL, /* _ecore_evas_x_alpha_set */
719    NULL, //transparent
720      
721      NULL // render
722 };
723
724 /* API */
725
726 static Ecore_Evas *
727 ecore_evas_software_wince_new_internal(int                 backend,
728                                        Ecore_WinCE_Window *parent,
729                                        int                 x,
730                                        int                 y,
731                                        int                 width,
732                                        int                 height,
733                                        int                 fullscreen)
734 {
735    Evas_Engine_Info_Software_16_WinCE *einfo;
736    Ecore_Evas                         *ee;
737    int                                 rmethod;
738
739    rmethod = evas_render_method_lookup("software_16_wince");
740    if (!rmethod)
741      return NULL;
742
743    if (!ecore_wince_init())
744      return NULL;
745
746    ee = calloc(1, sizeof(Ecore_Evas));
747    if (!ee)
748      {
749         ecore_wince_shutdown();
750         return NULL;
751      }
752
753    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
754
755    if (!_ecore_evas_wince_init())
756      {
757         free(ee);
758         ecore_wince_shutdown();
759         return NULL;
760      }
761
762    ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wince_engine_func;
763
764    ee->driver = "software_16_wince";
765
766    if (width < 1) width = 1;
767    if (height < 1) height = 1;
768    ee->x = x;
769    ee->y = y;
770    ee->w = width;
771    ee->h = height;
772
773    ee->prop.max.w = 32767;
774    ee->prop.max.h = 32767;
775    ee->prop.layer = 4;
776    ee->prop.request_pos = 0;
777    ee->prop.sticky = 0;
778    /* FIXME: sticky to add */
779
780    ee->prop.window = (Ecore_Window)ecore_wince_window_new((Ecore_WinCE_Window *)parent, x, y, width, height);
781    if (!ee->prop.window)
782      {
783         _ecore_evas_wince_shutdown();
784         free(ee);
785         ecore_wince_shutdown();
786         return NULL;
787      }
788
789    ecore_wince_window_fullscreen_set((Ecore_WinCE_Window *)ee->prop.window, fullscreen);
790
791    /* init evas here */
792    ee->evas = evas_new();
793    evas_data_attach_set(ee->evas, ee);
794    evas_output_method_set(ee->evas, rmethod);
795    evas_output_size_set(ee->evas, width, height);
796    evas_output_viewport_set(ee->evas, 0, 0, width, height);
797
798    einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(ee->evas);
799    if (einfo)
800      {
801         /* FIXME: REDRAW_DEBUG missing for now */
802         einfo->info.window = ((struct _Ecore_WinCE_Window *)ee->prop.window)->window;
803         einfo->info.width = width;
804         einfo->info.height = height;
805         einfo->info.backend = backend;
806         einfo->info.rotation = 0;
807         einfo->info.fullscreen = fullscreen;
808         evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
809
810         ecore_wince_window_backend_set((Ecore_WinCE_Window *)ee->prop.window, backend);
811         ecore_wince_window_suspend_set((Ecore_WinCE_Window *)ee->prop.window, einfo->func.suspend);
812         ecore_wince_window_resume_set((Ecore_WinCE_Window *)ee->prop.window, einfo->func.resume);
813      }
814
815    ee->engine.func->fn_render = _ecore_evas_wince_render;
816    _ecore_evas_register(ee);
817    ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process);
818    evas_focus_in(ee->evas);
819
820    return ee;
821 }
822
823 #else
824
825 static Ecore_Evas *
826 ecore_evas_software_wince_new_internal(int                 backend __UNUSED__,
827                                        Ecore_WinCE_Window *parent __UNUSED__,
828                                        int                 x __UNUSED__,
829                                        int                 y __UNUSED__,
830                                        int                 width __UNUSED__,
831                                        int                 height __UNUSED__,
832                                        int                 fullscreen __UNUSED__)
833 {
834    return NULL;
835 }
836
837 #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_WINCE */
838
839
840 EAPI Ecore_Evas *
841 ecore_evas_software_wince_new(Ecore_WinCE_Window *parent,
842                               int                 x,
843                               int                 y,
844                               int                 width,
845                               int                 height)
846 {
847    return ecore_evas_software_wince_new_internal(0, parent, x, y, width, height, 1);
848 }
849
850 EAPI Ecore_Evas *
851 ecore_evas_software_wince_fb_new(Ecore_WinCE_Window *parent,
852                                  int                 x,
853                                  int                 y,
854                                  int                 width,
855                                  int                 height)
856 {
857    return ecore_evas_software_wince_new_internal(1, parent, x, y, width, height, 1);
858 }
859
860 EAPI Ecore_Evas *
861 ecore_evas_software_wince_gapi_new(Ecore_WinCE_Window *parent,
862                                    int                 x,
863                                    int                 y,
864                                    int                 width,
865                                    int                 height)
866 {
867    return ecore_evas_software_wince_new_internal(2, parent, x, y, width, height, 1);
868 }
869
870 EAPI Ecore_Evas *
871 ecore_evas_software_wince_ddraw_new(Ecore_WinCE_Window *parent,
872                                     int                 x,
873                                     int                 y,
874                                     int                 width,
875                                     int                 height)
876 {
877    return ecore_evas_software_wince_new_internal(3, parent, x, y, width, height, 1);
878 }
879
880 EAPI Ecore_Evas *
881 ecore_evas_software_wince_gdi_new(Ecore_WinCE_Window *parent,
882                                   int                 x,
883                                   int                 y,
884                                   int                 width,
885                                   int                 height)
886 {
887    return ecore_evas_software_wince_new_internal(4, parent, x, y, width, height, 0);
888 }
889
890 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
891
892 EAPI Ecore_WinCE_Window *
893 ecore_evas_software_wince_window_get(const Ecore_Evas *ee)
894 {
895    return (Ecore_WinCE_Window *) ecore_evas_window_get(ee);
896 }
897
898 #else
899
900 EAPI Ecore_WinCE_Window *
901 ecore_evas_software_wince_window_get(const Ecore_Evas *ee __UNUSED__)
902 {
903    return NULL;
904 }
905
906 #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_WINCE */