void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumber )
{
    wxPoint tPosition;

    wxString msg;

    msg.Printf( _( "Call macro %d" ), aNumber );
    SetStatusText( msg );

    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    tPosition = GetNearestGridPosition( aPosition );

    m_canvas->CrossHairOff( aDC );
    SetMousePosition( tPosition );
    GeneralControl( aDC, tPosition );

    for( std::list<MACROS_RECORD>::iterator i = m_Macros[aNumber].m_Record.begin();
         i != m_Macros[aNumber].m_Record.end(); ++i )
    {
        wxPoint tmpPos = GetNearestGridPosition( tPosition + i->m_Position );

        SetMousePosition( tmpPos );

        GeneralControl( aDC, tmpPos, i->m_HotkeyCode );
    }

    cmd.SetId( ID_ZOOM_REDRAW );
    GetEventHandler()->ProcessEvent( cmd );

    m_canvas->CrossHairOn( aDC );
}
Пример #2
0
/*
 * InitMouse - initialize the mouse
 */
void InitMouse( void )
{
    USHORT          events;

    if( !EditFlags.UseMouse ) {
        return;
    }

    if( MouOpen( 0L, &mouseHandle ) != 0 ) {
        EditFlags.UseMouse = FALSE;
        return;
    }
    events = 0x007f;
    if( MouSetEventMask( &events, mouseHandle ) != 0 ) {
        events = 0x001f;
        if( MouSetEventMask( &events, mouseHandle ) == 0 ) {
            mouseHasTwoButtons = TRUE;
        }
    }

    SetMousePosition( WindMaxWidth / 2 - 1, WindMaxHeight / 2 - 1 );
    SetMouseSpeed( MouseSpeed );
    PollMouse( &MouseStatus, &MouseRow, &MouseCol );

} /* InitMouse */
Пример #3
0
static void PollMouse()
{
	if(IsKeyDown(192))
		g_bDebugMode = !g_bDebugMode;

	if(g_bDebugMode)
		SetCursorVisibility(1);
	else
	{
		SetCursorVisibility(0);

		int winX, winY;
		winX = winY = 0;

		s_window_placement wp = GetWindowLocation();
		int dw = (wp.left + wp.right) / 2;
		int dh = (wp.top + wp.bottom) / 2;

		int mx, my;
		GetMousePosition(mx, my);

		g_globalCam.RotateByMouse(mx - dw, my - dh, dw, dh);

		SetMousePosition(dw, dh);
	}
}
Пример #4
0
 bool handle_event(mouse_position npos){
   int dx = npos.x - 200;
   int dy = npos.y - 200;
   SetMousePosition(200,200);
   r1 += dx;
   r2 += dy;
   update_position(0,0,dx,dy);
   return true;
 }
Пример #5
0
void FInput::CenterMouseScreen(class FWindow* Window)
{
	POINT WindowCenter;
	WindowCenter.x = Window->GetWidth() / 2;
	WindowCenter.y = Window->GetHeight() / 2;
	ClientToScreen(Window->GetHandle(), &WindowCenter);

	SetMousePosition(WindowCenter.x, WindowCenter.y);
}
Пример #6
0
/** Discard enter notify events. */
void DiscardEnterEvents()
{
   XEvent event;
   JXSync(display, False);
   while(JXCheckMaskEvent(display, EnterWindowMask, &event)) {
      UpdateTime(&event);
      SetMousePosition(event.xmotion.x_root, event.xmotion.y_root,
                       event.xmotion.window);
   }
}
Пример #7
0
/** Process a leave notify event. */
void HandleLeaveNotify(const XCrossingEvent *event) {

   ClientNode *np;

   SetMousePosition(event->x_root, event->y_root);

   np = FindClientByParent(event->window);
   if(np) {
      SetDefaultCursor(np->parent);
   }

}
Пример #8
0
/** Discard motion events for the specified window. */
void DiscardMotionEvents(XEvent *event, Window w) {

   XEvent temp;

   while(JXCheckTypedEvent(display, MotionNotify, &temp)) {
      SetMousePosition(temp.xmotion.x_root, temp.xmotion.y_root);
      if(temp.xmotion.window == w) {
         *event = temp;
      }
   }

}
Пример #9
0
/** Discard motion events for the specified window. */
void DiscardMotionEvents(XEvent *event, Window w)
{
   XEvent temp;
   JXSync(display, False);
   while(JXCheckTypedEvent(display, MotionNotify, &temp)) {
      UpdateTime(&temp);
      SetMousePosition(temp.xmotion.x_root, temp.xmotion.y_root,
                       temp.xmotion.window);
      if(temp.xmotion.window == w) {
         *event = temp;
      }
   }
}
Пример #10
0
void UVaQuoleHUDComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
	// Update mouse position
	FVector2D MousePosition = FVector2D::ZeroVector;
	if (GetMouseScreenPosition(MousePosition))
	{
		float ScreenX = (MousePosition.X - ScreenPosition.X) * (Width / ScreenSize.X);
		float ScreenY = (MousePosition.Y - ScreenPosition.Y) * (Height / ScreenSize.Y);

		SetMousePosition(ScreenX, ScreenY);
	}

	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
