Associate an Ecore_Win32_Window to its HWND window, hence drop of the window list management. That should fix a bug when 2 windows are used in the same program. Add ecore_win32_screen_depth_get() to know the depth of the screen. Remove the management of the backend for direct3d and directdraw as they are done by the engines, now. More (ddraw 16 bits and gl) will follow later

SVN revision: 34908
This commit is contained in:
doursse 2008-06-26 04:30:29 +00:00 committed by doursse
parent 3d95a7bf7e
commit 50d48a1859
6 changed files with 55 additions and 165 deletions

View File

@ -35,12 +35,6 @@
typedef void Ecore_Win32_Window;
typedef void Ecore_Win32_Cursor;
typedef void Ecore_Win32_DDraw_Object;
typedef void Ecore_Win32_DDraw_Surface;
typedef void Ecore_Win32_Direct3D_Object;
typedef void Ecore_Win32_Direct3D_Device;
typedef void Ecore_Win32_Direct3D_Sprite;
typedef void Ecore_Win32_Direct3D_Texture;
typedef void Ecore_Win32_Glew_DC;
/* Window state */
@ -312,6 +306,7 @@ EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST;
EAPI int ecore_win32_init();
EAPI int ecore_win32_shutdown();
EAPI int ecore_win32_screen_depth_get();
EAPI double ecore_win32_current_time_get(void);
EAPI void ecore_win32_message_loop_begin (void);
@ -437,48 +432,6 @@ EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape s
EAPI int ecore_win32_cursor_size_get(void);
/* DirectDraw */
#ifdef __cplusplus
extern "C" {
#endif
EAPI int ecore_win32_ddraw_init(Ecore_Win32_Window *window);
EAPI int ecore_win32_ddraw_16_init(Ecore_Win32_Window *window);
EAPI void ecore_win32_ddraw_shutdown(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Object *ecore_win32_ddraw_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Surface *ecore_win32_ddraw_surface_primary_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Surface *ecore_win32_ddraw_surface_back_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Surface *ecore_win32_ddraw_surface_source_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_ddraw_depth_get(Ecore_Win32_Window *window);
/* Direct3D */
EAPI int ecore_win32_direct3d_init(Ecore_Win32_Window *window);
EAPI void ecore_win32_direct3d_shutdown(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Object *ecore_win32_direct3d_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Device *ecore_win32_direct3d_device_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Sprite *ecore_win32_direct3d_sprite_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Texture *ecore_win32_direct3d_texture_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_direct3d_depth_get(Ecore_Win32_Window *window);
#ifdef __cplusplus
}
#endif
/* OpenGL Glew */
EAPI int ecore_win32_glew_init(Ecore_Win32_Window *window);

View File

@ -15,8 +15,6 @@ Ecore_Win32.h
libecore_win32_la_SOURCES = \
ecore_win32.c \
ecore_win32_cursor.c \
ecore_win32_ddraw.cpp \
ecore_win32_direct3d.cpp \
ecore_win32_event.c \
ecore_win32_glew.c \
ecore_win32_window.c

View File

@ -7,7 +7,6 @@
#include "ecore_win32_private.h"
Ecore_List *_ecore_win32_windows_list = NULL;
HINSTANCE _ecore_win32_instance = NULL;
double _ecore_win32_double_click_time = 0.25;
double _ecore_win32_event_last_time = 0.0;
@ -91,15 +90,7 @@ _ecore_win32_window_procedure(HWND window,
RECT rect;
struct _Ecore_Win32_Window *w = NULL;
ecore_list_first_goto(_ecore_win32_windows_list);
while ((w = ecore_list_next(_ecore_win32_windows_list)))
{
if (w->window == window)
{
ecore_list_remove(_ecore_win32_windows_list);
break;
}
}
w = (struct _Ecore_Win32_Window *)GetWindowLong(window, GWL_USERDATA);
if (GetClientRect(window, &rect))
{
@ -321,14 +312,6 @@ ecore_win32_init()
return 0;
}
_ecore_win32_windows_list = ecore_list_new();
if (!_ecore_win32_windows_list)
{
UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance);
FreeLibrary(_ecore_win32_instance);
return 0;
}
if (!ECORE_WIN32_EVENT_KEY_DOWN)
{
ECORE_WIN32_EVENT_KEY_DOWN = ecore_event_type_new();
@ -374,8 +357,6 @@ ecore_win32_shutdown()
if (_ecore_win32_init_count > 0) return _ecore_win32_init_count;
if (!_ecore_win32_instance) return _ecore_win32_init_count;
ecore_list_destroy(_ecore_win32_windows_list);
UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance);
FreeLibrary(_ecore_win32_instance);
_ecore_win32_instance = NULL;
@ -385,6 +366,22 @@ ecore_win32_shutdown()
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.
*

View File

@ -329,21 +329,6 @@ _ecore_win32_event_char_get(int key,
return 1;
}
Ecore_Win32_Window *
_ecore_win32_event_window_get(HWND window)
{
Ecore_Win32_Window *w = NULL;
ecore_list_first_goto(_ecore_win32_windows_list);
while ((w = ecore_list_next(_ecore_win32_windows_list)))
{
if (((struct _Ecore_Win32_Window *)w)->window == window)
return w;
}
return w;
}
void
_ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg,
int is_keystroke)
@ -378,7 +363,12 @@ _ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg,
}
store_key:
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
if (!e->window)
{
free(e);
return;
}
e->time = (double)msg->time / 1000.0;
_ecore_win32_event_last_time = e->time;
@ -420,7 +410,12 @@ _ecore_win32_event_handle_key_release(Ecore_Win32_Callback_Data *msg,
}
store_key:
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
if (!e->window)
{
free(e);
return;
}
e->time = (double)msg->time / 1000.0;
_ecore_win32_event_last_time = e->time;
@ -434,7 +429,7 @@ _ecore_win32_event_handle_button_press(Ecore_Win32_Callback_Data *msg,
{
Ecore_Win32_Window *window;
window = _ecore_win32_event_window_get(msg->window);
window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
if (button > 3)
{
@ -526,7 +521,7 @@ _ecore_win32_event_handle_button_press(Ecore_Win32_Callback_Data *msg,
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
}
}
printf (" * ecore event button press\n");
/* printf (" * ecore event button press\n"); */
}
void
@ -535,7 +530,7 @@ _ecore_win32_event_handle_button_release(Ecore_Win32_Callback_Data *msg,
{
Ecore_Win32_Window *window;
window = _ecore_win32_event_window_get(msg->window);
window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
{
Ecore_Win32_Event_Mouse_Move *e;
@ -585,7 +580,7 @@ _ecore_win32_event_handle_button_release(Ecore_Win32_Callback_Data *msg,
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
}
printf (" * ecore event button release\n");
/* printf (" * ecore event button release\n"); */
}
void
@ -596,7 +591,7 @@ _ecore_win32_event_handle_motion_notify(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Move));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
@ -613,7 +608,7 @@ _ecore_win32_event_handle_enter_notify(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Move));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = msg->x;
e->y = msg->y;
e->time = (double)msg->time / 1000.0;
@ -630,7 +625,7 @@ _ecore_win32_event_handle_enter_notify(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Mouse_In *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_In));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = msg->x;
e->y = msg->y;
e->time = (double)msg->time / 1000.0;
@ -650,7 +645,7 @@ _ecore_win32_event_handle_leave_notify(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Move));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = msg->x;
e->y = msg->y;
e->time = (double)msg->time / 1000.0;
@ -667,7 +662,7 @@ _ecore_win32_event_handle_leave_notify(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Mouse_Out *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Out));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = msg->x;
e->y = msg->y;
e->time = (double)msg->time / 1000.0;
@ -686,7 +681,7 @@ _ecore_win32_event_handle_focus_in(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_Win32_Event_Window_Focus_In));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
_ecore_win32_event_last_time = e->time;
@ -702,7 +697,7 @@ _ecore_win32_event_handle_focus_out(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_Win32_Event_Window_Focus_Out));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
_ecore_win32_event_last_time = e->time;
@ -718,13 +713,13 @@ _ecore_win32_event_handle_expose(Ecore_Win32_Callback_Data *msg)
e = (Ecore_Win32_Event_Window_Damage *)calloc(1, sizeof(Ecore_Win32_Event_Window_Damage));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->x = msg->update.left;
e->y = msg->update.top;
e->width = msg->update.right - msg->update.left;
e->height = msg->update.bottom - msg->update.top;
printf (" * ecore : event expose %d %d\n", e->width, e->height);
/* printf (" * ecore : event expose %d %d\n", e->width, e->height); */
e->time = _ecore_win32_event_last_time;
@ -739,7 +734,7 @@ _ecore_win32_event_handle_create_notify(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Create));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
@ -754,7 +749,7 @@ _ecore_win32_event_handle_destroy_notify(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Destroy));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
if (e->window == _ecore_win32_event_last_window) _ecore_win32_event_last_window = NULL;
@ -770,7 +765,7 @@ _ecore_win32_event_handle_map_notify(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Show));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
@ -785,7 +780,7 @@ _ecore_win32_event_handle_unmap_notify(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Hide));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
@ -810,9 +805,9 @@ _ecore_win32_event_handle_configure_notify(Ecore_Win32_Callback_Data *msg)
return;
}
printf ("_ecore_win32_event_handle_configure_notify\n");
e->window = _ecore_win32_event_window_get(window_pos->hwnd);
e->abovewin = _ecore_win32_event_window_get(window_pos->hwndInsertAfter);
/* printf ("_ecore_win32_event_handle_configure_notify\n"); */
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->abovewin = (void *)GetWindowLong(window_pos->hwndInsertAfter, GWL_USERDATA);
e->x = wi.rcClient.left;
e->y = wi.rcClient.top;
e->width = wi.rcClient.right - wi.rcClient.left;
@ -834,11 +829,11 @@ _ecore_win32_event_handle_resize(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Resize));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->width = rect.right - rect.left;
e->height = rect.bottom - rect.top;
e->time = _ecore_win32_event_last_time;
printf (" * _ecore_win32_event_handle_resize %d %d\n", e->width, e->height);
/* printf (" * _ecore_win32_event_handle_resize %d %d\n", e->width, e->height); */
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_RESIZE, e, NULL, NULL);
}
@ -851,7 +846,7 @@ _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg)
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Delete_Request));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
e->time = _ecore_win32_event_last_time;
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);

