From: <tr...@us...> - 2008-08-15 22:14:31
|
Revision: 10369 http://alleg.svn.sourceforge.net/alleg/?rev=10369&view=rev Author: trentg Date: 2008-08-15 22:14:41 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Filled in 'display' field of mouse and keyboard events in windows Modified Paths: -------------- allegro/branches/4.9/examples/exnew_windows.c allegro/branches/4.9/src/win/win_new.h allegro/branches/4.9/src/win/wkeybdnu.c allegro/branches/4.9/src/win/wmouse.c allegro/branches/4.9/src/win/wnewwin.c Modified: allegro/branches/4.9/examples/exnew_windows.c =================================================================== --- allegro/branches/4.9/examples/exnew_windows.c 2008-08-15 21:34:42 UTC (rev 10368) +++ allegro/branches/4.9/examples/exnew_windows.c 2008-08-15 22:14:41 UTC (rev 10369) @@ -56,14 +56,12 @@ for (;;) { if (al_wait_for_event_timed(events, &event, 1)) { if (event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) { - for (i = 0; i < 2; i++) { - int a = rand() % adapter_count; - int w = info[a].x2 - info[a].x1; - int h = info[a].y2 - info[a].y1; - x = 20 + info[a].x1 + (rand() % (w-20)) - W; - y = 20 + info[a].y1 + (rand() % (h-20)) - H; - al_set_window_position(displays[i], x , y); - } + int a = rand() % adapter_count; + int w = info[a].x2 - info[a].x1; + int h = info[a].y2 - info[a].y1; + x = 20 + info[a].x1 + (rand() % (w-20)) - W; + y = 20 + info[a].y1 + (rand() % (h-20)) - H; + al_set_window_position(event.mouse.display, x, y); } else if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; Modified: allegro/branches/4.9/src/win/win_new.h =================================================================== --- allegro/branches/4.9/src/win/win_new.h 2008-08-15 21:34:42 UTC (rev 10368) +++ allegro/branches/4.9/src/win/win_new.h 2008-08-15 22:14:41 UTC (rev 10369) @@ -44,8 +44,10 @@ +ALLEGRO_DISPLAY *_al_win_get_event_display(void); + #if defined ALLEGRO_CFG_D3D AL_FUNC(int, _al_d3d_get_num_display_modes, Modified: allegro/branches/4.9/src/win/wkeybdnu.c =================================================================== --- allegro/branches/4.9/src/win/wkeybdnu.c 2008-08-15 21:34:42 UTC (rev 10368) +++ allegro/branches/4.9/src/win/wkeybdnu.c 2008-08-15 22:14:41 UTC (rev 10369) @@ -760,7 +760,7 @@ event->keyboard.type = event_type; event->keyboard.timestamp = al_current_time(); - event->keyboard.display = NULL; + event->keyboard.display = _al_win_get_event_display(); event->keyboard.keycode = mycode; event->keyboard.unichar = unicode; event->keyboard.modifiers = key_modifiers; Modified: allegro/branches/4.9/src/win/wmouse.c =================================================================== --- allegro/branches/4.9/src/win/wmouse.c 2008-08-15 21:34:42 UTC (rev 10368) +++ allegro/branches/4.9/src/win/wmouse.c 2008-08-15 22:14:41 UTC (rev 10369) @@ -24,6 +24,7 @@ #include "allegro5/internal/aintern.h" #include "allegro5/internal/aintern_mouse.h" #include "allegro5/platform/aintwin.h" +#include "win_new.h" #ifndef SCAN_DEPEND #include <process.h> @@ -1046,7 +1047,7 @@ event->mouse.type = type; event->mouse.timestamp = al_current_time(); - event->mouse.display = NULL; /* TODO */ + event->mouse.display = _al_win_get_event_display(); event->mouse.x = x; event->mouse.y = y; event->mouse.z = z; Modified: allegro/branches/4.9/src/win/wnewwin.c =================================================================== --- allegro/branches/4.9/src/win/wnewwin.c 2008-08-15 21:34:42 UTC (rev 10368) +++ allegro/branches/4.9/src/win/wnewwin.c 2008-08-15 22:14:41 UTC (rev 10369) @@ -35,6 +35,7 @@ HWND window; } WIN_WINDOW; static _AL_VECTOR win_window_list = _AL_VECTOR_INITIALIZER(WIN_WINDOW *); +static ALLEGRO_DISPLAY *event_display = NULL; /* @@ -279,14 +280,8 @@ if (i != system->displays._size) { switch (message) { - case WM_MOVE: - if (GetActiveWindow() == win_get_window()) { - if (!IsIconic(win_get_window())) { - wnd_x = (short) LOWORD(lParam); - wnd_y = (short) HIWORD(lParam); - } - } - break; + case WM_MOUSEACTIVATE: + return MA_ACTIVATEANDEAT; case WM_SETCURSOR: if (_win_hcursor == NULL) SetCursor(NULL); @@ -301,7 +296,8 @@ _al_win_wnd = win->window; win_grab_input(); if (d->vt->switch_in) - d->vt->switch_in(d); + d->vt->switch_in(d); + //event_display = d; _al_event_source_lock(es); if (_al_event_source_needs_to_generate_event(es)) { ALLEGRO_EVENT *event = _al_event_source_get_unused_event(es); @@ -324,7 +320,7 @@ if (d->flags & ALLEGRO_FULLSCREEN) { d->vt->switch_out(d); } - _al_win_ungrab_input(); + //_al_win_ungrab_input(); _al_event_source_lock(es); if (_al_event_source_needs_to_generate_event(es)) { ALLEGRO_EVENT *event = _al_event_source_get_unused_event(es); @@ -598,3 +594,31 @@ SetWindowPos(window, 0, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } + +ALLEGRO_DISPLAY *_al_win_get_event_display(void) +{ + ALLEGRO_DISPLAY *d; + unsigned int i, j; + WIN_WINDOW *win = NULL; + HWND foreground_window = GetForegroundWindow(); + ALLEGRO_SYSTEM *system = al_system_driver(); + + for (i = 0; i < system->displays._size; i++) { + ALLEGRO_DISPLAY **dptr = _al_vector_ref(&system->displays, i); + d = *dptr; + for (j = 0; j < win_window_list._size; j++) { + WIN_WINDOW **wptr = _al_vector_ref(&win_window_list, j); + win = *wptr; + if (win->display == d && win->window == foreground_window) { + goto found; + } + } + } + + return al_get_current_display(); + + found: + + return d; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |