//*************************************************************************** // Function Name: SetBacklightRequirement // // Purpose: Sets or releases the device power requirement to keep the // backlight at D0 // // Arguments: // IN BOOL fBacklightOn - TRUE to leave the backlight on // void SetBacklightRequirement(BOOL fBacklightOn) { // the name of the backlight device TCHAR tszBacklightName[] = TEXT("BKL1:"); static HANDLE s_hBacklightReq = NULL; if (fBacklightOn) { if (NULL == s_hBacklightReq) { // Set the requirement that the backlight device must remain // in device state D0 (full power) s_hBacklightReq = SetPowerRequirement(tszBacklightName, D0, POWER_NAME, NULL, 0); if (!s_hBacklightReq) { RETAILMSG(1, (L"SetPowerRequirement failed: %X\n", GetLastError())); } } } else { if (s_hBacklightReq) { if (ERROR_SUCCESS != ReleasePowerRequirement(s_hBacklightReq)) { RETAILMSG(1, (L"ReleasePowerRequirement failed: %X\n", GetLastError())); } s_hBacklightReq = NULL; } } }
void CMobileOpalDlg::HandleMessage(OpalMessage & message) { switch (message.m_type) { case OpalIndRegistration : switch (message.m_param.m_registrationStatus.m_status) { case OpalRegisterSuccessful : case OpalRegisterRestored : SetStatusText(IDS_REGISTERED); break; case OpalRegisterRemoved : SetStatusText(IDS_UNREGISTERED, message.m_param.m_registrationStatus.m_error); break; case OpalRegisterRetrying : SetStatusText(IDS_REGISTERING); break; case OpalRegisterFailed : SetStatusText(0, message.m_param.m_registrationStatus.m_error); } break; case OpalIndMessageWaiting : if (message.m_param.m_messageWaiting.m_type != NULL && *message.m_param.m_messageWaiting.m_type != '\0') { CStringA msg; msg.Format(IDS_MESSAGE_WAITING, message.m_param.m_messageWaiting.m_type, message.m_param.m_messageWaiting.m_party); SetStatusText(0, msg); } break; case OpalIndIncomingCall : if (m_incomingCallToken.IsEmpty() && m_currentCallToken.IsEmpty()) { m_incomingCallToken = message.m_param.m_incomingCall.m_callToken; SetStatusText(IDS_INCOMING_CALL); SetCallButton(true, IDS_ANSWER); m_ctrlCallAddress.EnableWindow(false); ShowWindow(true); BringWindowToTop(); EnableFullPower(); } else { OpalMessage command; memset(&command, 0, sizeof(command)); command.m_type = OpalCmdClearCall; command.m_param.m_clearCall.m_callToken = message.m_param.m_incomingCall.m_callToken; command.m_param.m_clearCall.m_reason = OpalCallEndedByAnswerDenied; OpalMessage * response = OpalSendMessage(m_opal, &command); if (response != NULL) OpalFreeMessage(response); SetStatusText(IDS_BUSY); } break; case OpalIndAlerting : SetStatusText(IDS_RINGING); break; case OpalIndEstablished : SetSpeakerMode(m_speakerphone); SetStatusText(IDS_ESTABLISHED); break; case OpalIndUserInput : SetStatusText(0, message.m_param.m_userInput.m_userInput); break; case OpalIndCallCleared : if (m_currentCallToken == message.m_param.m_callCleared.m_callToken || m_incomingCallToken == message.m_param.m_callCleared.m_callToken) { m_incomingCallToken.Empty(); m_currentCallToken.Empty(); SetCallButton(true, IDS_CALL); m_ctrlCallAddress.EnableWindow(true); SetStatusText(IDS_READY, message.m_param.m_callCleared.m_reason); if (m_hPowerRequirement != NULL) { ReleasePowerRequirement(m_hPowerRequirement); m_hPowerRequirement = NULL; } PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE); } } }
static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { struct graphics_priv* gra_priv = (struct graphics_priv*)GetWindowLongPtr( hwnd , DWLP_USER ); switch (Message) { case WM_CREATE: { if ( gra_priv ) { RECT rc ; GetClientRect( hwnd, &rc ); gra_priv->width = rc.right; gra_priv->height = rc.bottom; create_memory_dc(gra_priv); } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case WM_USER + 1: break; } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_USER+1: if ( gra_priv ) { RECT rc ; GetClientRect( hwnd, &rc ); gra_priv->width = rc.right; gra_priv->height = rc.bottom; create_memory_dc(gra_priv); callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height); } break; case WM_USER+2: { struct callback_list *cbl = (struct callback_list*)wParam; #ifdef HAVE_API_WIN32_CE /* FIXME: Reset the idle timer need a better place */ SystemIdleTimerReset(); #endif callback_list_call_0(cbl); } break; case WM_SIZE: if ( gra_priv ) { gra_priv->width = LOWORD( lParam ); gra_priv->height = HIWORD( lParam ); create_memory_dc(gra_priv); dbg(0, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height ); callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height); } break; case WM_DESTROY: #ifdef HAVE_API_WIN32_CE if ( gra_priv && gra_priv->window.priv ) { struct window_priv *win_priv = gra_priv->window.priv; if (win_priv->hBackLight) { ReleasePowerRequirement(win_priv->hBackLight); } } #endif PostQuitMessage(0); break; case WM_PAINT: if ( gra_priv && gra_priv->hMemDC) { struct graphics_priv* overlay; PAINTSTRUCT ps = { 0 }; HDC hdc; profile(0, NULL); dbg(1, "WM_PAINT\n"); overlay = gra_priv->overlays; #ifndef FAST_TRANSPARENCY BitBlt( gra_priv->hPrebuildDC, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY); #endif while ( !gra_priv->disabled && overlay) { if ( !overlay->disabled && overlay->p.x >= 0 && overlay->p.y >= 0 && overlay->p.x < gra_priv->width && overlay->p.y < gra_priv->height ) { int x,y; int destPixel, srcPixel; int h,w; #ifdef FAST_TRANSPARENCY if ( !overlay->hPrebuildDC ) { overlay->hPrebuildBitmap = CreateBitmap(overlay->width,overlay->height,1,1,NULL); overlay->hPrebuildDC = CreateCompatibleDC(NULL); overlay->hOldPrebuildBitmap = SelectBitmap( overlay->hPrebuildDC, overlay->hPrebuildBitmap); SetBkColor(overlay->hMemDC,RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,overlay->transparent_color.b >> 8)); BitBlt(overlay->hPrebuildDC,0,0,overlay->width,overlay->height,overlay->hMemDC,0,0,SRCCOPY); BitBlt(overlay->hMemDC,0,0,overlay->width,overlay->height,overlay->hPrebuildDC,0,0,SRCINVERT); } #else const COLORREF transparent_color = RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,overlay->transparent_color.b >> 8); BitBlt( overlay->hPrebuildDC, 0, 0, overlay->width , overlay->height, overlay->hMemDC, 0, 0, SRCCOPY); h=overlay->height; w=overlay->width; if (w > gra_priv->width-overlay->p.x) w=gra_priv->width-overlay->p.x; if (h > gra_priv->height-overlay->p.y) h=gra_priv->height-overlay->p.y; for ( y = 0; y < h ;y++ ) { for ( x = 0; x < w; x++ ) { srcPixel = y*overlay->width+x; destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x); if ( overlay->pPixelData[srcPixel] == transparent_color ) { destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x); gra_priv->pPixelData[destPixel] = RGB ( ((65535 - overlay->transparent_color.a) * GetRValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetRValue(overlay->pPixelData[srcPixel])) / 65535, ((65535 - overlay->transparent_color.a) * GetGValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetGValue(overlay->pPixelData[srcPixel])) / 65535, ((65535 - overlay->transparent_color.a) * GetBValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetBValue(overlay->pPixelData[srcPixel])) / 65535); } else { gra_priv->pPixelData[destPixel] = overlay->pPixelData[srcPixel]; } } } #endif } overlay = overlay->next; } #ifndef FAST_TRANSPARENCY hdc = BeginPaint(hwnd, &ps); BitBlt( hdc, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hPrebuildDC, 0, 0, SRCCOPY ); #else HDC hdc = BeginPaint(hwnd, &ps); BitBlt( hdc, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY ); overlay = gra_priv->overlays; while ( !gra_priv->disabled && overlay && !overlay->disabled ) { if ( overlay->p.x > 0 && overlay->p.y > 0 && overlay->p.x + overlay->width < gra_priv->width && overlay->p.y + overlay->height < gra_priv->height ) { BitBlt(hdc,overlay->p.x,overlay->p.y,overlay->width,overlay->height,overlay->hPrebuildDC,0,0,SRCAND); BitBlt(hdc,overlay->p.x,overlay->p.y,overlay->width,overlay->height,overlay->hMemDC,0,0,SRCPAINT); } overlay = overlay->next; } #endif EndPaint(hwnd, &ps); profile(0, "WM_PAINT\n"); }