Пример #11
0
/** Display a tray (for autohide). */
void ShowTray(TrayType *tp) {

   Window win1, win2;
   int winx, winy;
   unsigned int mask;
   int mousex, mousey;

   if(tp->hidden) {

      tp->hidden = 0;
      JXMoveWindow(display, tp->window, tp->x, tp->y);

      JXQueryPointer(display, rootWindow, &win1, &win2,
         &mousex, &mousey, &winx, &winy, &mask);
      SetMousePosition(mousex, mousey);

   }

}
Пример #12
0
/** Process an enter notify event. */
void HandleEnterNotify(const XCrossingEvent *event) {

   ClientNode *np;
   Cursor cur;

   SetMousePosition(event->x_root, event->y_root);

   np = FindClientByWindow(event->window);
   if(np) {
      if(!(np->state.status & STAT_ACTIVE) && (focusModel == FOCUS_SLOPPY)) {
         FocusClient(np);
      }
      if(np->parent == event->window) {
         np->borderAction = GetBorderActionType(np, event->x, event->y);
         cur = GetFrameCursor(np->borderAction);
         JXDefineCursor(display, np->parent, cur);
      } else if(np->borderAction != BA_NONE) {
         SetDefaultCursor(np->parent);
         np->borderAction = BA_NONE;
      }
   }

}
Пример #13
0
/** Handle a motion notify event. */
void HandleMotionNotify(const XMotionEvent *event) {

   ClientNode *np;
   Cursor cur;
   BorderActionType action;

   if(event->is_hint) {
      return;
   }

   SetMousePosition(event->x_root, event->y_root);

   np = FindClientByParent(event->window);
   if(np && (np->state.border & BORDER_OUTLINE)) {
      action = GetBorderActionType(np, event->x, event->y);
      if(np->borderAction != action) {
         np->borderAction = action;
         cur = GetFrameCursor(action);
         JXDefineCursor(display, np->parent, cur);
      }
   }

}
Пример #14
0
int CPROC EditMouseCallback( uintptr_t dwUser, int32_t x, int32_t y, uint32_t b )
{
	static int _x, _y, _right, _left;
	int right, left;
	PEDITOR pe = (PEDITOR)dwUser;
	Image surface = GetDisplayImage( pe->hVideo );
	right = b & MK_RBUTTON;
	left = b & MK_LBUTTON;

	//if( pe->bLocked )
	//{/
	//}
	pe->ptMouseDel[0] = x - pe->ptMouse[0];
	pe->ptMouseDel[1] = y - pe->ptMouse[1];
	pe->ptMouse[0] = x;
	pe->ptMouse[1] = y;

	if( !(left + right + _left + _right) ) // just moving mouse..
	{
		if( pe->bLocked )
		{
			if( pe->ptMouseDel[0] > MOUSE_LOCK || pe->ptMouseDel[0] < -MOUSE_LOCK ||
				 pe->ptMouseDel[1] > MOUSE_LOCK || pe->ptMouseDel[1] < -MOUSE_LOCK )
			{
				pe->bLocked = FALSE;
				SetMousePosition( pe->hVideo, pe->ptMouse[0], pe->ptMouse[1] );
				return 1; // done....
			}
		}
		else
		{
			if( ( abs( pe->ptO[0] - x ) < MOUSE_LOCK ) &&
				 ( abs( pe->ptO[1] - y ) < MOUSE_LOCK ) )
			{
				pe->bLocked = TRUE;
				pe->ptMouseDel[0] = 0;
				pe->ptMouseDel[1] = 0;
				pe->ptMouse[0] = pe->ptO[0];
				pe->ptMouse[1] = pe->ptO[1];
			}
			else
			if( ( abs( pe->ptN[0] - x) < MOUSE_LOCK ) &&
				 ( abs( pe->ptN[1] - y ) < MOUSE_LOCK ) )
			{
				pe->bLocked = TRUE;
				pe->ptMouseDel[0] = 0;
				pe->ptMouseDel[1] = 0;
				pe->ptMouse[0] = pe->ptN[0];
				pe->ptMouse[1] = pe->ptN[1];
			}
		}

		if( pe->bLocked ) // only reset mouse if not dragging??
		{
			pe->ptMouse[0] -= pe->ptMouseDel[0];
			pe->ptMouse[1] -= pe->ptMouseDel[1];
			SetMousePosition( pe->hVideo, pe->ptMouse[0],
											 pe->ptMouse[1] );
		}

	}

	if( pe->bLocked )
	{
		x = pe->ptMouse[0] - pe->ptMouseDel[0];
		y = pe->ptMouse[1] - pe->ptMouseDel[0];
	}

	if( !right && _right )
	{
#ifdef __WINDOWS__
		IMAGE_POINT p;
		int nCmd;
		GetCursorPos( (POINT*)&p );
		nCmd = TrackPopup( pe->hMenu
								//, TPM_CENTERALIGN
								//| TPM_TOPALIGN
								//| TPM_RIGHTBUTTON
								//| TPM_RETURNCMD
								//| TPM_NONOTIFY
								//,p[0]
								//,p[1]
								,0
							  // ,NULL // pe->hVideo->hWndOutput
							  //,NULL
							  );
		switch( nCmd )
		{
		case MNU_ADDLINE:
			break;
		}
#endif
	}

	if( left && !_left ) // left click select...
	{
		if( x == pe->ptO[0] && y == pe->ptO[1] )
		{
			pe->bDragOrigin = TRUE;
		} 
		else if( x == pe->ptN[0] && y == pe->ptN[1] )
		{
			pe->bDragNormal = TRUE;
		}
		else
		{
			pe->bDragWorld = TRUE;
		}	
	}
	else if( !left && _left ) // end click...
	{
		pe->bDragOrigin = FALSE; // cancel all operations...
		pe->bDragNormal = FALSE;
		pe->bDragWorld = FALSE;
	}
	else if( left && _left ) // probably dont want to do this if !left && !_left
	{
		if( pe->bDragOrigin )
		{
			VECTOR vo;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, vo );
				Invert( vo );
				GetRealPoint(surface, (PVECTOR)vo, pe->ptMouse );
				Apply( (PCTRANSFORM)pe->TView, pe->pCurrentLine->r.o, vo ); // apply inverse -> Apply...
				// update Intersecting lines......
				/*
				{
					PLINESEG pl;
					PLINESEGPSET plps;
					int l;
					plps = pe->pCurrentFacet->pLineSet;
					pl = pe->pCurrentLine->pTo;
					
					for( l = 0; l < plps->nUsedLines; l++ )
					{
						pl = plps->pLines[l];
						if( pl == pe->pCurrentLine )
							continue;

					}

				}
				*/
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		} 
		else if( pe->bDragNormal )
		{
			VECTOR vn;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, vn );
				Invert( vn );
				GetRealPoint(surface, (PVECTOR)vn, pe->ptMouse );
				sub( vn, vn, pe->pCurrentLine->r.o );
				Apply( (PCTRANSFORM)pe->TView, pe->pCurrentLine->r.n, vn ); // apply inverse -> Apply...
				// update Intersecting lines......
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		}
		else if( pe->bDragWorld )
		{
			VECTOR v1, v2;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, v1 );
				Invert( v1 );
				v2[vForward] = v1[vForward];
				pe->ptMouseDel[0] = pe->ptMouse[0] - pe->ptMouseDel[0];
				pe->ptMouseDel[1] = pe->ptMouse[1] - pe->ptMouseDel[1];

				GetRealPoint(surface, (PVECTOR)v1, pe->ptMouse );
				GetRealPoint(surface, (PVECTOR)v2, pe->ptMouseDel );
				sub( v1, v2, v1 );
				v1[vForward] = 0; 
				TranslateRelV( pe->TView, v1 );
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		}

	}

	_x = x;
	_y = y;
	_right = right;
	_left  = left;
	return 1;
}
Пример #15
0
//set the mouse position by using the call operator.
void InputMatrix::operator()(int x, int y){
	SetMousePosition(x, y);
}
Пример #16
0
/** Wait for an event and process it. */
char WaitForEvent(XEvent *event)
{
   struct timeval timeout;
   CallbackNode *cp;
   fd_set fds;
   long sleepTime;
   int fd;
   char handled;

#ifdef ConnectionNumber
   fd = ConnectionNumber(display);
#else
   fd = JXConnectionNumber(display);
#endif

   /* Compute how long we should sleep. */
   sleepTime = 10 * 1000;  /* 10 seconds. */
   for(cp = callbacks; cp; cp = cp->next) {
      if(cp->freq > 0 && cp->freq < sleepTime) {
         sleepTime = cp->freq;
      }
   }

   do {

      if(restack_pending) {
         RestackClients();
         restack_pending = 0;
      }
      if(task_update_pending) {
         UpdateTaskBar();
         task_update_pending = 0;
      }
      if(pager_update_pending) {
         UpdatePager();
         pager_update_pending = 0;
      }

      while(JXPending(display) == 0) {
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         timeout.tv_sec = sleepTime / 1000;
         timeout.tv_usec = (sleepTime % 1000) * 1000;
         if(select(fd + 1, &fds, NULL, NULL, &timeout) <= 0) {
            Signal();
         }
         if(JUNLIKELY(shouldExit)) {
            return 0;
         }
      }

      Signal();

      JXNextEvent(display, event);
      UpdateTime(event);

      switch(event->type) {
      case ConfigureRequest:
         HandleConfigureRequest(&event->xconfigurerequest);
         handled = 1;
         break;
      case MapRequest:
         HandleMapRequest(&event->xmap);
         handled = 1;
         break;
      case PropertyNotify:
         handled = HandlePropertyNotify(&event->xproperty);
         break;
      case ClientMessage:
         HandleClientMessage(&event->xclient);
         handled = 1;
         break;
      case UnmapNotify:
         HandleUnmapNotify(&event->xunmap);
         handled = 1;
         break;
      case Expose:
         handled = HandleExpose(&event->xexpose);
         break;
      case ColormapNotify:
         HandleColormapChange(&event->xcolormap);
         handled = 1;
         break;
      case DestroyNotify:
         handled = HandleDestroyNotify(&event->xdestroywindow);
         break;
      case SelectionClear:
         handled = HandleSelectionClear(&event->xselectionclear);
         break;
      case ResizeRequest:
         handled = HandleDockResizeRequest(&event->xresizerequest);
         break;
      case MotionNotify:
         SetMousePosition(event->xmotion.x_root, event->xmotion.y_root,
                          event->xmotion.window);
         handled = 0;
         break;
      case ButtonPress:
      case ButtonRelease:
         SetMousePosition(event->xbutton.x_root, event->xbutton.y_root,
                          event->xbutton.window);
         handled = 0;
         break;
      case EnterNotify:
         SetMousePosition(event->xcrossing.x_root, event->xcrossing.y_root,
                          event->xcrossing.window);
         handled = 0;
         break;
      case LeaveNotify:
         SetMousePosition(event->xcrossing.x_root, event->xcrossing.y_root,
                          None);
         handled = 0;
         break;
      case ReparentNotify:
         HandleDockReparentNotify(&event->xreparent);
         handled = 1;
         break;
      case ConfigureNotify:
         handled = HandleConfigureNotify(&event->xconfigure);
         break;
      case CreateNotify:
      case MapNotify:
      case GraphicsExpose:
      case NoExpose:
         handled = 1;
         break;
      default:
         if(0) {
#ifdef USE_SHAPE
         } else if(haveShape && event->type == shapeEvent) {
            HandleShapeEvent((XShapeEvent*)event);
            handled = 1;
#endif
         } else {
            handled = 0;
         }
         break;
      }

      if(!handled) {
         handled = ProcessTrayEvent(event);
      }
      if(!handled) {
         handled = ProcessDialogEvent(event);
      }
      if(!handled) {
         handled = ProcessSwallowEvent(event);
      }
      if(!handled) {
         handled = ProcessPopupEvent(event);
      }

   } while(handled && JLIKELY(!shouldExit));

   return !handled;

}
Пример #17
0
/** Process a key press event. */
void HandleKeyPress(const XKeyEvent *event)
{
   ClientNode *np;
   KeyType key;

   SetMousePosition(event->x_root, event->y_root, event->window);
   key = GetKey(event);
   np = GetActiveClient();
   switch(key & 0xFF) {
   case KEY_EXEC:
      RunKeyCommand(event);
      break;
   case KEY_DESKTOP:
      ChangeDesktop((key >> 8) - 1);
      break;
   case KEY_RDESKTOP:
      RightDesktop();
      break;
   case KEY_LDESKTOP:
      LeftDesktop();
      break;
   case KEY_UDESKTOP:
      AboveDesktop();
      break;
   case KEY_DDESKTOP:
      BelowDesktop();
      break;
   case KEY_SHOWDESK:
      ShowDesktop();
      break;
   case KEY_SHOWTRAY:
      ShowAllTrays();
      break;
   case KEY_NEXT:
      StartWindowWalk();
      FocusNext();
      break;
   case KEY_NEXTSTACK:
      StartWindowStackWalk();
      WalkWindowStack(1);
      break;
   case KEY_PREV:
      StartWindowWalk();
      FocusPrevious();
      break;
   case KEY_PREVSTACK:
      StartWindowStackWalk();
      WalkWindowStack(0);
      break;
   case KEY_CLOSE:
      if(np) {
         DeleteClient(np);
      }
      break;
   case KEY_SHADE:
      if(np) {
         if(np->state.status & STAT_SHADED) {
            UnshadeClient(np);
         } else {
            ShadeClient(np);
         }
      }
      break;
   case KEY_STICK:
      if(np) {
         if(np->state.status & STAT_STICKY) {
            SetClientSticky(np, 0);
         } else {
            SetClientSticky(np, 1);
         }
      }
      break;
   case KEY_MOVE:
      if(np) {
         MoveClientKeyboard(np);
      }
      break;
   case KEY_RESIZE:
      if(np) {
         ResizeClientKeyboard(np);
      }
      break;
   case KEY_MIN:
      if(np) {
         MinimizeClient(np, 1);
      }
      break;
   case KEY_MAX:
      if(np) {
         if(np->state.maxFlags) {
            MaximizeClient(np, MAX_NONE);
         } else {
            MaximizeClient(np, MAX_HORIZ | MAX_VERT);
         }
      }
      break;
   case KEY_MAXTOP:
      ToggleMaximized(np, MAX_TOP | MAX_HORIZ);
      break;
   case KEY_MAXBOTTOM:
      ToggleMaximized(np, MAX_BOTTOM | MAX_HORIZ);
      break;
   case KEY_MAXLEFT:
      ToggleMaximized(np, MAX_LEFT | MAX_VERT);
      break;
   case KEY_MAXRIGHT:
      ToggleMaximized(np, MAX_RIGHT | MAX_VERT);
      break;
   case KEY_MAXV:
      ToggleMaximized(np, MAX_VERT);
      break;
   case KEY_MAXH:
      ToggleMaximized(np, MAX_HORIZ);
      break;
   case KEY_ROOT:
      ShowKeyMenu(event);
      break;
   case KEY_WIN:
      if(np) {
         RaiseClient(np);
         ShowWindowMenu(np, np->x, np->y, 1);
      }
      break;
   case KEY_RESTART:
      Restart();
      break;
   case KEY_EXIT:
      Exit();
      break;
   case KEY_FULLSCREEN:
      if(np) {
         if(np->state.status & STAT_FULLSCREEN) {
            SetClientFullScreen(np, 0);
         } else {
            SetClientFullScreen(np, 1);
         }
      }
      break;
   case KEY_SENDR:
      if(np) {
         SetClientDesktop(np, GetRightDesktop(np->state.desktop));
      }
      break;
   case KEY_SENDL:
      if(np) {
         SetClientDesktop(np, GetLeftDesktop(np->state.desktop));
      }
      break;
   case KEY_SENDU:
      if(np) {
         SetClientDesktop(np, GetAboveDesktop(np->state.desktop));
      }
      break;
   case KEY_SENDD:
      if(np) {
         SetClientDesktop(np, GetBelowDesktop(np->state.desktop));
      }
      break;
   default:
      break;
   }
   DiscardEnterEvents();
}
Пример #18
0
/** Resize a client window (mouse initiated). */
void ResizeClient(ClientNode *np, BorderActionType action,
                  int startx, int starty) {

   XEvent event;
   int oldx, oldy;
   int oldw, oldh;
   int gwidth, gheight;
   int lastgwidth, lastgheight;
   int delta;
   int north, south, east, west;
   int ratio, minr, maxr;

   Assert(np);

   if(!(np->state.border & BORDER_RESIZE)) {
      return;
   }

   if(JUNLIKELY(!GrabMouseForResize(action))) {
      Debug("ResizeClient: could not grab mouse");
      return;
   }

   if(np->state.status & STAT_SHADED) {
      action &= ~(BA_RESIZE_N | BA_RESIZE_S);
   }

   np->controller = ResizeController;
   shouldStopResize = 0;

   oldx = np->x;
   oldy = np->y;
   oldw = np->width;
   oldh = np->height;

   gwidth = (np->width - np->baseWidth) / np->xinc;
   gheight = (np->height - np->baseHeight) / np->yinc;

   GetBorderSize(np, &north, &south, &east, &west);

   startx += np->x - west;
   starty += np->y - north;

   CreateResizeWindow(np);
   UpdateResizeWindow(np, gwidth, gheight);

   if(!(GetMouseMask() & (Button1Mask | Button3Mask))) {
      StopResize(np);
      return;
   }

   for(;;) {

      WaitForEvent(&event);

      if(shouldStopResize) {
         np->controller = NULL;
         return;
      }

      switch(event.type) {
      case ButtonRelease:
         if(   event.xbutton.button == Button1
            || event.xbutton.button == Button3) {
            StopResize(np);
            return;
         }
         break;
      case MotionNotify:

         SetMousePosition(event.xmotion.x_root, event.xmotion.y_root);
         DiscardMotionEvents(&event, np->window);

         if(action & BA_RESIZE_N) {
            delta = (event.xmotion.y - starty) / np->yinc;
            delta *= np->yinc;
            if(oldh - delta >= np->minHeight
               && (oldh - delta <= np->maxHeight || delta > 0)) {
               np->height = oldh - delta;
               np->y = oldy + delta;
            }
            if(!(action & (BA_RESIZE_E | BA_RESIZE_W))) {
               FixWidth(np);
            }
         }
         if(action & BA_RESIZE_S) {
            delta = (event.xmotion.y - starty) / np->yinc;
            delta *= np->yinc;
            np->height = oldh + delta;
            np->height = Max(np->height, np->minHeight);
            np->height = Min(np->height, np->maxHeight);
            if(!(action & (BA_RESIZE_E | BA_RESIZE_W))) {
               FixWidth(np);
            }
         }
         if(action & BA_RESIZE_E) {
            delta = (event.xmotion.x - startx) / np->xinc;
            delta *= np->xinc;
            np->width = oldw + delta;
            np->width = Max(np->width, np->minWidth);
            np->width = Min(np->width, np->maxWidth);
            if(!(action & (BA_RESIZE_N | BA_RESIZE_S))) {
               FixHeight(np);
            }
         }
         if(action & BA_RESIZE_W) {
            delta = (event.xmotion.x - startx) / np->xinc;
            delta *= np->xinc;
            if(oldw - delta >= np->minWidth
               && (oldw - delta <= np->maxWidth || delta > 0)) {
               np->width = oldw - delta;
               np->x = oldx + delta;
            }
            if(!(action & (BA_RESIZE_N | BA_RESIZE_S))) {
               FixHeight(np);
            }
         }

         if(np->sizeFlags & PAspect) {
            if((action & (BA_RESIZE_N | BA_RESIZE_S)) &&
               (action & (BA_RESIZE_E | BA_RESIZE_W))) {

               /* Fixed point with a 16-bit fraction. */
               ratio = (np->width << 16) / np->height;

               minr = (np->aspect.minx << 16) / np->aspect.miny;
               if(ratio < minr) {
                  delta = np->width;
                  np->width = (np->height * minr) >> 16;
                  if(action & BA_RESIZE_W) {
                     np->x -= np->width - delta;
                  }
               }

               maxr = (np->aspect.maxx << 16) / np->aspect.maxy;
               if(ratio > maxr) {
                  delta = np->height;
                  np->height = (np->width << 16) / maxr;
                  if(action & BA_RESIZE_N) {
                     np->y -= np->height - delta;
                  }
               }

            }
         }

         lastgwidth = gwidth;
         lastgheight = gheight;

         gwidth = (np->width - np->baseWidth) / np->xinc;
         gheight = (np->height - np->baseHeight) / np->yinc;

         if(lastgheight != gheight || lastgwidth != gwidth) {

            if(np->state.status & (STAT_HMAX | STAT_VMAX)) {
               np->state.status &= ~(STAT_HMAX | STAT_VMAX);
               WriteState(np);
               SendConfigureEvent(np);
            }

            UpdateResizeWindow(np, gwidth, gheight);

            if(resizeMode == RESIZE_OUTLINE) {
               ClearOutline();
               if(np->state.status & STAT_SHADED) {
                  DrawOutline(np->x - west, np->y - north,
                     np->width + west + east, north + south);
               } else {
                  DrawOutline(np->x - west, np->y - north,
                     np->width + west + east,
                     np->height + north + south);
               }
            } else {
               ResetRoundedRectWindow(np->parent);
               if(np->state.status & STAT_SHADED) {
                  ShapeRoundedRectWindow(np->parent, 
                     np->width + east + west,
                     north + south);
                  JXMoveResizeWindow(display, np->parent,
                     np->x - west, np->y - north,
                     np->width + west + east, north + south);
               } else {
                  ShapeRoundedRectWindow(np->parent, 
                     np->width + east + west,
                     np->height + north + south);
                  JXMoveResizeWindow(display, np->parent,
                     np->x - west, np->y - north,
                     np->width + west + east,
                     np->height + north + south);
               }
               JXMoveResizeWindow(display, np->window, west,
                  north, np->width, np->height);
               SendConfigureEvent(np);
            }

            UpdatePager();

         }

         break;
      default:
         break;
      }
Пример #19
0
/** Wait for an event and process it. */
void WaitForEvent(XEvent *event) {

   struct timeval timeout;
   fd_set fds;
   int fd;
   int handled;

   fd = JXConnectionNumber(display);

   do {

      while(JXPending(display) == 0) {
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         timeout.tv_usec = 0;
         timeout.tv_sec = 1;
         if(select(fd + 1, &fds, NULL, NULL, &timeout) <= 0) {
            Signal();
         }
      }

      Signal();

      JXNextEvent(display, event);

      switch(event->type) {
      case ConfigureRequest:
         HandleConfigureRequest(&event->xconfigurerequest);
         handled = 1;
         break;
      case MapRequest:
         HandleMapRequest(&event->xmap);
         handled = 1;
         break;
      case PropertyNotify:
         handled = HandlePropertyNotify(&event->xproperty);
         break;
      case ClientMessage:
         HandleClientMessage(&event->xclient);
         handled = 1;
         break;
      case UnmapNotify:
         HandleUnmapNotify(&event->xunmap);
         handled = 1;
         break;
      case Expose:
         handled = HandleExpose(&event->xexpose);
         break;
      case ColormapNotify:
         HandleColormapChange(&event->xcolormap);
         handled = 1;
         break;
      case DestroyNotify:
         handled = HandleDestroyNotify(&event->xdestroywindow);
         break;
      case SelectionClear:
         handled = HandleSelectionClear(&event->xselectionclear);
         break;
      case ResizeRequest:
         handled = HandleDockResizeRequest(&event->xresizerequest);
         break;
      case MotionNotify:
         SetMousePosition(event->xmotion.x_root, event->xmotion.y_root);
         handled = 0;
         break;
      case ReparentNotify:
         HandleDockReparentNotify(&event->xreparent);
         handled = 1;
         break;
      case ConfigureNotify:
         handled = 0;
         break;
      case CreateNotify:
      case MapNotify:
      case GraphicsExpose:
      case NoExpose:
         handled = 1;
         break;
      default:
#ifdef USE_SHAPE
         if(haveShape && event->type == shapeEvent) {
            HandleShapeEvent((XShapeEvent*)event);
            handled = 1;
         } else {
            handled = 0;
         }
#else
         handled = 0;
#endif
         break;
      }

      if(!handled) {
         handled = ProcessTrayEvent(event);
      }
      if(!handled) {
         handled = ProcessDialogEvent(event);
      }
      if(!handled) {
         handled = ProcessSwallowEvent(event);
      }
      if(!handled) {
         handled = ProcessPopupEvent(event);
      }

   } while(handled && !shouldExit);

}
Пример #20
0
 bool handle_event(mouse_position npos){
   int dx = npos.x - 200;
   int dy = npos.y - 200;
   SetMousePosition(200,200);
 }
Пример #21
0
		void CenterMouse( ) {
			TYPE::size_i size = Controls::context->GetSize( );
			SetMousePosition( { (real) size.w / 2,(real) size.h / 2 } );
		}