20edf810d1d3f307a0ea2ac7eaaada2756323ad0
[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    Ecore_Win32_Window *w;
45    int                 minimal_width;
46    int                 minimal_height;
47
48    w = (Ecore_Win32_Window *)calloc(1, sizeof(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 (!AdjustWindowRectEx(&rect, style, FALSE, 0))
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 ? ((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_PTR)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    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(((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 ((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((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 = ((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    Ecore_Win32_Window *w;
352    DWORD               style;
353    int                 x;
354    int                 y;
355    int                 minimal_width;
356    int                 minimal_height;
357
358    /* FIXME: on fullscreen, should not resize it */
359    if (!window) return;
360
361    INF("resizing window (%dx%d)", width, height);
362
363    w = (Ecore_Win32_Window *)window;
364
365    minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)w->min_width);
366    minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)w->min_height);
367
368    if (!GetWindowRect(w->window, &rect))
369      {
370         ERR("GetWindowRect() failed");
371         return;
372      }
373
374    x = rect.left;
375    y = rect.top;
376    rect.left = 0;
377    rect.top = 0;
378    if (width < minimal_width) width = minimal_width;
379    if (width > (int)w->max_width) width = w->max_width;
380    if (height < minimal_height) height = minimal_height;
381    if (height > (int)w->max_height) height = w->max_height;
382    rect.right = width;
383    rect.bottom = height;
384    if (!(style = GetWindowLong(w->window, GWL_STYLE)))
385      {
386         ERR("GetWindowLong() failed");
387         return;
388      }
389    if (!AdjustWindowRect(&rect, style, FALSE))
390      {
391         ERR("AdjustWindowRect() failed");
392         return;
393      }
394
395    if (!MoveWindow(w->window, x, y,
396                    rect.right - rect.left,
397                    rect.bottom - rect.top,
398                    TRUE))
399      {
400         ERR("MoveWindow() failed");
401      }
402 }
403
404 /**
405  * @brief Move and resize the given window to a given position and size.
406  *
407  * @param window The window to move and resize.
408  * @param x The x coordinate of the destination position.
409  * @param y The x coordinate of the destination position.
410  * @param width The new width.
411  * @param height The new height.
412  *
413  * This function resize @p window to the new position of coordinates @p x
414  * and @p y and the new @p width and @p height. If @p window is @c NULL,
415  * or if it is fullscreen, or on error, this function does nothing.
416  */
417 EAPI void
418 ecore_win32_window_move_resize(Ecore_Win32_Window *window,
419                                int                 x,
420                                int                 y,
421                                int                 width,
422                                int                 height)
423 {
424    RECT                rect;
425    Ecore_Win32_Window *w;
426    DWORD               style;
427    int                 minimal_width;
428    int                 minimal_height;
429
430    /* FIXME: on fullscreen, should not move/resize it */
431    if (!window) return;
432
433    INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
434
435    w = ((Ecore_Win32_Window *)window);
436
437    minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)w->min_width);
438    minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)w->min_height);
439
440    rect.left = 0;
441    rect.top = 0;
442    if (width < minimal_width) width = minimal_width;
443    if (width > (int)w->max_width) width = w->max_width;
444    if (height < minimal_height) height = minimal_height;
445    if (height > (int)w->max_height) height = w->max_height;
446    rect.right = width;
447    rect.bottom = height;
448    if (!(style = GetWindowLong(w->window, GWL_STYLE)))
449      {
450         ERR("GetWindowLong() failed");
451         return;
452      }
453    if (!AdjustWindowRect(&rect, style, FALSE))
454      {
455         ERR("AdjustWindowRect() failed");
456         return;
457      }
458
459    if (!MoveWindow(w->window, x, y,
460                    rect.right - rect.left,
461                    rect.bottom - rect.top,
462                    TRUE))
463      {
464         ERR("MoveWindow() failed");
465      }
466 }
467
468 /**
469  * @brief Get the geometry of the given window.
470  *
471  * @param window The window to retrieve the geometry from.
472  * @param x The x coordinate of the position.
473  * @param y The x coordinate of the position.
474  * @param width The width.
475  * @param height The height.
476  *
477  * This function retrieves the position and size of @p window. @p x,
478  * @p y, @p width and @p height can be buffers that will be filled with
479  * the corresponding values. If one of them is @c NULL, nothing will
480  * be done for that parameter. If @p window is @c NULL, and if the
481  * buffers are not @c NULL, they will be filled with respectively 0,
482  * 0, the size of the screen and the height of the screen.
483  */
484 EAPI void
485 ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
486                                 int                *x,
487                                 int                *y,
488                                 int                *width,
489                                 int                *height)
490 {
491    RECT rect;
492    int  w;
493    int  h;
494
495    INF("getting window geometry");
496
497    if (!window)
498      {
499         if (x) *x = 0;
500         if (y) *y = 0;
501         if (width) *width = GetSystemMetrics(SM_CXSCREEN);
502         if (height) *height = GetSystemMetrics(SM_CYSCREEN);
503
504         return;
505      }
506
507    if (!GetClientRect(((Ecore_Win32_Window *)window)->window,
508                       &rect))
509      {
510         ERR("GetClientRect() failed");
511
512         if (x) *x = 0;
513         if (y) *y = 0;
514         if (width) *width = 0;
515         if (height) *height = 0;
516
517         return;
518      }
519
520    w = rect.right - rect.left;
521    h = rect.bottom - rect.top;
522
523    if (!GetWindowRect(((Ecore_Win32_Window *)window)->window,
524                       &rect))
525      {
526         ERR("GetWindowRect() failed");
527
528         if (x) *x = 0;
529         if (y) *y = 0;
530         if (width) *width = 0;
531         if (height) *height = 0;
532
533         return;
534      }
535
536    if (x) *x = rect.left;
537    if (y) *y = rect.top;
538    if (width) *width = w;
539    if (height) *height = h;
540 }
541
542 /**
543  * @brief Get the size of the given window.
544  *
545  * @param window The window to retrieve the size from.
546  * @param width The width.
547  * @param height The height.
548  *
549  * This function retrieves the size of @p window. @p width and
550  * @p height can be buffers that will be filled with the corresponding
551  * values. If one of them is @c NULL, nothing will be done for that
552  * parameter. If @p window is @c NULL, and if the buffers are not
553  * @c NULL, they will be filled with respectively the size of the screen
554  * and the height of the screen.
555  */
556 EAPI void
557 ecore_win32_window_size_get(Ecore_Win32_Window *window,
558                             int                *width,
559                             int                *height)
560 {
561    RECT rect;
562
563    INF("getting window size");
564
565    if (!window)
566      {
567         if (width) *width = GetSystemMetrics(SM_CXSCREEN);
568         if (height) *height = GetSystemMetrics(SM_CYSCREEN);
569
570         return;
571      }
572
573    if (!GetClientRect(((Ecore_Win32_Window *)window)->window,
574                       &rect))
575      {
576         ERR("GetClientRect() failed");
577
578         if (width) *width = 0;
579         if (height) *height = 0;
580      }
581
582    if (width) *width = rect.right - rect.left;
583    if (height) *height = rect.bottom - rect.top;
584 }
585
586 /**
587  * @brief Set the minimum size of the given window.
588  *
589  * @param window The window.
590  * @param min_width The minimal width.
591  * @param min_height The minimal height.
592  *
593  * This function sets the minimum size of @p window to @p min_width
594  * and *p min_height. If @p window is @c NULL, this functions does
595  * nothing.
596  */
597 EAPI void
598 ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
599                                 unsigned int        min_width,
600                                 unsigned int        min_height)
601 {
602    Ecore_Win32_Window *w;
603
604    if (!window) return;
605
606    printf ("ecore_win32_window_size_min_set : %p  %d %d\n", window, min_width, min_height);
607    w = (Ecore_Win32_Window *)window;
608    w->min_width = min_width;
609    w->min_height = min_height;
610 }
611
612 /**
613  * @brief Get the minimum size of the given window.
614  *
615  * @param window The window.
616  * @param min_width The minimal width.
617  * @param min_height The minimal height.
618  *
619  * This function fills the minimum size of @p window in the buffers
620  * @p min_width and *p min_height. They both can be @c NULL. If
621  * @p window is @c NULL, this functions does nothing.
622  */
623 EAPI void
624 ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
625                                 unsigned int       *min_width,
626                                 unsigned int       *min_height)
627 {
628    Ecore_Win32_Window *w;
629
630    if (!window) return;
631
632    w = (Ecore_Win32_Window *)window;
633    printf ("ecore_win32_window_size_min_get : %p  %d %d\n", window, w->min_width, w->min_height);
634    if (min_width) *min_width = w->min_width;
635    if (min_height) *min_height = w->min_height;
636 }
637
638 /**
639  * @brief Set the maximum size of the given window.
640  *
641  * @param window The window.
642  * @param max_width The maximal width.
643  * @param max_height The maximal height.
644  *
645  * This function sets the maximum size of @p window to @p max_width
646  * and *p max_height. If @p window is @c NULL, this functions does
647  * nothing.
648  */
649 EAPI void
650 ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
651                                 unsigned int        max_width,
652                                 unsigned int        max_height)
653 {
654    Ecore_Win32_Window *w;
655
656    if (!window) return;
657
658    printf ("ecore_win32_window_size_max_set : %p  %d %d\n", window, max_width, max_height);
659    w = (Ecore_Win32_Window *)window;
660    w->max_width = max_width;
661    w->max_height = max_height;
662 }
663
664 /**
665  * @brief Get the maximum size of the given window.
666  *
667  * @param window The window.
668  * @param max_width The maximal width.
669  * @param max_height The maximal height.
670  *
671  * This function fills the maximum size of @p window in the buffers
672  * @p max_width and *p max_height. They both can be @c NULL. If
673  * @p window is @c NULL, this functions does nothing.
674  */
675 EAPI void
676 ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
677                                 unsigned int       *max_width,
678                                 unsigned int       *max_height)
679 {
680    Ecore_Win32_Window *w;
681
682    if (!window) return;
683
684    w = (Ecore_Win32_Window *)window;
685    printf ("ecore_win32_window_size_max_get : %p  %d %d\n", window, w->max_width, w->max_height);
686    if (max_width) *max_width = w->max_width;
687    if (max_height) *max_height = w->max_height;
688 }
689
690 /**
691  * @brief Set the base size of the given window.
692  *
693  * @param window The window.
694  * @param base_width The base width.
695  * @param base_height The base height.
696  *
697  * This function sets the base size of @p window to @p base_width
698  * and *p base_height. If @p window is @c NULL, this functions does
699  * nothing.
700  */
701 EAPI void
702 ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
703                                  unsigned int        base_width,
704                                  unsigned int        base_height)
705 {
706    Ecore_Win32_Window *w;
707
708    printf ("ecore_win32_window_size_base_set : %p  %d %d\n", window, base_width, base_height);
709    if (!window) return;
710
711    w = (Ecore_Win32_Window *)window;
712    w->base_width = base_width;
713    w->base_height = base_height;
714 }
715
716 /**
717  * @brief Get the base size of the given window.
718  *
719  * @param window The window.
720  * @param base_width The base width.
721  * @param base_height The bas height.
722  *
723  * This function fills the base size of @p window in the buffers
724  * @p base_width and *p base_height. They both can be @c NULL. If
725  * @p window is @c NULL, this functions does nothing.
726  */
727 EAPI void
728 ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
729                                  unsigned int       *base_width,
730                                  unsigned int       *base_height)
731 {
732    Ecore_Win32_Window *w;
733
734    if (!window) return;
735
736    w = (Ecore_Win32_Window *)window;
737    printf ("ecore_win32_window_size_base_get : %p  %d %d\n", window, w->base_width, w->base_height);
738    if (base_width) *base_width = w->base_width;
739    if (base_height) *base_height = w->base_height;
740 }
741
742 /**
743  * @brief Set the step size of the given window.
744  *
745  * @param window The window.
746  * @param step_width The step width.
747  * @param step_height The step height.
748  *
749  * This function sets the step size of @p window to @p step_width
750  * and *p step_height. If @p window is @c NULL, this functions does
751  * nothing.
752  */
753 EAPI void
754 ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
755                                  unsigned int        step_width,
756                                  unsigned int        step_height)
757 {
758    Ecore_Win32_Window *w;
759
760    printf ("ecore_win32_window_size_step_set : %p  %d %d\n", window, step_width, step_height);
761    if (!window) return;
762
763    w = (Ecore_Win32_Window *)window;
764    w->step_width = step_width;
765    w->step_height = step_height;
766 }
767
768 /**
769  * @brief Get the step size of the given window.
770  *
771  * @param window The window.
772  * @param step_width The step width.
773  * @param step_height The bas height.
774  *
775  * This function fills the step size of @p window in the buffers
776  * @p step_width and *p step_height. They both can be @c NULL. If
777  * @p window is @c NULL, this functions does nothing.
778  */
779 EAPI void
780 ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
781                                  unsigned int       *step_width,
782                                  unsigned int       *step_height)
783 {
784    Ecore_Win32_Window *w;
785
786    if (!window) return;
787
788    w = (Ecore_Win32_Window *)window;
789    printf ("ecore_win32_window_size_step_get : %p  %d %d\n", window, w->step_width, w->step_height);
790    if (step_width) *step_width = w->step_width;
791    if (step_height) *step_height = w->step_height;
792 }
793
794 EAPI void
795 ecore_win32_window_shape_set(Ecore_Win32_Window *window,
796                              unsigned short      width,
797                              unsigned short      height,
798                              unsigned char      *mask)
799 {
800    Ecore_Win32_Window *wnd;
801    HRGN                        rgn;
802    int                         x;
803    int                         y;
804    OSVERSIONINFO               version_info;
805
806    if (!window)
807       return;
808
809    wnd = (Ecore_Win32_Window *)window;
810
811    if (!mask)
812      {
813         wnd->shape.enabled = 0;
814         if (wnd->shape.layered != 0)
815           {
816              wnd->shape.layered = 0;
817 #if defined(WS_EX_LAYERED)
818              SetLastError(0);
819              if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
820                                    GetWindowLong(wnd->window, GWL_EXSTYLE) & (~WS_EX_LAYERED)) &&
821                  (GetLastError() != 0))
822                {
823                   ERR("SetWindowLongPtr() failed");
824                   return;
825                }
826              if (!RedrawWindow(wnd->window, NULL, NULL,
827                                RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN))
828                {
829                   ERR("RedrawWindow() failed");
830                   return;
831                }
832 #endif
833           }
834         else
835           if (!SetWindowRgn(wnd->window, NULL, TRUE))
836             {
837                ERR("SetWindowRgn() failed");
838             }
839         return;
840      }
841
842    if (width == 0 || height == 0)
843      return;
844
845    wnd->shape.enabled = 1;
846
847    if (width != wnd->shape.width || height != wnd->shape.height)
848      {
849        wnd->shape.width = width;
850        wnd->shape.height = height;
851        if (wnd->shape.mask)
852          {
853            free(wnd->shape.mask);
854            wnd->shape.mask = NULL;
855          }
856        wnd->shape.mask = malloc(width * height);
857      }
858    memcpy(wnd->shape.mask, mask, width * height);
859
860    wnd->shape.layered = 0;
861
862 #if defined(WS_EX_LAYERED)
863    version_info.dwOSVersionInfoSize = sizeof(version_info);
864    if (GetVersionEx(&version_info) == TRUE && version_info.dwMajorVersion == 5)
865      {
866        SetLastError(0);
867        if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
868                              GetWindowLong(wnd->window, GWL_EXSTYLE) | WS_EX_LAYERED) &&
869            (GetLastError() != 0))
870             {
871                ERR("SetWindowLongPtr() failed");
872                return;
873             }
874        wnd->shape.layered = 1;
875        return;
876      }
877 #endif
878
879    if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
880      {
881         ERR("CreateRectRgn() failed");
882         return;
883      }
884    for (y = 0; y < height; y++)
885      {
886         HRGN rgnLine;
887
888         if (!(rgnLine = CreateRectRgn(0, 0, 0, 0)))
889           {
890              ERR("CreateRectRgn() failed");
891              return;
892           }
893         for (x = 0; x < width; x++)
894           {
895              if (mask[y * width + x] > 0)
896                {
897                   HRGN rgnDot;
898
899                   if (!(rgnDot = CreateRectRgn(x, y, x + 1, y + 1)))
900                     {
901                        ERR("CreateRectRgn() failed");
902                        return;
903                     }
904                   if (CombineRgn(rgnLine, rgnLine, rgnDot, RGN_OR) == ERROR)
905                     {
906                        ERR("CombineRgn() has not created a new region");
907                     }
908                   if (!DeleteObject(rgnDot))
909                     {
910                        ERR("DeleteObject() failed");
911                        return;
912                     }
913                }
914           }
915         if (CombineRgn(rgn, rgn, rgnLine, RGN_OR) == ERROR)
916           {
917              ERR("CombineRgn() has not created a new region");
918           }
919         if (!DeleteObject(rgnLine))
920           {
921              ERR("DeleteObject() failed");
922              return;
923           }
924      }
925    if (!SetWindowRgn(wnd->window, rgn, TRUE))
926      {
927         ERR("SetWindowRgn() failed");
928      }
929 }
930
931 /**
932  * @brief Show the given window.
933  *
934  * @param window The window to show.
935  *
936  * This function shows @p window. If @p window is @c NULL, or on
937  * error, this function does nothing.
938  */
939 EAPI void
940 ecore_win32_window_show(Ecore_Win32_Window *window)
941 {
942    if (!window) return;
943
944    INF("showing window");
945
946    ShowWindow(((Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL);
947    if (!UpdateWindow(((Ecore_Win32_Window *)window)->window))
948      {
949         ERR("UpdateWindow() failed");
950      }
951 }
952
953 /* FIXME: seems to block the taskbar */
954 /**
955  * @brief Hide the given window.
956  *
957  * @param window The window to show.
958  *
959  * This function hides @p window. If @p window is @c NULL, or on
960  * error, this function does nothing.
961  */
962 EAPI void
963 ecore_win32_window_hide(Ecore_Win32_Window *window)
964 {
965    if (!window) return;
966
967    INF("hiding window");
968
969    ShowWindow(((Ecore_Win32_Window *)window)->window, SW_HIDE);
970 }
971
972 /**
973  * @brief Place the given window at the top of the Z order.
974  *
975  * @param window The window to place at the top.
976  *
977  * This function places @p window at the top of the Z order. If
978  * @p window is @c NULL, this function does nothing.
979  */
980 EAPI void
981 ecore_win32_window_raise(Ecore_Win32_Window *window)
982 {
983    if (!window) return;
984
985    INF("raising window");
986
987    if (!SetWindowPos(((Ecore_Win32_Window *)window)->window,
988                      HWND_TOP, 0, 0, 0, 0,
989                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
990      {
991         ERR("SetWindowPos() failed");
992      }
993 }
994
995 /**
996  * @brief Place the given window at the bottom of the Z order.
997  *
998  * @param window The window to place at the bottom.
999  *
1000  * This function places @p window at the bottom of the Z order. If
1001  * @p window is @c NULL, this function does nothing.
1002  */
1003 EAPI void
1004 ecore_win32_window_lower(Ecore_Win32_Window *window)
1005 {
1006    if (!window) return;
1007
1008    INF("lowering window");
1009
1010    if (!SetWindowPos(((Ecore_Win32_Window *)window)->window,
1011                      HWND_BOTTOM, 0, 0, 0, 0,
1012                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
1013      {
1014         ERR("SetWindowPos() failed");
1015      }
1016 }
1017
1018 /**
1019  * @brief Set the title of the given window.
1020  *
1021  * @param window The window to set the title.
1022  * @param title The new title.
1023  *
1024  * This function sets the title of @p window to @p title. If @p window
1025  * is @c NULL, or if @p title is @c NULL or empty, or on error, this
1026  * function does nothing.
1027  */
1028 EAPI void
1029 ecore_win32_window_title_set(Ecore_Win32_Window *window,
1030                              const char         *title)
1031 {
1032    if (!window) return;
1033
1034    if (!title || !title[0]) return;
1035
1036    INF("setting window title");
1037
1038    if (!SetWindowText(((Ecore_Win32_Window *)window)->window, title))
1039      {
1040         ERR("SetWindowText() failed");
1041      }
1042 }
1043
1044 /**
1045  * @brief Set the focus to the given window.
1046  *
1047  * @param window The window to give focus to.
1048  *
1049  * This function gives the focus to @p window. If @p window is
1050  * @c NULL, this function does nothing.
1051  */
1052 EAPI void
1053 ecore_win32_window_focus_set(Ecore_Win32_Window *window)
1054 {
1055    if (!window) return;
1056
1057    INF("focusing window");
1058
1059    if (!SetFocus(((Ecore_Win32_Window *)window)->window))
1060      {
1061         ERR("SetFocus() failed");
1062      }
1063 }
1064
1065 /**
1066  * @brief Iconify or restore the given window.
1067  *
1068  * @param window The window.
1069  * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it.
1070  *
1071  * This function iconify or restore @p window. If @p on
1072  * is set to EINA_TRUE, the window will be iconified, if it is set to
1073  * EINA_FALSE, it will be restored. If @p window is @c NULL or if the
1074  * state does not change (like iconifying the window while it is
1075  * already iconified), this function does nothing.
1076  */
1077 EAPI void
1078 ecore_win32_window_iconified_set(Ecore_Win32_Window *window,
1079                                  Eina_Bool           on)
1080 {
1081    Ecore_Win32_Window *ew;
1082
1083    if (!window) return;
1084
1085    ew = (Ecore_Win32_Window *)window;
1086    if (((ew->iconified) && (on)) ||
1087        ((!ew->iconified) && (!on)))
1088      return;
1089
1090    INF("iconifying window: %s", on ? "yes" : "no");
1091
1092    ShowWindow(ew->window, on ? SW_MINIMIZE : SW_RESTORE);
1093    ew->iconified = on;
1094 }
1095
1096 /**
1097  * @brief Remove or restore the border of the given window.
1098  *
1099  * @param window The window.
1100  * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it.
1101  *
1102  * This function remove or restore the border of @p window. If @p on
1103  * is set to EINA_TRUE, the window will have no border, if it is set to
1104  * EINA_FALSE, it will have a border. If @p window is @c NULL or if the
1105  * state does not change (like setting to borderless while the window
1106  * has no border), this function does nothing.
1107  */
1108 EAPI void
1109 ecore_win32_window_borderless_set(Ecore_Win32_Window *window,
1110                                   Eina_Bool           on)
1111 {
1112    RECT                rect;
1113    DWORD               style;
1114    Ecore_Win32_Window *ew;
1115    HWND                w;
1116
1117    if (!window) return;
1118
1119    ew = (Ecore_Win32_Window *)window;
1120    if (((ew->borderless) && (on)) ||
1121        ((!ew->borderless) && (!on)))
1122      return;
1123
1124    INF("setting window without border: %s", on ? "yes" : "no");
1125
1126    w = ew->window;
1127
1128    style = GetWindowLong(w, GWL_STYLE);
1129    if (on)
1130      {
1131         if (!GetClientRect(w, &rect))
1132           {
1133              ERR("GetClientRect() failed");
1134              return;
1135           }
1136         SetLastError(0);
1137         if (!SetWindowLongPtr(w, GWL_STYLE, style & ~(WS_CAPTION | WS_THICKFRAME)) && (GetLastError() != 0))
1138           {
1139              ERR("SetWindowLongPtr() failed");
1140              return;
1141           }
1142      }
1143    else
1144      {
1145         if (!GetWindowRect(w, &rect))
1146           {
1147              ERR("GetWindowRect() failed");
1148              return;
1149           }
1150         style |= WS_CAPTION | WS_THICKFRAME;
1151         if (!AdjustWindowRect (&rect, style, FALSE))
1152           {
1153              ERR("AdjustWindowRect() failed");
1154              return;
1155           }
1156         SetLastError(0);
1157         if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1158           {
1159              ERR("SetWindowLongPtr() failed");
1160              return;
1161           }
1162      }
1163    if (!SetWindowPos(w, HWND_TOPMOST,
1164                      rect.left, rect.top,
1165                      rect.right - rect.left, rect.bottom - rect.top,
1166                      SWP_NOMOVE | SWP_FRAMECHANGED))
1167      {
1168         ERR("SetWindowPos() failed");
1169         return;
1170      }
1171    ew->borderless = on;
1172 }
1173
1174 /**
1175  * @brief Set the given window to fullscreen.
1176  *
1177  * @param window The window.
1178  * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode.
1179  *
1180  * This function set @p window to fullscreen or windowed mode. If @p on
1181  * is set to EINA_TRUE, the window will be fullscreen, if it is set to
1182  * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the
1183  * state does not change (like setting to fullscreen while the window
1184  * is already fullscreen), this function does nothing.
1185  */
1186 EAPI void
1187 ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
1188                                   Eina_Bool           on)
1189 {
1190    Ecore_Win32_Window *ew;
1191    HWND                        w;
1192
1193    if (!window) return;
1194
1195    ew = (Ecore_Win32_Window *)window;
1196    if (((ew->fullscreen) && (on)) ||
1197        ((!ew->fullscreen) && (!on)))
1198      return;
1199
1200    INF("setting fullscreen: %s", on ? "yes" : "no");
1201
1202    ew->fullscreen = !!on;
1203    w = ew->window;
1204
1205    if (on)
1206      {
1207         DWORD style;
1208
1209         if (!GetWindowRect(w, &ew->rect))
1210           {
1211              ERR("GetWindowRect() failed");
1212              return;
1213           }
1214         if (!(ew->style = GetWindowLong(w, GWL_STYLE)))
1215           {
1216              ERR("GetWindowLong() failed");
1217              return;
1218           }
1219         style = ew->style & ~WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX;
1220         style |= WS_VISIBLE | WS_POPUP;
1221         SetLastError(0);
1222         if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1223           {
1224              ERR("SetWindowLongPtr() failed");
1225              return;
1226           }
1227         SetLastError(0);
1228         if (!SetWindowLongPtr(w, GWL_EXSTYLE, WS_EX_TOPMOST) && (GetLastError() != 0))
1229           {
1230              ERR("SetWindowLongPtr() failed");
1231              return;
1232           }
1233         if (!SetWindowPos(w, HWND_TOPMOST, 0, 0,
1234                           GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN),
1235                           SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1236           {
1237              ERR("SetWindowPos() failed");
1238              return;
1239           }
1240      }
1241    else
1242      {
1243         SetLastError(0);
1244         if (!SetWindowLongPtr(w, GWL_STYLE, ew->style) && (GetLastError() != 0))
1245           {
1246              ERR("SetWindowLongPtr() failed");
1247              return;
1248           }
1249         SetLastError(0);
1250         if (!SetWindowLongPtr(w, GWL_EXSTYLE, 0) && (GetLastError() != 0))
1251           {
1252              ERR("SetWindowLongPtr() failed");
1253              return;
1254           }
1255         if (!SetWindowPos(w, HWND_NOTOPMOST,
1256                           ew->rect.left,
1257                           ew->rect.top,
1258                           ew->rect.right - ew->rect.left,
1259                           ew->rect.bottom - ew->rect.top,
1260                           SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1261           {
1262              ERR("SetWindowPos() failed");
1263              return;
1264           }
1265      }
1266 }
1267
1268 /**
1269  * @brief Set the given cursor to the given window.
1270  *
1271  * @param window The window to modify the cursor.
1272  * @param cursor The new cursor.
1273  *
1274  * This function sets @p cursor to @p window. @p cursor must have been
1275  * obtained by ecore_win32_cursor_new() or
1276  * ecore_win32_cursor_shaped_new(). If @p window or @p cursor is
1277  * @c NULL, the function does nothing.
1278  */
1279 EAPI void
1280 ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
1281                               Ecore_Win32_Cursor *cursor)
1282 {
1283    INF("setting cursor");
1284
1285    if (!window || !cursor)
1286      return;
1287
1288    if (!SetClassLongPtr(((Ecore_Win32_Window *)window)->window,
1289                      GCL_HCURSOR, (LONG_PTR)cursor))
1290      {
1291         ERR("SetClassLong() failed");
1292      }
1293 }
1294
1295 /**
1296  * @brief Set the state of the given window.
1297  *
1298  * @param window The window to modify the state.
1299  * @param state An array of the new states.
1300  * @param num The number of states in the array.
1301  *
1302  * This function set the state of @p window. @p state is an array of
1303  * states of size @p num. If @p window or @p state are @c NULL, or if
1304  * @p num is less or equal than 0, the function does nothing.
1305  */
1306 EAPI void
1307 ecore_win32_window_state_set(Ecore_Win32_Window       *window,
1308                              Ecore_Win32_Window_State *state,
1309                              unsigned int              num)
1310 {
1311    unsigned int i;
1312
1313    if (!window || !state || (num <= 0))
1314      return;
1315
1316    INF("setting cursor state");
1317
1318    for (i = 0; i < num; i++)
1319      {
1320         switch (state[i])
1321           {
1322           case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1323             ((Ecore_Win32_Window *)window)->state.iconified = 1;
1324             break;
1325           case ECORE_WIN32_WINDOW_STATE_MODAL:
1326             ((Ecore_Win32_Window *)window)->state.modal = 1;
1327             break;
1328           case ECORE_WIN32_WINDOW_STATE_STICKY:
1329             ((Ecore_Win32_Window *)window)->state.sticky = 1;
1330             break;
1331           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1332             ((Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1333             break;
1334           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1335             ((Ecore_Win32_Window *)window)->state.maximized_horz = 1;
1336             break;
1337           case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1338             ((Ecore_Win32_Window *)window)->state.maximized_horz = 1;
1339             ((Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1340             break;
1341           case ECORE_WIN32_WINDOW_STATE_SHADED:
1342             ((Ecore_Win32_Window *)window)->state.shaded = 1;
1343             break;
1344           case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1345             ((Ecore_Win32_Window *)window)->state.hidden = 1;
1346             break;
1347           case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1348             ((Ecore_Win32_Window *)window)->state.fullscreen = 1;
1349             break;
1350           case ECORE_WIN32_WINDOW_STATE_ABOVE:
1351             ((Ecore_Win32_Window *)window)->state.above = 1;
1352             break;
1353           case ECORE_WIN32_WINDOW_STATE_BELOW:
1354             ((Ecore_Win32_Window *)window)->state.below = 1;
1355             break;
1356           case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1357             ((Ecore_Win32_Window *)window)->state.demands_attention = 1;
1358             break;
1359           case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1360             /* nothing to be done */
1361             break;
1362           }
1363      }
1364 }
1365
1366 /**
1367  * @brief Apply the modification of the state to the given window.
1368  *
1369  * @param window The window.
1370  * @param state The state to apply changes.
1371  * @param set The value of the state change.
1372  *
1373  * This function applies the modification of the state @p state of
1374  * @p window. @p set is used only for
1375  * #ECORE_WIN32_WINDOW_STATE_ICONIFIED and
1376  * #ECORE_WIN32_WINDOW_STATE_FULLSCREEN. If @p window is @c NULL, the
1377  * function does nothing.
1378  */
1379 EAPI void
1380 ecore_win32_window_state_request_send(Ecore_Win32_Window      *window,
1381                                       Ecore_Win32_Window_State state,
1382                                       unsigned int             set)
1383 {
1384    Ecore_Win32_Window *ew;
1385    HWND                w;
1386
1387    if (!window) return;
1388
1389    ew = (Ecore_Win32_Window *)window;
1390    w = ew->window;
1391
1392    INF("sending cursor state");
1393
1394    switch (state)
1395      {
1396       case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1397          if (ew->state.iconified)
1398            ecore_win32_window_iconified_set(window, set);
1399          break;
1400       case ECORE_WIN32_WINDOW_STATE_MODAL:
1401          ew->state.modal = 1;
1402          break;
1403       case ECORE_WIN32_WINDOW_STATE_STICKY:
1404          ew->state.sticky = 1;
1405          break;
1406       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1407          if (ew->state.maximized_vert)
1408            {
1409               RECT rect;
1410               int  y;
1411               int  height;
1412
1413               if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1414                                         &rect, 0))
1415                 {
1416                    ERR("SystemParametersInfo() failed");
1417                    break;
1418                 }
1419               y = rect.top;
1420               height = rect.bottom - rect.top;
1421
1422               if (!GetClientRect(w, &rect))
1423                 {
1424                    ERR("GetClientRect() failed");
1425                    break;
1426                 }
1427
1428               if (!MoveWindow(w, rect.left, y,
1429                               rect.right - rect.left,
1430                               height,
1431                               TRUE))
1432                 {
1433                    ERR("MoveWindow() failed");
1434                 }
1435            }
1436          break;
1437       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1438          if (ew->state.maximized_horz)
1439            {
1440               RECT rect;
1441
1442               if (!GetClientRect(w, &rect))
1443                 {
1444                    ERR("GetClientRect() failed");
1445                    break;
1446                 }
1447
1448               if (!MoveWindow(w, 0, rect.top,
1449                               GetSystemMetrics(SM_CXSCREEN),
1450                               rect.bottom - rect.top,
1451                               TRUE))
1452                 {
1453                    ERR("MoveWindow() failed");
1454                 }
1455            }
1456          break;
1457       case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1458          if (ew->state.maximized_vert && ew->state.maximized_horz)
1459            {
1460               RECT rect;
1461
1462               if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1463                                         &rect, 0))
1464                 {
1465                    ERR("SystemParametersInfo() failed");
1466                    break;
1467                 }
1468
1469               if (!MoveWindow(w, 0, 0,
1470                               GetSystemMetrics(SM_CXSCREEN),
1471                               rect.bottom - rect.top,
1472                               TRUE))
1473                 {
1474                    ERR("MoveWindow() failed");
1475                 }
1476            }
1477          break;
1478       case ECORE_WIN32_WINDOW_STATE_SHADED:
1479          ew->state.shaded = 1;
1480          break;
1481       case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1482          ew->state.hidden = 1;
1483          break;
1484       case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1485          if (ew->state.fullscreen)
1486            ecore_win32_window_fullscreen_set(window, set);
1487          break;
1488       case ECORE_WIN32_WINDOW_STATE_ABOVE:
1489          if (ew->state.above)
1490            if (!SetWindowPos(w, HWND_TOP,
1491                              0, 0,
1492                              0, 0,
1493                              SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1494              {
1495                 ERR("SetWindowPos() failed");
1496              }
1497          break;
1498       case ECORE_WIN32_WINDOW_STATE_BELOW:
1499          if (ew->state.below)
1500            if (!SetWindowPos(w, HWND_BOTTOM,
1501                              0, 0,
1502                              0, 0,
1503                              SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1504              {
1505                 ERR("SetWindowPos() failed");
1506              }
1507          break;
1508       case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1509          ew->state.demands_attention = 1;
1510          break;
1511       case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1512          /* nothing to be done */
1513          break;
1514      }
1515 }
1516
1517 /**
1518  * @brief Set the type of the given window.
1519  *
1520  * @param window The window to modify the type.
1521  * @param type The new types.
1522  *
1523  * This function set the type of @p window to @p type. If
1524  * @p window is @c NULL, the function does nothing.
1525  */
1526 EAPI void
1527 ecore_win32_window_type_set(Ecore_Win32_Window      *window,
1528                             Ecore_Win32_Window_Type  type)
1529 {
1530    if (!window)
1531      return;
1532
1533    INF("setting window type");
1534
1535    switch (type)
1536      {
1537      case ECORE_WIN32_WINDOW_TYPE_DESKTOP:
1538        ((Ecore_Win32_Window *)window)->type.desktop = 1;
1539        break;
1540      case ECORE_WIN32_WINDOW_TYPE_DOCK:
1541        ((Ecore_Win32_Window *)window)->type.dock = 1;
1542        break;
1543      case ECORE_WIN32_WINDOW_TYPE_TOOLBAR:
1544        ((Ecore_Win32_Window *)window)->type.toolbar = 1;
1545        break;
1546      case ECORE_WIN32_WINDOW_TYPE_MENU:
1547        ((Ecore_Win32_Window *)window)->type.menu = 1;
1548        break;
1549      case ECORE_WIN32_WINDOW_TYPE_UTILITY:
1550        ((Ecore_Win32_Window *)window)->type.utility = 1;
1551        break;
1552      case ECORE_WIN32_WINDOW_TYPE_SPLASH:
1553        ((Ecore_Win32_Window *)window)->type.splash = 1;
1554        break;
1555      case ECORE_WIN32_WINDOW_TYPE_DIALOG:
1556        ((Ecore_Win32_Window *)window)->type.dialog = 1;
1557        break;
1558      case ECORE_WIN32_WINDOW_TYPE_NORMAL:
1559        ((Ecore_Win32_Window *)window)->type.normal = 1;
1560        break;
1561      case ECORE_WIN32_WINDOW_TYPE_UNKNOWN:
1562        ((Ecore_Win32_Window *)window)->type.normal = 1;
1563        break;
1564      }
1565 }
1566
1567 /**
1568  * @}
1569  */