Ejemplo n.º 1
0
static void
GrResizeWindowWrapper(void *r)
{
	nxResizeWindowReq *req = r;

	GrResizeWindow(req->windowid, req->width, req->height);
}
Ejemplo n.º 2
0
void
mvpw_resize(const mvp_widget_t *widget, int w, int h)
{
	*((int *)&(widget->width)) =  w;
	*((int *)&(widget->height)) = h;
	GrResizeWindow(widget->wid, w, h);
}
Ejemplo n.º 3
0
void rightbar_mousemoved(win *window, GR_EVENT_MOUSE *event)
{
	GR_SIZE newwidth;
	struct pos_size *pos;

	Dprintf("rightbar_mousemoved window %d\n", window->wid);

	if(!window->active)
		return;

	pos = (struct pos_size *) window->data;
	newwidth = event->rootx - pos->xorig;
	GrResizeWindow(window->pid, newwidth, pos->height);
}
Ejemplo n.º 4
0
void bottombar_mousemoved(win *window, GR_EVENT_MOUSE *event)
{
	GR_SIZE newheight;
	struct pos_size *pos;

	Dprintf("bottombar_mousemoved window %d\n", window->wid);

	if(!window->active)
		return;

	pos = (struct pos_size *)window->data;
	newheight = event->rooty - pos->yorig;
	GrResizeWindow(window->pid, pos->width, newheight);
}
Ejemplo n.º 5
0
int NX_EnterFullScreen (_THIS)
{
    if (! currently_fullscreen) {
        GR_SCREEN_INFO si ;

        GrGetScreenInfo (& si) ;
        GrResizeWindow (FSwindow, si.cols, si.rows) ;
        GrUnmapWindow (SDL_Window) ;
        GrMapWindow (FSwindow) ;
        GrRaiseWindow (FSwindow) ;
        GrSetFocus (FSwindow) ;
        currently_fullscreen = 1 ;      
    }

    return 1 ;
}
Ejemplo n.º 6
0
void leftbar_mousemoved(win *window, GR_EVENT_MOUSE *event)
{
	GR_COORD newx;
	GR_SIZE newwidth;
	struct pos_size *pos;

	Dprintf("leftbar_mousemoved window %d\n", window->wid);

	if(!window->active)
		return;

	pos = (struct pos_size *) window->data;
	newx = event->rootx - pos->xoff;
	newwidth = pos->width + pos->xorig - event->rootx - pos->xoff;

	GrMoveWindow(window->pid, newx, pos->yorig);
	GrResizeWindow(window->pid, newwidth, pos->height);
}
Ejemplo n.º 7
0
void wm_container_buttonup(win *window, GR_EVENT_BUTTON *event)
{
	GR_RECT		r;
	GR_COORD	cxborder = 0, cyborder = 0;
	GR_WINDOW_INFO	info;

	Dprintf("wm_container_buttonup window %d\n", window->wid);

	GrGetWindowInfo(window->wid, &info);

	/* Check for close box press*/
	if ((info.props & (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) ==
	    (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) {

		/* calc border sizes*/
		if (info.props & GR_WM_PROPS_BORDER) {
			cxborder = 1;
			cyborder = 1;
		}
		if (info.props & GR_WM_PROPS_APPFRAME) {
			cxborder = CXBORDER;
			cyborder = CYBORDER;
		}

		/* Get close box rect*/
		r.x = info.width - CXCLOSEBOX - cxborder - 2;
		r.y = cyborder + 2;
		r.width = CXCLOSEBOX;
		r.height = CYCLOSEBOX;

		/* Check mouseup in close box*/
		if (PtInRect(&r, event->x, event->y)) {
			if(window->close == GR_TRUE) {
				/*
				 * This sends a CLOSE_REQ event to the window.
				 * NXLIB clients catch this and convert it
				 * to an X11 ClientMessage with a WM_DELETE_WINDOW
				 * atom, causing the window to close.
				 */
				GrCloseWindow(window->clientid);
        		window->close = GR_FALSE;
        		return;
      		}
		}
	}
	window->close = GR_FALSE;

	if(window->active) {
#if OUTLINE_MOVE
	  struct pos_size * pos = (struct pos_size *)window->data;
	  GR_GC_ID gc = GrNewGC();

	  GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN);
	  GrRect(GR_ROOT_WINDOW_ID, gc, pos->xorig, pos->yorig, pos->width, pos->height);
	  GrMoveWindow(window->wid, pos->xorig, pos->yorig);
	  GrDestroyGC(gc);
#endif
	  free(window->data);
	  window->active = GR_FALSE;
	  window->data = 0;
	}
	
	if(window->sizing) {
	  struct pos_size * pos = (struct pos_size *)window->data;
	  GR_GC_ID gc = GrNewGC();
	  GR_WINDOW_INFO info;
	  GR_SIZE w, h;

	  GrGetWindowInfo(window->wid, &info);
	  GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN);
	  GrRect(GR_ROOT_WINDOW_ID, gc, info.x, info.y, pos->width, pos->height);
	  GrDestroyGC(gc);

	  w = info.width + (event->x - pos->xorig);
	  h = info.height + (event->y - pos->yorig);
	  GrResizeWindow(window->wid, w, h);
	  GrResizeWindow(window->clientid, w - pos->xoff, h - pos->yoff);

	  free(window->data);
	  window->sizing = GR_FALSE;
	  window->data = 0;
	}
}
Ejemplo n.º 8
0
/*
 * Demo to test child window movement and redrawing
 */
