Exemple #1
0
void
Show(IWidget& wgt)
{
	SetVisibleOf(wgt, true);
	RequestFocus(wgt);
	Invalidate(wgt);
}
CASW_VGUI_Skip_Intro::CASW_VGUI_Skip_Intro( vgui::Panel *pParent, const char *pElementName) 
:	vgui::Panel( pParent, pElementName ),
	CASW_VGUI_Ingame_Panel()
{
	SetKeyBoardInputEnabled(true);	
	RequestFocus();
}
CampaignFrame::CampaignFrame(Panel *parent, const char *panelName, bool showTaskbarIcon) :
	vgui::Frame(parent, panelName, showTaskbarIcon)
{
	vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew");
	SetScheme(scheme);
	SetSize( ScreenWidth() + 1, ScreenHeight() + 1 );
	SetTitle("Campaign", true );
	SetPos(0,0);
	SetMoveable(false);
	SetSizeable(false);
	SetMenuButtonVisible(false);
	SetMaximizeButtonVisible(false);
	SetMinimizeToSysTrayButtonVisible(false);
	SetCloseButtonVisible(false);
	SetTitleBarVisible(false);
	SetAlpha(0.3f);
	SetPaintBackgroundEnabled(false);

	m_pCampaignPanel = new CampaignPanel( this, "CampaignPanel" );

	RequestFocus();
	SetVisible(true);
	SetEnabled(true);
	SetKeyBoardInputEnabled(false);

	if (GetClientModeASW() && GetClientModeASW()->m_bSpectator)
	{
		engine->ServerCmd("cl_spectating");
	}
}
void CWebWindow::ShowPanel( bool bShow )
{
	int x, y;
	GetPos( x, y );
	if ( x < 0 || y < 0 )
	{
		SetPos( 0, 0 );
	}

	if ( BaseClass::IsVisible() == bShow )
		return;

	if ( bShow )
	{
		SetVisible( true );
		Activate ();
		SetMouseInputEnabled( true );
		RequestFocus ();
		m_pHTMLMessage->OpenURL( m_czURL, null, true );
	}
	else
	{
		SetVisible( false );
		SetMouseInputEnabled( false );
	}
}
    bool SilverlightView::OnMousePressed(const MouseEvent& event)
    {
        RequestFocus();

        MSG msg = event.native_event();
        ax_host_->OnWindowlessMouseMessage(msg.message, msg.wParam, msg.lParam);
        return true;
    }
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void VideoPanel::Activate( void )
{
	MoveToFront();
	RequestFocus();
	SetVisible( true );
	SetEnabled( true );

	vgui::surface()->SetMinimized( GetVPanel(), false );
}
Exemple #7
0
void
OnTouchDown_RequestToTopFocused(CursorEventArgs&& e)
{
    IWidget& wgt(e.GetSender());

    if(e.Strategy != RoutedEventArgs::Bubble)
        RequestToTop(wgt);
    if(e.Strategy == RoutedEventArgs::Direct)
        ClearFocusingOf(wgt);
    if(e.Strategy != RoutedEventArgs::Tunnel)
        RequestFocus(wgt);
}
Exemple #8
0
  MapControl()
  : initial(true),
    lon(7.13601),
    lat(50.68924),
    magnification(2*1024),
    requestNewMap(true),
    backgroundColor(241.0/255,238.0/255,233.0/255,1.0)
  {
    SetCanFocus(true);
    RequestFocus();

    Observe(jobFinishedAction);
  }
    void NativeButton::ButtonPressed()
    {
        RequestFocus();

        // TODO(beng): obtain mouse event flags for native buttons someday.
        DWORD pos = GetMessagePos();
        POINTS points = MAKEPOINTS(pos);
        gfx::Point cursor_point(points.x, points.y);

        view::MouseEvent event(view::Event::ET_MOUSE_RELEASED,
            cursor_point.x(), cursor_point.y(),
            view::Event::EF_LEFT_BUTTON_DOWN);
        NotifyClick(event);
    }
