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 Ecore_Win32_Window *w;
48 w = (Ecore_Win32_Window *)calloc(1, sizeof(Ecore_Win32_Window));
51 ERR("malloc() failed");
59 if (!AdjustWindowRectEx(&rect, style, FALSE, 0))
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 ? ((Ecore_Win32_Window *)parent)->window : NULL,
88 NULL, _ecore_win32_instance, NULL);
91 ERR("CreateWindowEx() failed");
97 if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG_PTR)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 Ecore_Win32_Window *wnd = window;
237 INF("destroying window");
240 free(wnd->shape.mask);
242 DestroyWindow(((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 ((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((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 = ((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 Ecore_Win32_Window *w;
358 /* FIXME: on fullscreen, should not resize it */
361 INF("resizing window (%dx%d)", width, height);
363 w = (Ecore_Win32_Window *)window;
365 minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)w->min_width);
366 minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)w->min_height);
368 if (!GetWindowRect(w->window, &rect))
370 ERR("GetWindowRect() failed");
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;
383 rect.bottom = height;
384 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
386 ERR("GetWindowLong() failed");
389 if (!AdjustWindowRect(&rect, style, FALSE))
391 ERR("AdjustWindowRect() failed");
395 if (!MoveWindow(w->window, x, y,
396 rect.right - rect.left,
397 rect.bottom - rect.top,
400 ERR("MoveWindow() failed");
405 * @brief Move and resize the given window to a given position and size.
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.
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.
418 ecore_win32_window_move_resize(Ecore_Win32_Window *window,
425 Ecore_Win32_Window *w;
430 /* FIXME: on fullscreen, should not move/resize it */
433 INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
435 w = ((Ecore_Win32_Window *)window);
437 minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)w->min_width);
438 minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)w->min_height);
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;
447 rect.bottom = height;
448 if (!(style = GetWindowLong(w->window, GWL_STYLE)))
450 ERR("GetWindowLong() failed");
453 if (!AdjustWindowRect(&rect, style, FALSE))
455 ERR("AdjustWindowRect() failed");
459 if (!MoveWindow(w->window, x, y,
460 rect.right - rect.left,
461 rect.bottom - rect.top,
464 ERR("MoveWindow() failed");
469 * @brief Get the geometry of the given window.
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.
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.
485 ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
495 INF("getting window geometry");
501 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
502 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
507 if (!GetClientRect(((Ecore_Win32_Window *)window)->window,
510 ERR("GetClientRect() failed");
514 if (width) *width = 0;
515 if (height) *height = 0;
520 w = rect.right - rect.left;
521 h = rect.bottom - rect.top;
523 if (!GetWindowRect(((Ecore_Win32_Window *)window)->window,
526 ERR("GetWindowRect() failed");
530 if (width) *width = 0;
531 if (height) *height = 0;
536 if (x) *x = rect.left;
537 if (y) *y = rect.top;
538 if (width) *width = w;
539 if (height) *height = h;
543 * @brief Get the size of the given window.
545 * @param window The window to retrieve the size from.
546 * @param width The width.
547 * @param height The height.
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.
557 ecore_win32_window_size_get(Ecore_Win32_Window *window,
563 INF("getting window size");
567 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
568 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
573 if (!GetClientRect(((Ecore_Win32_Window *)window)->window,
576 ERR("GetClientRect() failed");
578 if (width) *width = 0;
579 if (height) *height = 0;
582 if (width) *width = rect.right - rect.left;
583 if (height) *height = rect.bottom - rect.top;
587 * @brief Set the minimum size of the given window.
589 * @param window The window.
590 * @param min_width The minimal width.
591 * @param min_height The minimal height.
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
598 ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
599 unsigned int min_width,
600 unsigned int min_height)
602 Ecore_Win32_Window *w;
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;
613 * @brief Get the minimum size of the given window.
615 * @param window The window.
616 * @param min_width The minimal width.
617 * @param min_height The minimal height.
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.
624 ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
625 unsigned int *min_width,
626 unsigned int *min_height)
628 Ecore_Win32_Window *w;
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;
639 * @brief Set the maximum size of the given window.
641 * @param window The window.
642 * @param max_width The maximal width.
643 * @param max_height The maximal height.
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
650 ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
651 unsigned int max_width,
652 unsigned int max_height)
654 Ecore_Win32_Window *w;
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;
665 * @brief Get the maximum size of the given window.
667 * @param window The window.
668 * @param max_width The maximal width.
669 * @param max_height The maximal height.
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.
676 ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
677 unsigned int *max_width,
678 unsigned int *max_height)
680 Ecore_Win32_Window *w;
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;
691 * @brief Set the base size of the given window.
693 * @param window The window.
694 * @param base_width The base width.
695 * @param base_height The base height.
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
702 ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
703 unsigned int base_width,
704 unsigned int base_height)
706 Ecore_Win32_Window *w;
708 printf ("ecore_win32_window_size_base_set : %p %d %d\n", window, base_width, base_height);
711 w = (Ecore_Win32_Window *)window;
712 w->base_width = base_width;
713 w->base_height = base_height;
717 * @brief Get the base size of the given window.
719 * @param window The window.
720 * @param base_width The base width.
721 * @param base_height The bas height.
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.
728 ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
729 unsigned int *base_width,
730 unsigned int *base_height)
732 Ecore_Win32_Window *w;
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;
743 * @brief Set the step size of the given window.
745 * @param window The window.
746 * @param step_width The step width.
747 * @param step_height The step height.
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
754 ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
755 unsigned int step_width,
756 unsigned int step_height)
758 Ecore_Win32_Window *w;
760 printf ("ecore_win32_window_size_step_set : %p %d %d\n", window, step_width, step_height);
763 w = (Ecore_Win32_Window *)window;
764 w->step_width = step_width;
765 w->step_height = step_height;
769 * @brief Get the step size of the given window.
771 * @param window The window.
772 * @param step_width The step width.
773 * @param step_height The bas height.
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.
780 ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
781 unsigned int *step_width,
782 unsigned int *step_height)
784 Ecore_Win32_Window *w;
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;
795 ecore_win32_window_shape_set(Ecore_Win32_Window *window,
796 unsigned short width,
797 unsigned short height,
800 Ecore_Win32_Window *wnd;
804 OSVERSIONINFO version_info;
809 wnd = (Ecore_Win32_Window *)window;
813 wnd->shape.enabled = 0;
814 if (wnd->shape.layered != 0)
816 wnd->shape.layered = 0;
817 #if defined(WS_EX_LAYERED)
819 if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
820 GetWindowLong(wnd->window, GWL_EXSTYLE) & (~WS_EX_LAYERED)) &&
821 (GetLastError() != 0))
823 ERR("SetWindowLongPtr() failed");
826 if (!RedrawWindow(wnd->window, NULL, NULL,
827 RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN))
829 ERR("RedrawWindow() failed");
835 if (!SetWindowRgn(wnd->window, NULL, TRUE))
837 ERR("SetWindowRgn() failed");
842 if (width == 0 || height == 0)
845 wnd->shape.enabled = 1;
847 if (width != wnd->shape.width || height != wnd->shape.height)
849 wnd->shape.width = width;
850 wnd->shape.height = height;
853 free(wnd->shape.mask);
854 wnd->shape.mask = NULL;
856 wnd->shape.mask = malloc(width * height);
858 memcpy(wnd->shape.mask, mask, width * height);
860 wnd->shape.layered = 0;
862 #if defined(WS_EX_LAYERED)
863 version_info.dwOSVersionInfoSize = sizeof(version_info);
864 if (GetVersionEx(&version_info) == TRUE && version_info.dwMajorVersion == 5)
867 if (!SetWindowLongPtr(wnd->window, GWL_EXSTYLE,
868 GetWindowLong(wnd->window, GWL_EXSTYLE) | WS_EX_LAYERED) &&
869 (GetLastError() != 0))
871 ERR("SetWindowLongPtr() failed");
874 wnd->shape.layered = 1;
879 if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
881 ERR("CreateRectRgn() failed");
884 for (y = 0; y < height; y++)
888 if (!(rgnLine = CreateRectRgn(0, 0, 0, 0)))
890 ERR("CreateRectRgn() failed");
893 for (x = 0; x < width; x++)
895 if (mask[y * width + x] > 0)
899 if (!(rgnDot = CreateRectRgn(x, y, x + 1, y + 1)))
901 ERR("CreateRectRgn() failed");
904 if (CombineRgn(rgnLine, rgnLine, rgnDot, RGN_OR) == ERROR)
906 ERR("CombineRgn() has not created a new region");
908 if (!DeleteObject(rgnDot))
910 ERR("DeleteObject() failed");
915 if (CombineRgn(rgn, rgn, rgnLine, RGN_OR) == ERROR)
917 ERR("CombineRgn() has not created a new region");
919 if (!DeleteObject(rgnLine))
921 ERR("DeleteObject() failed");
925 if (!SetWindowRgn(wnd->window, rgn, TRUE))
927 ERR("SetWindowRgn() failed");
932 * @brief Show the given window.
934 * @param window The window to show.
936 * This function shows @p window. If @p window is @c NULL, or on
937 * error, this function does nothing.
940 ecore_win32_window_show(Ecore_Win32_Window *window)
944 INF("showing window");
946 ShowWindow(((Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL);
947 if (!UpdateWindow(((Ecore_Win32_Window *)window)->window))
949 ERR("UpdateWindow() failed");
953 /* FIXME: seems to block the taskbar */
955 * @brief Hide the given window.
957 * @param window The window to show.
959 * This function hides @p window. If @p window is @c NULL, or on
960 * error, this function does nothing.
963 ecore_win32_window_hide(Ecore_Win32_Window *window)
967 INF("hiding window");
969 ShowWindow(((Ecore_Win32_Window *)window)->window, SW_HIDE);
973 * @brief Place the given window at the top of the Z order.
975 * @param window The window to place at the top.
977 * This function places @p window at the top of the Z order. If
978 * @p window is @c NULL, this function does nothing.
981 ecore_win32_window_raise(Ecore_Win32_Window *window)
985 INF("raising window");
987 if (!SetWindowPos(((Ecore_Win32_Window *)window)->window,
988 HWND_TOP, 0, 0, 0, 0,
989 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
991 ERR("SetWindowPos() failed");
996 * @brief Place the given window at the bottom of the Z order.
998 * @param window The window to place at the bottom.
1000 * This function places @p window at the bottom of the Z order. If
1001 * @p window is @c NULL, this function does nothing.
1004 ecore_win32_window_lower(Ecore_Win32_Window *window)
1006 if (!window) return;
1008 INF("lowering window");
1010 if (!SetWindowPos(((Ecore_Win32_Window *)window)->window,
1011 HWND_BOTTOM, 0, 0, 0, 0,
1012 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
1014 ERR("SetWindowPos() failed");
1019 * @brief Set the title of the given window.
1021 * @param window The window to set the title.
1022 * @param title The new title.
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.
1029 ecore_win32_window_title_set(Ecore_Win32_Window *window,
1032 if (!window) return;
1034 if (!title || !title[0]) return;
1036 INF("setting window title");
1038 if (!SetWindowText(((Ecore_Win32_Window *)window)->window, title))
1040 ERR("SetWindowText() failed");
1045 * @brief Set the focus to the given window.
1047 * @param window The window to give focus to.
1049 * This function gives the focus to @p window. If @p window is
1050 * @c NULL, this function does nothing.
1053 ecore_win32_window_focus_set(Ecore_Win32_Window *window)
1055 if (!window) return;
1057 INF("focusing window");
1059 if (!SetFocus(((Ecore_Win32_Window *)window)->window))
1061 ERR("SetFocus() failed");
1066 * @brief Iconify or restore the given window.
1068 * @param window The window.
1069 * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it.
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.
1078 ecore_win32_window_iconified_set(Ecore_Win32_Window *window,
1081 Ecore_Win32_Window *ew;
1083 if (!window) return;
1085 ew = (Ecore_Win32_Window *)window;
1086 if (((ew->iconified) && (on)) ||
1087 ((!ew->iconified) && (!on)))
1090 INF("iconifying window: %s", on ? "yes" : "no");
1092 ShowWindow(ew->window, on ? SW_MINIMIZE : SW_RESTORE);
1097 * @brief Remove or restore the border of the given window.
1099 * @param window The window.
1100 * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it.
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.
1109 ecore_win32_window_borderless_set(Ecore_Win32_Window *window,
1114 Ecore_Win32_Window *ew;
1117 if (!window) return;
1119 ew = (Ecore_Win32_Window *)window;
1120 if (((ew->borderless) && (on)) ||
1121 ((!ew->borderless) && (!on)))
1124 INF("setting window without border: %s", on ? "yes" : "no");
1128 style = GetWindowLong(w, GWL_STYLE);
1131 if (!GetClientRect(w, &rect))
1133 ERR("GetClientRect() failed");
1137 if (!SetWindowLongPtr(w, GWL_STYLE, style & ~(WS_CAPTION | WS_THICKFRAME)) && (GetLastError() != 0))
1139 ERR("SetWindowLongPtr() failed");
1145 if (!GetWindowRect(w, &rect))
1147 ERR("GetWindowRect() failed");
1150 style |= WS_CAPTION | WS_THICKFRAME;
1151 if (!AdjustWindowRect (&rect, style, FALSE))
1153 ERR("AdjustWindowRect() failed");
1157 if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1159 ERR("SetWindowLongPtr() failed");
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))
1168 ERR("SetWindowPos() failed");
1171 ew->borderless = on;
1175 * @brief Set the given window to fullscreen.
1177 * @param window The window.
1178 * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode.
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.
1187 ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
1190 Ecore_Win32_Window *ew;
1193 if (!window) return;
1195 ew = (Ecore_Win32_Window *)window;
1196 if (((ew->fullscreen) && (on)) ||
1197 ((!ew->fullscreen) && (!on)))
1200 INF("setting fullscreen: %s", on ? "yes" : "no");
1202 ew->fullscreen = !!on;
1209 if (!GetWindowRect(w, &ew->rect))
1211 ERR("GetWindowRect() failed");
1214 if (!(ew->style = GetWindowLong(w, GWL_STYLE)))
1216 ERR("GetWindowLong() failed");
1219 style = ew->style & ~WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX;
1220 style |= WS_VISIBLE | WS_POPUP;
1222 if (!SetWindowLongPtr(w, GWL_STYLE, style) && (GetLastError() != 0))
1224 ERR("SetWindowLongPtr() failed");
1228 if (!SetWindowLongPtr(w, GWL_EXSTYLE, WS_EX_TOPMOST) && (GetLastError() != 0))
1230 ERR("SetWindowLongPtr() failed");
1233 if (!SetWindowPos(w, HWND_TOPMOST, 0, 0,
1234 GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN),
1235 SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1237 ERR("SetWindowPos() failed");
1244 if (!SetWindowLongPtr(w, GWL_STYLE, ew->style) && (GetLastError() != 0))
1246 ERR("SetWindowLongPtr() failed");
1250 if (!SetWindowLongPtr(w, GWL_EXSTYLE, 0) && (GetLastError() != 0))
1252 ERR("SetWindowLongPtr() failed");
1255 if (!SetWindowPos(w, HWND_NOTOPMOST,
1258 ew->rect.right - ew->rect.left,
1259 ew->rect.bottom - ew->rect.top,
1260 SWP_NOCOPYBITS | SWP_SHOWWINDOW))
1262 ERR("SetWindowPos() failed");
1269 * @brief Set the given cursor to the given window.
1271 * @param window The window to modify the cursor.
1272 * @param cursor The new cursor.
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.
1280 ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
1281 Ecore_Win32_Cursor *cursor)
1283 INF("setting cursor");
1285 if (!window || !cursor)
1288 if (!SetClassLongPtr(((Ecore_Win32_Window *)window)->window,
1289 GCL_HCURSOR, (LONG_PTR)cursor))
1291 ERR("SetClassLong() failed");
1296 * @brief Set the state of the given window.
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.
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.
1307 ecore_win32_window_state_set(Ecore_Win32_Window *window,
1308 Ecore_Win32_Window_State *state,
1313 if (!window || !state || (num <= 0))
1316 INF("setting cursor state");
1318 for (i = 0; i < num; i++)
1322 case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1323 ((Ecore_Win32_Window *)window)->state.iconified = 1;
1325 case ECORE_WIN32_WINDOW_STATE_MODAL:
1326 ((Ecore_Win32_Window *)window)->state.modal = 1;
1328 case ECORE_WIN32_WINDOW_STATE_STICKY:
1329 ((Ecore_Win32_Window *)window)->state.sticky = 1;
1331 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1332 ((Ecore_Win32_Window *)window)->state.maximized_vert = 1;
1334 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1335 ((Ecore_Win32_Window *)window)->state.maximized_horz = 1;
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;
1341 case ECORE_WIN32_WINDOW_STATE_SHADED:
1342 ((Ecore_Win32_Window *)window)->state.shaded = 1;
1344 case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1345 ((Ecore_Win32_Window *)window)->state.hidden = 1;
1347 case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1348 ((Ecore_Win32_Window *)window)->state.fullscreen = 1;
1350 case ECORE_WIN32_WINDOW_STATE_ABOVE:
1351 ((Ecore_Win32_Window *)window)->state.above = 1;
1353 case ECORE_WIN32_WINDOW_STATE_BELOW:
1354 ((Ecore_Win32_Window *)window)->state.below = 1;
1356 case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1357 ((Ecore_Win32_Window *)window)->state.demands_attention = 1;
1359 case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1360 /* nothing to be done */
1367 * @brief Apply the modification of the state to the given window.
1369 * @param window The window.
1370 * @param state The state to apply changes.
1371 * @param set The value of the state change.
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.
1380 ecore_win32_window_state_request_send(Ecore_Win32_Window *window,
1381 Ecore_Win32_Window_State state,
1384 Ecore_Win32_Window *ew;
1387 if (!window) return;
1389 ew = (Ecore_Win32_Window *)window;
1392 INF("sending cursor state");
1396 case ECORE_WIN32_WINDOW_STATE_ICONIFIED:
1397 if (ew->state.iconified)
1398 ecore_win32_window_iconified_set(window, set);
1400 case ECORE_WIN32_WINDOW_STATE_MODAL:
1401 ew->state.modal = 1;
1403 case ECORE_WIN32_WINDOW_STATE_STICKY:
1404 ew->state.sticky = 1;
1406 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT:
1407 if (ew->state.maximized_vert)
1413 if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1416 ERR("SystemParametersInfo() failed");
1420 height = rect.bottom - rect.top;
1422 if (!GetClientRect(w, &rect))
1424 ERR("GetClientRect() failed");
1428 if (!MoveWindow(w, rect.left, y,
1429 rect.right - rect.left,
1433 ERR("MoveWindow() failed");
1437 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ:
1438 if (ew->state.maximized_horz)
1442 if (!GetClientRect(w, &rect))
1444 ERR("GetClientRect() failed");
1448 if (!MoveWindow(w, 0, rect.top,
1449 GetSystemMetrics(SM_CXSCREEN),
1450 rect.bottom - rect.top,
1453 ERR("MoveWindow() failed");
1457 case ECORE_WIN32_WINDOW_STATE_MAXIMIZED:
1458 if (ew->state.maximized_vert && ew->state.maximized_horz)
1462 if (!SystemParametersInfo(SPI_GETWORKAREA, 0,
1465 ERR("SystemParametersInfo() failed");
1469 if (!MoveWindow(w, 0, 0,
1470 GetSystemMetrics(SM_CXSCREEN),
1471 rect.bottom - rect.top,
1474 ERR("MoveWindow() failed");
1478 case ECORE_WIN32_WINDOW_STATE_SHADED:
1479 ew->state.shaded = 1;
1481 case ECORE_WIN32_WINDOW_STATE_HIDDEN:
1482 ew->state.hidden = 1;
1484 case ECORE_WIN32_WINDOW_STATE_FULLSCREEN:
1485 if (ew->state.fullscreen)
1486 ecore_win32_window_fullscreen_set(window, set);
1488 case ECORE_WIN32_WINDOW_STATE_ABOVE:
1489 if (ew->state.above)
1490 if (!SetWindowPos(w, HWND_TOP,
1493 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1495 ERR("SetWindowPos() failed");
1498 case ECORE_WIN32_WINDOW_STATE_BELOW:
1499 if (ew->state.below)
1500 if (!SetWindowPos(w, HWND_BOTTOM,
1503 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW))
1505 ERR("SetWindowPos() failed");
1508 case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION:
1509 ew->state.demands_attention = 1;
1511 case ECORE_WIN32_WINDOW_STATE_UNKNOWN:
1512 /* nothing to be done */
1518 * @brief Set the type of the given window.
1520 * @param window The window to modify the type.
1521 * @param type The new types.
1523 * This function set the type of @p window to @p type. If
1524 * @p window is @c NULL, the function does nothing.
1527 ecore_win32_window_type_set(Ecore_Win32_Window *window,
1528 Ecore_Win32_Window_Type type)
1533 INF("setting window type");
1537 case ECORE_WIN32_WINDOW_TYPE_DESKTOP:
1538 ((Ecore_Win32_Window *)window)->type.desktop = 1;
1540 case ECORE_WIN32_WINDOW_TYPE_DOCK:
1541 ((Ecore_Win32_Window *)window)->type.dock = 1;
1543 case ECORE_WIN32_WINDOW_TYPE_TOOLBAR:
1544 ((Ecore_Win32_Window *)window)->type.toolbar = 1;
1546 case ECORE_WIN32_WINDOW_TYPE_MENU:
1547 ((Ecore_Win32_Window *)window)->type.menu = 1;
1549 case ECORE_WIN32_WINDOW_TYPE_UTILITY:
1550 ((Ecore_Win32_Window *)window)->type.utility = 1;
1552 case ECORE_WIN32_WINDOW_TYPE_SPLASH:
1553 ((Ecore_Win32_Window *)window)->type.splash = 1;
1555 case ECORE_WIN32_WINDOW_TYPE_DIALOG:
1556 ((Ecore_Win32_Window *)window)->type.dialog = 1;
1558 case ECORE_WIN32_WINDOW_TYPE_NORMAL:
1559 ((Ecore_Win32_Window *)window)->type.normal = 1;
1561 case ECORE_WIN32_WINDOW_TYPE_UNKNOWN:
1562 ((Ecore_Win32_Window *)window)->type.normal = 1;