[ecore] merged svn latest code (svn54830)
[profile/ivi/ecore.git] / src / lib / ecore_win32 / ecore_win32_window.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <stdlib.h>
6 #include <stdio.h>   /* for printf */
7
8 #define WIN32_LEAN_AND_MEAN
9 #include <windows.h>
10 #undef WIN32_LEAN_AND_MEAN
11
12 #include <Eina.h>
13
14 #include "Ecore_Win32.h"
15 #include "ecore_win32_private.h"
16
17 /*============================================================================*
18  *                                  Local                                     *
19  *============================================================================*/
20
21 /**
22  * @cond LOCAL
23  */
24
25
26 typedef enum _Ecore_Win32_Window_Z_Order Ecore_Win32_Window_Z_Order;
27 enum _Ecore_Win32_Window_Z_Order
28 {
29   ECORE_WIN32_WINDOW_Z_ORDER_BOTTOM,
30   ECORE_WIN32_WINDOW_Z_ORDER_NOTOPMOST,
31   ECORE_WIN32_WINDOW_Z_ORDER_TOP,
32   ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST
33 };
34
35 static Ecore_Win32_Window *
36 ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
37                                 int                 x,
38                                 int                 y,
39                                 int                 width,
40                                 int                 height,
41                                 DWORD               style)
42 {
43    RECT                        rect;
44    struct _Ecore_Win32_Window *w;
45    int                         minimal_width;
46    int                         minimal_height;
47
48    w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window));
49    if (!w)
50      {
51         ERR("malloc() failed");
52         return NULL;
53      }
54
55    rect.left = 0;
56    rect.top = 0;
57    rect.right = width;
58    rect.bottom = height;
59    if (!AdjustWindowRect(&rect, style, FALSE))
60      {
61         ERR("AdjustWindowRect() failed");
62         free(w);
63         return NULL;
64      }
65
66    minimal_width = GetSystemMetrics(SM_CXMIN);
67    minimal_height = GetSystemMetrics(SM_CYMIN);
68 /*    if (((rect.right - rect.left) < minimal_width) || */
69 /*        ((rect.bottom - rect.top) < minimal_height)) */
70 /*      { */
71 /*         fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */
72 /*         fprintf (stderr, "                Wrong size %ld\n", rect.right - rect.left); */
73 /*         free(w); */
74 /*         return NULL; */
75 /*      } */
76    if ((rect.right - rect.left) < minimal_width)
77      {
78        rect.right = rect.left + minimal_width;
79      }
80
81    w->window = CreateWindowEx(0,
82                               ECORE_WIN32_WINDOW_CLASS, "",
83                               style,
84                               x, y,
85                               rect.right - rect.left,
86                               rect.bottom - rect.top,
87                               parent ? ((struct _Ecore_Win32_Window *)parent)->window : NULL,
88                               NULL, _ecore_win32_instance, NULL);
89    if (!w->window)
90      {
91         ERR("CreateWindowEx() failed");
92         free(w);
93         return NULL;
94      }
95
96    SetLastError(0);
97    if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0))
98      {
99         ERR("SetWindowLongPtr() failed");
100         DestroyWindow(w->window);
101         free(w);
102         return NULL;
103      }
104
105    w->min_width   = 0;
106    w->min_height  = 0;
107    w->max_width   = 32767;
108    w->max_height  = 32767;
109    w->base_width  = -1;
110    w->base_height = -1;
111    w->step_width  = -1;
112    w->step_height = -1;
113
114    w->state.iconified         = 0;
115    w->state.modal             = 0;
116    w->state.sticky            = 0;
117    w->state.maximized_vert    = 0;
118    w->state.maximized_horz    = 0;
119    w->state.shaded            = 0;
120    w->state.hidden            = 0;
121    w->state.fullscreen        = 0;
122    w->state.above             = 0;
123    w->state.below             = 0;
124    w->state.demands_attention = 0;
125
126    w->type.desktop = 0;
127    w->type.dock    = 0;
128    w->type.toolbar = 0;
129    w->type.menu    = 0;
130    w->type.utility = 0;
131    w->type.splash  = 0;
132    w->type.dialog  = 0;
133    w->type.normal  = 0;
134
135    w->pointer_is_in = 0;
136    w->borderless    = 0;
137    w->iconified     = 0;
138    w->fullscreen    = 0;
139
140    return w;
141 }
142
143 /**
144  * @endcond
145  */
146
147
148 /*============================================================================*
149  *                                 Global                                     *
150  *============================================================================*/
151
152 /*============================================================================*
153  *                                   API                                      *
154  *============================================================================*/
155
156 /**
157  * @addtogroup Ecore_Win32_Group Ecore_Win32 library
158  *
159  * @{
160  */
161
162 /**
163  * @brief Creates a new window.
164  *
165  * @param parent The parent window.
166  * @param x The x coordinate of the top-left corner of the window.
167  * @param y The y coordinate of the top-left corner of the window.
168  * @param width The width of the window.
169  * @param height The height of hte window.
170  * @return A newly allocated window.
171  *
172  * This function creates a new window which parent is @p parent. @p width and
173  * @p height are the size of the window content (the client part),
174  * without the border and title bar. @p x and @p y are the system
175  * coordinates of the top left cerner of the window (that is, of the
176  * title bar). This function returns a newly created window on
177  * success, and @c NULL on failure.
178  */
179 EAPI Ecore_Win32_Window *
180 ecore_win32_window_new(Ecore_Win32_Window *parent,
181                        int                 x,
182                        int                 y,
183                        int                 width,
184                        int                 height)
185 {
186    INF("creating window with border");
187
188    return ecore_win32_window_internal_new(parent,
189                                           x, y,
190                                           width, height,
191                                           WS_OVERLAPPEDWINDOW | WS_SIZEBOX);
192 }
193
194 /**
195  * @brief Creates a new borderless window.
196  *
197  * @param parent The parent window.
198  * @param x The x coordinate of the top-left corner of the window.
199  * @param y The y coordinate of the top-left corner of the window.
200  * @param width The width of the window.
201  * @param height The height of hte window.
202  * @return A newly allocated window.
203  *
204  * This function is the same than ecore_win32_window_override_new()
205  * but the returned window is borderless.
206  */
207 EAPI Ecore_Win32_Window *
208 ecore_win32_window_override_new(Ecore_Win32_Window *parent,
209                                 int                 x,
210                                 int                 y,
211                                 int                 width,
212                                 int                 height)
213 {
214    INF("creating window without border");
215
216    return ecore_win32_window_internal_new(parent,
217                                           x, y,
218                                           width, height,
219                                           WS_POPUP);
220 }
221
222 /**
223  * @brief Free the given window.
224  *
225  * @param window The window to free.
226  *
227  * This function frees @p window. If @p window is @c NULL, this
228  * function does nothing.
229  */
230 EAPI void
231 ecore_win32_window_free(Ecore_Win32_Window *window)
232 {
233    struct _Ecore_Win32_Window *wnd = window;
234
235    if (!window) return;
236
237    INF("destroying window");
238
239    if (wnd->shape.mask)
240       free(wnd->shape.mask);
241
242    DestroyWindow(((struct _Ecore_Win32_Window *)window)->window);
243    free(window);
244 }
245
246 /**
247  * @brief Return the window HANDLE associated to the given window.
248  *
249  * @param window The window to retrieve the HANDLE from.
250  *
251  * This function returns the window HANDLE associated to @p window. If
252  * @p window is @c NULL, this function returns @c NULL.
253  */
254 EAPI void *
255 ecore_win32_window_hwnd_get(Ecore_Win32_Window *window)
256 {
257    if (!window) return NULL;
258
259    return ((struct _Ecore_Win32_Window *)window)->window;
260 }
261
262 /*
263 void
264 ecore_win32_window_configure(Ecore_Win32_Window        *window,
265                              Ecore_Win32_Window_Z_Order order,
266                              int                        x,
267                              int                        y,
268                              int                        width,
269                              int                        height)
270 {
271   HWND w;
272
273   switch (order)
274     {
275     case ECORE_WIN32_WINDOW_Z_ORDER_BOTTOM:
276       w = HWND_BOTTOM;
277       break;
278     case ECORE_WIN32_WINDOW_Z_ORDER_NOTOPMOST:
279       w = HWND_NOTOPMOST;
280       break;
281     case ECORE_WIN32_WINDOW_Z_ORDER_TOP:
282       w = HWND_TOP;
283       break;
284     case ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST:
285       w = HWND_TOPMOST;
286       break;
287     default:
288       return;
289     }
290   SetWindowPos((struct _Ecore_Win32_Window *)window->window, w, x, y, width, height, ???);
291 }
292 */
293
294 /**
295  * @brief Move the given window to a given position.
296  *
297  * @param window The window to move.
298  * @param x The x coordinate of the destination position.
299  * @param y The y coordinate of the destination position.
300  *
301  * This function move @p window to the new position of coordinates @p x
302  * and @p y. If @p window is @c NULL, or if it is fullscreen, or on
303  * error, this function does nothing.
304  */
305 EAPI void
306 ecore_win32_window_move(Ecore_Win32_Window *window,
307                         int                 x,
308                         int                 y)
309 {
310    RECT rect;
311    HWND w;
312
313    /* FIXME: on fullscreen, should not move it */
314    if (!window) return;
315
316    INF("moving window (%dx%d)", x, y);
317
318    w = ((struct _Ecore_Win32_Window *)window)->window;
319    if (!GetWindowRect(w, &rect))
320      {
321         ERR("GetWindowRect() failed");
322         return;
323      }
324
325    if (!MoveWindow(w, x, y,
326                    rect.right - rect.left,
327                    rect.bottom - rect.top,
328                    TRUE))
329      {
330         ERR("MoveWindow() failed");
331      }
332 }
333
334 /**
335  * @brief Resize the given window to a given size.
336  *
337  * @param window The window to resize.
338  * @param width The new width.
339  * @param height The new height.
340  *
341  * This function resize @p window to the new @p width and @p height.
342  * If @p window is @c NULL, or if it is fullscreen, or on error, this
343  * function does nothing.
344  */
345 EAPI void
346 ecore_win32_window_resize(Ecore_Win32_Window *window,
347                           int                 width,
348                           int                 height)
349 {
350    RECT                        rect;
351    struct _Ecore_Win32_Window *w;
352    DWORD                       style;
353    int                         x;
354    int                         y;
355
356    /* FIXME: on fullscreen, should not resize it */
357    if (!window) return;
358
359    INF("resizing window (%dx%d)", width, height);
360
361    w = (struct _Ecore_Win32_Window *)window;
362    if (!GetWindowRect(w->window, &rect))
363      {
364         ERR("GetWindowRect() failed");
365         return;
366      }
367
368    x = rect.left;
369    y = rect.top;
370    rect.left = 0;
371    rect.top = 0;
372 /*    if (width < w->min_width) width = w->min_width; */
373 /*    if (width > w->max_width) width = w->max_width; */
374 /*    printf ("ecore_win32_window_resize 1 : %d %d %d\n", w->min_height, w->max_height, height); */
375 /*    if (height < w->min_height) height = w->min_height; */
376 /*    printf ("ecore_win32_window_resize 2 : %d %d\n", w->max_height, height); */
377 /*    if (height > w->max_height) height = w->max_height; */
378 /*    printf ("ecore_win32_window_resize 3 : %d %d\n", w->max_height, height); */
379    rect.right = width;
380    rect.bottom = height;
381    if (!(style = GetWindowLong(w->window, GWL_STYLE)))
382      {
383         ERR("GetWindowLong() failed");
384         return;
385      }
386    if (!AdjustWindowRect(&rect, style, FALSE))
387      {
388         ERR("AdjustWindowRect() failed");
389         return;
390      }
391
392    if (!MoveWindow(w->window, x, y,
393                    rect.right - rect.left,
394                    rect.bottom - rect.top,
395                    TRUE))
396      {
397         ERR("MoveWindow() failed");
398      }
399 }
400
401 /**
402  * @brief Move and resize the given window to a given position and size.
403  *
404  * @param window The window to move and resize.
405  * @param x The x coordinate of the destination position.
406  * @param y The x coordinate of the destination position.
407  * @param width The new width.
408  * @param height The new height.
409  *
410  * This function resize @p window to the new position of coordinates @p x
411  * and @p y and the new @p width and @p height. If @p window is @c NULL,
412  * or if it is fullscreen, or on error, this function does nothing.
413  */
414 EAPI void
415 ecore_win32_window_move_resize(Ecore_Win32_Window *window,
416                                int                 x,
417                                int                 y,
418                                int                 width,
419                                int                 height)
420 {
421    RECT                        rect;
422    struct _Ecore_Win32_Window *w;
423    DWORD                       style;
424
425    /* FIXME: on fullscreen, should not move/resize it */
426    if (!window) return;
427
428    INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
429
430    w = ((struct _Ecore_Win32_Window *)window);
431    rect.left = 0;
432    rect.top = 0;
433    if ((unsigned int)width < w->min_width) width = w->min_width;
434    if ((unsigned int)width > w->max_width) width = w->max_width;
435    if ((unsigned int)height < w->min_height) height = w->min_height;
436    if ((unsigned int)height > w->max_height) height = w->max_height;
437    rect.right = width;
438    rect.bottom = height;
439    if (!(style = GetWindowLong(w->window, GWL_STYLE)))
440      {
441         ERR("GetWindowLong() failed");
442         return;
443      }
444    if (!AdjustWindowRect(&rect, style, FALSE))
445      {
446         ERR("AdjustWindowRect() failed");
447         return;
448      }
449
450    if (!MoveWindow(w->window, x, y,
451                    rect.right - rect.left,
452                    rect.bottom - rect.top,
453                    TRUE))
454      {
455         ERR("MoveWindow() failed");
456      }
457 }
458
459 /**
460  * @brief Get the geometry of the given window.
461  *
462  * @param window The window to retrieve the geometry from.
463  * @param x The x coordinate of the position.
464  * @param y The x coordinate of the position.
465  * @param width The width.
466  * @param height The height.
467  *
468  * This function retrieves the position and size of @p window. @p x,
469  * @p y, @p width and @p height can be buffers that will be filled with
470  * the corresponding values. If one of them is @c NULL, nothing will
471  * be done for that parameter. If @p window is @c NULL, and if the
472  * buffers are not @c NULL, they will be filled with respectively 0,
473  * 0, the size of the screen and the height of the screen.
474  */
475 EAPI void
476 ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
477                                 int                *x,
478                                 int                *y,
479                                 int                *width,
480                                 int                *height)
481 {
482    RECT rect;
483    int  w;
484    int  h;
485
486    INF("getting window geometry");
487
488    if (!window)
489      {
490         if (x) *x = 0;
491         if (y) *y = 0;
492         if (width) *width = GetSystemMetrics(SM_CXSCREEN);
493         if (height) *height = GetSystemMetrics(SM_CYSCREEN);
494
495         return;
496      }
497
498    if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
499                       &rect))
500      {
501         ERR("GetClientRect() failed");
502
503         if (x) *x = 0;
504         if (y) *y = 0;
505         if (width) *width = 0;
506         if (height) *height = 0;
507
508         return;
509      }
510
511    w = rect.right - rect.left;
512    h = rect.bottom - rect.top;
513
514    if (!GetWindowRect(((struct _Ecore_Win32_Window *)window)->window,
515                       &rect))
516      {
517         ERR("GetWindowRect() failed");
518
519         if (x) *x = 0;
520         if (y) *y = 0;
521         if (width) *width = 0;
522         if (height) *height = 0;
523
524         return;
525      }
526
527    if (x) *x = rect.left;
528    if (y) *y = rect.top;
529    if (width) *width = w;
530    if (height) *height = h;
531 }
532
533 /**
534  * @brief Get the size of the given window.
535  *
536  * @param window The window to retrieve the size from.
537  * @param width The width.
538  * @param height The height.
539  *
540  * This function retrieves the size of @p window. @p width and
541  * @p height can be buffers that will be filled with the corresponding
542  * values. If one of them is @c NULL, nothing will be done for that
543  * parameter. If @p window is @c NULL, and if the buffers are not
544  * @c NULL, they will be filled with respectively the size of the screen
545  * and the height of the screen.
546  */
547 EAPI void
548 ecore_win32_window_size_get(Ecore_Win32_Window *window,
549                             int                *width,
550                             int                *height)
551 {
552    RECT rect;
553
554    INF("getting window size");
555
556    if (!window)
557      {
558         if (width) *width = GetSystemMetrics(SM_CXSCREEN);
559         if (height) *height = GetSystemMetrics(SM_CYSCREEN);
560
561         return;
562      }
563
564    if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
565                       &rect))
566      {
567         ERR("GetClientRect() failed");
568
569         if (width) *width = 0;
570         if (height) *height = 0;
571      }
572
573    if (width) *width = rect.right - rect.left;
574    if (height) *height = rect.bottom - rect.top;
575 }
576
577 /**
578  * @brief Set the minimum size of the given window.
579  *
580  * @param window The window.
581  * @param min_width The minimal width.
582  * @param min_height The minimal height.
583  *
584  * This function sets the minimum size of @p window to @p min_width
585  * and *p min_height. If @p window is @c NULL, this functions does
586  * nothing.
587  */
588 EAPI void
589 ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
590                                 unsigned int        min_width,
591                                 unsigned int        min_height)
592 {
593    struct _Ecore_Win32_Window *w;
594
595    if (!window) return;
596
597    printf ("ecore_win32_window_size_min_set : %p  %d %d\n", window, min_width, min_height);
598    w = (struct _Ecore_Win32_Window *)window;
599    w->min_width = min_width;
600    w->min_height = min_height;
601 }
602
603 /**
604  * @brief Get the minimum size of the given window.
605  *
606  * @param window The window.
607  * @param min_width The minimal width.
608  * @param min_height The minimal height.
609  *
610  * This function fills the minimum size of @p window in the buffers
611  * @p min_width and *p min_height. They both can be @c NULL. If
612  * @p window is @c NULL, this functions does nothing.
613  */
614 EAPI void
615 ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
616                                 unsigned int       *min_width,
617                                 unsigned int       *min_height)
618 {
619    struct _Ecore_Win32_Window *w;
620
621    if (!window) return;
622
623    w = (struct _Ecore_Win32_Window *)window;
624    printf ("ecore_win32_window_size_min_get : %p  %d %d\n", window, w->min_width, w->min_height);
625    if (min_width) *min_width = w->min_width;
626    if (min_height) *min_height = w->min_height;
627 }
628
629 /**
630  * @brief Set the maximum size of the given window.
631  *
632  * @param window The window.
633  * @param max_width The maximal width.
634  * @param max_height The maximal height.
635  *
636  * This function sets the maximum size of @p window to @p max_width
637  * and *p max_height. If @p window is @c NULL, this functions does
638  * nothing.
639  */
640 EAPI void
641 ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
642                                 unsigned int        max_width,
643                                 unsigned int        max_height)
644 {
645    struct _Ecore_Win32_Window *w;
646
647    if (!window) return;
648
649    printf ("ecore_win32_window_size_max_set : %p  %d %d\n", window, max_width, max_height);
650    w = (struct _Ecore_Win32_Window *)window;
651    w->max_width = max_width;
652    w->max_height = max_height;
653 }
654
655 /**
656  * @brief Get the maximum size of the given window.
657  *
658  * @param window The window.
659  * @param max_width The maximal width.
660  * @param max_height The maximal height.
661  *
662  * This function fills the maximum size of @p window in the buffers
663  * @p max_width and *p max_height. They both can be @c NULL. If
664  * @p window is @c NULL, this functions does nothing.
665  */
666 EAPI void
667 ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
668                                 unsigned int       *max_width,
669                                 unsigned int       *max_height)
670 {
671    struct _Ecore_Win32_Window *w;
672
673    if (!window) return;
674
675    w = (struct _Ecore_Win32_Window *)window;
676    printf ("ecore_win32_window_size_max_get : %p  %d %d\n", window, w->max_width, w->max_height);
677    if (max_width) *max_width = w->max_width;
678    if (max_height) *max_height = w->max_height;
679 }
680
681 /**
682  * @brief Set the base size of the given window.
683  *
684  * @param window The window.
685  * @param base_width The base width.
686  * @param base_height The base height.
687  *
688  * This function sets the base size of @p window to @p base_width
689  * and *p base_height. If @p window is @c NULL, this functions does
690  * nothing.
691  */
692 EAPI void
693 ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
694                                  unsigned int        base_width,
695                                  unsigned int        base_height)
696 {
697    struct _Ecore_Win32_Window *w;
698
699    printf ("ecore_win32_window_size_base_set : %p  %d %d\n", window, base_width, base_height);
700    if (!window) return;
701
702    w = (struct _Ecore_Win32_Window *)window;
703    w->base_width = base_width;
704    w->base_height = base_height;
705 }
706
707 /**
708  * @brief Get the base size of the given window.
709  *
710  * @param window The window.
711  * @param base_width The base width.
712  * @param base_height The bas height.
713  *
714  * This function fills the base size of @p window in the buffers
715  * @p base_width and *p base_height. They both can be @c NULL. If
716  * @p window is @c NULL, this functions does nothing.
717  */
718 EAPI void
719 ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
720                                  unsigned int       *base_width,
721                                  unsigned int       *base_height)
722 {
723    struct _Ecore_Win32_Window *w;
724
725    if (!window) return;
726
727    w = (struct _Ecore_Win32_Window *)window;
728    printf ("ecore_win32_window_size_base_get : %p  %d %d\n", window, w->base_width, w->base_height);
729    if (base_width) *base_width = w->base_width;
730    if (base_height) *base_height = w->base_height;
731 }
732
733 /**
734  * @brief Set the step size of the given window.
735  *
736  * @param window The window.
737  * @param step_width The step width.
738  * @param step_height The step height.
739  *
740  * This function sets the step size of @p window to @p step_width
741  * and *p step_height. If @p window is @c NULL, this functions does
742  * nothing.
743  */
744 EAPI void
745 ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
746                                  unsigned int        step_width,
747                                  unsigned int        step_height)
748 {
749    struct _Ecore_Win32_Window *w;
750
751    printf ("ecore_win32_window_size_step_set : %p  %d %d\n", window, step_width, step_height);
752    if (!window) return;
753
754    w = (struct _Ecore_Win32_Window *)window;
755    w->step_width = step_width;
756    w->step_height = step_height;
757 }
758
759 /**
760  * @brief Get the step size of the given window.
761  *
762  * @param window The window.
763  * @param step_width The step width.
764  * @param step_height The bas height.
765  *
766  * This function fills the step size of @p window in the buffers
767  * @p step_width and *p step_height. They both can be @c NULL. If
768  * @p window is @c NULL, this functions does nothing.
769  */
770 EAPI void
771 ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
772                                  unsigned int       *step_width,
773                                  unsigned int       *step_height)
774 {
775    struct _Ecore_Win32_Window *w;
776
777    if (!window) return;
778
779    w = (struct _Ecore_Win32_Window *)window;
780    printf ("ecore_win32_window_size_step_get : %p  %d %d\n", window, w->step_width, w->step_height);
781    if (step_width) *step_width = w->step_width;
782    if (step_height) *step_height = w->step_height;
783 }
784
785 EAPI void
786 ecore_win32_window_shape_set(Ecore_Win32_Window *window,
787                              unsigned short      width,
788                              unsigned short      height,
789                              unsigned char      *mask)
790 {
791    struct _Ecore_Win32_Window *wnd;
792    HRGN                        rgn;
793    int                         x;
794    int                         y;
795    OSVERSIONINFO               version_info;
796
797    if (!window)
798       return;
799
800    wnd = (struct _Ecore_Win32_Window *)window;
801
802    if (!mask)
803      {
804         wnd->shape.enabled = 0;
805         if (wnd->shape.layered != 0)
806           {
807              wnd->shape.layered = 0;
808 #if defined(WS_EX_LAYERED)
809              SetLastError(0);
810              if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
811                                    GetWindowLong(wnd->window, GWL_EXSTYLE) & (~WS_EX_LAYERED)) &&
812                  (GetLastError() != 0))
813                {
814                   ERR("SetWindowLongPtr() failed");
815                   return;
816                }
817              if (!RedrawWindow(wnd->window, NULL, NULL,
818                                RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN))
819                {
820                   ERR("RedrawWindow() failed");
821                   return;
822                }
823 #endif
824           }
825         else
826           if (!SetWindowRgn(wnd->window, NULL, TRUE))
827             {
828                ERR("SetWindowRgn() failed");
829             }
830         return;
831      }
832
833    if (width == 0 || height == 0)
834      return;
835
836    wnd->shape.enabled = 1;
837
838    if (width != wnd->shape.width || height != wnd->shape.height)
839      {
840        wnd->shape.width = width;
841        wnd->shape.height = height;
842        if (wnd->shape.mask)
843          {
844            free(wnd->shape.mask);
845            wnd->shape.mask = NULL;
846          }
847        wnd->shape.mask = malloc(width * height);
848      }
849    memcpy(wnd->shape.mask, mask, width * height);
850
851    wnd->shape.layered = 0;
852
853 #if defined(WS_EX_LAYERED)
854    version_info.dwOSVersionInfoSize = sizeof(version_info);
855    if (GetVersionEx(&version_info) == TRUE && version_info.dwMajorVersion == 5)
856      {
857        SetLastError(0);
858        if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
859                              GetWindowLong(wnd->window, GWL_EXSTYLE) | WS_EX_LAYERED) &&
860            (GetLastError() != 0))
861             {
862                ERR("SetWindowLongPtr() failed");
863                return;
864             }
865        wnd->shape.layered = 1;
866        return;
867      }
868 #endif
869
870    if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
871      {
872         ERR("CreateRectRgn() failed");
873         return;
874      }
875    for (y = 0; y < height; y++)
876      {
877         HRGN rgnLine;
878
879         if (!(rgnLine = CreateRectRgn(0, 0, 0, 0)))
880           {
881              ERR("CreateRectRgn() failed");
882              return;
883           }
884         for (x = 0; x < width; x++)
885           {
886              if (mask[y * width + x] > 0)
887                {
888                   HRGN rgnDot;
889
890                   if (!(rgnDot = CreateRectRgn(x, y, x + 1, y + 1)))
891                     {
892                        ERR("CreateRectRgn() failed");
893                        return;
894                     }
895                   if (CombineRgn(rgnLine, rgnLine, rgnDot, RGN_OR) == ERROR)
896                     {
897                        ERR("CombineRgn() has not created a new region");
898                     }
899                   if (!DeleteObject(rgnDot))
900                     {
901                        ERR("DeleteObject() failed");
902                        return;
903                     }
904                }
905           }
906         if (CombineRgn(rgn, rgn, rgnLine, RGN_OR) == ERROR)
907           {
908              ERR("CombineRgn() has not created a new region");
909           }
910         if (!DeleteObject(rgnLine))
911           {
912              ERR("DeleteObject() failed");
913              return;
914           }
915      }
916    if (!SetWindowRgn(wnd->window, rgn, TRUE))
917      {
918         ERR("SetWindowRgn() failed");
919      }
920 }
921
922 /**
923  * @brief Show the given window.
924  *
925  * @param window The window to show.
926  *
927  * This function shows @p window. If @p window is @c NULL, or on
928  * error, this function does nothing.
929  */
930 EAPI void
931 ecore_win32_window_show(Ecore_Win32_Window *window)
932 {
933    if (!window) return;
934
935    INF("showing window");
936
937    ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL);
938    if (!UpdateWindow(((struct _Ecore_Win32_Window *)window)->window))
939      {
940         ERR("UpdateWindow() failed");
941      }
942 }
943
944 /* FIXME: seems to block the taskbar */
945 /**
946  * @brief Hide the given window.
947  *
948  * @param window The window to show.
949  *
950  * This function hides @p window. If @p window is @c NULL, or on
951  * error, this function does nothing.
952  */
953 EAPI void
954 ecore_win32_window_hide(Ecore_Win32_Window *window)
955 {
956    if (!window) return;
957
958    INF("hiding window");
959
960    ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE);
961 }
962
963 /**
964  * @brief Place the given window at the top of the Z order.
965  *
966  * @param window The window to place at the top.
967  *
968  * This function places @p window at the top of the Z order. If
969  * @p window is @c NULL, this function does nothing.
970  */
971 EAPI void
972 ecore_win32_window_raise(Ecore_Win32_Window *window)
973 {
974    if (!window) return;
975
976    INF("raising window");
977
978    if (!SetWindowPos(((struct _Ecore_Win32_Window *)window)->window,
979                      HWND_TOP, 0, 0, 0, 0,
980                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
981      {
982         ERR("SetWindowPos() failed");
983      }
984 }
985
986 /**
987  * @brief Place the given window at the bottom of the Z order.
988  *
989  * @param window The window to place at the bottom.
990  *
991  * This function places @p window at the bottom of the Z order. If
992  * @p window is @c NULL, this function does nothing.
993  */
994 EAPI void
995 ecore_win32_window_lower(Ecore_Win32_Window *window)
996 {
997    if (!window) return;
998
999    INF("lowering window");
1000
1001    if (!SetWindowPos(((struct _Ecore_Win32_Window *)window)->window,
1002                      HWND_BOTTOM, 0, 0, 0, 0,
1003                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
1004      {
1005         ERR("SetWindowPos() failed");
1006      }
1007 }
1008
1009 /**
1010  * @brief Set the title of the given window.
1011  *
1012  * @param window The window to set the title.
1013  * @param title The new title.
1014  *
1015  * This function sets the title of @p window to @p title. If @p window
1016  * is @c NULL, or if @p title is @c NULL or empty, or on error, this
1017  * function does nothing.
1018  */
1019 EAPI void
1020 ecore_win32_window_title_set(Ecore_Win32_Window *window,
1021                              const char         *title)
1022 {
1023    if (!window) return;
1024
1025    if (!title || !title[0]) return;
1026
1027    INF("setting window title");
1028
1029    if (!SetWindowText(((struct _Ecore_Win32_Window *)window)->window, title))
1030      {
1031         ERR("SetWindowText() failed");
1032      }
1033 }
1034
1035 /**
1036  * @brief Set the focus to the given window.
1037  *
1038  * @param window The window to give focus to.
1039  *
1040  * This function gives the focus to @p window. If @p window is
1041  * @c NULL, this function does nothing.
1042  */
1043 EAPI void
1044 ecore_win32_window_focus_set(Ecore_Win32_Window *window)
1045 {
1046    if (!window) return;
1047
1048    INF("focusing window");
1049
1050    if (!SetFocus(((struct _Ecore_Win32_Window *)window)->window))
1051      {
1052         ERR("SetFocus() failed");
1053      }
1054 }
1055
1056 /**
1057  * @brief Iconify or restore the given window.
1058  *
1059  * @param window The window.
1060  * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it.
1061  *
1062  * This function iconify or restore @p window. If @p on
1063  * is set to EINA_TRUE, the window will be iconified, if it is set to
1064  * EINA_FALSE, it will be restored. If @p window is @c NULL or if the
1065  * state does not change (like iconifying the window while it is
1066  * already iconified), this function does nothing.
1067  */
1068 EAPI void
1069 ecore_win32_window_iconified_set(Ecore_Win32_Window *window,
1070                                  Eina_Bool           on)
1071 {
1072    struct _Ecore_Win32_Window *ew;
1073
1074    if (!window) return;
1075
1076    ew = (struct _Ecore_Win32_Window *)window;
1077    if (((ew->iconified) && (on)) ||
1078        ((!ew->iconified) && (!on)))
1079      return;
1080
1081    INF("iconifying window: %s", on ? "yes" : "no");
1082
1083    ShowWindow(ew->window, on ? SW_MINIMIZE : SW_RESTORE);
1084    ew->iconified = on;
1085 }
1086
1087 /**
1088  * @brief Remove or restore the border of the given window.
1089  *
1090  * @param window The window.
1091  * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it.
1092  *
1093  * This function remove or restore the border of @p window. If @p on
1094  * is set to EINA_TRUE, the window will have no border, if it is set to
1095  * EINA_FALSE, it will have a border. If @p window is @c NULL or if the
1096  * state does not change (like setting to borderless while the window
1097  * has no border), this function does nothing.
1098  */
1099 EAPI void
1100 ecore_win32_window_borderless_set(Ecore_Win32_Window *window,
1101                                   Eina_Bool           on)
1102 {
1103    RECT                        rect;
1104    DWORD                       style;
1105    struct _Ecore_Win32_Window *ew;
1106    HWND                        w;
1107
1108    if (!window) return;
1109
1110    ew = (struct _Ecore_Win32_Window *)window;
1111    if (((ew->borderless) && (on)) ||
1112        ((!ew->borderless) && (!on)))
1113      return;
1114
1115    INF("setting window without border: %s", on ? "yes" : "no");
1116
1117    w = ew->window;
1118
1119    style = GetWindowLong(w, GWL_STYLE);
1120    if (on)
1121      {
1122         if (!GetClientRect(w, &rect))
1123           {
1124              ERR("GetClientRect() failed");
1125              return;
1126           }
1127         SetLastError(0);
1128         if (!SetWindowLongPtr(w, GWL_STYLE, style & ~(WS_CAPTION | WS_THICKFRAME)) && (GetLastError() != 0))
1129           {
1130              ERR("SetWindowLongPtr() failed");
1131              return;
1132           }
1133      }
1134    else
1135      {
1136         if (!GetWindowRect(w, &rect))
1137           {
1138              ERR("GetWindowRect() failed");
1139              return;
1140           }
1141         style |= WS_CAPTION | WS_THICKFRAME;
1142         if (!AdjustWindowRect (&rect, style, FALSE))
1143           {
1144              ERR("AdjustWindowRect() failed");
1145              return;
1146           }
1147         SetLastError(0);
1148         if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1149           {
1150              ERR("SetWindowLongPtr() failed");
1151              return;
1152           }
1153      }
1154    if (!SetWindowPos(w, HWND_TOPMOST,
1155                      rect.left, rect.top,
1156                      rect.right - rect.left, rect.bottom - rect.top,
1157                      SWP_NOMOVE | SWP_FRAMECHANGED))
1158      {
1159         ERR("SetWindowPos() failed");
1160         return;
1161      }
1162    ew->borderless = on;
1163 }
1164
1165 /**
1166  * @brief Set the given window to fullscreen.
1167  *
1168  * @param window The window.
1169  * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode.
1170  *
1171  * This function set @p window to fullscreen or windowed mode. If @p on
1172  * is set to EINA_TRUE, the window will be fullscreen, if it is set to
1173  * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the
1174  * state does not change (like setting to fullscreen while the window
1175  * is already fullscreen), this function does nothing.
1176  */
1177 EAPI void
1178 ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
1179                                   Eina_Bool           on)
1180 {
1181    struct _Ecore_Win32_Window *ew;
1182    HWND                        w;
1183
1184    if (!window) return;
1185
1186    ew = (struct _Ecore_Win32_Window *)window;
1187    if (((ew->fullscreen) && (on)) ||
1188        ((!ew->fullscreen) && (!on)))
1189      return;
1190
1191    INF("setting fullscreen: %s", on ? "yes" : "no");
1192
1193    ew->fullscreen = !!on;
1194    w = ew->window;
1195
1196    if (on)
1197      {
1198         DWORD style;
1199
1200         if (!GetWindowRect(w, &ew->rect))
1201           {
1202              ERR("GetWindowRect() failed");
1203              return;
1204           }
1205         if (!(ew->style = GetWindowLong(w, GWL_STYLE)))
1206           {
1207              ERR("GetWindowLong() failed");
1208              return;
1209           }
1210         style = ew->style & ~WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX;
1211         style |= WS_VISIBLE | WS_POPUP;
1212         SetLastError(0);
1213         if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1214           {
1215              ERR("SetWindowLongPtr() failed");
1216              return;
1217           }
1218         SetLastError(0);
1219         if (!SetWindowLongPtr(w, GWL_EXSTYLE, WS_EX_TOPMOST) && (GetLastError() != 0))
1220           {
1221              ERR("SetWindowLongPtr() failed");
1222              return;
1223           }
1224         if (!SetWindowPos(w, HWND_TOPMOST, 0, 0,
1225                           GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN),
1226                           SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1227           {
1228              ERR("SetWindowPos() failed");
1229              return;
1230           }
1231      }
1232    else
1233      {
1234         SetLastError(0);
1235         if (!SetWindowLongPtr(w, GWL_STYLE, ew->style) && (GetLastError() != 0))
1236           {
1237              ERR("SetWindowLongPtr() failed");
1238              return;
1239           }
1240         SetLastError(0);
1241         if (!SetWindowLongPtr(w, GWL_EXSTYLE, 0) && (GetLastError() != 0))
1242           {
1243              ERR("SetWindowLongPtr() failed");
1244              return;
1245           }
1246         if (!SetWindowPos(w, HWND_NOTOPMOST,
1247                           ew->rect.left,
1248                           ew->rect.top,
1249                           ew->rect.right - ew->rect.left,
1250                           ew->rect.bottom - ew->rect.top,
1251                           SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1252           {
1253              ERR("SetWindowPos() failed");
1254              return;
1255           }
1256      }
1257 }
1258
1259 /**
1260  * @brief Set the given cursor to the given window.
1261  *
1262  * @param window The window to modify the cursor.
1263  * @param cursor The new cursor.
1264  *
1265  * This function sets @p cursor to @p window. @p cursor must have been
1266  * obtained by ecore_win32_cursor_new() or
1267  * ecore_win32_cursor_shaped_new(). If @p window or @p cursor is
1268  * @c NULL, the function does nothing.
1269  */
1270 EAPI void
1271 ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
1272                               Ecore_Win32_Cursor *cursor)
1273 {
1274    INF("setting cursor");
1275
1276    if (!window || !cursor)
1277      return;
1278
1279    if (!SetClassLong(((struct _Ecore_Win32_Window *)window)->window,
1280                      GCL_HCURSOR, (LONG)cursor))
1281      {
1282         ERR("SetClassLong() failed");
1283      }
1284 }
1285
1286 /**
1287  * @brief Set the state of the given window.
1288  *
1289  * @param window The window to modify the state.
1290  * @param state An array of the new states.
1291  * @param num The number of states in the array.
1292  *
1293  * This function set the state of @p window. @p state is an array of
1294  * states of size @p num. If @p window or @p state are @c NULL, or if
1295  * @p num is less or equal than 0, the function does nothing.
1296  */
1297 EAPI void
1298 ecore_win32_window_state_set(Ecore_Win32_Window       *window,
1299                              Ecore_Win32_Window_State *state,
1300                              unsigned int              num)
1301 {
1302    unsigned int i;
1303
1304    if (!window || !state || (num <= 0))
1305      return;
1306
1307    INF("setting cursor state");
1308
1309    for (i = 0; i < num; i++)
1310      {
1311         switch (state[i])
1312           {
1313           case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1314             ((struct _Ecore_Win32_Window *)window)->state.iconified = 1;
1315             break;
1316           case ECORE_WIN32_WINDOW_STATE_MODAL:
1317             ((struct _Ecore_Win32_Window *)window)->state.modal = 1;
1318             break;
1319           case ECORE_WIN32_WINDOW_STATE_STICKY:
1320             ((struct _Ecore_Win32_Window *)window)->state.sticky = 1;
1321             break;
1322           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1323             ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1324             break;
1325           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1326             ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1;
1327             break;
1328           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1329             ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1;
1330             ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1331             break;
1332           case ECORE_WIN32_WINDOW_STATE_SHADED:
1333             ((struct _Ecore_Win32_Window *)window)->state.shaded = 1;
1334             break;
1335           case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1336             ((struct _Ecore_Win32_Window *)window)->state.hidden = 1;
1337             break;
1338           case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1339             ((struct _Ecore_Win32_Window *)window)->state.fullscreen = 1;
1340             break;
1341           case ECORE_WIN32_WINDOW_STATE_ABOVE:
1342             ((struct _Ecore_Win32_Window *)window)->state.above = 1;
1343             break;
1344           case ECORE_WIN32_WINDOW_STATE_BELOW:
1345             ((struct _Ecore_Win32_Window *)window)->state.below = 1;
1346             break;
1347           case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1348             ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1;
1349             break;
1350           case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1351             /* nothing to be done */
1352             break;
1353           }
1354      }
1355 }
1356
1357 /**
1358  * @brief Apply the modification of the state to the given window.
1359  *
1360  * @param window The window.
1361  * @param state The state to apply changes.
1362  * @param set The value of the state change.
1363  *
1364  * This function applies the modification of the state @p state of
1365  * @p window. @p set is used only for
1366  * #ECORE_WIN32_WINDOW_STATE_ICONIFIED and
1367  * #ECORE_WIN32_WINDOW_STATE_FULLSCREEN. If @p window is @c NULL, the
1368  * function does nothing.
1369  */
1370 EAPI void
1371 ecore_win32_window_state_request_send(Ecore_Win32_Window      *window,
1372                                       Ecore_Win32_Window_State state,
1373                                       unsigned int             set)
1374 {
1375    struct _Ecore_Win32_Window *ew;
1376    HWND                        w;
1377
1378    if (!window) return;
1379
1380    ew = (struct _Ecore_Win32_Window *)window;
1381    w = ew->window;
1382
1383    INF("sending cursor state");
1384
1385    switch (state)
1386      {
1387       case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1388          if (ew->state.iconified)
1389            ecore_win32_window_iconified_set(window, set);
1390          break;
1391       case ECORE_WIN32_WINDOW_STATE_MODAL:
1392          ew->state.modal = 1;
1393          break;
1394       case ECORE_WIN32_WINDOW_STATE_STICKY:
1395          ew->state.sticky = 1;
1396          break;
1397       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1398          if (ew->state.maximized_vert)
1399            {
1400               RECT rect;
1401               int  y;
1402               int  height;
1403
1404               if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1405                                         &rect, 0))
1406                 {
1407                    ERR("SystemParametersInfo() failed");
1408                    break;
1409                 }
1410               y = rect.top;
1411               height = rect.bottom - rect.top;
1412
1413               if (!GetClientRect(w, &rect))
1414                 {
1415                    ERR("GetClientRect() failed");
1416                    break;
1417                 }
1418
1419               if (!MoveWindow(w, rect.left, y,
1420                               rect.right - rect.left,
1421                               height,
1422                               TRUE))
1423                 {
1424                    ERR("MoveWindow() failed");
1425                 }
1426            }
1427          break;
1428       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1429          if (ew->state.maximized_horz)
1430            {
1431               RECT rect;
1432
1433               if (!GetClientRect(w, &rect))
1434                 {
1435                    ERR("GetClientRect() failed");
1436                    break;
1437                 }
1438
1439               if (!MoveWindow(w, 0, rect.top,
1440                               GetSystemMetrics(SM_CXSCREEN),
1441                               rect.bottom - rect.top,
1442                               TRUE))
1443                 {
1444                    ERR("MoveWindow() failed");
1445                 }
1446            }
1447          break;
1448       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1449          if (ew->state.maximized_vert && ew->state.maximized_horz)
1450            {
1451               RECT rect;
1452
1453               if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1454                                         &rect, 0))
1455                 {
1456                    ERR("SystemParametersInfo() failed");
1457                    break;
1458                 }
1459
1460               if (!MoveWindow(w, 0, 0,
1461                               GetSystemMetrics(SM_CXSCREEN),
1462                               rect.bottom - rect.top,
1463                               TRUE))
1464                 {
1465                    ERR("MoveWindow() failed");
1466                 }
1467            }
1468          break;
1469       case ECORE_WIN32_WINDOW_STATE_SHADED:
1470          ew->state.shaded = 1;
1471          break;
1472       case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1473          ew->state.hidden = 1;
1474          break;
1475       case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1476          if (ew->state.fullscreen)
1477            ecore_win32_window_fullscreen_set(window, set);
1478          break;
1479       case ECORE_WIN32_WINDOW_STATE_ABOVE:
1480          if (ew->state.above)
1481            if (!SetWindowPos(w, HWND_TOP,
1482                              0, 0,
1483                              0, 0,
1484                              SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1485              {
1486                 ERR("SetWindowPos() failed");
1487              }
1488          break;
1489       case ECORE_WIN32_WINDOW_STATE_BELOW:
1490          if (ew->state.below)
1491            if (!SetWindowPos(w, HWND_BOTTOM,
1492                              0, 0,
1493                              0, 0,
1494                              SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1495              {
1496                 ERR("SetWindowPos() failed");
1497              }
1498          break;
1499       case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1500          ew->state.demands_attention = 1;
1501          break;
1502       case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1503          /* nothing to be done */
1504          break;
1505      }
1506 }
1507
1508 /**
1509  * @brief Set the type of the given window.
1510  *
1511  * @param window The window to modify the type.
1512  * @param type The new types.
1513  *
1514  * This function set the type of @p window to @p type. If
1515  * @p window is @c NULL, the function does nothing.
1516  */
1517 EAPI void
1518 ecore_win32_window_type_set(Ecore_Win32_Window      *window,
1519                             Ecore_Win32_Window_Type  type)
1520 {
1521    if (!window)
1522      return;
1523
1524    INF("setting window type");
1525
1526    switch (type)
1527      {
1528      case ECORE_WIN32_WINDOW_TYPE_DESKTOP:
1529        ((struct _Ecore_Win32_Window *)window)->type.desktop = 1;
1530        break;
1531      case ECORE_WIN32_WINDOW_TYPE_DOCK:
1532        ((struct _Ecore_Win32_Window *)window)->type.dock = 1;
1533        break;
1534      case ECORE_WIN32_WINDOW_TYPE_TOOLBAR:
1535        ((struct _Ecore_Win32_Window *)window)->type.toolbar = 1;
1536        break;
1537      case ECORE_WIN32_WINDOW_TYPE_MENU:
1538        ((struct _Ecore_Win32_Window *)window)->type.menu = 1;
1539        break;
1540      case ECORE_WIN32_WINDOW_TYPE_UTILITY:
1541        ((struct _Ecore_Win32_Window *)window)->type.utility = 1;
1542        break;
1543      case ECORE_WIN32_WINDOW_TYPE_SPLASH:
1544        ((struct _Ecore_Win32_Window *)window)->type.splash = 1;
1545        break;
1546      case ECORE_WIN32_WINDOW_TYPE_DIALOG:
1547        ((struct _Ecore_Win32_Window *)window)->type.dialog = 1;
1548        break;
1549      case ECORE_WIN32_WINDOW_TYPE_NORMAL:
1550        ((struct _Ecore_Win32_Window *)window)->type.normal = 1;
1551        break;
1552      case ECORE_WIN32_WINDOW_TYPE_UNKNOWN:
1553        ((struct _Ecore_Win32_Window *)window)->type.normal = 1;
1554        break;
1555      }
1556 }
1557
1558 /**
1559  * @}
1560  */