void CReplayBrowserBasePage::OnTick()
{
	if ( !IsVisible() )
		return;

	int nCursorX, nCursorY;
	input()->GetCursorPos( nCursorX, nCursorY );

	if ( input()->IsMouseDown( MOUSE_LEFT ) &&
		 !m_pSearchTextEntry->IsWithin( nCursorX, nCursorY ) &&
		 m_pSearchTextEntry->HasFocus() )
	{
		RequestFocus();
	}
}
Exemple #11
0
	void SetSelected(bool bSelected)
	{
		if (bSelected == m_bSelected)
			return;

		m_bSelected = bSelected;
		if (bSelected)
		{
			RequestFocus();
		}

		UpdateImage();
		InvalidateLayout();
		Repaint();
	}
void CFileListManager::OnMousePressed( vgui::MouseCode code )
{
	// determine where we were pressed
	int x, y, row, column;
	vgui::input()->GetCursorPos( x, y );
	GetCellAtPos( x, y, row, column );

	if ( code == MOUSE_LEFT )
	{
		bool bIsFakeToggleButton = column == CI_LOADED;
		if ( bIsFakeToggleButton && row >= 0 && row < GetItemCount() )
		{
			int itemID = GetItemIDFromRow( row );
			KeyValues *kv = GetItem( itemID );

			const char *pStr = kv->GetString( GetKey( ( ColumnIndex_t )column ), "" );
			Assert( *pStr == 'Y' || *pStr == 'N' );
			bool bSet = *pStr == 'N'; // bSet is the NEW state, not the old one
			kv->SetString( GetKey( ( ColumnIndex_t )column ), bSet ? "Y" : "N" );

			SetLoaded( ( DmFileId_t )GetItemUserData( itemID ), bSet );

			// get the key focus
			RequestFocus();
			return;
		}
	}
	else if ( code == MOUSE_RIGHT )
	{
		int itemID = -1;
		if ( row >= 0 && row < GetItemCount() )
		{
			itemID = GetItemIDFromRow( row );

			if ( !IsItemSelected( itemID ) )
			{
				SetSingleSelectedItem( itemID );
			}
		}

		KeyValues *kv = new KeyValues( "OpenContextMenu", "itemID", itemID );
		OnOpenContextMenu( kv );
		kv->deleteThis();
		return;
	}

	BaseClass::OnMousePressed( code );
}
void CGUICommunity::ShowPanel( bool bShow )
{
	if ( BaseClass::IsVisible() == bShow )
		return;

	if ( bShow )
	{
		SetMouseInputEnabled( true );
		Activate();
		RequestFocus();
	}
	else
	{
		SetVisible( false );
		SetMouseInputEnabled( false );
	}
}
ProtectedMethod void CCreditPanel::ShowPanel( bool bShow )
{
	if ( BaseClass::IsVisible() == bShow )
		return;

	if ( bShow )
	{
		SetMouseInputEnabled( true );
		Activate();
		RequestFocus();
	}
	else
	{
		SetVisible( false );
		SetMouseInputEnabled( false );
	}
}
Exemple #15
0
bool CGUITextBox::HandleMouse( UINT uMsg, WPARAM wParam, LPARAM lParam ) {
	GetCursorPos(&m_MousePos);
	switch(uMsg){
		case WM_MOUSEMOVE:
			if(!m_bMouseOver && PtInBB(m_MousePos) && GetVisible()){
				OnMouseEnter();
			}if(m_bMouseOver && !PtInBB(m_MousePos)){
				OnMouseLeave();
			}
			if(m_bButtonDown)
				PlaceCaret(m_MousePos);
			break;
		case WM_LBUTTONDOWN:
			if(m_bMouseOver){
				if(!m_bButtonDown){
					if(GetFocus() || RequestFocus())
						m_bButtonDown=true;

				}
				PlaceCaret(m_MousePos);
				if( GetKeyState( VK_SHIFT ) >= 0 )
					SyncSelStart();
				return true;
			}
			break;
		case WM_LBUTTONUP:
			m_bButtonDown=false;
			break;
		case WM_MOUSEWHEEL:
			if(m_bMouseOver){
				if((int)wParam>0){//Scroll Up
					m_Scrolly=max((int)m_Scrolly-1, 0);
				}else{
					m_Scrolly=min((int)m_Scrolly+1, max((int)m_MaxCarety-((int)(m_height/13))+1, 0));
				}
				//m_Scrollx=min(max(m_Scrollx, 0), m_MaxCaretx+((int)(width/8)));
				SetTextDraw();
			}
			break; 
	}
	if(m_bMouseOver)
		return true;
	return false;
}
CASW_VGUI_Computer_Frame::CASW_VGUI_Computer_Frame( vgui::Panel *pParent, const char *pElementName, C_ASW_Hack_Computer* pHackComputer ) 
:	vgui::Panel( pParent, pElementName ),
	CASW_VGUI_Ingame_Panel(),
	m_pHackComputer( pHackComputer )
{
	m_bHideLogoffButton = false;

	SetKeyBoardInputEnabled(true);
	m_fLastThinkTime = gpGlobals->curtime;
	m_pCurrentPanel = NULL;
	m_pMenuPanel = NULL;
	m_pSplash = NULL;
	m_bSetAlpha = false;

	m_pLogoffLabel = new ImageButton(this, "LogoffLabel", "");
	m_pLogoffLabel->AddActionSignalTarget(this);

	KeyValues *msg = new KeyValues("Command");	
	msg->SetString("command", "Logoff");
	m_pLogoffLabel->SetCommand(msg);

	KeyValues *cmsg = new KeyValues("Command");			
	cmsg->SetString( "command", "Cancel" );
	m_pLogoffLabel->SetCancelCommand( cmsg );
	
	m_pLogoffLabel->SetText("#asw_log_off");


	for (int i=0;i<3;i++)
	{
		m_pScan[i] = new vgui::ImagePanel(this, "ComputerScan0");
		m_pScan[i]->SetShouldScaleImage(true);
		m_pScan[i]->SetImage("swarm/Computer/ComputerScan");
	}
	m_pBackdropImage = new vgui::ImagePanel(this, "SplashImage");
	m_pBackdropImage->SetShouldScaleImage(true);
	m_iBackdropType = -1;
	SetBackdrop(0);
	
	RequestFocus();

	m_bPlayingSplash = !IsPDA();
}
bool CGUIHorizontalScrollBar::HandleMouse( UINT uMsg, WPARAM wParam, LPARAM lParam ) {
	POINT MousePos;
	GetCursorPos(&MousePos);
	switch(uMsg){
		case WM_MOUSEMOVE:
			
			if(!m_bMouseOver && PtInBB(MousePos) && GetVisible()){
				OnMouseEnter();
			}if(m_bMouseOver && !PtInBB(MousePos)){
				OnMouseLeave();
			}
			if(m_bButtonDown && m_bMouseOver){
				Scroll((MousePos.x-m_mouseStart.x)*(m_maxValue/(m_maxBarWidth-m_barWidth)));
				m_mouseStart=MousePos;
			}
			//if(Parent && ((CGUIWindow*)Parent)->GetFocusElement()==this)
				//return true;

			break;
		case WM_LBUTTONDOWN:
			if(m_bMouseOver){
				if(GetFocus() || RequestFocus()){
					m_bButtonDown=true;
					m_mouseStart=MousePos;
				}
				return true;
			}
			break;
		case WM_LBUTTONUP:
			if(m_bButtonDown && m_bMouseOver){
				OnHotkey();
				m_bButtonDown=false; 
				return true;
			}
			m_bButtonDown=false; 
			break;
	}
	if(m_bMouseOver)
		return true;
	return false;
}
Exemple #18
0
	//Fire action signal when mouse is pressed down instead  of on release.
	virtual void OnMousePressed(MouseCode code) 
	{
		// check for context menu open
		if (!IsEnabled())
			return;
		
		if (!IsMouseClickEnabled(code))
			return;
		
		if (IsUseCaptureMouseEnabled())
		{
			{
				RequestFocus();
				FireActionSignal();
				SetSelected(true);
				Repaint();
			}
			
			// lock mouse input to going to this button
			input()->SetMouseCapture(GetVPanel());
		}
	}
