ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/SDL/video_sdl.cpp
(Generate patch)

Comparing BasiliskII/src/SDL/video_sdl.cpp (file contents):
Revision 1.22 by gbeauche, 2005-11-29T23:20:31Z vs.
Revision 1.23 by gbeauche, 2006-03-28T07:01:19Z

# Line 204 | Line 204 | static inline void vm_release_framebuffe
204  
205  
206   /*
207 + *  Windows message handler
208 + */
209 +
210 + #ifdef WIN32
211 + #include <dbt.h>
212 + static WNDPROC sdl_window_proc = NULL;                          // Window proc used by SDL
213 +
214 + extern void SysMediaArrived(void);
215 + extern void SysMediaRemoved(void);
216 + extern HWND GetMainWindowHandle(void);
217 +
218 + static LRESULT CALLBACK windows_message_handler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
219 + {
220 +        switch (msg) {
221 +        case WM_DEVICECHANGE:
222 +                if (wParam == DBT_DEVICEREMOVECOMPLETE) {
223 +                        DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam;
224 +                        if (p->dbch_devicetype == DBT_DEVTYP_VOLUME)
225 +                                SysMediaRemoved();
226 +                }
227 +                else if (wParam == DBT_DEVICEARRIVAL) {
228 +                        DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam;
229 +                        if (p->dbch_devicetype == DBT_DEVTYP_VOLUME)
230 +                                SysMediaArrived();
231 +                }
232 +                return 0;
233 +
234 +        default:
235 +                if (sdl_window_proc)
236 +                        return CallWindowProc(sdl_window_proc, hwnd, msg, wParam, lParam);
237 +        }
238 +
239 +        return DefWindowProc(hwnd, msg, wParam, lParam);
240 + }
241 + #endif
242 +
243 +
244 + /*
245   *  SheepShaver glue
246   */
247  
# Line 1025 | Line 1063 | bool SDL_monitor_desc::video_open(void)
1063                  return false;
1064          }
1065  
1066 + #ifdef WIN32
1067 +        // Chain in a new message handler for WM_DEVICECHANGE
1068 +        HWND the_window = GetMainWindowHandle();
1069 +        sdl_window_proc = (WNDPROC)GetWindowLongPtr(the_window, GWLP_WNDPROC);
1070 +        SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)windows_message_handler);
1071 + #endif
1072 +
1073          // Initialize VideoRefresh function
1074          VideoRefreshInit();
1075  
# Line 1259 | Line 1304 | void SDL_monitor_desc::video_close(void)
1304   {
1305          D(bug("video_close()\n"));
1306  
1307 + #ifdef WIN32
1308 +        // Remove message handler for WM_DEVICECHANGE
1309 +        HWND the_window = GetMainWindowHandle();
1310 +        SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)sdl_window_proc);
1311 + #endif
1312 +
1313          // Stop redraw thread
1314   #ifndef USE_CPU_EMUL_SERVICES
1315          if (redraw_thread_active) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines