diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32.c b/legacy/ecore/src/lib/ecore_win32/ecore_win32.c index 6579e9d5d1..6766a40336 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32.c +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32.c @@ -2,17 +2,211 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include /* for printf */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN #include +#ifdef HAVE_OPENGL_GLEW +# include +#endif /* HAVE_OPENGL_GLEW */ + +#include "Ecore.h" +#include "Ecore_Win32.h" #include "ecore_win32_private.h" +/***** Global declarations *****/ + HINSTANCE _ecore_win32_instance = NULL; double _ecore_win32_double_click_time = 0.25; double _ecore_win32_event_last_time = 0.0; Ecore_Win32_Window *_ecore_win32_event_last_window = NULL; -static int _ecore_win32_init_count = 0; +int ECORE_WIN32_EVENT_KEY_DOWN = 0; +int ECORE_WIN32_EVENT_KEY_UP = 0; +int ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = 0; +int ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = 0; +int ECORE_WIN32_EVENT_MOUSE_MOVE = 0; +int ECORE_WIN32_EVENT_MOUSE_IN = 0; +int ECORE_WIN32_EVENT_MOUSE_OUT = 0; +int ECORE_WIN32_EVENT_MOUSE_WHEEL = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; +int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; +int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; +int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; +int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; +int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; +int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; +int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; +int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; + + +/***** Private declarations *****/ + +static int _ecore_win32_init_count = 0; + +LRESULT CALLBACK _ecore_win32_window_procedure(HWND window, + UINT message, + WPARAM window_param, + LPARAM data_param); + + +/***** API *****/ + + +int +ecore_win32_init() +{ + WNDCLASS wc; + + if (_ecore_win32_init_count > 0) + { + _ecore_win32_init_count++; + return _ecore_win32_init_count; + } + + printf (" *** ecore_win32_init\n"); + _ecore_win32_instance = GetModuleHandle(NULL); + if (!_ecore_win32_instance) + return 0; + + memset (&wc, 0, sizeof (WNDCLASS)); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = _ecore_win32_window_procedure; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = _ecore_win32_instance; + wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; + + if(!RegisterClass(&wc)) + { + FreeLibrary(_ecore_win32_instance); + return 0; + } + + if (!ECORE_WIN32_EVENT_KEY_DOWN) + { + ECORE_WIN32_EVENT_KEY_DOWN = ecore_event_type_new(); + ECORE_WIN32_EVENT_KEY_UP = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_MOVE = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_WHEEL = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); + } + +#ifdef HAVE_OPENGL_GLEW + if (GLEW_VERSION_2_0) + { + printf ("pas 2.0\n"); + return 0; + } + else { + printf ("2.0 !!\n"); + } +#endif /* HAVE_OPENGL_GLEW */ + + _ecore_win32_init_count++; + + return _ecore_win32_init_count; +} + +int +ecore_win32_shutdown() +{ + _ecore_win32_init_count++; + if (_ecore_win32_init_count > 0) return _ecore_win32_init_count; + if (!_ecore_win32_instance) return _ecore_win32_init_count; + + UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); + FreeLibrary(_ecore_win32_instance); + _ecore_win32_instance = NULL; + + if (_ecore_win32_init_count < 0) _ecore_win32_init_count = 0; + + return _ecore_win32_init_count; +} + +int +ecore_win32_screen_depth_get() +{ + HDC dc; + int depth; + + dc = GetDC(NULL); + if (!dc) + return 0; + + depth = GetDeviceCaps(dc, BITSPIXEL); + ReleaseDC(NULL, dc); + + return depth; +} + +/** + * Sets the timeout for a double and triple clicks to be flagged. + * + * This sets the time between clicks before the double_click flag is + * set in a button down event. If 3 clicks occur within double this + * time, the triple_click flag is also set. + * + * @param t The time in seconds + */ +void +ecore_win32_double_click_time_set(double t) +{ + if (t < 0.0) t = 0.0; + _ecore_win32_double_click_time = t; +} + +/** + * Retrieves the double and triple click flag timeout. + * + * See @ref ecore_win32_double_click_time_set for more information. + * + * @return The timeout for double clicks in seconds. + */ +double +ecore_win32_double_click_time_get(void) +{ + return _ecore_win32_double_click_time; +} + +/** + * Return the last event time + */ +double +ecore_win32_current_time_get(void) +{ + return _ecore_win32_event_last_time; +} + + +/***** Private functions definitions *****/ LRESULT CALLBACK @@ -231,191 +425,3 @@ _ecore_win32_window_procedure(HWND window, } } - -/* - Events: - -x * key down - * key sys down -x * key up - * key sys up -x * mouse button down left -x * mouse button down middle -x * mouse button down right -x * mouse button up left -x * mouse button up middle -x * mouse button up right -x * mouse move (contains enter) -x * mouse leave -x * focus in -x * focus out -x * expose -x * create -x * destroy -x * configure -x * resize -x * delete - -*/ - -EAPI int ECORE_WIN32_EVENT_KEY_DOWN = 0; -EAPI int ECORE_WIN32_EVENT_KEY_UP = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_MOVE = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_IN = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_OUT = 0; -EAPI int ECORE_WIN32_EVENT_MOUSE_WHEEL = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; -EAPI int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; - - -EAPI int -ecore_win32_init() -{ - WNDCLASS wc; - - if (_ecore_win32_init_count > 0) - { - _ecore_win32_init_count++; - return _ecore_win32_init_count; - } - - printf (" *** ecore_win32_init\n"); - _ecore_win32_instance = GetModuleHandle(NULL); - if (!_ecore_win32_instance) - return 0; - - memset (&wc, 0, sizeof (WNDCLASS)); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = _ecore_win32_window_procedure; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = _ecore_win32_instance; - wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); - wc.lpszMenuName = NULL; - wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; - - if(!RegisterClass(&wc)) - { - FreeLibrary(_ecore_win32_instance); - return 0; - } - - if (!ECORE_WIN32_EVENT_KEY_DOWN) - { - ECORE_WIN32_EVENT_KEY_DOWN = ecore_event_type_new(); - ECORE_WIN32_EVENT_KEY_UP = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_MOVE = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_WHEEL = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); - } - -#ifdef HAVE_OPENGL_GLEW - if (GLEW_VERSION_2_0) - { - printf ("pas 2.0\n"); - return 0; - } - else { - printf ("2.0 !!\n"); - } -#endif /* HAVE_OPENGL_GLEW */ - - _ecore_win32_init_count++; - - return _ecore_win32_init_count; -} - -EAPI int -ecore_win32_shutdown() -{ - _ecore_win32_init_count++; - if (_ecore_win32_init_count > 0) return _ecore_win32_init_count; - if (!_ecore_win32_instance) return _ecore_win32_init_count; - - UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); - FreeLibrary(_ecore_win32_instance); - _ecore_win32_instance = NULL; - - if (_ecore_win32_init_count < 0) _ecore_win32_init_count = 0; - - return _ecore_win32_init_count; -} - -EAPI int -ecore_win32_screen_depth_get() -{ - HDC dc; - int depth; - - dc = GetDC(NULL); - if (!dc) - return 0; - - depth = GetDeviceCaps(dc, BITSPIXEL); - ReleaseDC(NULL, dc); - - return depth; -} - -/** - * Sets the timeout for a double and triple clicks to be flagged. - * - * This sets the time between clicks before the double_click flag is - * set in a button down event. If 3 clicks occur within double this - * time, the triple_click flag is also set. - * - * @param t The time in seconds - */ -EAPI void -ecore_win32_double_click_time_set(double t) -{ - if (t < 0.0) t = 0.0; - _ecore_win32_double_click_time = t; -} - -/** - * Retrieves the double and triple click flag timeout. - * - * See @ref ecore_win32_double_click_time_set for more information. - * - * @return The timeout for double clicks in seconds. - */ -EAPI double -ecore_win32_double_click_time_get(void) -{ - return _ecore_win32_double_click_time; -} - -/** - * Return the last event time - */ -EAPI double -ecore_win32_current_time_get(void) -{ - return _ecore_win32_event_last_time; -} diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_cursor.c b/legacy/ecore/src/lib/ecore_win32/ecore_win32_cursor.c index 4a72d3c54b..7e89f9a274 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_cursor.c +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32_cursor.c @@ -2,9 +2,21 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + +#include "Ecore_Win32.h" #include "ecore_win32_private.h" -EAPI Ecore_Win32_Cursor * + +/***** API *****/ + +Ecore_Win32_Cursor * ecore_win32_cursor_new(const void *pixels_and, const void *pixels_xor, int width, @@ -33,13 +45,13 @@ ecore_win32_cursor_new(const void *pixels_and, return cursor; } -EAPI void +void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor) { DestroyCursor(cursor); } -EAPI Ecore_Win32_Cursor * +Ecore_Win32_Cursor * ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) { Ecore_Win32_Cursor *cursor = NULL; @@ -99,7 +111,7 @@ ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) return cursor; } -EAPI int +int ecore_win32_cursor_size_get(void) { int width; diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_ddraw.cpp b/legacy/ecore/src/lib/ecore_win32/ecore_win32_ddraw.cpp deleted file mode 100644 index 31ad9bb183..0000000000 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_ddraw.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -#include "ecore_win32_private.h" -#include "Ecore_Win32.h" - - -EAPI int -ecore_win32_ddraw_init(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - DDSURFACEDESC surface_desc; - DDPIXELFORMAT pixel_format; - RECT rect; - struct _Ecore_Win32_Window *w; - - if (!window) - return 0; - - w = (struct _Ecore_Win32_Window *)window; - w->ddraw.surface_source = NULL; - { - RECT rect; - GetClientRect(w->window, &rect); - printf (" *** ecore_win32_ddraw_init %ld %ld\n", - rect.right - rect.left, rect.bottom - rect.top); - } - - if (FAILED(DirectDrawCreate(NULL, &w->ddraw.object, NULL))) - return 0; - - if (FAILED(w->ddraw.object->SetCooperativeLevel(w->window, DDSCL_NORMAL))) - goto no_coop_level; - - if (FAILED(w->ddraw.object->CreateClipper(0, &w->ddraw.clipper, NULL))) - goto no_clipper; - - if (FAILED(w->ddraw.clipper->SetHWnd(0, w->window))) - goto no_clipper_set_window; - - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - surface_desc.dwFlags = DDSD_CAPS; - surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - if (FAILED(w->ddraw.object->CreateSurface(&surface_desc, - &w->ddraw.surface_primary, - NULL))) - goto no_primary_surf; - - if (FAILED(w->ddraw.surface_primary->SetClipper(w->ddraw.clipper))) - goto no_primary_surf_set_clipper; - - if (!GetClientRect(w->window, &rect)) - goto no_get_client; - - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - surface_desc.dwWidth = rect.right - rect.left; - surface_desc.dwHeight = rect.bottom - rect.top; - - if (FAILED(w->ddraw.object->CreateSurface(&surface_desc, - &w->ddraw.surface_back, - NULL))) - goto no_back_surf; - - ZeroMemory(&pixel_format, sizeof(pixel_format)); - pixel_format.dwSize = sizeof(pixel_format); - - if (FAILED(w->ddraw.surface_primary->GetPixelFormat(&pixel_format))) - goto no_get_pix_fmt; - - w->ddraw.depth = pixel_format.dwRGBBitCount; - - w->backend = ECORE_WIN32_BACKEND_DIRECTDRAW; - - return 1; - - no_get_pix_fmt: - /* no need to release the back surface. the next call free its memory */ - no_back_surf: - no_get_client: - no_primary_surf_set_clipper: - w->ddraw.surface_primary->Release(); - no_primary_surf: - no_clipper_set_window: - w->ddraw.clipper->Release(); - no_clipper: - no_coop_level: - w->ddraw.object->Release(); -#endif /* HAVE_DIRECTDRAW */ - - return 0; -} - -EAPI int -ecore_win32_ddraw_16_init(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - DDSURFACEDESC surface_desc; - DDPIXELFORMAT pixel_format; - RECT rect; - void *source; - struct _Ecore_Win32_Window *w; - - if (!window) - return 0; - - w = (struct _Ecore_Win32_Window *)window; - { - RECT rect; - GetClientRect(w->window, &rect); - printf (" *** ecore_win32_ddraw_init %ld %ld\n", - rect.right - rect.left, rect.bottom - rect.top); - } - w->ddraw.clipper = NULL; - - if (FAILED(DirectDrawCreate(NULL, &w->ddraw.object, NULL))) - return 0; - - if (FAILED(w->ddraw.object->SetCooperativeLevel(w->window, DDSCL_NORMAL))) - goto no_coop_level; - - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - surface_desc.dwFlags = DDSD_CAPS; - surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - if (FAILED(w->ddraw.object->CreateSurface(&surface_desc, - &w->ddraw.surface_primary, - NULL))) - goto no_primary_surf; - - if (!GetClientRect(w->window, &rect)) - goto no_get_client; - - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - surface_desc.dwWidth = rect.right - rect.left; - surface_desc.dwHeight = rect.bottom - rect.top; - - if (FAILED(w->ddraw.object->CreateSurface(&surface_desc, - &w->ddraw.surface_back, - NULL))) - goto no_back_surf; - - ZeroMemory(&pixel_format, sizeof(pixel_format)); - pixel_format.dwSize = sizeof(pixel_format); - - if (FAILED(w->ddraw.surface_primary->GetPixelFormat(&pixel_format))) - goto no_get_pix_fmt; - - w->ddraw.depth = pixel_format.dwRGBBitCount; - - source = malloc((rect.right - rect.left) * (rect.bottom - rect.top) * 2); - if (!source) - goto no_source; - - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - surface_desc.dwFlags = - DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | - DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT; - surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - surface_desc.dwWidth = rect.right - rect.left; - surface_desc.dwHeight = rect.bottom - rect.top; - surface_desc.lPitch = 2 * surface_desc.dwWidth; - surface_desc.lpSurface = source; - - surface_desc.ddpfPixelFormat = pixel_format; - - if (FAILED(w->ddraw.object->CreateSurface(&surface_desc, - &w->ddraw.surface_source, - NULL))) - goto no_source_surf; - - w->backend = ECORE_WIN32_BACKEND_DIRECTDRAW_16; - - return 1; - - no_source_surf: - free(source); - no_source: - no_get_pix_fmt: - /* no need to release the back surface. the next call free its memory */ - no_back_surf: - no_get_client: - w->ddraw.surface_primary->Release(); - no_primary_surf: - no_coop_level: - w->ddraw.object->Release(); -#endif /* HAVE_DIRECTDRAW */ - - return 0; -} - -EAPI void -ecore_win32_ddraw_shutdown(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - struct _Ecore_Win32_Window *w; - - if (!window) - return; - - w = (struct _Ecore_Win32_Window *)window; - - if (w->ddraw.surface_primary) - { - w->ddraw.surface_primary->Release(); - w->ddraw.surface_primary = NULL; - } - - if (w->ddraw.surface_source) - { - DDSURFACEDESC surface_desc; - - ZeroMemory(&surface_desc, sizeof(surface_desc)); - surface_desc.dwSize = sizeof(surface_desc); - - if (w->ddraw.surface_source->Lock(NULL, - &surface_desc, - DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, - NULL) == DD_OK) - { - free(surface_desc.lpSurface); - if (w->ddraw.surface_source->Unlock(NULL) == DD_OK) - { - w->ddraw.surface_source->Release(); - } - } - w->ddraw.surface_source = NULL; - } - - /* no need to release the back surface. the previous call free its memory */ - - if (w->ddraw.clipper) - { - w->ddraw.clipper->Release(); - w->ddraw.clipper = NULL; - } - - if (w->ddraw.object) - { - w->ddraw.object->Release(); - w->ddraw.object = NULL; - } - - w->backend = ECORE_WIN32_BACKEND_NONE; -#endif /* HAVE_DIRECTDRAW */ -} - -EAPI Ecore_Win32_DDraw_Object * -ecore_win32_ddraw_object_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - return ((struct _Ecore_Win32_Window *)window)->ddraw.object; -#else - return NULL; -#endif /* HAVE_DIRECTDRAW */ -} - -EAPI Ecore_Win32_DDraw_Surface * -ecore_win32_ddraw_surface_primary_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - return ((struct _Ecore_Win32_Window *)window)->ddraw.surface_primary; -#else - return NULL; -#endif /* HAVE_DIRECTDRAW */ -} - -EAPI Ecore_Win32_DDraw_Surface * -ecore_win32_ddraw_surface_back_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - return ((struct _Ecore_Win32_Window *)window)->ddraw.surface_back; -#else - return NULL; -#endif /* HAVE_DIRECTDRAW */ -} - -EAPI Ecore_Win32_DDraw_Surface * -ecore_win32_ddraw_surface_source_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - return ((struct _Ecore_Win32_Window *)window)->ddraw.surface_source; -#else - return NULL; -#endif /* HAVE_DIRECTDRAW */ -} - -EAPI int -ecore_win32_ddraw_depth_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECTDRAW - return ((struct _Ecore_Win32_Window *)window)->ddraw.depth; -#else - return 0; -#endif /* HAVE_DIRECTDRAW */ -} diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_direct3d.cpp b/legacy/ecore/src/lib/ecore_win32/ecore_win32_direct3d.cpp deleted file mode 100644 index cb7bfeef39..0000000000 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_direct3d.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ - -#include "config.h" -#include "ecore_win32_private.h" -#include "Ecore_Win32.h" -#include - - -EAPI int -ecore_win32_direct3d_init(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - D3DPRESENT_PARAMETERS pp; - D3DDISPLAYMODE dm; - D3DSURFACE_DESC sd; - D3DCAPS9 caps; - RECT rect; - struct _Ecore_Win32_Window *w; - DWORD flag; - - if (!window) - return 0; - - w = (struct _Ecore_Win32_Window *)window; - - printf ("ecore_win32_direct3d_init debut : %p (%d %d) (%d %d)\n", - w, - w->min_width, - w->min_height, - w->max_width, - w->max_height); - - w->d3d.object = Direct3DCreate9 (D3D_SDK_VERSION); - if (!w->d3d.object) - return 0; - - if (FAILED (w->d3d.object->GetAdapterDisplayMode (D3DADAPTER_DEFAULT, - &dm))) - goto no_get_adapter; - - if (FAILED (w->d3d.object->GetDeviceCaps (D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - &caps))) - goto no_caps; - - if (!GetClientRect(w->window, &rect)) - goto no_get_client; - - flag = (caps.VertexProcessingCaps != 0) - ? D3DCREATE_HARDWARE_VERTEXPROCESSING - : D3DCREATE_SOFTWARE_VERTEXPROCESSING; - - ZeroMemory(&pp, sizeof(pp)); - pp.BackBufferWidth = rect.right - rect.left; - pp.BackBufferHeight = rect.bottom - rect.top; - pp.BackBufferFormat = dm.Format; - pp.BackBufferCount = 1; - pp.MultiSampleType = D3DMULTISAMPLE_NONE; - pp.MultiSampleQuality = 0; - pp.SwapEffect = D3DSWAPEFFECT_FLIP; - pp.hDeviceWindow = w->window; - pp.Windowed = TRUE; - pp.EnableAutoDepthStencil = FALSE; - pp.FullScreen_RefreshRateInHz = 0; - pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (FAILED(w->d3d.object->CreateDevice (D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - w->window, - flag, - &pp, - &w->d3d.device))) - goto no_device; - - if (FAILED (D3DXCreateSprite (w->d3d.device, &w->d3d.sprite))) - goto no_sprite; - - if (FAILED (w->d3d.device->CreateTexture (rect.right - rect.left, - rect.bottom - rect.top, - 1, - D3DUSAGE_DYNAMIC, - dm.Format, - D3DPOOL_DEFAULT, - &w->d3d.texture, NULL))) - goto no_texture; - - if (FAILED (w->d3d.texture->GetLevelDesc (0, &sd))) - goto no_level_desc; - - switch (sd.Format) { - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - w->d3d.depth = 32; - break; - case D3DFMT_R5G6B5: - w->d3d.depth = 16; - break; - default: - goto no_supported_depth; - } - - w->backend = ECORE_WIN32_BACKEND_DIRECT3D; - - printf ("ecore_win32_direct3d_init fin : %p (%d %d) (%d %d)\n", - w, - w->min_width, - w->min_height, - w->max_width, - w->max_height); - - return 1; - - no_supported_depth: - no_level_desc: - w->d3d.texture->Release(); - no_texture: - w->d3d.sprite->Release(); - no_sprite: - w->d3d.device->Release(); - no_device: - no_get_client: - no_caps: - no_get_adapter: - w->d3d.object->Release(); -#endif /* HAVE_DIRECT3D */ - - return 0; -} - -EAPI void -ecore_win32_direct3d_shutdown(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - struct _Ecore_Win32_Window *w; - - if (!window) - return; - - w = (struct _Ecore_Win32_Window *)window; - - printf ("0\n"); - if (w->d3d.texture) - w->d3d.texture->Release(); - - printf ("1\n"); -// if (w->d3d.sprite) -// w->d3d.sprite->OnLostDevice(); - - printf ("2\n"); -// if (w->d3d.device) -// w->d3d.device->Release(); - - printf ("3\n"); - if (w->d3d.object) - w->d3d.object->Release(); - - printf ("4\n"); - w->backend = ECORE_WIN32_BACKEND_NONE; -#endif /* HAVE_DIRECT3D */ -} - -EAPI Ecore_Win32_Direct3D_Object * -ecore_win32_direct3d_object_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - return ((struct _Ecore_Win32_Window *)window)->d3d.object; -#else - return NULL; -#endif /* HAVE_DIRECT3D */ -} - -EAPI Ecore_Win32_Direct3D_Device * -ecore_win32_direct3d_device_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - return ((struct _Ecore_Win32_Window *)window)->d3d.device; -#else - return NULL; -#endif /* HAVE_DIRECT3D */ -} - -EAPI Ecore_Win32_Direct3D_Sprite * -ecore_win32_direct3d_sprite_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - return ((struct _Ecore_Win32_Window *)window)->d3d.sprite; -#else - return NULL; -#endif /* HAVE_DIRECT3D */ -} - -EAPI Ecore_Win32_Direct3D_Texture * -ecore_win32_direct3d_texture_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - return ((struct _Ecore_Win32_Window *)window)->d3d.texture; -#else - return NULL; -#endif /* HAVE_DIRECT3D */ -} - -EAPI int -ecore_win32_direct3d_depth_get(Ecore_Win32_Window *window) -{ -#ifdef HAVE_DIRECT3D - return ((struct _Ecore_Win32_Window *)window)->d3d.depth; -#else - return 0; -#endif /* HAVE_DIRECT3D */ -} diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_event.c b/legacy/ecore/src/lib/ecore_win32/ecore_win32_event.c index b474777974..4b0b342015 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_event.c +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32_event.c @@ -2,13 +2,26 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include /* for printf */ + +#define WIN32_LEAN_AND_MEAN #include +#undef WIN32_LEAN_AND_MEAN #include #include "Ecore.h" +#include "Ecore_Win32.h" #include "ecore_win32_private.h" +/***** Private declarations *****/ + + static Ecore_Win32_Window *_ecore_win32_mouse_down_last_window = NULL; static Ecore_Win32_Window *_ecore_win32_mouse_down_last_last_window = NULL; static double _ecore_win32_mouse_down_last_time = 0; @@ -16,318 +29,24 @@ static double _ecore_win32_mouse_down_last_last_time = 0; static int _ecore_win32_mouse_down_did_triple = 0; static int _ecore_win32_mouse_up_count = 0; -static void -_ecore_win32_event_free_key_down(void *data, - void *ev) -{ - Ecore_Win32_Event_Key_Down *e; +static void _ecore_win32_event_free_key_down(void *data, + void *ev); - e = ev; - if (e->keyname) free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->keycompose) free(e->keycompose); - free(e); -} +static void _ecore_win32_event_free_key_up(void *data, + void *ev); -static void -_ecore_win32_event_free_key_up(void *data, - void *ev) -{ - Ecore_Win32_Event_Key_Up *e; +static int _ecore_win32_event_keystroke_get(int key, + char **keyname, + char **keysymbol, + char **keycompose); - e = ev; - if (e->keyname) free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->keycompose) free(e->keycompose); - free(e); -} +static int _ecore_win32_event_char_get(int key, + char **keyname, + char **keysymbol, + char **keycompose); -static int -_ecore_win32_event_keystroke_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) -{ - char *kn; - char *ks; - char *kc; - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; - - switch (key) - { - /* Keystroke */ - case VK_PRIOR: - kn = "KP_Prior"; - ks = "KP_Prior"; - kc = ""; - break; - case VK_NEXT: - kn = "KP_Next"; - ks = "KP_Next"; - kc = ""; - break; - case VK_END: - kn = "KP_End"; - ks = "KP_End"; - kc = ""; - break; - case VK_HOME: - kn = "KP_Home"; - ks = "KP_Home"; - kc = ""; - break; - case VK_LEFT: - kn = "KP_Left"; - ks = "KP_Left"; - kc = ""; - break; - case VK_UP: - kn = "KP_Up"; - ks = "KP_Up"; - kc = ""; - break; - case VK_RIGHT: - kn = "KP_Right"; - ks = "KP_Right"; - kc = ""; - break; - case VK_DOWN: - kn = "KP_Down"; - ks = "KP_Down"; - kc = ""; - break; - case VK_INSERT: - kn = "KP_Insert"; - ks = "KP_Insert"; - kc = ""; - break; - case VK_DELETE: - kn = "KP_Delete"; - ks = "KP_Delete"; - kc = ""; - break; - case VK_F1: - kn = "F1"; - ks = "F1"; - kc = ""; - break; - case VK_F2: - kn = "F2"; - ks = "F2"; - kc = ""; - break; - case VK_F3: - kn = "F3"; - ks = "F3"; - kc = ""; - break; - case VK_F4: - kn = "F4"; - ks = "F4"; - kc = ""; - break; - case VK_F5: - kn = "F5"; - ks = "F5"; - kc = ""; - break; - case VK_F6: - kn = "F6"; - ks = "F6"; - kc = ""; - break; - case VK_F7: - kn = "F7"; - ks = "F7"; - kc = ""; - break; - case VK_F8: - kn = "F8"; - ks = "F8"; - kc = ""; - break; - case VK_F9: - kn = "F9"; - ks = "F9"; - kc = ""; - break; - case VK_F10: - kn = "F10"; - ks = "F10"; - kc = ""; - break; - case VK_F11: - kn = "F11"; - ks = "F11"; - kc = ""; - break; - case VK_F12: - kn = "F12"; - ks = "F12"; - kc = ""; - break; - case VK_F13: - kn = "F13"; - ks = "F13"; - kc = ""; - break; - case VK_F14: - kn = "F14"; - ks = "F14"; - kc = ""; - break; - case VK_F15: - kn = "F15"; - ks = "F15"; - kc = ""; - break; - case VK_F16: - kn = "F16"; - ks = "F16"; - kc = ""; - break; - case VK_F17: - kn = "F17"; - ks = "F17"; - kc = ""; - break; - case VK_F18: - kn = "F18"; - ks = "F18"; - kc = ""; - break; - case VK_F19: - kn = "F19"; - ks = "F19"; - kc = ""; - break; - case VK_F20: - kn = "F20"; - ks = "F20"; - kc = ""; - break; - case VK_F21: - kn = "F21"; - ks = "F21"; - kc = ""; - break; - case VK_F22: - kn = "F22"; - ks = "F22"; - kc = ""; - break; - case VK_F23: - kn = "F23"; - ks = "F23"; - kc = ""; - break; - case VK_F24: - kn = "F24"; - ks = "F24"; - kc = ""; - break; - default: - /* other non keystroke characters */ - return 0; - } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) - { - free(*keyname); - *keyname = NULL; - return 0; - } - *keycompose = strdup(kc); - if (!*keycompose) - { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; - } - - return 1; -} - -static int -_ecore_win32_event_char_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) -{ - char kn[32]; - char ks[32]; - char *kc; - - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; - - switch (key) - { - case VK_BACK: - strncpy(kn, "Backspace", 32); - strncpy(ks, "Backspace", 32); - kc = ""; - break; - case VK_TAB: - strncpy(kn, "Tab", 32); - strncpy(ks, "Tab", 32); - kc = ""; - break; - case 0x0a: - /* Line feed (Shift + Enter) */ - strncpy(kn, "LineFeed", 32); - strncpy(ks, "LineFeed", 32); - kc = ""; - break; - case VK_RETURN: - strncpy(kn, "Return", 32); - strncpy(ks, "Return", 32); - kc = ""; - break; - case VK_ESCAPE: - strncpy(kn, "Escape", 32); - strncpy(ks, "Escape", 32); - kc = ""; - break; - default: - /* displayable characters */ - printf (" * key : %d\n", key); - kn[0] = (TCHAR)key; - kn[1] = '\0'; - ks[0] = (TCHAR)key; - ks[1] = '\0'; - kc = ""; - break; - } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) - { - free(*keyname); - *keyname = NULL; - return 0; - } - *keycompose = strdup(kc); - if (!*keycompose) - { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; - } - - return 1; -} +/***** Global functions definitions *****/ void _ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg, @@ -851,3 +570,319 @@ _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg) ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); } + + +/***** Private functions definitions *****/ + +static void +_ecore_win32_event_free_key_down(void *data, + void *ev) +{ + Ecore_Win32_Event_Key_Down *e; + + e = ev; + if (e->keyname) free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->keycompose) free(e->keycompose); + free(e); +} + +static void +_ecore_win32_event_free_key_up(void *data, + void *ev) +{ + Ecore_Win32_Event_Key_Up *e; + + e = ev; + if (e->keyname) free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->keycompose) free(e->keycompose); + free(e); +} + +static int +_ecore_win32_event_keystroke_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) +{ + char *kn; + char *ks; + char *kc; + + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; + + switch (key) + { + /* Keystroke */ + case VK_PRIOR: + kn = "KP_Prior"; + ks = "KP_Prior"; + kc = ""; + break; + case VK_NEXT: + kn = "KP_Next"; + ks = "KP_Next"; + kc = ""; + break; + case VK_END: + kn = "KP_End"; + ks = "KP_End"; + kc = ""; + break; + case VK_HOME: + kn = "KP_Home"; + ks = "KP_Home"; + kc = ""; + break; + case VK_LEFT: + kn = "KP_Left"; + ks = "KP_Left"; + kc = ""; + break; + case VK_UP: + kn = "KP_Up"; + ks = "KP_Up"; + kc = ""; + break; + case VK_RIGHT: + kn = "KP_Right"; + ks = "KP_Right"; + kc = ""; + break; + case VK_DOWN: + kn = "KP_Down"; + ks = "KP_Down"; + kc = ""; + break; + case VK_INSERT: + kn = "KP_Insert"; + ks = "KP_Insert"; + kc = ""; + break; + case VK_DELETE: + kn = "KP_Delete"; + ks = "KP_Delete"; + kc = ""; + break; + case VK_F1: + kn = "F1"; + ks = "F1"; + kc = ""; + break; + case VK_F2: + kn = "F2"; + ks = "F2"; + kc = ""; + break; + case VK_F3: + kn = "F3"; + ks = "F3"; + kc = ""; + break; + case VK_F4: + kn = "F4"; + ks = "F4"; + kc = ""; + break; + case VK_F5: + kn = "F5"; + ks = "F5"; + kc = ""; + break; + case VK_F6: + kn = "F6"; + ks = "F6"; + kc = ""; + break; + case VK_F7: + kn = "F7"; + ks = "F7"; + kc = ""; + break; + case VK_F8: + kn = "F8"; + ks = "F8"; + kc = ""; + break; + case VK_F9: + kn = "F9"; + ks = "F9"; + kc = ""; + break; + case VK_F10: + kn = "F10"; + ks = "F10"; + kc = ""; + break; + case VK_F11: + kn = "F11"; + ks = "F11"; + kc = ""; + break; + case VK_F12: + kn = "F12"; + ks = "F12"; + kc = ""; + break; + case VK_F13: + kn = "F13"; + ks = "F13"; + kc = ""; + break; + case VK_F14: + kn = "F14"; + ks = "F14"; + kc = ""; + break; + case VK_F15: + kn = "F15"; + ks = "F15"; + kc = ""; + break; + case VK_F16: + kn = "F16"; + ks = "F16"; + kc = ""; + break; + case VK_F17: + kn = "F17"; + ks = "F17"; + kc = ""; + break; + case VK_F18: + kn = "F18"; + ks = "F18"; + kc = ""; + break; + case VK_F19: + kn = "F19"; + ks = "F19"; + kc = ""; + break; + case VK_F20: + kn = "F20"; + ks = "F20"; + kc = ""; + break; + case VK_F21: + kn = "F21"; + ks = "F21"; + kc = ""; + break; + case VK_F22: + kn = "F22"; + ks = "F22"; + kc = ""; + break; + case VK_F23: + kn = "F23"; + ks = "F23"; + kc = ""; + break; + case VK_F24: + kn = "F24"; + ks = "F24"; + kc = ""; + break; + default: + /* other non keystroke characters */ + return 0; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } + + return 1; +} + +static int +_ecore_win32_event_char_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) +{ + char kn[32]; + char ks[32]; + char *kc; + + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; + + switch (key) + { + case VK_BACK: + strncpy(kn, "Backspace", 32); + strncpy(ks, "Backspace", 32); + kc = ""; + break; + case VK_TAB: + strncpy(kn, "Tab", 32); + strncpy(ks, "Tab", 32); + kc = ""; + break; + case 0x0a: + /* Line feed (Shift + Enter) */ + strncpy(kn, "LineFeed", 32); + strncpy(ks, "LineFeed", 32); + kc = ""; + break; + case VK_RETURN: + strncpy(kn, "Return", 32); + strncpy(ks, "Return", 32); + kc = ""; + break; + case VK_ESCAPE: + strncpy(kn, "Escape", 32); + strncpy(ks, "Escape", 32); + kc = ""; + break; + default: + /* displayable characters */ + printf (" * key : %d\n", key); + kn[0] = (TCHAR)key; + kn[1] = '\0'; + ks[0] = (TCHAR)key; + ks[1] = '\0'; + kc = ""; + break; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } + + return 1; +} diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_glew.c b/legacy/ecore/src/lib/ecore_win32/ecore_win32_glew.c index 847ae9a4d4..c9f3e2f359 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_glew.c +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32_glew.c @@ -2,11 +2,20 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include +#endif + +#include /* for printf */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + #include -#include "ecore_win32_private.h" + #include "Ecore_Win32.h" -#include +#include "ecore_win32_private.h" static int _ecore_win32_glew_init = 0; @@ -18,9 +27,7 @@ ecore_win32_glew_init(Ecore_Win32_Window *window) PIXELFORMATDESCRIPTOR pfd; int format; - RECT rect; struct _Ecore_Win32_Window *w; - DWORD flag; if (!window) return 0; @@ -85,7 +92,6 @@ ecore_win32_glew_init(Ecore_Win32_Window *window) return 1; no_glew_2_0: - no_glew_init: no_format: ReleaseDC (w->window, w->glew.dc); no_dc: diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_private.h b/legacy/ecore/src/lib/ecore_win32/ecore_win32_private.h index bfd44e86b0..8de0cf8596 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_private.h +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32_private.h @@ -6,23 +6,6 @@ #define __ECORE_WIN32_PRIVATE_H__ -#ifdef HAVE_CONFIG_H -# include -#endif - -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#ifdef HAVE_OPENGL_GLEW -# include -#endif /* HAVE_OPENGL_GLEW */ - -#include -#include - -#include "Ecore_Win32.h" - - #define ECORE_WIN32_WINDOW_CLASS "Ecore_Win32_Window_Class" @@ -104,7 +87,6 @@ struct _Ecore_Win32_Window }; -extern Ecore_List *_ecore_win32_windows_list; extern HINSTANCE _ecore_win32_instance; extern double _ecore_win32_double_click_time; extern double _ecore_win32_event_last_time; diff --git a/legacy/ecore/src/lib/ecore_win32/ecore_win32_window.c b/legacy/ecore/src/lib/ecore_win32/ecore_win32_window.c index 28134e7cf7..d5bad2f5ed 100644 --- a/legacy/ecore/src/lib/ecore_win32/ecore_win32_window.c +++ b/legacy/ecore/src/lib/ecore_win32/ecore_win32_window.c @@ -2,13 +2,24 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include +#ifdef HAVE_CONFIG_H +# include +#endif -#include +#include +#include /* for printf */ +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + +#include "Ecore_Win32.h" #include "ecore_win32_private.h" +/***** Private declarations *****/ + + typedef enum _Ecore_Win32_Window_Z_Order Ecore_Win32_Window_Z_Order; enum _Ecore_Win32_Window_Z_Order { @@ -18,6 +29,793 @@ enum _Ecore_Win32_Window_Z_Order ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST }; +static Ecore_Win32_Window *ecore_win32_window_internal_new(Ecore_Win32_Window *parent, + int x, + int y, + int width, + int height, + DWORD style); + + +/***** API *****/ + +Ecore_Win32_Window * +ecore_win32_window_new(Ecore_Win32_Window *parent, + int x, + int y, + int width, + int height) +{ + return ecore_win32_window_internal_new(parent, + x, y, + width, height, + WS_OVERLAPPEDWINDOW | WS_SIZEBOX); +} + +/* simulate X11 override windows */ +Ecore_Win32_Window * +ecore_win32_window_override_new(Ecore_Win32_Window *parent, + int x, + int y, + int width, + int height) +{ + return ecore_win32_window_internal_new(parent, + x, y, + width, height, + WS_POPUP); +} + +void +ecore_win32_window_del(Ecore_Win32_Window *window) +{ + if (!window) return; + + switch (((struct _Ecore_Win32_Window *)window)->backend) + { + case ECORE_WIN32_BACKEND_DIRECTDRAW_16: +#ifdef HAVE_DIRECTDRAW +/* ecore_win32_ddraw_shutdown(window); */ +#endif /* HAVE_DIRECTDRAW */ + break; + case ECORE_WIN32_BACKEND_GLEW: +#ifdef HAVE_OPENGL_GLEW + ecore_win32_glew_shutdown(window); +#endif /* HAVE_OPENGL_GLEW */ + break; + default: + break; + } + + DestroyWindow(((struct _Ecore_Win32_Window *)window)->window); + free(window); + printf ("ecore_win32_window_del\n"); +} + +/* +void +ecore_win32_window_configure(Ecore_Win32_Window *window, + Ecore_Win32_Window_Z_Order order, + int x, + int y, + int width, + int height) +{ + HWND w; + + switch (order) + { + case ECORE_WIN32_WINDOW_Z_ORDER_BOTTOM: + w = HWND_BOTTOM; + break; + case ECORE_WIN32_WINDOW_Z_ORDER_NOTOPMOST: + w = HWND_NOTOPMOST; + break; + case ECORE_WIN32_WINDOW_Z_ORDER_TOP: + w = HWND_TOP; + break; + case ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST: + w = HWND_TOPMOST; + break; + default: + return; + } + SetWindowPos((struct _Ecore_Win32_Window *)window->window, w, x, y, width, height, ???); +} +*/ + +void +ecore_win32_window_move(Ecore_Win32_Window *window, + int x, + int y) +{ + RECT rect; + HWND w; + + if (!window) return; + + printf ("ecore_win32_window_move %p : %d %d\n", window, x, y); + w = ((struct _Ecore_Win32_Window *)window)->window; + if (!GetWindowRect(w, &rect)) + return; + + MoveWindow(w, x, y, + rect.right - rect.left, + rect.bottom - rect.top, + TRUE); +} + +void +ecore_win32_window_resize(Ecore_Win32_Window *window, + int width, + int height) +{ + RECT rect; + struct _Ecore_Win32_Window *w; + DWORD style; + int x; + int y; + + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + if (!GetWindowRect(w->window, &rect)) return; + + printf ("ecore_win32_window_resize 0 : %p (%d %d) (%d %d) (%d %d)\n", + w, + w->min_width, + w->min_height, + w->max_width, + w->max_height, + width, + height); + + x = rect.left; + y = rect.top; + rect.left = 0; + rect.top = 0; +/* if (width < w->min_width) width = w->min_width; */ +/* if (width > w->max_width) width = w->max_width; */ +/* printf ("ecore_win32_window_resize 1 : %d %d %d\n", w->min_height, w->max_height, height); */ +/* if (height < w->min_height) height = w->min_height; */ +/* printf ("ecore_win32_window_resize 2 : %d %d\n", w->max_height, height); */ +/* if (height > w->max_height) height = w->max_height; */ +/* printf ("ecore_win32_window_resize 3 : %d %d\n", w->max_height, height); */ + rect.right = width; + rect.bottom = height; + style = GetWindowLong(w->window, GWL_STYLE); + if (!AdjustWindowRect(&rect, style, FALSE)) + return; + + if (!MoveWindow(w->window, x, y, + rect.right - rect.left, + rect.bottom - rect.top, + FALSE)) + { + printf (" MEEERDE !!!\n"); + } + printf ("ecore_win32_window_resize 4 : %d %d\n", width, height); +} + +void +ecore_win32_window_move_resize(Ecore_Win32_Window *window, + int x, + int y, + int width, + int height) +{ + RECT rect; + struct _Ecore_Win32_Window *w; + DWORD style; + + if (!window) return; + + printf ("ecore_win32_window_move_resize 0 : %p %d %d\n", window, width, height); + w = ((struct _Ecore_Win32_Window *)window); + rect.left = 0; + rect.top = 0; + if ((unsigned int)width < w->min_width) width = w->min_width; + if ((unsigned int)width > w->max_width) width = w->max_width; + if ((unsigned int)height < w->min_height) height = w->min_height; + if ((unsigned int)height > w->max_height) height = w->max_height; + printf ("ecore_win32_window_move_resize 1 : %d %d\n", width, height); + rect.right = width; + rect.bottom = height; + style = GetWindowLong(w->window, GWL_STYLE); + if (!AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE)) + return; + + MoveWindow(w->window, x, y, + rect.right - rect.left, + rect.bottom - rect.top, + TRUE); +} + +void +ecore_win32_window_geometry_get(Ecore_Win32_Window *window, + int *x, + int *y, + int *width, + int *height) +{ + RECT rect; + int w; + int h; + + printf ("ecore_win32_window_geometry_get %p\n", window); + if (!window) + { + if (x) *x = 0; + if (y) *y = 0; + if (width) *width = GetSystemMetrics(SM_CXSCREEN); + if (height) *height = GetSystemMetrics(SM_CYSCREEN); + + return; + } + + if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, + &rect)) + { + if (x) *x = 0; + if (y) *y = 0; + if (width) *width = 0; + if (height) *height = 0; + + return; + } + + w = rect.right - rect.left; + h = rect.bottom - rect.top; + + if (!GetWindowRect(((struct _Ecore_Win32_Window *)window)->window, + &rect)) + { + if (x) *x = 0; + if (y) *y = 0; + if (width) *width = 0; + if (height) *height = 0; + + return; + } + + if (x) *x = rect.left; + if (y) *y = rect.top; + if (width) *width = w; + if (height) *height = h; +} + +void +ecore_win32_window_size_get(Ecore_Win32_Window *window, + int *width, + int *height) +{ + RECT rect; + + printf ("ecore_win32_window_size_get %p\n", window); + if (!window) + { + if (width) *width = GetSystemMetrics(SM_CXSCREEN); + if (height) *height = GetSystemMetrics(SM_CYSCREEN); + + return; + } + + if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, + &rect)) + { + if (width) *width = 0; + if (height) *height = 0; + } + + if (width) *width = rect.right - rect.left; + if (height) *height = rect.bottom - rect.top; +} + +void +ecore_win32_window_size_min_set(Ecore_Win32_Window *window, + unsigned int min_width, + unsigned int min_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + printf ("ecore_win32_window_size_min_set : %p %d %d\n", window, min_width, min_height); + w = (struct _Ecore_Win32_Window *)window; + w->min_width = min_width; + w->min_height = min_height; +} + +void +ecore_win32_window_size_min_get(Ecore_Win32_Window *window, + unsigned int *min_width, + unsigned int *min_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + printf ("ecore_win32_window_size_min_get : %p %d %d\n", window, w->min_width, w->min_height); + if (min_width) *min_width = w->min_width; + if (min_height) *min_height = w->min_height; +} + +void +ecore_win32_window_size_max_set(Ecore_Win32_Window *window, + unsigned int max_width, + unsigned int max_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + printf ("ecore_win32_window_size_max_set : %p %d %d\n", window, max_width, max_height); + w = (struct _Ecore_Win32_Window *)window; + w->max_width = max_width; + w->max_height = max_height; +} + +void +ecore_win32_window_size_max_get(Ecore_Win32_Window *window, + unsigned int *max_width, + unsigned int *max_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + printf ("ecore_win32_window_size_max_get : %p %d %d\n", window, w->max_width, w->max_height); + if (max_width) *max_width = w->max_width; + if (max_height) *max_height = w->max_height; +} + +void +ecore_win32_window_size_base_set(Ecore_Win32_Window *window, + unsigned int base_width, + unsigned int base_height) +{ + struct _Ecore_Win32_Window *w; + + printf ("ecore_win32_window_size_base_set : %p %d %d\n", window, base_width, base_height); + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + w->base_width = base_width; + w->base_height = base_height; +} + +void +ecore_win32_window_size_base_get(Ecore_Win32_Window *window, + unsigned int *base_width, + unsigned int *base_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + printf ("ecore_win32_window_size_base_get : %p %d %d\n", window, w->base_width, w->base_height); + if (base_width) *base_width = w->base_width; + if (base_height) *base_height = w->base_height; +} + +void +ecore_win32_window_size_step_set(Ecore_Win32_Window *window, + unsigned int step_width, + unsigned int step_height) +{ + struct _Ecore_Win32_Window *w; + + printf ("ecore_win32_window_size_step_set : %p %d %d\n", window, step_width, step_height); + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + w->step_width = step_width; + w->step_height = step_height; +} + +void +ecore_win32_window_size_step_get(Ecore_Win32_Window *window, + unsigned int *step_width, + unsigned int *step_height) +{ + struct _Ecore_Win32_Window *w; + + if (!window) return; + + w = (struct _Ecore_Win32_Window *)window; + printf ("ecore_win32_window_size_step_get : %p %d %d\n", window, w->step_width, w->step_height); + if (step_width) *step_width = w->step_width; + if (step_height) *step_height = w->step_height; +} + +/* TODO: ecore_win32_window_shaped_set */ + +void +ecore_win32_window_show(Ecore_Win32_Window *window) +{ + if (!window) return; + + printf (" ** ecore_win32_window_show %p\n", window); + ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL); + UpdateWindow(((struct _Ecore_Win32_Window *)window)->window); +} + +/* FIXME: seems to block the taskbar */ +void +ecore_win32_window_hide(Ecore_Win32_Window *window) +{ + if (!window) return; + + printf (" ** ecore_win32_window_hide %p\n", window); + ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE); +} + +void +ecore_win32_window_raise(Ecore_Win32_Window *window) +{ + if (!window) return; + + printf (" ** ecore_win32_window_raise %p\n", window); + SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, + HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); +} + +void +ecore_win32_window_lower(Ecore_Win32_Window *window) +{ + if (!window) return; + + printf (" ** ecore_win32_window_lower %p\n", window); + SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, + HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); +} + +void +ecore_win32_window_title_set(Ecore_Win32_Window *window, + const char *title) +{ + if (!window) return; + + if (!title || !title[0]) return; + + SetWindowText(((struct _Ecore_Win32_Window *)window)->window, title); +} + +void +ecore_win32_window_focus_set(Ecore_Win32_Window *window) +{ + if (!window) return; + + SetFocus(((struct _Ecore_Win32_Window *)window)->window); +} + +void +ecore_win32_window_iconified_set(Ecore_Win32_Window *window, + int on) +{ + struct _Ecore_Win32_Window *ew; + + if (!window) return; + + ew = (struct _Ecore_Win32_Window *)window; + if (((ew->iconified) && (on)) || + ((!ew->iconified) && (!on))) + return; + + if (on) + { + ShowWindow(ew->window, + SW_MINIMIZE); + } + else + { + ShowWindow(ew->window, + SW_RESTORE); + } + ew->iconified = on; +} + +void +ecore_win32_window_borderless_set(Ecore_Win32_Window *window, + int on) +{ + RECT rect; + DWORD style; + struct _Ecore_Win32_Window *ew; + HWND w; + + if (!window) return; + + printf (" ** ecore_win32_window_borderless_set %p %d\n", window, on); + ew = (struct _Ecore_Win32_Window *)window; + if (((ew->borderless) && (on)) || + ((!ew->borderless) && (!on))) + return; + + w = ew->window; + + style = GetWindowLong(w, GWL_STYLE); + if (on) + { + if (!GetClientRect(w, &rect)) return; + SetWindowLong(w, GWL_STYLE, style & ~WS_CAPTION); + } + else + { + if (!GetWindowRect(w, &rect)) return; + style |= WS_CAPTION; + AdjustWindowRect (&rect, style, FALSE); + SetWindowLong(w, GWL_STYLE, style); + } + SetWindowPos(w, HWND_TOPMOST, + rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, + SWP_NOMOVE | SWP_FRAMECHANGED); + ew->borderless = on; +} + +void +ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, + int on) +{ + struct _Ecore_Win32_Window *ew; + HWND w; + int width; + int height; + + if (!window) return; + + ew = (struct _Ecore_Win32_Window *)window; + if (((ew->fullscreen) && (on)) || + ((!ew->fullscreen) && (!on))) + return; + + ew->fullscreen = on; + w = ew->window; + + if (on) + { + if (!GetWindowRect(w, &ew->rect)) return; + ew->style = GetWindowLong(w, GWL_STYLE); + width = GetSystemMetrics (SM_CXSCREEN); + height = GetSystemMetrics (SM_CYSCREEN); + if (!SetWindowLong(w, GWL_STYLE, + (ew->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP)) + return; + SetWindowPos(w, HWND_TOP, 0, 0, width, height, + SWP_NOCOPYBITS | SWP_SHOWWINDOW); + } + else + { + if (!SetWindowLong(w, GWL_STYLE, ew->style)) + return; + SetWindowPos(w, HWND_NOTOPMOST, + ew->rect.left, + ew->rect.top, + ew->rect.right - ew->rect.left, + ew->rect.bottom - ew->rect.top, + SWP_NOCOPYBITS | SWP_SHOWWINDOW); + } +} + +void +ecore_win32_window_cursor_set(Ecore_Win32_Window *window, + Ecore_Win32_Cursor *cursor) +{ + SetClassLong(((struct _Ecore_Win32_Window *)window)->window, + GCL_HCURSOR, (LONG)cursor); +} + +void +ecore_win32_window_state_set(Ecore_Win32_Window *window, + Ecore_Win32_Window_State *state, + unsigned int num) +{ + unsigned int i; + + if (!num) + return; + + for (i = 0; i < num; i++) + { + switch (state[i]) + { + case ECORE_WIN32_WINDOW_STATE_ICONIFIED: + ((struct _Ecore_Win32_Window *)window)->state.iconified = 1; + break; + case ECORE_WIN32_WINDOW_STATE_MODAL: + ((struct _Ecore_Win32_Window *)window)->state.modal = 1; + break; + case ECORE_WIN32_WINDOW_STATE_STICKY: + ((struct _Ecore_Win32_Window *)window)->state.sticky = 1; + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT: + ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1; + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ: + ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1; + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED: + ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1; + ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1; + break; + case ECORE_WIN32_WINDOW_STATE_SHADED: + ((struct _Ecore_Win32_Window *)window)->state.shaded = 1; + break; + case ECORE_WIN32_WINDOW_STATE_HIDDEN: + ((struct _Ecore_Win32_Window *)window)->state.hidden = 1; + break; + case ECORE_WIN32_WINDOW_STATE_FULLSCREEN: + ((struct _Ecore_Win32_Window *)window)->state.fullscreen = 1; + break; + case ECORE_WIN32_WINDOW_STATE_ABOVE: + ((struct _Ecore_Win32_Window *)window)->state.above = 1; + break; + case ECORE_WIN32_WINDOW_STATE_BELOW: + ((struct _Ecore_Win32_Window *)window)->state.below = 1; + break; + case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION: + ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1; + break; + case ECORE_WIN32_WINDOW_STATE_UNKNOWN: + /* nothing to be done */ + break; + } + } +} + +void +ecore_win32_window_state_request_send(Ecore_Win32_Window *window, + Ecore_Win32_Window_State state, + unsigned int set) +{ + if (!window) + return; + + switch (state) + { + case ECORE_WIN32_WINDOW_STATE_ICONIFIED: + if (((struct _Ecore_Win32_Window *)window)->state.iconified) + ecore_win32_window_iconified_set(window, set); + break; + case ECORE_WIN32_WINDOW_STATE_MODAL: + ((struct _Ecore_Win32_Window *)window)->state.modal = 1; + break; + case ECORE_WIN32_WINDOW_STATE_STICKY: + ((struct _Ecore_Win32_Window *)window)->state.sticky = 1; + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT: + if (((struct _Ecore_Win32_Window *)window)->state.maximized_vert) + { + RECT rect; + int y; + int height; + + if (!SystemParametersInfo(SPI_GETWORKAREA, 0, + &rect, 0)) + break; + y = rect.top; + height = rect.bottom - rect.top; + + if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, + &rect)) + break; + + MoveWindow(window, rect.left, y, + rect.right - rect.left, + height, + TRUE); + } + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ: + if (((struct _Ecore_Win32_Window *)window)->state.maximized_horz) + { + RECT rect; + + if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, + &rect)) + break; + + MoveWindow(window, 0, rect.top, + GetSystemMetrics(SM_CXSCREEN), + rect.bottom - rect.top, + TRUE); + } + break; + case ECORE_WIN32_WINDOW_STATE_MAXIMIZED: + if (((struct _Ecore_Win32_Window *)window)->state.maximized_vert && + ((struct _Ecore_Win32_Window *)window)->state.maximized_horz) + { + RECT rect; + + if (!SystemParametersInfo(SPI_GETWORKAREA, 0, + &rect, 0)) + break; + + MoveWindow(window, 0, 0, + GetSystemMetrics(SM_CXSCREEN), + rect.bottom - rect.top, + TRUE); + } + break; + case ECORE_WIN32_WINDOW_STATE_SHADED: + ((struct _Ecore_Win32_Window *)window)->state.shaded = 1; + break; + case ECORE_WIN32_WINDOW_STATE_HIDDEN: + ((struct _Ecore_Win32_Window *)window)->state.hidden = 1; + break; + case ECORE_WIN32_WINDOW_STATE_FULLSCREEN: + if (((struct _Ecore_Win32_Window *)window)->state.fullscreen) + ecore_win32_window_fullscreen_set(window, set); + break; + case ECORE_WIN32_WINDOW_STATE_ABOVE: + if (((struct _Ecore_Win32_Window *)window)->state.above) + SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, + HWND_TOP, + 0, 0, + 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + break; + case ECORE_WIN32_WINDOW_STATE_BELOW: + if (((struct _Ecore_Win32_Window *)window)->state.below) + SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, + HWND_BOTTOM, + 0, 0, + 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + break; + case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION: + ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1; + break; + case ECORE_WIN32_WINDOW_STATE_UNKNOWN: + /* nothing to be done */ + break; + } +} + +void +ecore_win32_window_type_set(Ecore_Win32_Window *window, + Ecore_Win32_Window_Type type) +{ + switch (type) + { + case ECORE_WIN32_WINDOW_TYPE_DESKTOP: + ((struct _Ecore_Win32_Window *)window)->type.desktop = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_DOCK: + ((struct _Ecore_Win32_Window *)window)->type.dock = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_TOOLBAR: + ((struct _Ecore_Win32_Window *)window)->type.toolbar = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_MENU: + ((struct _Ecore_Win32_Window *)window)->type.menu = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_UTILITY: + ((struct _Ecore_Win32_Window *)window)->type.utility = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_SPLASH: + ((struct _Ecore_Win32_Window *)window)->type.splash = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_DIALOG: + ((struct _Ecore_Win32_Window *)window)->type.dialog = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_NORMAL: + ((struct _Ecore_Win32_Window *)window)->type.normal = 1; + break; + case ECORE_WIN32_WINDOW_TYPE_UNKNOWN: + ((struct _Ecore_Win32_Window *)window)->type.normal = 1; + break; + } +} + + +/***** Private functions definitions *****/ static Ecore_Win32_Window * ecore_win32_window_internal_new(Ecore_Win32_Window *parent, @@ -132,780 +930,3 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent, return w; } - -EAPI Ecore_Win32_Window * -ecore_win32_window_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height) -{ - return ecore_win32_window_internal_new(parent, - x, y, - width, height, - WS_OVERLAPPEDWINDOW | WS_SIZEBOX); -} - -/* simulate X11 override windows */ -EAPI Ecore_Win32_Window * -ecore_win32_window_override_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height) -{ - return ecore_win32_window_internal_new(parent, - x, y, - width, height, - WS_POPUP); -} - -EAPI void -ecore_win32_window_del(Ecore_Win32_Window *window) -{ - Ecore_Win32_Window *w; - - if (!window) return; - - switch (((struct _Ecore_Win32_Window *)window)->backend) - { - case ECORE_WIN32_BACKEND_DIRECTDRAW_16: -#ifdef HAVE_DIRECTDRAW -/* ecore_win32_ddraw_shutdown(window); */ -#endif /* HAVE_DIRECTDRAW */ - break; - case ECORE_WIN32_BACKEND_GLEW: -#ifdef HAVE_OPENGL_GLEW - ecore_win32_glew_shutdown(window); -#endif /* HAVE_OPENGL_GLEW */ - break; - default: - break; - } - - DestroyWindow(((struct _Ecore_Win32_Window *)window)->window); - free(window); - printf ("ecore_win32_window_del\n"); -} - -/* -EAPI void -ecore_win32_window_configure(Ecore_Win32_Window *window, - Ecore_Win32_Window_Z_Order order, - int x, - int y, - int width, - int height) -{ - HWND w; - - switch (order) - { - case ECORE_WIN32_WINDOW_Z_ORDER_BOTTOM: - w = HWND_BOTTOM; - break; - case ECORE_WIN32_WINDOW_Z_ORDER_NOTOPMOST: - w = HWND_NOTOPMOST; - break; - case ECORE_WIN32_WINDOW_Z_ORDER_TOP: - w = HWND_TOP; - break; - case ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST: - w = HWND_TOPMOST; - break; - default: - return; - } - SetWindowPos((struct _Ecore_Win32_Window *)window->window, w, x, y, width, height, ???); -} -*/ - -EAPI void -ecore_win32_window_move(Ecore_Win32_Window *window, - int x, - int y) -{ - RECT rect; - HWND w; - - if (!window) return; - - printf ("ecore_win32_window_move %p : %d %d\n", window, x, y); - w = ((struct _Ecore_Win32_Window *)window)->window; - if (!GetWindowRect(w, &rect)) - return; - - MoveWindow(w, x, y, - rect.right - rect.left, - rect.bottom - rect.top, - TRUE); -} - -EAPI void -ecore_win32_window_resize(Ecore_Win32_Window *window, - int width, - int height) -{ - RECT rect; - struct _Ecore_Win32_Window *w; - DWORD style; - int x; - int y; - - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - if (!GetWindowRect(w->window, &rect)) return; - - printf ("ecore_win32_window_resize 0 : %p (%d %d) (%d %d) (%d %d)\n", - w, - w->min_width, - w->min_height, - w->max_width, - w->max_height, - width, - height); - - x = rect.left; - y = rect.top; - rect.left = 0; - rect.top = 0; -/* if (width < w->min_width) width = w->min_width; */ -/* if (width > w->max_width) width = w->max_width; */ -/* printf ("ecore_win32_window_resize 1 : %d %d %d\n", w->min_height, w->max_height, height); */ -/* if (height < w->min_height) height = w->min_height; */ -/* printf ("ecore_win32_window_resize 2 : %d %d\n", w->max_height, height); */ -/* if (height > w->max_height) height = w->max_height; */ -/* printf ("ecore_win32_window_resize 3 : %d %d\n", w->max_height, height); */ - rect.right = width; - rect.bottom = height; - style = GetWindowLong(w->window, GWL_STYLE); - if (!AdjustWindowRect(&rect, style, FALSE)) - return; - - if (!MoveWindow(w->window, x, y, - rect.right - rect.left, - rect.bottom - rect.top, - FALSE)) - { - printf (" MEEERDE !!!\n"); - } - printf ("ecore_win32_window_resize 4 : %d %d\n", width, height); -} - -EAPI void -ecore_win32_window_move_resize(Ecore_Win32_Window *window, - int x, - int y, - int width, - int height) -{ - RECT rect; - struct _Ecore_Win32_Window *w; - DWORD style; - - if (!window) return; - - printf ("ecore_win32_window_move_resize 0 : %p %d %d\n", window, width, height); - w = ((struct _Ecore_Win32_Window *)window); - rect.left = 0; - rect.top = 0; - if (width < w->min_width) width = w->min_width; - if (width > w->max_width) width = w->max_width; - if (height < w->min_height) height = w->min_height; - if (height > w->max_height) height = w->max_height; - printf ("ecore_win32_window_move_resize 1 : %d %d\n", width, height); - rect.right = width; - rect.bottom = height; - style = GetWindowLong(w->window, GWL_STYLE); - if (!AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE)) - return; - - MoveWindow(w->window, x, y, - rect.right - rect.left, - rect.bottom - rect.top, - TRUE); -} - -EAPI void -ecore_win32_window_geometry_get(Ecore_Win32_Window *window, - int *x, - int *y, - int *width, - int *height) -{ - RECT rect; - int w; - int h; - - printf ("ecore_win32_window_geometry_get %p\n", window); - if (!window) - { - if (x) *x = 0; - if (y) *y = 0; - if (width) *width = GetSystemMetrics(SM_CXSCREEN); - if (height) *height = GetSystemMetrics(SM_CYSCREEN); - - return; - } - - if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, - &rect)) - { - if (x) *x = 0; - if (y) *y = 0; - if (width) *width = 0; - if (height) *height = 0; - - return; - } - - w = rect.right - rect.left; - h = rect.bottom - rect.top; - - if (!GetWindowRect(((struct _Ecore_Win32_Window *)window)->window, - &rect)) - { - if (x) *x = 0; - if (y) *y = 0; - if (width) *width = 0; - if (height) *height = 0; - - return; - } - - if (x) *x = rect.left; - if (y) *y = rect.top; - if (width) *width = w; - if (height) *height = h; -} - -EAPI void -ecore_win32_window_size_get(Ecore_Win32_Window *window, - int *width, - int *height) -{ - RECT rect; - - printf ("ecore_win32_window_size_get %p\n", window); - if (!window) - { - if (width) *width = GetSystemMetrics(SM_CXSCREEN); - if (height) *height = GetSystemMetrics(SM_CYSCREEN); - - return; - } - - if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, - &rect)) - { - if (width) *width = 0; - if (height) *height = 0; - } - - if (width) *width = rect.right - rect.left; - if (height) *height = rect.bottom - rect.top; -} - -EAPI void -ecore_win32_window_size_min_set(Ecore_Win32_Window *window, - unsigned int min_width, - unsigned int min_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - printf ("ecore_win32_window_size_min_set : %p %d %d\n", window, min_width, min_height); - w = (struct _Ecore_Win32_Window *)window; - w->min_width = min_width; - w->min_height = min_height; -} - -EAPI void -ecore_win32_window_size_min_get(Ecore_Win32_Window *window, - unsigned int *min_width, - unsigned int *min_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - printf ("ecore_win32_window_size_min_get : %p %d %d\n", window, w->min_width, w->min_height); - if (min_width) *min_width = w->min_width; - if (min_height) *min_height = w->min_height; -} - -EAPI void -ecore_win32_window_size_max_set(Ecore_Win32_Window *window, - unsigned int max_width, - unsigned int max_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - printf ("ecore_win32_window_size_max_set : %p %d %d\n", window, max_width, max_height); - w = (struct _Ecore_Win32_Window *)window; - w->max_width = max_width; - w->max_height = max_height; -} - -EAPI void -ecore_win32_window_size_max_get(Ecore_Win32_Window *window, - unsigned int *max_width, - unsigned int *max_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - printf ("ecore_win32_window_size_max_get : %p %d %d\n", window, w->max_width, w->max_height); - if (max_width) *max_width = w->max_width; - if (max_height) *max_height = w->max_height; -} - -EAPI void -ecore_win32_window_size_base_set(Ecore_Win32_Window *window, - unsigned int base_width, - unsigned int base_height) -{ - struct _Ecore_Win32_Window *w; - - printf ("ecore_win32_window_size_base_set : %p %d %d\n", window, base_width, base_height); - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - w->base_width = base_width; - w->base_height = base_height; -} - -EAPI void -ecore_win32_window_size_base_get(Ecore_Win32_Window *window, - unsigned int *base_width, - unsigned int *base_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - printf ("ecore_win32_window_size_base_get : %p %d %d\n", window, w->base_width, w->base_height); - if (base_width) *base_width = w->base_width; - if (base_height) *base_height = w->base_height; -} - -EAPI void -ecore_win32_window_size_step_set(Ecore_Win32_Window *window, - unsigned int step_width, - unsigned int step_height) -{ - struct _Ecore_Win32_Window *w; - - printf ("ecore_win32_window_size_step_set : %p %d %d\n", window, step_width, step_height); - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - w->step_width = step_width; - w->step_height = step_height; -} - -EAPI void -ecore_win32_window_size_step_get(Ecore_Win32_Window *window, - unsigned int *step_width, - unsigned int *step_height) -{ - struct _Ecore_Win32_Window *w; - - if (!window) return; - - w = (struct _Ecore_Win32_Window *)window; - printf ("ecore_win32_window_size_step_get : %p %d %d\n", window, w->step_width, w->step_height); - if (step_width) *step_width = w->step_width; - if (step_height) *step_height = w->step_height; -} - -/* TODO: ecore_win32_window_shaped_set */ - -EAPI void -ecore_win32_window_show(Ecore_Win32_Window *window) -{ - if (!window) return; - - printf (" ** ecore_win32_window_show %p\n", window); - ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_SHOWNORMAL); - UpdateWindow(((struct _Ecore_Win32_Window *)window)->window); -} - -/* FIXME: seems to block the taskbar */ -EAPI void -ecore_win32_window_hide(Ecore_Win32_Window *window) -{ - if (!window) return; - - printf (" ** ecore_win32_window_hide %p\n", window); - ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE); -} - -EAPI void -ecore_win32_window_raise(Ecore_Win32_Window *window) -{ - if (!window) return; - - printf (" ** ecore_win32_window_raise %p\n", window); - SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, - HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); -} - -EAPI void -ecore_win32_window_lower(Ecore_Win32_Window *window) -{ - if (!window) return; - - printf (" ** ecore_win32_window_lower %p\n", window); - SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, - HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); -} - -EAPI void -ecore_win32_window_title_set(Ecore_Win32_Window *window, - const char *title) -{ - if (!window) return; - - if (!title || !title[0]) return; - - SetWindowText(((struct _Ecore_Win32_Window *)window)->window, title); -} - -EAPI void -ecore_win32_window_focus_set(Ecore_Win32_Window *window) -{ - if (!window) return; - - SetFocus(((struct _Ecore_Win32_Window *)window)->window); -} - -EAPI void -ecore_win32_window_iconified_set(Ecore_Win32_Window *window, - int on) -{ - struct _Ecore_Win32_Window *ew; - - if (!window) return; - - ew = (struct _Ecore_Win32_Window *)window; - if (((ew->iconified) && (on)) || - ((!ew->iconified) && (!on))) - return; - - if (on) - { - ShowWindow(ew->window, - SW_MINIMIZE); - } - else - { - ShowWindow(ew->window, - SW_RESTORE); - } - ew->iconified = on; -} - -EAPI void -ecore_win32_window_borderless_set(Ecore_Win32_Window *window, - int on) -{ - RECT rect; - DWORD style; - struct _Ecore_Win32_Window *ew; - HWND w; - - if (!window) return; - - printf (" ** ecore_win32_window_borderless_set %p %d\n", window, on); - ew = (struct _Ecore_Win32_Window *)window; - if (((ew->borderless) && (on)) || - ((!ew->borderless) && (!on))) - return; - - w = ew->window; - - style = GetWindowLong(w, GWL_STYLE); - if (on) - { - if (!GetClientRect(w, &rect)) return; - SetWindowLong(w, GWL_STYLE, style & ~WS_CAPTION); - } - else - { - if (!GetWindowRect(w, &rect)) return; - style |= WS_CAPTION; - AdjustWindowRect (&rect, style, FALSE); - SetWindowLong(w, GWL_STYLE, style); - } - SetWindowPos(w, HWND_TOPMOST, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_NOMOVE | SWP_FRAMECHANGED); - ew->borderless = on; -} - -EAPI void -ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, - int on) -{ - struct _Ecore_Win32_Window *ew; - HWND w; - int width; - int height; - - if (!window) return; - - ew = (struct _Ecore_Win32_Window *)window; - if (((ew->fullscreen) && (on)) || - ((!ew->fullscreen) && (!on))) - return; - - ew->fullscreen = on; - w = ew->window; - - if (on) - { - if (!GetWindowRect(w, &ew->rect)) return; - ew->style = GetWindowLong(w, GWL_STYLE); - width = GetSystemMetrics (SM_CXSCREEN); - height = GetSystemMetrics (SM_CYSCREEN); - if (!SetWindowLong(w, GWL_STYLE, - (ew->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP)) - return; - SetWindowPos(w, HWND_TOP, 0, 0, width, height, - SWP_NOCOPYBITS | SWP_SHOWWINDOW); - } - else - { - if (!SetWindowLong(w, GWL_STYLE, ew->style)) - return; - SetWindowPos(w, HWND_NOTOPMOST, - ew->rect.left, - ew->rect.top, - ew->rect.right - ew->rect.left, - ew->rect.bottom - ew->rect.top, - SWP_NOCOPYBITS | SWP_SHOWWINDOW); - } -} - -EAPI void -ecore_win32_window_cursor_set(Ecore_Win32_Window *window, - Ecore_Win32_Cursor *cursor) -{ - SetClassLong(((struct _Ecore_Win32_Window *)window)->window, - GCL_HCURSOR, (LONG)cursor); -} - -EAPI void -ecore_win32_window_state_set(Ecore_Win32_Window *window, - Ecore_Win32_Window_State *state, - unsigned int num) -{ - unsigned int i; - - if (!num) - return; - - for (i = 0; i < num; i++) - { - switch (state[i]) - { - case ECORE_WIN32_WINDOW_STATE_ICONIFIED: - ((struct _Ecore_Win32_Window *)window)->state.iconified = 1; - break; - case ECORE_WIN32_WINDOW_STATE_MODAL: - ((struct _Ecore_Win32_Window *)window)->state.modal = 1; - break; - case ECORE_WIN32_WINDOW_STATE_STICKY: - ((struct _Ecore_Win32_Window *)window)->state.sticky = 1; - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT: - ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1; - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ: - ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1; - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED: - ((struct _Ecore_Win32_Window *)window)->state.maximized_horz = 1; - ((struct _Ecore_Win32_Window *)window)->state.maximized_vert = 1; - break; - case ECORE_WIN32_WINDOW_STATE_SHADED: - ((struct _Ecore_Win32_Window *)window)->state.shaded = 1; - break; - case ECORE_WIN32_WINDOW_STATE_HIDDEN: - ((struct _Ecore_Win32_Window *)window)->state.hidden = 1; - break; - case ECORE_WIN32_WINDOW_STATE_FULLSCREEN: - ((struct _Ecore_Win32_Window *)window)->state.fullscreen = 1; - break; - case ECORE_WIN32_WINDOW_STATE_ABOVE: - ((struct _Ecore_Win32_Window *)window)->state.above = 1; - break; - case ECORE_WIN32_WINDOW_STATE_BELOW: - ((struct _Ecore_Win32_Window *)window)->state.below = 1; - break; - case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION: - ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1; - break; - case ECORE_WIN32_WINDOW_STATE_UNKNOWN: - /* nothing to be done */ - break; - } - } -} - -EAPI void -ecore_win32_window_state_request_send(Ecore_Win32_Window *window, - Ecore_Win32_Window_State state, - unsigned int set) -{ - if (!window) - return; - - switch (state) - { - case ECORE_WIN32_WINDOW_STATE_ICONIFIED: - if (((struct _Ecore_Win32_Window *)window)->state.iconified) - ecore_win32_window_iconified_set(window, set); - break; - case ECORE_WIN32_WINDOW_STATE_MODAL: - ((struct _Ecore_Win32_Window *)window)->state.modal = 1; - break; - case ECORE_WIN32_WINDOW_STATE_STICKY: - ((struct _Ecore_Win32_Window *)window)->state.sticky = 1; - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT: - if (((struct _Ecore_Win32_Window *)window)->state.maximized_vert) - { - RECT rect; - int y; - int height; - - if (!SystemParametersInfo(SPI_GETWORKAREA, 0, - &rect, 0)) - break; - y = rect.top; - height = rect.bottom - rect.top; - - if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, - &rect)) - break; - - MoveWindow(window, rect.left, y, - rect.right - rect.left, - height, - TRUE); - } - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ: - if (((struct _Ecore_Win32_Window *)window)->state.maximized_horz) - { - RECT rect; - - if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window, - &rect)) - break; - - MoveWindow(window, 0, rect.top, - GetSystemMetrics(SM_CXSCREEN), - rect.bottom - rect.top, - TRUE); - } - break; - case ECORE_WIN32_WINDOW_STATE_MAXIMIZED: - if (((struct _Ecore_Win32_Window *)window)->state.maximized_vert && - ((struct _Ecore_Win32_Window *)window)->state.maximized_horz) - { - RECT rect; - - if (!SystemParametersInfo(SPI_GETWORKAREA, 0, - &rect, 0)) - break; - - MoveWindow(window, 0, 0, - GetSystemMetrics(SM_CXSCREEN), - rect.bottom - rect.top, - TRUE); - } - break; - case ECORE_WIN32_WINDOW_STATE_SHADED: - ((struct _Ecore_Win32_Window *)window)->state.shaded = 1; - break; - case ECORE_WIN32_WINDOW_STATE_HIDDEN: - ((struct _Ecore_Win32_Window *)window)->state.hidden = 1; - break; - case ECORE_WIN32_WINDOW_STATE_FULLSCREEN: - if (((struct _Ecore_Win32_Window *)window)->state.fullscreen) - ecore_win32_window_fullscreen_set(window, set); - break; - case ECORE_WIN32_WINDOW_STATE_ABOVE: - if (((struct _Ecore_Win32_Window *)window)->state.above) - SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, - HWND_TOP, - 0, 0, - 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - break; - case ECORE_WIN32_WINDOW_STATE_BELOW: - if (((struct _Ecore_Win32_Window *)window)->state.below) - SetWindowPos(((struct _Ecore_Win32_Window *)window)->window, - HWND_BOTTOM, - 0, 0, - 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - break; - case ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION: - ((struct _Ecore_Win32_Window *)window)->state.demands_attention = 1; - break; - case ECORE_WIN32_WINDOW_STATE_UNKNOWN: - /* nothing to be done */ - break; - } -} - -EAPI void -ecore_win32_window_type_set(Ecore_Win32_Window *window, - Ecore_Win32_Window_Type type) -{ - switch (type) - { - case ECORE_WIN32_WINDOW_TYPE_DESKTOP: - ((struct _Ecore_Win32_Window *)window)->type.desktop = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_DOCK: - ((struct _Ecore_Win32_Window *)window)->type.dock = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_TOOLBAR: - ((struct _Ecore_Win32_Window *)window)->type.toolbar = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_MENU: - ((struct _Ecore_Win32_Window *)window)->type.menu = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_UTILITY: - ((struct _Ecore_Win32_Window *)window)->type.utility = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_SPLASH: - ((struct _Ecore_Win32_Window *)window)->type.splash = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_DIALOG: - ((struct _Ecore_Win32_Window *)window)->type.dialog = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_NORMAL: - ((struct _Ecore_Win32_Window *)window)->type.normal = 1; - break; - case ECORE_WIN32_WINDOW_TYPE_UNKNOWN: - ((struct _Ecore_Win32_Window *)window)->type.normal = 1; - break; - } -}