void CGUIListenServer::ShowPanel( bool bShow )
{
	if ( BaseClass::IsVisible() == bShow )
		return;

	if ( bShow )
	{
		int x, y, w, h;
		vgui::surface()->GetWorkspaceBounds( x, y, w, h );
		SetPos( 0, 0 );
		SetSize( w, h );

		SetMouseInputEnabled( true );
		Activate();
		RequestFocus();
	}
	else
	{
		SetVisible( false );
		SetMouseInputEnabled( false );
	}
}
Exemple #20
0
void FlexGrid::OnChildRequestedFocus(UiViewModel &child)
{
	if (!IsFocused()) {
		RequestFocus();
	}

	if (IsFocused()) {
		// Switch focus to the new child, if possible.
		if (focusedCell) {
			rows[focusedCell->first][focusedCell->second]->DropFocus();
			focusedCell = boost::none;
		}
		if (child.TryFocus()) {
			//TODO: Track focus on the cell, and track coords in the cell.
			focusedCell = FindChild(&child);
			SetFocused(true);
		}
		else {
			// The child that requested focus refused to take the focus.
			RelinquishFocus(Control::Nav::NEUTRAL);
		}
	}
}
Exemple #21
0
  void Button::CalcSize()
  {
    /* Let the frame calculate its size */
    switch (type) {
      case typeNormal:
      SetBackground(OS::display->GetFill(OS::Display::buttonBackgroundFillIndex));
      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      if (OS::display->GetTheme()->RequestFingerFriendlyControls()) {
        SetMinWidth(OS::display->GetTheme()->GetFingerFriendlyMinWidth());
        SetMinHeight(OS::display->GetTheme()->GetFingerFriendlyMinHeight());
      }
      break;
    case typeDefault:
      SetBackground(OS::display->GetFill(OS::Display::defaultButtonBackgroundFillIndex));

      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      if (OS::display->GetTheme()->RequestFingerFriendlyControls()) {
        SetMinWidth(OS::display->GetTheme()->GetFingerFriendlyMinWidth());
        SetMinHeight(OS::display->GetTheme()->GetFingerFriendlyMinHeight());
      }
      break;
    case typeCommit:
      SetBackground(OS::display->GetFill(OS::Display::positiveButtonBackgroundFillIndex));

      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      if (OS::display->GetTheme()->RequestFingerFriendlyControls()) {
        SetMinWidth(OS::display->GetTheme()->GetFingerFriendlyMinWidth());
        SetMinHeight(OS::display->GetTheme()->GetFingerFriendlyMinHeight());
      }
      break;
    case typeCancel:
      SetBackground(OS::display->GetFill(OS::Display::negativeButtonBackgroundFillIndex));

      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      if (OS::display->GetTheme()->RequestFingerFriendlyControls()) {
        SetMinWidth(OS::display->GetTheme()->GetFingerFriendlyMinWidth());
        SetMinHeight(OS::display->GetTheme()->GetFingerFriendlyMinHeight());
      }
      break;
    case typeIcon:
      SetBackground(OS::display->GetFill(OS::Display::buttonBackgroundFillIndex));

      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      break;
    case typeAdditional:
      SetBackground(OS::display->GetFill(OS::Display::buttonBackgroundFillIndex));

      if (!OS::display->GetTheme()->FocusOnEditableControlsOnly()) {
        RequestFocus();
      }

      break;
    case typeToolBar:
      SetBackground(OS::display->GetFill(OS::Display::toolbarButtonBackgroundFillIndex));
      SetCanFocus(false);
      break;
    case typeScroll:
      SetBackground(OS::display->GetFill(OS::Display::scrollButtonBackgroundFillIndex));
      SetCanFocus(false);
      break;
    }

    width=0;
    height=0;
    minWidth=0;
    minHeight=0;

    if (ShowObject()) {
      /*
        Now we let the image calculate its bounds and simply add its size
        to the size of the button.
      */
      object->CalcSize();
      width=object->GetOWidth();
      height=object->GetOHeight();
      minWidth=object->GetOMinWidth();
      minHeight=object->GetOMinHeight();
    }

    if (ShowImage()) {
      minWidth+=image->GetWidth();
      width+=image->GetWidth();
      minHeight=std::max(minHeight,image->GetHeight());
      height=std::max(height,image->GetHeight());
    }

    if (ShowObject() && ShowImage()) {
      minWidth+=OS::display->GetSpaceHorizontal(OS::Display::spaceIntraObject);
      width+=OS::display->GetSpaceHorizontal(OS::Display::spaceIntraObject);
    }

    maxWidth=30000;
    maxHeight=30000;

    /* We *must* call CalcSize of our superclass! */
    Control::CalcSize();
  }