int 
main(int ac,char **av)
{
  GR_COORD      offset_x = 0, offset_y = 0;
  GR_WINDOW_ID 	window1, subwindow1, subsubwin1;
  GR_WINDOW_ID 	window2, subwindow2;
  /*GR_WINDOW_ID	subsubwin2;*/
  GR_EVENT 	event;

  fprintf(stderr,"This is a demo program.\n");
  fprintf(stderr,"Left-button drags window\n");
  fprintf(stderr,"Right-button raises window\n");
  
  GrOpen();
  window1 = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, 100, 60, 4, BLACK, BLUE);
  subwindow1 = GrNewWindow(window1, 5, 5, 90, 50, 4, WHITE, RED);
  subsubwin1 = GrNewWindow(subwindow1, 10, 10, 10, 10, 2, GREEN, BLUE);

  window2 = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 100, 100, 60, 4, BLACK, BLUE);
  subwindow2 = GrNewWindow(window2, 5, 5, 90, 50, 4, WHITE, RED);
/*    subsubwin2 = GrNewWindow(subwindow2, 10, 10, 10, 10, 2, GREEN, BLUE); */

  GrSelectEvents(window1, 
  		 GR_EVENT_MASK_EXPOSURE |
		 GR_EVENT_MASK_BUTTON_DOWN |
		 GR_EVENT_MASK_BUTTON_UP |
		 GR_EVENT_MASK_MOUSE_ENTER |
		 GR_EVENT_MASK_MOUSE_EXIT |
		 GR_EVENT_MASK_MOUSE_MOTION |
		 GR_EVENT_MASK_CLOSE_REQ);

  GrSelectEvents(window2, 
  		 GR_EVENT_MASK_EXPOSURE |
		 GR_EVENT_MASK_BUTTON_DOWN |
		 GR_EVENT_MASK_BUTTON_UP |
		 GR_EVENT_MASK_MOUSE_ENTER |
		 GR_EVENT_MASK_MOUSE_EXIT |
		 GR_EVENT_MASK_MOUSE_MOTION |
		 GR_EVENT_MASK_CLOSE_REQ);

  GrSelectEvents(subsubwin1, 
		 GR_EVENT_MASK_BUTTON_DOWN |
		 0);

  GrMapWindow(subsubwin1);
  GrMapWindow(subwindow1);
  GrMapWindow(window1);

  /*GrMapWindow(subsubwin2);*/
  GrMapWindow(subwindow2);
  GrMapWindow(window2);
  
  while(1) {
    GrGetNextEvent(&event);
    
    switch (event.type) {
    case GR_EVENT_TYPE_NONE:
      break;
    case GR_EVENT_TYPE_BUTTON_DOWN:
	offset_x = event.button.x;
	offset_y = event.button.y;

      if (event.button.changebuttons & GR_BUTTON_R) {
	GrRaiseWindow(event.button.wid);
      }
      if (event.button.wid == subsubwin1) {
	GR_WINDOW_INFO winfo;
	GrGetWindowInfo(subsubwin1, &winfo);
	if (winfo.parent == subwindow1) {
	  GrReparentWindow(subsubwin1, subwindow2, 10, 10);
	} else {
	  GrReparentWindow(subsubwin1, subwindow1, 10, 10);
	}
      }
    case GR_EVENT_TYPE_MOUSE_MOTION:
      if (event.mouse.buttons == GR_BUTTON_L && 
	  (event.mouse.wid == window1 || event.mouse.wid == window2)) {
	GrMoveWindow(event.mouse.wid, 
		     event.mouse.rootx - offset_x, 
		     event.mouse.rooty - offset_y);
      }
      if (event.mouse.buttons == GR_BUTTON_R) {
	GrResizeWindow(event.mouse.wid, 
		     event.mouse.x + 1, 
		     event.mouse.y + 1);
      }
      break;
    case GR_EVENT_TYPE_EXPOSURE:
      /*GrFillRect(event.exposure.wid, defgc,
	event.exposure.x, event.exposure.y,
	event.exposure.width, event.exposure.height);*/
      break;
    case GR_EVENT_TYPE_CLOSE_REQ:
      GrClose();
      exit(0);
    default:
      fprintf(stderr, "%d\n", event.type);
    }
  }
  GrClose();
}