コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: Mrdini/XCSoar
bool
MainWindow::on_activate()
{
  SingleWindow::on_activate();

  full_screen();

  return true;
}
コード例 #2
0
ファイル: player_impl.cpp プロジェクト: BigShows/avplayer
LRESULT player_impl::win_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	PAINTSTRUCT ps;
	HDC hdc;

	switch (msg)
	{
	case WM_CREATE:
		{
			SetTimer(hwnd, ID_PLAYER_TIMER, 100, NULL);
		}
		break;
	case WM_TIMER:
		{
			if (wparam != ID_PLAYER_TIMER)
				break;
			// 计算显示客户区.
			int more_y = GetSystemMetrics(SM_CYCAPTION)
				+ (GetSystemMetrics(SM_CYBORDER) * 2)
				+ (GetSystemMetrics(SM_CYDLGFRAME) * 2);
			int more_x = (GetSystemMetrics(SM_CXDLGFRAME) * 2)
				+ (GetSystemMetrics(SM_CXBORDER) * 2);

			if (!m_avplay || !m_avplay->m_video_ctx)
				break;

			if (m_avplay && m_avplay->m_video_ctx &&
				(m_avplay->m_video_ctx->width != 0
				|| m_avplay->m_video_ctx->height != 0
				|| m_avplay->m_play_status == playing))
			{
				RECT rc = { 0 };
				GetWindowRect(hwnd, &rc);
				SetWindowPos(hwnd, HWND_NOTOPMOST, rc.left, rc.top,
					m_avplay->m_video_ctx->width + more_x,
					m_avplay->m_video_ctx->height + more_y,
					SWP_FRAMECHANGED);
				KillTimer(hwnd, ID_PLAYER_TIMER);
			}

			// 得到正确的宽高信息.
			m_video_width = m_avplay->m_video_ctx->width;
			m_video_height = m_avplay->m_video_ctx->height;
		}
		break;
	case WM_KEYDOWN:
		if (wparam == VK_F2)
		{
			full_screen(!m_full_screen);
		}
		break;
	case WM_RBUTTONDOWN:
		{
			if (m_avplay && m_avplay->m_play_status == playing)
				pause();
			else if (m_avplay && m_avplay->m_play_status == paused)
				resume();
		}
		break;
	case WM_LBUTTONDOWN:
		{
			RECT rc = { 0 };
			GetWindowRect(hwnd, &rc);
			int width = rc.right - rc.left;
			int xpos = LOWORD(lparam);
			double fact = (double)xpos / width;

			if (m_avplay && (m_avplay->m_play_status == playing
				|| m_avplay->m_play_status == completed)
				&& (fact >= 0.0f && fact <= 1.0f))
				::av_seek(m_avplay, fact);
		}
		break;
// 	case WM_PAINT:
// 		hdc = BeginPaint(hwnd, &ps);
// 		if (m_avplay)
// 			win_paint(hwnd, hdc);
// 		EndPaint(hwnd, &ps);
// 		break;
	case WM_ERASEBKGND:
		{
			return 1;
// 			if (m_video && m_avplay->m_play_status == playing)
// 				return 1;
// 			else
// 				return DefWindowProc(hwnd, msg, wparam, lparam);
		}
	case WM_ACTIVATE:
	case WM_SYNCPAINT:
		break;
	case WM_MOVING:
	case WM_MOVE:
	case WM_SIZE:
		{
			RECT window;
			GetClientRect(hwnd, &window);
			if (m_avplay && m_avplay->m_vo_ctx &&
				m_video->priv)
			{
				m_video->re_size(m_video, LOWORD(lparam), HIWORD(lparam));
			}
			InvalidateRect(hwnd, NULL, TRUE);
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		break;
	}

	if (m_old_win_proc)
		return CallWindowProc(m_old_win_proc, hwnd, msg, wparam, lparam);// m_old_win_proc(hwnd, msg, wparam, lparam);
	else
		return DefWindowProc(hwnd, msg, wparam, lparam);
}
コード例 #3
0
ファイル: win.c プロジェクト: Vykook/acme-sac
static OSStatus
handle_kbd_event(EventRef event)
{
	OSStatus result = noErr;

	char macCharCodes;
	UInt32 macKeyCode;
	UInt32 macKeyModifiers;

	GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar,
					NULL, sizeof(macCharCodes), NULL, &macCharCodes);
	GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL,
					sizeof(macKeyCode), NULL, &macKeyCode);
	GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL,
					sizeof(macKeyModifiers), NULL, &macKeyModifiers);

//	fprint(2, "mac char is %04x=%c\n", macCharCodes, macCharCodes);
//	fprint(2, "mac key code is %ld\n", macKeyCode);

	UInt32 kind = GetEventKind (event);
	switch(kind) {

	case kEventRawKeyModifiersChanged:
//		fprint(2, "kbd event:	key modifiers changed!\n");
		switch(macKeyModifiers & (optionKey | cmdKey)) {

		case (optionKey | cmdKey):
			/* due to chording we need to handle the case when both
			 * modifier keys are pressed at the same time.
			 * currently it's only 2-3 snarf and the 3-2 noop
			 */
			 
//			fprint(2, "kbd event:	Opt|Cmd pressed!\n");
			altPressed = true;
			cmdPressed = true;
			if(mousebuttons & 1 || mousebuttons & 2 || mousebuttons & 4) {
				mousebuttons |= 2;	/* set button 2 */
				mousebuttons |= 4;	/* set button 3 */
				button2 = true;
				button3 = true;
				sendbuttons(mousebuttons, mouseX, mouseY);
			}
			break;
		
		case optionKey:
//			fprint(2, "kbd event:	Opt pressed!\n");
			altPressed = true;
			if(mousebuttons & 1 || mousebuttons & 4) {
				mousebuttons |= 2;	/* set button 2 */
				button2 = true;
				sendbuttons(mousebuttons, mouseX, mouseY);
			}
			break;
		
		case cmdKey:
//			fprint(2, "kbd event:	Cmd pressed!\n");
			cmdPressed = true;
			if(mousebuttons & 1 || mousebuttons & 2) {
				mousebuttons |= 4;	/* set button 3 */
				button3 = true;
				sendbuttons(mousebuttons, mouseX, mouseY);
			}
			break;
		
		default:
			if(button2 || button3) {
				if(button2) {
					mousebuttons &= ~2;	/* clear button 2 */
					button2 = false;
				}
				if(button3) {
					mousebuttons &= ~4;	/* clear button 3 */
					button3 = false;
				}
				sendbuttons(mousebuttons, mouseX, mouseY);
			}		
			altPressed = false;
			cmdPressed = false;
			break;
		}
		break;
		
	case kEventRawKeyDown:
	case kEventRawKeyRepeat:
		if(macKeyModifiers == cmdKey) {
			// catch fullscreen toggle key sequences while in fullscreen mode
			if(macCharCodes == 'f' || macCharCodes == 'F') {
				if(fullscreen_race)
					fullscreen_race = false;
				else
					full_screen();
			}
		}
		else {
			if(macKeyCode == QZ_ESCAPE)
				gkbdputc(gkbdq, 27);
			else
				result = eventNotHandledErr;
		}
		break;
						
	default:	
		result = eventNotHandledErr;
		break;

	}

	return result;
}