CASW_VGUI_Info_Message::CASW_VGUI_Info_Message( vgui::Panel *pParent, const char *pElementName, C_ASW_Info_Message* pMessage ) 
:	vgui::Panel( pParent, pElementName ),
	CASW_VGUI_Ingame_Panel()
{	
	//input->MouseEvent(0, false);	// unclick all our mouse buttons when this panel pops up (so firing doesn't get stuck on)

	if (g_hCurrentInfoPanel.Get())
	{
		g_hCurrentInfoPanel->MarkForDeletion();
		g_hCurrentInfoPanel->SetVisible(false);
	}
	g_hCurrentInfoPanel = this;
	m_hMessage = pMessage;
	for (int i=0;i<4;i++)
	{
		m_pLine[i] = new vgui::WrappedLabel(this, "InfoMessageLabel", "");
		m_pLine[i]->SetContentAlignment(vgui::Label::a_northwest);
		m_pLine[i]->SetMouseInputEnabled(false);
	}	
	m_pOkayButton = new ImageButton(this, "OkayButton", "#asw_close");
	m_pOkayButton->AddActionSignalTarget(this);
	KeyValues *msg = new KeyValues("Command");	
	msg->SetString("command", "OkayButton");
	m_pOkayButton->SetCommand(msg);

	m_pMessageImage = new vgui::ImagePanel(this, "MessageImage");
	m_pMessageImage->SetVisible(false);
	m_pMessageImage->SetShouldScaleImage(true);
	m_szImageName[0] = '\0';
	
	if (ShouldAddLogButton())
	{
		m_pLogButton = new ImageButton(this, "LogButton", "#asw_message_log");
		m_pLogButton->AddActionSignalTarget(this);
		KeyValues *msg = new KeyValues("Command");	
		msg->SetString("command", "MessageLog");
		m_pLogButton->SetCommand(msg);
	}
	else
	{
		Msg("  so not adding it\n");
		m_pLogButton = NULL;
	}

	// find use key bind	
	char lkeybuffer[12];
	Q_snprintf(lkeybuffer, sizeof(lkeybuffer), "%s", ASW_FindKeyBoundTo("+use"));
	Q_strupr(lkeybuffer);

	// copy the found key into wchar_t format (localize it if it's a token rather than a normal keyname)
	wchar_t keybuffer[24];
	if (lkeybuffer[0] == '#')
	{
		const wchar_t *pLocal = g_pVGuiLocalize->Find(lkeybuffer);
		if (pLocal)
			wcsncpy(keybuffer, pLocal, 24);
		else
			g_pVGuiLocalize->ConvertANSIToUnicode(lkeybuffer, keybuffer, sizeof(keybuffer));
	}
	else
		g_pVGuiLocalize->ConvertANSIToUnicode(lkeybuffer, keybuffer, sizeof(keybuffer));

	// look up close text localised
	const wchar_t *pLocal = g_pVGuiLocalize->Find("#asw_close");
	
	if (pLocal)
	{
		// join use key and close text together
		wchar_t buffer[ 256 ];
		g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#asw_use_icon_format"), 2, keybuffer, pLocal );
		// set label
		m_pOkayButton->SetText(buffer);
	}

	if (GetControllerFocus())
	{
		GetControllerFocus()->AddToFocusList(m_pOkayButton);
		GetControllerFocus()->SetFocusPanel(m_pOkayButton);
		if (m_pLogButton)
		{
			GetControllerFocus()->AddToFocusList(m_pLogButton);
		}
	}

	m_bClosingMessage = false;	
	
	CLocalPlayerFilter filter;

	// check for a special sound in the info message
	const char *pszSound = pMessage ? pMessage->GetSound() : NULL;	
	if (pszSound && Q_strlen(pszSound) > 0)
	{
		StopInfoMessageSound();

		EmitSound_t ep;
		ep.m_pSoundName = pszSound;
		ep.m_flVolume = 1.0f;
		ep.m_nPitch = PITCH_NORM;
		ep.m_SoundLevel = SNDLVL_NONE;
		ep.m_nChannel = CHAN_STATIC;

		C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, ep ); 
		g_LastInfoSoundGUID = enginesound->GetGuidForLastSoundEmitted();
	}

	UpdateMessage();

	SetAlpha(0);
	vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 255, 0.0f, 0.3f, vgui::AnimationController::INTERPOLATOR_LINEAR);	

	SetKeyBoardInputEnabled(true);
	SetMouseInputEnabled(true);
	RequestFocus();

	ASWInput()->SetCameraFixed( true );

	g_asw_iGUIWindowsOpen++;		
}
void emX11WindowPort::HandleEvent(XEvent & event)
{
	emInputEvent inputEvent;
	emX11WindowPort * wp;
	char tmp[256];
	char keymap[32];
	KeySym ks;
	emInputKey key;
	Status status;
	int i,x,y,w,h,mask,repeat,variant,len;
	double mx,my;
	bool inside;

	// Remember:
	// - Calling InputToView may delete this window port.
	// - The grab stuff is very very tricky.

	switch (event.type) {
	case MotionNotify:
		mx=PaneX+event.xmotion.x+Screen.MouseWarpX;
		my=PaneY+event.xmotion.y+Screen.MouseWarpY;
		if (
			Screen.InputState.GetMouseX()!=mx ||
			Screen.InputState.GetMouseY()!=my
		) {
			Screen.InputState.SetMouse(mx,my);
			Screen.InputStateClock++;
		}
		for (i=0; i<3; i++) {
			if      (i==0) { key=EM_KEY_LEFT_BUTTON  ; mask=Button1Mask; }
			else if (i==1) { key=EM_KEY_MIDDLE_BUTTON; mask=Button2Mask; }
			else           { key=EM_KEY_RIGHT_BUTTON ; mask=Button3Mask; }
			if (Screen.InputState.Get(key) && (event.xmotion.state&mask)==0) {
				Screen.InputState.Set(key,false);
				Screen.InputStateClock++;
			}
		}
		return;
	case ButtonPress:
		mx=PaneX+event.xbutton.x+Screen.MouseWarpX;
		my=PaneY+event.xbutton.y+Screen.MouseWarpY;
		if (
			Screen.InputState.GetMouseX()!=mx ||
			Screen.InputState.GetMouseY()!=my
		) {
			Screen.InputState.SetMouse(mx,my);
			Screen.InputStateClock++;
		}
		wp=SearchOwnedPopupAt(mx,my);
		if (wp) {
			if (wp->Mapped) {
				event.xbutton.x+=PaneX-wp->PaneX;
				event.xbutton.y+=PaneY-wp->PaneY;
				wp->HandleEvent(event);
			}
			return;
		}
		if (ModalDescendants>0) {
			FocusModalDescendant(true);
			return;
		}
		inside=(
			mx>=PaneX && mx<PaneX+PaneW &&
			my>=PaneY && my<PaneY+PaneH
		);
		if (
			!inside &&
			Screen.GrabbingWinPort==this &&
			(GetWindowFlags()&emWindow::WF_POPUP)!=0
		) {
			XMutex.Lock();
			XAllowEvents(Disp,ReplayPointer,CurrentTime);
			XMutex.Unlock();
			Screen.GrabbingWinPort=NULL;
			LastButtonPress=EM_KEY_NONE;
			SignalWindowClosing();
		}
		for (i=Screen.WinPorts.GetCount()-1; i>=0; i--) {
			wp=Screen.WinPorts[i];
			if (
				(wp->GetWindowFlags()&emWindow::WF_POPUP)!=0 &&
				wp!=this && !wp->IsAncestorOf(this)
			) {
				wp->SignalWindowClosing();
			}
		}
		if (!inside) return;
		if (!Focused && event.xbutton.button>=1 && event.xbutton.button<=5) {
			RequestFocus();
			Screen.UpdateKeymapAndInputState();
		}
		if (event.xbutton.button>=1 && event.xbutton.button<=3) {
			if      (event.xbutton.button==1) key=EM_KEY_LEFT_BUTTON;
			else if (event.xbutton.button==2) key=EM_KEY_MIDDLE_BUTTON;
			else                              key=EM_KEY_RIGHT_BUTTON;
			if (!Screen.InputState.Get(key)) {
				Screen.InputState.Set(key,true);
				Screen.InputStateClock++;
				if (
					key==LastButtonPress &&
					event.xbutton.time>LastButtonPressTime &&
					event.xbutton.time-LastButtonPressTime<=330 &&
					event.xbutton.x>=LastButtonPressX-10 &&
					event.xbutton.x<=LastButtonPressX+10 &&
					event.xbutton.y>=LastButtonPressY-10 &&
					event.xbutton.y<=LastButtonPressY+10
				) {
					repeat=LastButtonPressRepeat+1;
				}
				else {
					repeat=0;
				}
				LastButtonPress=key;
				LastButtonPressTime=event.xbutton.time;
				LastButtonPressX=event.xbutton.x;
				LastButtonPressY=event.xbutton.y;
				LastButtonPressRepeat=repeat;
				inputEvent.Setup(key,"",repeat,0);
				InputStateClock=Screen.InputStateClock;
				InputToView(inputEvent,Screen.InputState);
				return;
			}
		}
		else if (event.xbutton.button==4) {
			inputEvent.Setup(EM_KEY_WHEEL_UP,"",0,0);
			InputStateClock=Screen.InputStateClock;
			InputToView(inputEvent,Screen.InputState);
			return;
		}
		else if (event.xbutton.button==5) {
			inputEvent.Setup(EM_KEY_WHEEL_DOWN,"",0,0);
			InputStateClock=Screen.InputStateClock;
			InputToView(inputEvent,Screen.InputState);
			return;
		}
		return;
	case ButtonRelease:
		mx=PaneX+event.xbutton.x+Screen.MouseWarpX;
		my=PaneY+event.xbutton.y+Screen.MouseWarpY;
		if (
			Screen.InputState.GetMouseX()!=mx ||
			Screen.InputState.GetMouseY()!=my
		) {
			Screen.InputState.SetMouse(mx,my);
			Screen.InputStateClock++;
		}
		if (event.xbutton.button>=1 && event.xbutton.button<=3) {
			if      (event.xbutton.button==1) key=EM_KEY_LEFT_BUTTON;
			else if (event.xbutton.button==2) key=EM_KEY_MIDDLE_BUTTON;
			else                              key=EM_KEY_RIGHT_BUTTON;
			if (Screen.InputState.Get(key)) {
				Screen.InputState.Set(key,false);
				Screen.InputStateClock++;
				inputEvent.Eat();
				InputStateClock=Screen.InputStateClock;
				InputToView(inputEvent,Screen.InputState);
				return;
			}
		}
		return;
	case KeyPress:
		i=event.xkey.keycode/8;
		mask=1<<(event.xkey.keycode&7);
		if (i<32 && (Screen.Keymap[i]&mask)==0) {
			Screen.Keymap[i]|=mask;
			Screen.UpdateInputStateFromKeymap();
		}
		if (InputContext) {
			XMutex.Lock();
			len=XmbLookupString(
				InputContext,
				&event.xkey,
				tmp,
				sizeof(tmp)-1,
				&ks,
				&status
			);
			XMutex.Unlock();
			if (status!=XLookupChars && status!=XLookupBoth) len=0;
			if (status!=XLookupKeySym && status!=XLookupBoth) ks=0;
		}
		else {
			XMutex.Lock();
			len=XLookupString(
				&event.xkey,
				tmp,
				sizeof(tmp)-1,
				&ks,
				&ComposeStatus
			);
			XMutex.Unlock();
		}
		tmp[len]=0;
		key=emX11Screen::ConvertKey(ks,&variant);
		if (key==EM_KEY_NONE && !tmp[0]) return;
		repeat=0;
		if (
			key!=EM_KEY_NONE &&
			Screen.InputState.Get(key) &&
			RepeatKey==key
		) {
			repeat=KeyRepeat+1;
		}
		if (ModalDescendants>0) return;
		RepeatKey=key;
		KeyRepeat=repeat;
		inputEvent.Setup(key,tmp,repeat,variant);
		InputStateClock=Screen.InputStateClock;
		InputToView(inputEvent,Screen.InputState);
		return;
	case KeyRelease:
		memset(keymap,0,sizeof(keymap));
		XMutex.Lock();
		XQueryKeymap(Disp,keymap);
		XMutex.Unlock();
		i=event.xkey.keycode/8;
		mask=1<<(event.xkey.keycode&7);
		if (i<32 && (keymap[i]&mask)==0) {
			RepeatKey=EM_KEY_NONE;
			if ((Screen.Keymap[i]&mask)!=0) {
				Screen.Keymap[i]&=~mask;
				Screen.UpdateInputStateFromKeymap();
			}
		}
		return;
	case Expose:
		x=event.xexpose.x;
		y=event.xexpose.y;
		w=event.xexpose.width;
		h=event.xexpose.height;
		InvalidatePainting(PaneX+x,PaneY+y,w,h);
		return;
	case FocusIn:
		if (
			event.xfocus.mode==NotifyNormal ||
			event.xfocus.mode==NotifyWhileGrabbed
		) {
			if (InputContext) {
				XMutex.Lock();
				XSetICFocus(InputContext);
				XMutex.Unlock();
			}
			Screen.UpdateKeymapAndInputState();
			RepeatKey=EM_KEY_NONE;
			if (!Focused) {
				Focused=true;
				SetViewFocused(true);
			}
			if (ModalDescendants>0) FocusModalDescendant();
		}
		return;
	case FocusOut:
		if (
			event.xfocus.mode==NotifyNormal ||
			event.xfocus.mode==NotifyWhileGrabbed
		) {
			if (InputContext) {
				XMutex.Lock();
				XUnsetICFocus(InputContext);
				XMutex.Unlock();
			}
			if (Focused) {
				Focused=false;
				SetViewFocused(false);
			}
			LastButtonPress=EM_KEY_NONE;
			RepeatKey=EM_KEY_NONE;
		}
		return;
	case ConfigureNotify:
		// The meaning of the coordinates from event.xconfigure depends on
		// the window manager. Therefore:
		GetAbsWinGeometry(Disp,Win,&x,&y,&w,&h);
		if (PaneX!=x || PaneY!=y || PaneW!=w || PaneH!=h) {
			PaneX=x;
			PaneY=y;
			PaneW=w;
			PaneH=h;
			ClipX1=PaneX;
			ClipY1=PaneY;
			ClipX2=PaneX+PaneW;
			ClipY2=PaneY+PaneH;
			InvalidRects.Set(PaneX,PaneY,PaneX+PaneW,PaneY+PaneH);
			WakeUp();
			if (!PosPending && !SizePending) {
				SetViewGeometry(
					PaneX,PaneY,
					PaneW,PaneH,
					Screen.PixelTallness
				);
			}
			else if (!PosPending) {
				SetViewGeometry(
					PaneX,PaneY,
					GetViewWidth(),GetViewHeight(),
					Screen.PixelTallness
				);
			}
			else if (!SizePending) {
				SetViewGeometry(
					GetViewX(),GetViewY(),
					PaneW,PaneH,
					Screen.PixelTallness
				);
			}
			Screen.InputStateClock++;
		}
		return;
	case MapNotify:
		if (event.xmap.window==Win && !Mapped) {
			Mapped=true;
			WakeUp();
		}
		return;
	case UnmapNotify:
		if (event.xmap.window==Win && Mapped) {
			Mapped=false;
		}
		return;
	case ClientMessage:
		if (event.xclient.data.l[0]==(long)Screen.WM_DELETE_WINDOW) {
			if (ModalDescendants<=0) SignalWindowClosing();
			else FocusModalDescendant(true);
		}
		return;
	}
}