static LCUI_BOOL MouseProc( void ) { #ifdef USE_THIS_CODE LCUI_Pos pos; POINT new_pos; /* 获取鼠标坐标 */ GetCursorPos( &new_pos ); /* 转换成相对于窗口客户区的坐标 */ ScreenToClient( Win32_GetSelfHWND(), &new_pos ); if (new_pos.x > LCUIDisplay_GetWidth() ) { new_pos.x = LCUIDisplay_GetWidth(); } if( new_pos.y > LCUIDisplay_GetHeight() ) { new_pos.y = LCUIDisplay_GetHeight(); } new_pos.x = new_pos.x<0 ? 0:new_pos.x; new_pos.y = new_pos.y<0 ? 0:new_pos.y; LCUICursor_GetPos( &pos ); if( pos.x == new_pos.x && pos.y == new_pos.y ) { return FALSE; } pos.x = new_pos.x; pos.y = new_pos.y; /* 更新鼠标游标的位置 */ LCUICursor_SetPos( pos ); LCUI_PostMouseMoveEvent( pos ); #endif return TRUE; }
LCUI_API int LCUIScreen_Destroy( void ) { LCUI_Graph *graph; LCUI_Sys.state = KILLED; graph = GraphLayer_GetSelfGraph( LCUI_Sys.root_glayer ); GraphLayer_Free( LCUI_Sys.root_glayer ); DeleteDC( hdc_framebuffer ); ReleaseDC( Win32_GetSelfHWND(), hdc_client ); free( pixel_mem ); return 0; }
/* 运行目标循环 */ LCUI_API int LCUI_MainLoop_Run( LCUI_MainLoop *loop ) { LCUI_App *app; int idle_time = 1; #ifdef LCUI_BUILD_IN_WIN32 MSG msg; #endif app = LCUIApp_GetSelf(); if( !app ) { printf("%s(): %s", __FUNCTION__, APP_ERROR_UNRECORDED_APP); return -1; } DEBUG_MSG("loop: %p, enter\n", loop); loop->running = TRUE; while( !loop->quit && LCUI_Sys.state == ACTIVE ) { if( LCUIApp_HaveTask(app) ) { idle_time = 1; LCUIApp_RunTask( app ); } else { LCUI_MSleep (idle_time); if (idle_time < MAX_APP_IDLE_TIME) { idle_time += 1; } } #ifdef LCUI_BUILD_IN_WIN32 if( PeekMessage( &msg, Win32_GetSelfHWND(), 0, 0, PM_REMOVE) ) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } #endif } loop->running = FALSE; DEBUG_MSG("loop: %p, exit\n", loop); return 0; }