View File

@ -13,13 +13,6 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef HAVE_DIRECTDRAW
# include <ddraw.h>
#endif /* HAVE_DIRECTDRAW */
#ifdef HAVE_DIRECT3D
# include <d3d9.h>
# include <d3dx9.h>
#endif /* HAVE_DIRECT3D */
#ifdef HAVE_OPENGL_GLEW
# include <GL/glew.h>
#endif /* HAVE_OPENGL_GLEW */
@ -35,9 +28,7 @@
typedef enum
{
ECORE_WIN32_BACKEND_DIRECTDRAW,
ECORE_WIN32_BACKEND_DIRECTDRAW_16,
ECORE_WIN32_BACKEND_DIRECT3D,
ECORE_WIN32_BACKEND_GLEW,
ECORE_WIN32_BACKEND_NONE
}Ecore_Win32_Backend;
@ -62,27 +53,6 @@ struct _Ecore_Win32_Window
Ecore_Win32_Backend backend;
#ifdef HAVE_DIRECTDRAW
struct {
LPDIRECTDRAW object;
LPDIRECTDRAWSURFACE surface_primary;
LPDIRECTDRAWSURFACE surface_back;
LPDIRECTDRAWSURFACE surface_source;
LPDIRECTDRAWCLIPPER clipper;
int depth;
} ddraw;
#endif /* HAVE_DIRECTDRAW */
#ifdef HAVE_DIRECT3D
struct {
LPDIRECT3D9 object;
LPDIRECT3DDEVICE9 device;
LPD3DXSPRITE sprite;
LPDIRECT3DTEXTURE9 texture;
int depth;
} d3d;
#endif /* HAVE_DIRECT3D */
#ifdef HAVE_OPENGL_GLEW
struct {
HDC dc;

View File

@ -79,9 +79,9 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
return NULL;
}
if (ecore_list_append(_ecore_win32_windows_list, w) == FALSE)
SetLastError(0);
if (!SetWindowLong(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0))
{
ecore_win32_ddraw_shutdown(w);
DestroyWindow(w->window);
free(w);
return NULL;
@ -167,36 +167,13 @@ ecore_win32_window_del(Ecore_Win32_Window *window)
if (!window) return;
ecore_list_first_goto(_ecore_win32_windows_list);
while ((w = ecore_list_next(_ecore_win32_windows_list)))
{
if (w == window)
{
ecore_list_remove(_ecore_win32_windows_list);
break;
}
}
/* ecore_list_remove(_ecore_win32_windows_list); */
switch (((struct _Ecore_Win32_Window *)window)->backend)
{
case ECORE_WIN32_BACKEND_DIRECTDRAW:
#ifdef HAVE_DIRECTDRAW
ecore_win32_ddraw_shutdown(window);
#endif /* HAVE_DIRECTDRAW */
break;
case ECORE_WIN32_BACKEND_DIRECTDRAW_16:
#ifdef HAVE_DIRECTDRAW
/* ecore_win32_ddraw_shutdown(window); */
#endif /* HAVE_DIRECTDRAW */
break;
case ECORE_WIN32_BACKEND_DIRECT3D:
#ifdef HAVE_DIRECT3D
printf ("d3d shut 0 \n");
ecore_win32_direct3d_shutdown(window);
printf ("d3d shut 1 \n");
#endif /* HAVE_DIRECT3D */
break;
case ECORE_WIN32_BACKEND_GLEW:
#ifdef HAVE_OPENGL_GLEW
ecore_win32_glew_shutdown(window);