6 #include <stdio.h> /* for printf */
8 #define WIN32_LEAN_AND_MEAN
10 #undef WIN32_LEAN_AND_MEAN
14 #include "Ecore_Win32.h"
15 #include "ecore_win32_private.h"
17 /*============================================================================*
19 *============================================================================*/
26 typedef enum _Ecore_Win32_Window_Z_Order Ecore_Win32_Window_Z_Order;
27 enum _Ecore_Win32_Window_Z_Order
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
35 static Ecore_Win32_Window *
36 ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
44 struct _Ecore_Win32_Window *w;
48 w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window));
51 ERR("malloc() failed");
59 if (!AdjustWindowRect(&rect, style, FALSE))
61 ERR("AdjustWindowRect() failed");
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)) */
71 /* fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */
72 /* fprintf (stderr, " Wrong size %ld\n", rect.right - rect.left); */
76 if ((rect.right - rect.left) < minimal_width)
78 rect.right = rect.left + minimal_width;
81 w->window = CreateWindowEx(0,
82 ECORE_WIN32_WINDOW_CLASS, "",
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);
91 ERR("CreateWindowEx() failed");
97 if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0))
99 ERR("SetWindowLongPtr() failed");
100 DestroyWindow(w->window);
107 w->max_width = 32767;
108 w->max_height = 32767;
114 w->state.iconified = 0;
117 w->state.maximized_vert = 0;
118 w->state.maximized_horz = 0;
121 w->state.fullscreen = 0;
124 w->state.demands_attention = 0;
135 w->pointer_is_in = 0;
148 /*============================================================================*
150 *============================================================================*/
152 /*============================================================================*
154 *============================================================================*/
157 * @addtogroup Ecore_Win32_Group Ecore_Win32 library
163 * @brief Creates a new window.
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.
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.
179 EAPI Ecore_Win32_Window *
180 ecore_win32_window_new(Ecore_Win32_Window *parent,
186 INF("creating window with border");
188 return ecore_win32_window_internal_new(parent,
191 WS_OVERLAPPEDWINDOW | WS_SIZEBOX);
195 * @brief Creates a new borderless window.
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.
204 * This function is the same than ecore_win32_window_override_new()
205 * but the returned window is borderless.
207 EAPI Ecore_Win32_Window *
208 ecore_win32_window_override_new(Ecore_Win32_Window *parent,
214 INF("creating window without border");
216 return ecore_win32_window_internal_new(parent,
223 * @brief Free the given window.
225 * @param window The window to free.
227 * This function frees @p window. If @p window is @c NULL, this
228 * function does nothing.
231 ecore_win32_window_free(Ecore_Win32_Window *window)
233 struct _Ecore_Win32_Window *wnd = window;
237 INF("destroying window");
240 free(wnd->shape.mask);
242 DestroyWindow(((struct _Ecore_Win32_Window *)window)->window);
247 * @brief Return the window HANDLE associated to the given window.
249 * @param window The window to retrieve the HANDLE from.
251 * This function returns the window HANDLE associated to @p window. If
252 * @p window is @c NULL, this function returns @c NULL.
255 ecore_win32_window_hwnd_get(Ecore_Win32_Window *window)
257 if (!window) return NULL;
259 return ((struct _Ecore_Win32_Window *)window)->window;
264 ecore_win32_window_configure(Ecore_Win32_Window *window,
265 Ecore_Win32_Window_Z_Order order,
275 case ECORE_WIN32_WINDOW_Z_ORDER_BOTTOM:
278 case ECORE_WIN32_WINDOW_Z_ORDER_NOTOPMOST:
281 case ECORE_WIN32_WINDOW_Z_ORDER_TOP:
284 case ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST:
290 SetWindowPos((struct _Ecore_Win32_Window *)window->window, w, x, y, width, height, ???);
295 * @brief Move the given window to a given position.
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.
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.
306 ecore_win32_window_move(Ecore_Win32_Window *window,
313 /* FIXME: on fullscreen, should not move it */
316 INF("moving window (%dx%d)", x, y);
318 w = ((struct _Ecore_Win32_Window *)window)->window;
319 if (!GetWindowRect(w, &rect))
321 ERR("GetWindowRect() failed");
325 if (!MoveWindow(w, x, y,
326 rect.right - rect.left,
327 rect.bottom - rect.top,
330 ERR("MoveWindow() failed");
335 * @brief Resize the given window to a given size.
337 * @param window The window to resize.
338 * @param width The new width.
339 * @param height The new height.
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.
346 ecore_win32_window_resize(Ecore_Win32_Window *window,
351 struct _Ecore_Win32_Window *w;
356 /* FIXME: on fullscreen, should not resize it */
359 INF("resizing window (%dx%d)", width, height);
361 w = (struct _Ecore_Win32_Window *)window;
362 if (!GetWindowRect(w->window, &rect))
364 ERR("GetWindowRect() failed");
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); */
380 rect.bottom = height;
381 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
383 ERR("GetWindowLong() failed");
386 if (!AdjustWindowRect(&rect, style, FALSE))
388 ERR("AdjustWindowRect() failed");
392 if (!MoveWindow(w->window, x, y,
393 rect.right - rect.left,
394 rect.bottom - rect.top,
397 ERR("MoveWindow() failed");
402 * @brief Move and resize the given window to a given position and size.
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.
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.
415 ecore_win32_window_move_resize(Ecore_Win32_Window *window,
422 struct _Ecore_Win32_Window *w;
425 /* FIXME: on fullscreen, should not move/resize it */
428 INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
430 w = ((struct _Ecore_Win32_Window *)window);
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;
438 rect.bottom = height;
439 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
441 ERR("GetWindowLong() failed");
444 if (!AdjustWindowRect(&rect, style, FALSE))
446 ERR("AdjustWindowRect() failed");
450 if (!MoveWindow(w->window, x, y,
451 rect.right - rect.left,
452 rect.bottom - rect.top,
455 ERR("MoveWindow() failed");
460 * @brief Get the geometry of the given window.
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.
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.
476 ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
486 INF("getting window geometry");
492 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
493 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
498 if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
501 ERR("GetClientRect() failed");
505 if (width) *width = 0;
506 if (height) *height = 0;
511 w = rect.right - rect.left;
512 h = rect.bottom - rect.top;
514 if (!GetWindowRect(((struct _Ecore_Win32_Window *)window)->window,
517 ERR("GetWindowRect() failed");
521 if (width) *width = 0;
522 if (height) *height = 0;
527 if (x) *x = rect.left;
528 if (y) *y = rect.top;
529 if (width) *width = w;
530 if (height) *height = h;
534 * @brief Get the size of the given window.
536 * @param window The window to retrieve the size from.
537 * @param width The width.
538 * @param height The height.
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.
548 ecore_win32_window_size_get(Ecore_Win32_Window *window,
554 INF("getting window size");
558 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
559 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
564 if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
567 ERR("GetClientRect() failed");
569 if (width) *width = 0;
570 if (height) *height = 0;
573 if (width) *width = rect.right - rect.left;
574 if (height) *height = rect.bottom - rect.top;
578 * @brief Set the minimum size of the given window.
580 * @param window The window.
581 * @param min_width The minimal width.
582 * @param min_height The minimal height.
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
589 ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
590 unsigned int min_width,
591 unsigned int min_height)
593 struct _Ecore_Win32_Window *w;
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;
604 * @brief Get the minimum size of the given window.
606 * @param window The window.
607 * @param min_width The minimal width.
608 * @param min_height The minimal height.
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.
615 ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
616 unsigned int *min_width,
617 unsigned int *min_height)
619 struct _Ecore_Win32_Window *w;
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;
630 * @brief Set the maximum size of the given window.
632 * @param window The window.
633 * @param max_width The maximal width.
634 * @param max_height The maximal height.
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
641 ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
642 unsigned int max_width,
643 unsigned int max_height)
645 struct _Ecore_Win32_Window *w;
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;
656 * @brief Get the maximum size of the given window.
658 * @param window The window.
659 * @param max_width The maximal width.
660 * @param max_height The maximal height.
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.
667 ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
668 unsigned int *max_width,
669 unsigned int *max_height)
671 struct _Ecore_Win32_Window *w;
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;
682 * @brief Set the base size of the given window.
684 * @param window The window.
685 * @param base_width The base width.
686 * @param base_height The base height.
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
693 ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
694 unsigned int base_width,
695 unsigned int base_height)
697 struct _Ecore_Win32_Window *w;
699 printf ("ecore_win32_window_size_base_set : %p %d %d\n", window, base_width, base_height);
702 w = (struct _Ecore_Win32_Window *)window;
703 w->base_width = base_width;
704 w->base_height = base_height;
708 * @brief Get the base size of the given window.
710 * @param window The window.
711 * @param base_width The base width.
712 * @param base_height The bas height.
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.
719 ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
720 unsigned int *base_width,
721 unsigned int *base_height)
723 struct _Ecore_Win32_Window *w;
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;
734 * @brief Set the step size of the given window.
736 * @param window The window.
737 * @param step_width The step width.
738 * @param step_height The step height.
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
745 ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
746 unsigned int step_width,
747 unsigned int step_height)
749 struct _Ecore_Win32_Window *w;
751 printf ("ecore_win32_window_size_step_set : %p %d %d\n", window, step_width, step_height);
754 w = (struct _Ecore_Win32_Window *)window;
755 w->step_width = step_width;
756 w->step_height = step_height;
760 * @brief Get the step size of the given window.
762 * @param window The window.
763 * @param step_width The step width.
764 * @param step_height The bas height.
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.
771 ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
772 unsigned int *step_width,
773 unsigned int *step_height)
775 struct _Ecore_Win32_Window *w;
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;
786 ecore_win32_window_shape_set(Ecore_Win32_Window *window,
787 unsigned short width,
788 unsigned short height,
791 struct _Ecore_Win32_Window *wnd;
795 OSVERSIONINFO version_info;
800 wnd = (struct _Ecore_Win32_Window *)window;
804 wnd->shape.enabled = 0;
805 if (wnd->shape.layered != 0)
807 wnd->shape.layered = 0;
808 #if defined(WS_EX_LAYERED)
810 if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
811 GetWindowLong(wnd->window, GWL_EXSTYLE) & (~WS_EX_LAYERED)) &&
812 (GetLastError() != 0))
814 ERR("SetWindowLongPtr() failed");
817 if (!RedrawWindow(wnd->window, NULL, NULL,
818 RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN))
820 ERR("RedrawWindow() failed");
826 if (!SetWindowRgn(wnd->window, NULL, TRUE))
828 ERR("SetWindowRgn() failed");
833 if (width == 0 || height == 0)
836 wnd->shape.enabled = 1;
838 if (width != wnd->shape.width || height != wnd->shape.height)
840 wnd->shape.width = width;
841 wnd->shape.height = height;
844 free(wnd->shape.mask);
845 wnd->shape.mask = NULL;
847 wnd->shape.mask = malloc(width * height);
849 memcpy(wnd->shape.mask, mask, width * height);
851 wnd->shape.layered = 0;
853 #if defined(WS_EX_LAYERED)
854 version_info.dwOSVersionInfoSize = sizeof(version_info);
855 if (GetVersionEx(&version_info) == TRUE && version_info.dwMajorVersion == 5)
858 if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
859 GetWindowLong(wnd->window, GWL_EXSTYLE) | WS_EX_LAYERED) &&
860 (GetLastError() != 0))
862 ERR("SetWindowLongPtr() failed");
865 wnd->shape.layered = 1;
870 if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
872 ERR("CreateRectRgn() failed");
875 for (y = 0; y < height; y++)
879 if (!(rgnLine = CreateRectRgn(0, 0, 0, 0)))
881 ERR("CreateRectRgn() failed");
884 for (x = 0; x < width; x++)
886 if (mask[y * width + x] > 0)
890 if (!(rgnDot = CreateRectRgn(x, y, x + 1, y + 1)))
892 ERR("CreateRectRgn() failed");
895 if (CombineRgn(rgnLine, rgnLine, rgnDot, RGN_OR) == ERROR)
897 ERR("CombineRgn() has not created a new region");
899 if (!DeleteObject(rgnDot))
901 ERR("DeleteObject() failed");
906 if (CombineRgn(rgn, rgn, rgnLine, RGN_OR) == ERROR)
908 ERR("CombineRgn() has not created a new region");
910 if (!DeleteObject(rgnLine))
912 ERR("DeleteObject() failed");
916 if (!SetWindowRgn(wnd->window, rgn, TRUE))
918 ERR("SetWindowRgn() failed");
923 * @brief Show the given window.
925 * @param window The window to show.
927 * This function shows @p window. If @p window is @c NULL, or on
928 * error, this function does nothing.
931 ecore_win32_window_show(Ecore_Win32_Window *window)
935 INF("showing window");
937 ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL);
938 if (!UpdateWindow(((struct _Ecore_Win32_Window *)window)->window))
940 ERR("UpdateWindow() failed");
944 /* FIXME: seems to block the taskbar */
946 * @brief Hide the given window.
948 * @param window The window to show.
950 * This function hides @p window. If @p window is @c NULL, or on
951 * error, this function does nothing.
954 ecore_win32_window_hide(Ecore_Win32_Window *window)
958 INF("hiding window");
960 ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE);
964 * @brief Place the given window at the top of the Z order.
966 * @param window The window to place at the top.
968 * This function places @p window at the top of the Z order. If
969 * @p window is @c NULL, this function does nothing.
972 ecore_win32_window_raise(Ecore_Win32_Window *window)
976 INF("raising window");
978 if (!SetWindowPos(((struct _Ecore_Win32_Window *)window)->window,
979 HWND_TOP, 0, 0, 0, 0,
980 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
982 ERR("SetWindowPos() failed");
987 * @brief Place the given window at the bottom of the Z order.
989 * @param window The window to place at the bottom.
991 * This function places @p window at the bottom of the Z order. If
992 * @p window is @c NULL, this function does nothing.
995 ecore_win32_window_lower(Ecore_Win32_Window *window)
999 INF("lowering window");
1001 if (!SetWindowPos(((struct _Ecore_Win32_Window *)window)->window,
1002 HWND_BOTTOM, 0, 0, 0, 0,
1003 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
1005 ERR("SetWindowPos() failed");
1010 * @brief Set the title of the given window.
1012 * @param window The window to set the title.
1013 * @param title The new title.
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.
1020 ecore_win32_window_title_set(Ecore_Win32_Window *window,
1023 if (!window) return;
1025 if (!title || !title[0]) return;
1027 INF("setting window title");
1029 if (!SetWindowText(((struct _Ecore_Win32_Window *)window)->window, title))
1031 ERR("SetWindowText() failed");
1036 * @brief Set the focus to the given window.
1038 * @param window The window to give focus to.
1040 * This function gives the focus to @p window. If @p window is
1041 * @c NULL, this function does nothing.
1044 ecore_win32_window_focus_set(Ecore_Win32_Window *window)
1046 if (!window) return;
1048 INF("focusing window");
1050 if (!SetFocus(((struct _Ecore_Win32_Window *)window)->window))
1052 ERR("SetFocus() failed");
1057 * @brief Iconify or restore the given window.
1059 * @param window The window.
1060 * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it.
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.
1069 ecore_win32_window_iconified_set(Ecore_Win32_Window *window,
1072 struct _Ecore_Win32_Window *ew;
1074 if (!window) return;
1076 ew = (struct _Ecore_Win32_Window *)window;
1077 if (((ew->iconified) && (on)) ||
1078 ((!ew->iconified) && (!on)))
1081 INF("iconifying window: %s", on ? "yes" : "no");
1083 ShowWindow(ew->window, on ? SW_MINIMIZE : SW_RESTORE);
1088 * @brief Remove or restore the border of the given window.
1090 * @param window The window.
1091 * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it.
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.
1100 ecore_win32_window_borderless_set(Ecore_Win32_Window *window,
1105 struct _Ecore_Win32_Window *ew;
1108 if (!window) return;
1110 ew = (struct _Ecore_Win32_Window *)window;
1111 if (((ew->borderless) && (on)) ||
1112 ((!ew->borderless) && (!on)))
1115 INF("setting window without border: %s", on ? "yes" : "no");
1119 style = GetWindowLong(w, GWL_STYLE);
1122 if (!GetClientRect(w, &rect))
1124 ERR("GetClientRect() failed");
1128 if (!SetWindowLongPtr(w, GWL_STYLE, style & ~(WS_CAPTION | WS_THICKFRAME)) && (GetLastError() != 0))
1130 ERR("SetWindowLongPtr() failed");
1136 if (!GetWindowRect(w, &rect))
1138 ERR("GetWindowRect() failed");
1141 style |= WS_CAPTION | WS_THICKFRAME;
1142 if (!AdjustWindowRect (&rect, style, FALSE))
1144 ERR("AdjustWindowRect() failed");
1148 if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1150 ERR("SetWindowLongPtr() failed");
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))
1159 ERR("SetWindowPos() failed");
1162 ew->borderless = on;
1166 * @brief Set the given window to fullscreen.
1168 * @param window The window.
1169 * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode.
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.
1178 ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
1181 struct _Ecore_Win32_Window *ew;
1184 if (!window) return;
1186 ew = (struct _Ecore_Win32_Window *)window;
1187 if (((ew->fullscreen) && (on)) ||
1188 ((!ew->fullscreen) && (!on)))
1191 INF("setting fullscreen: %s", on ? "yes" : "no");
1193 ew->fullscreen = !!on;
1200 if (!GetWindowRect(w, &ew->rect))
1202 ERR("GetWindowRect() failed");
1205 if (!(ew->style = GetWindowLong(w, GWL_STYLE)))
1207 ERR("GetWindowLong() failed");
1210 style = ew->style & ~WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX;
1211 style |= WS_VISIBLE | WS_POPUP;
1213 if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1215 ERR("SetWindowLongPtr() failed");
1219 if (!SetWindowLongPtr(w, GWL_EXSTYLE, WS_EX_TOPMOST) && (GetLastError() != 0))
1221 ERR("SetWindowLongPtr() failed");
1224 if (!SetWindowPos(w, HWND_TOPMOST, 0, 0,
1225 GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN),
1226 SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1228 ERR("SetWindowPos() failed");
1235 if (!SetWindowLongPtr(w, GWL_STYLE, ew->style) && (GetLastError() != 0))
1237 ERR("SetWindowLongPtr() failed");
1241 if (!SetWindowLongPtr(w, GWL_EXSTYLE, 0) && (GetLastError() != 0))
1243 ERR("SetWindowLongPtr() failed");
1246 if (!SetWindowPos(w, HWND_NOTOPMOST,
1249 ew->rect.right - ew->rect.left,
1250 ew->rect.bottom - ew->rect.top,
1251 SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1253 ERR("SetWindowPos() failed");
1260 * @brief Set the given cursor to the given window.
1262 * @param window The window to modify the cursor.
1263 * @param cursor The new cursor.
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.
1271 ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
1272 Ecore_Win32_Cursor *cursor)
1274 INF("setting cursor");
1276 if (!window || !cursor)
1279 if (!SetClassLong(((struct _Ecore_Win32_Window *)window)->window,
1280 GCL_HCURSOR, (LONG)cursor))
1282 ERR("SetClassLong() failed");
1287 * @brief Set the state of the given window.
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.
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.
1298 ecore_win32_window_state_set(Ecore_Win32_Window *window,
1299 Ecore_Win32_Window_State *state,
1304 if (!window || !state || (num <= 0))
1307 INF("setting cursor state");
1309 for (i = 0; i < num; i++)
1313 case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1314 ((struct _Ecore_Win32_Window *)window)->state.iconified = 1;
1316 case ECORE_WIN32_WINDOW_STATE_MODAL:
1317 ((struct _Ecore_Win32_Window *)window)->state.modal = 1;
1319 case ECORE_WIN32_WINDOW_STATE_STICKY:
1320 ((struct _Ecore_Win32_Window *)window)->state.sticky = 1;
1322 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1323 ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1325 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1326 ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1;
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;
1332 case ECORE_WIN32_WINDOW_STATE_SHADED:
1333 ((struct _Ecore_Win32_Window *)window)->state.shaded = 1;
1335 case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1336 ((struct _Ecore_Win32_Window *)window)->state.hidden = 1;
1338 case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1339 ((struct _Ecore_Win32_Window *)window)->state.fullscreen = 1;
1341 case ECORE_WIN32_WINDOW_STATE_ABOVE:
1342 ((struct _Ecore_Win32_Window *)window)->state.above = 1;
1344 case ECORE_WIN32_WINDOW_STATE_BELOW:
1345 ((struct _Ecore_Win32_Window *)window)->state.below = 1;
1347 case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1348 ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1;
1350 case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1351 /* nothing to be done */
1358 * @brief Apply the modification of the state to the given window.
1360 * @param window The window.
1361 * @param state The state to apply changes.
1362 * @param set The value of the state change.
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.
1371 ecore_win32_window_state_request_send(Ecore_Win32_Window *window,
1372 Ecore_Win32_Window_State state,
1375 struct _Ecore_Win32_Window *ew;
1378 if (!window) return;
1380 ew = (struct _Ecore_Win32_Window *)window;
1383 INF("sending cursor state");
1387 case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1388 if (ew->state.iconified)
1389 ecore_win32_window_iconified_set(window, set);
1391 case ECORE_WIN32_WINDOW_STATE_MODAL:
1392 ew->state.modal = 1;
1394 case ECORE_WIN32_WINDOW_STATE_STICKY:
1395 ew->state.sticky = 1;
1397 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1398 if (ew->state.maximized_vert)
1404 if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1407 ERR("SystemParametersInfo() failed");
1411 height = rect.bottom - rect.top;
1413 if (!GetClientRect(w, &rect))
1415 ERR("GetClientRect() failed");
1419 if (!MoveWindow(w, rect.left, y,
1420 rect.right - rect.left,
1424 ERR("MoveWindow() failed");
1428 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1429 if (ew->state.maximized_horz)
1433 if (!GetClientRect(w, &rect))
1435 ERR("GetClientRect() failed");
1439 if (!MoveWindow(w, 0, rect.top,
1440 GetSystemMetrics(SM_CXSCREEN),
1441 rect.bottom - rect.top,
1444 ERR("MoveWindow() failed");
1448 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1449 if (ew->state.maximized_vert && ew->state.maximized_horz)
1453 if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1456 ERR("SystemParametersInfo() failed");
1460 if (!MoveWindow(w, 0, 0,
1461 GetSystemMetrics(SM_CXSCREEN),
1462 rect.bottom - rect.top,
1465 ERR("MoveWindow() failed");
1469 case ECORE_WIN32_WINDOW_STATE_SHADED:
1470 ew->state.shaded = 1;
1472 case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1473 ew->state.hidden = 1;
1475 case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1476 if (ew->state.fullscreen)
1477 ecore_win32_window_fullscreen_set(window, set);
1479 case ECORE_WIN32_WINDOW_STATE_ABOVE:
1480 if (ew->state.above)
1481 if (!SetWindowPos(w, HWND_TOP,
1484 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1486 ERR("SetWindowPos() failed");
1489 case ECORE_WIN32_WINDOW_STATE_BELOW:
1490 if (ew->state.below)
1491 if (!SetWindowPos(w, HWND_BOTTOM,
1494 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1496 ERR("SetWindowPos() failed");
1499 case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1500 ew->state.demands_attention = 1;
1502 case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1503 /* nothing to be done */
1509 * @brief Set the type of the given window.
1511 * @param window The window to modify the type.
1512 * @param type The new types.
1514 * This function set the type of @p window to @p type. If
1515 * @p window is @c NULL, the function does nothing.
1518 ecore_win32_window_type_set(Ecore_Win32_Window *window,
1519 Ecore_Win32_Window_Type type)
1524 INF("setting window type");
1528 case ECORE_WIN32_WINDOW_TYPE_DESKTOP:
1529 ((struct _Ecore_Win32_Window *)window)->type.desktop = 1;
1531 case ECORE_WIN32_WINDOW_TYPE_DOCK:
1532 ((struct _Ecore_Win32_Window *)window)->type.dock = 1;
1534 case ECORE_WIN32_WINDOW_TYPE_TOOLBAR:
1535 ((struct _Ecore_Win32_Window *)window)->type.toolbar = 1;
1537 case ECORE_WIN32_WINDOW_TYPE_MENU:
1538 ((struct _Ecore_Win32_Window *)window)->type.menu = 1;
1540 case ECORE_WIN32_WINDOW_TYPE_UTILITY:
1541 ((struct _Ecore_Win32_Window *)window)->type.utility = 1;
1543 case ECORE_WIN32_WINDOW_TYPE_SPLASH:
1544 ((struct _Ecore_Win32_Window *)window)->type.splash = 1;
1546 case ECORE_WIN32_WINDOW_TYPE_DIALOG:
1547 ((struct _Ecore_Win32_Window *)window)->type.dialog = 1;
1549 case ECORE_WIN32_WINDOW_TYPE_NORMAL:
1550 ((struct _Ecore_Win32_Window *)window)->type.normal = 1;
1552 case ECORE_WIN32_WINDOW_TYPE_UNKNOWN:
1553 ((struct _Ecore_Win32_Window *)window)->type.normal = 1;