コード例 #1
0
ファイル: QueryPointer.c プロジェクト: BadrElh/microwindows
Bool
XQueryPointer(Display * display, Window w, Window *root, Window *child,
	int *root_x, int *root_y, int *win_x, int *win_y, unsigned int *mask)
{
	int x, y;
	GR_WINDOW_INFO winfo;

	*root = GR_ROOT_WINDOW_ID;

	/* FIXME: child should be None if not descendant of pointer window*/
	GrQueryPointer((GR_WINDOW_ID *) child, root_x, root_y, mask);

	/* convert window coords to absolute*/
	GrGetWindowInfo(w, &winfo);
	x = winfo.x;
	y = winfo.y;
	while (winfo.parent != 0) {
		GrGetWindowInfo(winfo.parent, &winfo);
		x += winfo.x;
		y += winfo.y;
	}

	/* return pointer as window relative coords*/
	*win_x = *root_x - x;
	*win_y = *root_y - y;

	return True;
}
コード例 #2
0
ファイル: QueryPointer.c プロジェクト: BadrElh/microwindows
static GR_WINDOW_ID
_checkWindowCoords(GR_WINDOW_ID win, int x, int y)
{
	GR_WINDOW_ID cwin;
	GR_WINDOW_INFO winfo;

	/* Go through each of the children and compare them */
	GrGetWindowInfo(win, &winfo);
	if (!winfo.child)
		return (win);

	cwin = winfo.child;

	do {
		GR_WINDOW_ID ret;
		GrGetWindowInfo(cwin, &winfo);

		if (x >= winfo.x && x <= winfo.x + winfo.width &&
		    y >= winfo.y && y <= winfo.x + winfo.height
		    && winfo.mapped) {
			ret = _checkWindowCoords(cwin, x - winfo.x,
						 y - winfo.y);
			if (ret)
				return (ret);
		}

		cwin = winfo.sibling;
	} while (cwin);

	return win;
}
コード例 #3
0
ファイル: npanel.c プロジェクト: ghaerr/microwindows
static void
do_update(GR_EVENT_UPDATE *ep)
{
	mwin *	mwp;
	mwin *	tmwp;
	GR_WINDOW_INFO winfo;

	if (IsDecoration(ep->wid)) return;

	if ((mwp = FindWindow(ep->wid)) == NULL) {
		/* We have a new window */
		if (ep->utype != GR_UPDATE_MAP) return;
		if ((mwp = NewWindow(ep->wid)) == NULL) {
			GrError("malloc failed\n");
			return;
		}
		GrGetWindowInfo(ep->wid, &winfo);
		mwp->x = ep->x - winfo.bordersize;
		mwp->y = ep->y - winfo.bordersize;
		mwp->width = ep->width + 2 * winfo.bordersize;
		GrMoveWindow(mwp->wid, mwp->x + winfo.bordersize,
					mwp->y + DEC_HEIGHT +
						2 * winfo.bordersize);
		mwp->fid = GrNewWindow(GR_ROOT_WINDOW_ID, mwp->x + 1,
				mwp->y + 1, mwp->width - 2,
				DEC_HEIGHT - 2, 1, BLUE, BLACK);
		GrSelectEvents(mwp->fid, GR_EVENT_MASK_BUTTON_DOWN |
			GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION);
		GrMapWindow(mwp->fid);
	} else {
		switch (ep->utype) {
			case GR_UPDATE_UNMAP:
				GrUnmapWindow(mwp->fid);
				GrDestroyWindow(mwp->fid);
				if (mwins == mwp) {
					mwins = mwp->next;
				} else for(tmwp = mwins; tmwp; tmwp = tmwp->next) {
					if (tmwp->next == mwp) {
						tmwp->next = mwp->next;
					}
				}
				free(mwp);
				break;
			case GR_UPDATE_MOVE:
				GrGetWindowInfo(ep->wid, &winfo);
				if ((ep->x == (mwp->x + winfo.bordersize)) &&
					(ep->y == (mwp->y + winfo.bordersize
							+ DEC_HEIGHT))) {
					return;
				}
				mwp->x = ep->x - winfo.bordersize;
				mwp->y = ep->y - winfo.bordersize - DEC_HEIGHT;
				GrMoveWindow(mwp->fid, mwp->x + 1, mwp->y + 1);
			default:
				break;
		}
	}
}
コード例 #4
0
ファイル: tunnel.c プロジェクト: ProjectZeroSlackr/Floydzilla
// Creates a new tunnel "app" window
void new_tunnel_window(void)
{
	
    tunnel_gc = pz_get_gc(1);       /* Get the graphics context */
	
    /* Open the window: */
    tunnel_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);
	
	GrGetWindowInfo(tunnel_wid, &wi); /* Get screen info */	
	
    /* Select the types of events you need for your window: */
    GrSelectEvents (tunnel_wid, GR_EVENT_MASK_TIMER|GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);
	
	// set up pixmap 
	temp_pixmap = GrNewPixmap(screen_info.cols,
							  (screen_info.rows - (HEADER_TOPLINE + 1)),
							  NULL);
	
    /* Display the window: */
    GrMapWindow (tunnel_wid);
	draw_header();
	readHighScore();
	reset();
}
コード例 #5
0
//Create the blackjack window
void new_blackjack_window(void)
{

	srand((unsigned int)time(NULL) / 2);  //Make a seed for our random # generator

    blackjack_gc = pz_get_gc(1);       /* Get the graphics context */

    /* Open the window: */
    blackjack_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);

	GrGetWindowInfo(blackjack_wid, &wi); /* Get screen info */

    /* Select the types of events you need for your window: */
    GrSelectEvents (blackjack_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);

    /* Display the window: */
    GrMapWindow (blackjack_wid);

	readPot();
	reset();
}
コード例 #6
0
// creates a new MandelPod window
void new_mandel_window(void)
{
	// get the graphics context
	mandel_gc = pz_get_gc(1);
		
	// create the main window
	mandel_wid = pz_new_window (0, 21,
				screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1),
				draw_header, handle_event);
#ifdef MANDELPOD_STATUS
	// create the status window
	status_wid = pz_new_window (22, 4, 12, 12, draw_idle_status, handle_event);
#endif
	 // get screen info
	GrGetWindowInfo(mandel_wid, &wi);
	
	// select the event types
	GrSelectEvents (mandel_wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMER);
		
	// display the window
	GrMapWindow (mandel_wid);
#ifdef MANDELPOD_STATUS
	GrMapWindow (status_wid);
#endif

    // create the timer for the busy status animation
    mandel_timer_id = GrCreateTimer (mandel_wid, 250);

	// start main app
	init_values();
	create_status();
	draw_header();
	calculate_mandel();
}
コード例 #7
0
ファイル: SDL_nxvideo.c プロジェクト: Goettsch/game-editor
// Update the current mouse state and position
static void NX_UpdateMouse (_THIS)
{
    int            x, y ;
    GR_WINDOW_INFO info ;
    GR_SCREEN_INFO si ;


    Dprintf ("enter NX_UpdateMouse\n") ;

    // Lock the event thread, in multi-threading environments
    SDL_Lock_EventThread () ;
    
    GrGetScreenInfo (& si) ;
    GrGetWindowInfo (SDL_Window, & info) ;
    x = si.xpos - info.x ;
    y = si.ypos - info.y ;
    if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) {
        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
        SDL_PrivateMouseMotion (0, 0, x, y);
    } else {
        SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
    }

    SDL_Unlock_EventThread () ;
    Dprintf ("leave NX_UpdateMouse\n") ;
}
コード例 #8
0
void drawText(GR_WINDOW_ID id, char **text, int count) {

    int tw, th, tb;
    int xpos, ypos;
    int i;

    GR_GC_ID gc = GrNewGC();
    GR_FONT_ID font = GrCreateFont(GR_FONT_GUI_VAR, 12, 0);
    GR_WINDOW_INFO info;

    GrGetWindowInfo(id, &info);

    GrSetGCFont(gc, font);
    GrSetGCForeground(gc, FGCOLOR);
    GrSetGCBackground(gc, BGCOLOR);

    /* Get the first line of text from the array, and check the size */
    GrGetGCTextSize(gc, text[0], -1, GR_TFTOP, &tw, &th, &tb);

    ypos = (info.height - ((count * th)+ 3)) / 2;

    /* Draw each line of the instructions */

    for(i = 0; i < count; i++) {
        GrGetGCTextSize(gc, text[i], -1, GR_TFTOP, &tw, &th, &tb);
        xpos = (info.width - tw) / 2;
        GrText(id, gc, xpos, ypos, text[i], -1, GR_TFTOP);

        ypos += th + 3;
    }

    GrDestroyGC(gc);
    GrDestroyFont(font);
}
コード例 #9
0
ファイル: wmaction.c プロジェクト: ghaerr/microwindows
void resizebar_buttondown(win *window, GR_EVENT_BUTTON *event)
{
	GR_WINDOW_INFO wi;
	struct pos_size *pos;

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

	GrRaiseWindow(window->pid);

	if(window->active)
		return;

	if(!window->data)
		if(!(window->data = malloc(sizeof(struct pos_size))))
			return;

	GrGetWindowInfo(window->pid, &wi);
	pos = (struct pos_size *)window->data;
	pos->xoff = event->x;
	pos->yoff = event->y;
	pos->xorig = wi.x;
	pos->yorig = wi.y;
	pos->width = wi.width;
	pos->height = wi.height;

	window->active = GR_TRUE;
}
コード例 #10
0
ファイル: demo-dash.c プロジェクト: ghaerr/microwindows
static void
draw_screen(void)
{
	GR_POINT tri[4] = { {5, 115}, {105, 115}, {55, 200}, {5, 115} };
	GR_WINDOW_INFO winfo;
	GR_GC_ID gc;
	char dash1[2] = { 10, 5 };
	char dash2[4] = { 5, 2, 1, 2 };
	char dash3[4] = { 5, 2, 5, 5 };
	char dash4[2] = { 2, 2 };

	GrGetWindowInfo(g_main, &winfo);

	/* Draw several lines and a few boxes */
	gc = GrNewGC();
	GrSetGCLineAttributes(gc, GR_LINE_ONOFF_DASH);

	/* Draw a dashed box */

	GrSetGCDash(gc, dash1, 2);
	GrRect(g_main, gc, 5, 5, 100, 100);

	GrSetGCDash(gc, dash2, 4);
	GrLine(g_main, gc, 10, 10, 95, 95);

	GrSetGCDash(gc, dash3, 4);
	GrEllipse(g_main, gc, 160, 55, 50, 50);

	GrSetGCDash(gc, dash4, 2);
	GrPoly(g_main, gc, 4, tri);

	GrDestroyGC(gc);
}
コード例 #11
0
ファイル: wmaction.c プロジェクト: koujinogaku/helloos
void wm_redraw_ncarea(win *window)
{
	GR_WINDOW_INFO info;
	GR_WM_PROPERTIES props;
	GR_BOOL active;

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

	GrGetWindowInfo(window->wid, &info);
	GrGetWMProperties(window->clientid, &props);

	/*
	 * Check for invalid window.  This will be the
	 * case if the client exited, and we're just
	 * getting the paint notification for our parent.
	 */
	if (props.flags) {
		active = (window->clientid == GrGetFocus());
		nxPaintNCArea(window->wid, info.width, info.height, props.title,
			active, props.props);
	}

	/* free title returned from GrGetWMProperties*/
	if (props.title)
		free(props.title);
}
コード例 #12
0
ファイル: QueryPointer.c プロジェクト: BadrElh/microwindows
Bool
XTranslateCoordinates(Display * display, Window src_w, Window dest_w,
		      int src_x, int src_y, int *dest_x_return,
		      int *dest_y_return, Window * child_return)
{
	int rx = src_x, ry = src_y;
	int dx = 0, dy = 0;
	GR_WINDOW_ID parent = (GR_WINDOW_ID) src_w;

	/* Get the root x and y of the src values */
	do {
		GR_WINDOW_INFO winfo;
		GrGetWindowInfo(parent, &winfo);

		rx += winfo.x;
		ry += winfo.y;

		if (parent == GR_ROOT_WINDOW_ID)
			break;
		parent = winfo.parent;
	} while (1);

	/* Now find the destination window absolute coordinates */
	parent = (GR_WINDOW_ID) dest_w;
	do {
		GR_WINDOW_INFO winfo;
		GrGetWindowInfo(parent, &winfo);

		dx += winfo.x;
		dy += winfo.y;

		if (parent == GR_ROOT_WINDOW_ID)
			break;
		parent = winfo.parent;
	} while (1);

	*dest_x_return = rx - dx;
	*dest_y_return = ry - dy;

	/* Now, see if this window is actually within any of our children */
	*child_return = _checkWindowCoords((GR_WINDOW_ID) dest_w,
				*dest_x_return, *dest_y_return);
	if (*child_return == dest_w)
		*child_return = None;

	return True;
}
コード例 #13
0
ファイル: CrGC.c プロジェクト: ghaerr/microwindows
int
XSetTile(Display * display, GC gc, Pixmap tile)
{
	GR_WINDOW_INFO wi;

	GrGetWindowInfo(tile, &wi);
	GrSetGCTile(gc->gid, tile, wi.width, wi.height);
	return 1;
}
コード例 #14
0
ファイル: srvnet.c プロジェクト: koujinogaku/helloos
static void
GrGetWindowInfoWrapper(void *r)
{
	nxGetWindowInfoReq *req = r;
	GR_WINDOW_INFO      wi;

	GrGetWindowInfo(req->windowid, &wi);
	GsWriteType(current_fd,GrNumGetWindowInfo);
	GsWrite(current_fd, &wi, sizeof(wi));
}
コード例 #15
0
void NX_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
    GR_WINDOW_INFO info ;

    Dprintf ("enter NX_WarpWMCursor\n") ;
    SDL_Lock_EventThread () ;
    
    GrGetWindowInfo (SDL_Window, & info) ;
    GrMoveCursor (info.x + x, info.y + y) ;

    SDL_Unlock_EventThread () ;
    Dprintf ("leave NX_WarpWMCursor\n") ;
}
コード例 #16
0
static void credits_var_init(void)
{
	int i;
	
	GrGetWindowInfo(credits_wid, &credits_info);
	GrClearWindow(credits_wid, GR_FALSE);

	cols = (credits_info.width/COL_W)+1;
	stream = credits_malloc(cols);
	for (i = 0; i < cols; i++) {
		stream[i] = ' '; 
	}
}
コード例 #17
0
ファイル: nxclock.c プロジェクト: george-hopkins/opentom
int
main(int ac, char **av)
{
    GR_EVENT event;
    GR_GC_ID gc;
    GR_WINDOW_ID pmap;
    GR_WINDOW_ID window;
    GR_WINDOW_INFO info;

    if (GrOpen() < 0) {
	fprintf(stderr, "cannot open graphics\n");
	exit(1);
    }

    window = nxCreateAppWindow(&ac, &av, args);
    gc = GrNewGC();
    GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOW));
    GrSetGCBackground(gc, GrGetSysColor(GR_COLOR_WINDOWTEXT));

    GrSelectEvents(window, GR_EVENT_MASK_EXPOSURE |
		   GR_EVENT_MASK_UPDATE | GR_EVENT_MASK_CLOSE_REQ);

    GrGetWindowInfo(window, &info);
    pmap = resize(info.width, info.height, 0);

    GrMapWindow(window);

    while (1) {
	GrGetNextEventTimeout(&event, 500L);

	switch (event.type) {
	case GR_EVENT_TYPE_EXPOSURE:
	case GR_EVENT_TYPE_TIMEOUT:
	    draw_clock(0, 0, width, height, pmap, gc, window);
	    break;

	case GR_EVENT_TYPE_CLOSE_REQ:
	    GrClose();
	    exit(0);

	case GR_EVENT_TYPE_UPDATE:
	    switch (event.update.utype) {
	    case GR_UPDATE_SIZE:
		pmap = resize(event.update.width, event.update.height, pmap);
		break;
	    }
	}
    }
    return 0;
}
コード例 #18
0
ファイル: wmaction.c プロジェクト: ghaerr/microwindows
/*
 * This function performs a depth first search on window 
 * and finds if any of its children has focus. 
 * i.e. wid equal to ref 
 * -- Amit Kulkarni
 */
static GR_BOOL
checkHasFocus(GR_WINDOW_ID wid,GR_WINDOW_ID ref)
{
	GR_WINDOW_INFO winfo;
	GR_WINDOW_ID childwid;
	if(wid==ref)
		return GR_TRUE;
	GrGetWindowInfo(wid, &winfo);

	/*Go down*/
	childwid = winfo.child;
	while (childwid)
	{
		if(checkHasFocus(childwid,ref)) 
			return GR_TRUE;
		GrGetWindowInfo (childwid,&winfo);

		/*Go right*/
		childwid=winfo.sibling;
	}
	/*Nah.. no match here*/
	return GR_FALSE;
}
コード例 #19
0
ファイル: CrGC.c プロジェクト: ghaerr/microwindows
int
XSetStipple(Display * display, GC gc, Pixmap stipple)
{
	GR_WINDOW_INFO wi;
	GR_BITMAP *bitmap;

	GrGetWindowInfo(stipple, &wi);

	bitmap = GrNewBitmapFromPixmap(stipple, 0, 0, wi.width, wi.height);
	GrSetGCStipple(gc->gid, bitmap, wi.width, wi.height);
	free(bitmap);

	return 1;
}
コード例 #20
0
ファイル: CrCursor.c プロジェクト: Kvasshtain/uos-embedded
Cursor
XCreatePixmapCursor(Display * display, Pixmap source, Pixmap mask,
		    XColor * fg, XColor * bg, unsigned int x, unsigned y)
{
	Cursor ret;
	GR_RECT cbb, mbb;
	GR_WINDOW_INFO winfo;

	GrGetWindowInfo(source, &winfo);
	cbb.x = cbb.y = 0;
	cbb.width = winfo.width;
	cbb.height = winfo.height;

	GrGetWindowInfo(mask, &winfo);
	mbb.x = mbb.y = 0;
	mbb.width = winfo.width;
	mbb.height = winfo.height;

	ret = _nxCreateCursor(source, &cbb, mask, &mbb, x, y,
		       GR_RGB(fg->red >> 8, fg->green >> 8, fg->blue >> 8),
		       GR_RGB(bg->red >> 8, bg->green >> 8, bg->blue >> 8));

	return ret;
}
コード例 #21
0
ファイル: wmaction.c プロジェクト: ghaerr/microwindows
void wm_container_mouse_enter(win *window, GR_EVENT_GENERAL *event)
{
	GR_RECT		r;
	GR_WINDOW_INFO info, cinfo;

#if !NO_CORNER_RESIZE
	/* Don't allow window move if NORESIZE property set*/
	GrGetWindowInfo(window->wid, &info);
	if (info.props & GR_WM_PROPS_NORESIZE)
		return;
	
	GrGetWindowInfo(window->clientid, &cinfo);
	if (cinfo.props & GR_WM_PROPS_NORESIZE)
		return;

	/* check for corner resize */
	r.x = info.width - 5;
	r.y = info.height - 5;
	r.width = 5;
	r.height = 5;
	if (PtInRect(&r,event->x, event->y))
		set_resize_cursor(window->wid);
#endif
}
コード例 #22
0
ファイル: widget.c プロジェクト: cgbarnwell/mvpmc
int
mvpw_visible(const mvp_widget_t *widget)
{
	GR_WINDOW_INFO info;

	if (widget == NULL)
		return 0;

	GrGetWindowInfo(widget->wid, &info);

	if (info.realized)
		return 1;
	else
		return 0;
}
コード例 #23
0
ファイル: npanel.c プロジェクト: ghaerr/microwindows
/*
 * Handle mouse position events
 */
static void
do_mouse(GR_EVENT_MOUSE *ep)
{
#ifdef SHOW_WINDOW_MOTION
	GR_WINDOW_INFO winfo;

	if(!in_motion) return;

	in_motion->x = ep->rootx - move_xoff - 1;
	in_motion->y = ep->rooty - move_yoff - 1;
	GrMoveWindow(in_motion->fid, in_motion->x + 1, in_motion->y + 1);
	GrGetWindowInfo(in_motion->wid, &winfo);
	GrMoveWindow(in_motion->wid, in_motion->x + winfo.bordersize - 1,
			in_motion->y + 2 * winfo.bordersize + DEC_HEIGHT - 1);
#endif
}
コード例 #24
0
ファイル: nglx.c プロジェクト: joshdekock/jim-psp
/* we assume here that drawable is a window */
int nglXMakeCurrent( NGLXDrawable drawable,
                     NGLXContext ctx1)
{
  TinyNGLXContext *ctx = (TinyNGLXContext *) ctx1;
  int mode, xsize, ysize;
  ZBuffer *zb;
  GR_WINDOW_INFO win_info;

  if (ctx->gl_context == NULL) {
      /* create the TinyGL context */
      GrGetWindowInfo(drawable, &win_info);

      xsize = win_info.width;
      ysize = win_info.height;

      /* currently, we only support 16 bit rendering */
      mode = ZB_MODE_5R6G5B;
      zb=ZB_open(xsize,ysize,mode,0,NULL,NULL,NULL);
      if (zb == NULL) {
          fprintf(stderr, "Error while initializing Z buffer\n");
          exit(1);
      }

      ctx->pixtype = MWPF_TRUECOLOR565;

      /* create a gc */
      ctx->gc = GrNewGC();
      
      /* initialisation of the TinyGL interpreter */
      glInit(zb);
      ctx->gl_context=gl_get_context();
      ctx->gl_context->opaque=(void *) ctx;
      ctx->gl_context->gl_resize_viewport=glX_resize_viewport;

      /* set the viewport : we force a call to glX_resize_viewport */
      ctx->gl_context->viewport.xsize=-1;
      ctx->gl_context->viewport.ysize=-1;
      
      glViewport(0, 0, xsize, ysize);
  }
  
  return 1;
}
コード例 #25
0
static void msg_do_draw()
{
	GR_WINDOW_INFO winfo;
	int i;

	GrGetWindowInfo(msg_wid, &winfo);

	/* fill the background */
	GrSetGCForeground(msg_gc, appearance_get_color( 
				(this_is_error)?CS_ERRORBG:CS_MESSAGEBG ));
	GrFillRect( msg_wid, msg_gc, 0, 0, winfo.width, winfo.height );

	GrSetGCForeground(msg_gc, appearance_get_color( CS_MESSAGELINE ));
	GrRect(msg_wid, msg_gc, 1, 1, winfo.width - 2, winfo.height - 2);

	GrSetGCForeground(msg_gc, appearance_get_color( CS_MESSAGEFG ));
	for(i=linenum; i; i--)
		GrText(msg_wid, msg_gc, 5, (((winfo.height-10) /
				linenum) * i), msglines[i-1], -1,
				GR_TFASCII);
}
コード例 #26
0
ファイル: Shape.c プロジェクト: ghaerr/microwindows
void
XShapeCombineMask(Display *dpy, Window dest, int destKind, int xOff, int yOff,
	Pixmap src, int op)
{
	GR_REGION_ID	mask;
	GR_WINDOW_INFO	info;

	if (destKind != ShapeBounding || op != ShapeSet)
	//if (destKind != ShapeClip || op != ShapeSet)
		return;

	if (src == None) {
		GrSetWindowRegion(dest, 0, 0);
		return;
	}

	GrGetWindowInfo(src, &info);
	mask = GrNewRegionFromPixmap(src, 0, 0, info.width, info.height);
	GrSetWindowRegion(dest, mask, mask);
	GrDestroyRegion(mask);
}
コード例 #27
0
ファイル: wmaction.c プロジェクト: ghaerr/microwindows
void wm_redraw_ncarea(win *window)
{
	GR_WINDOW_INFO info;
	GR_WM_PROPERTIES props;
	GR_BOOL active;
	GR_WINDOW_ID focusedwindow;

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

	GrGetWindowInfo(window->wid, &info);
	GrGetWMProperties(window->clientid, &props);

	/*
	 * Check for invalid window.  This will be the
	 * case if the client exited, and we're just
	 * getting the paint notification for our parent.
	 */
	if (props.flags) {
 		/* Get window with keyboard focus*/
 		focusedwindow = GrGetFocus();
 		/*
 	 	 * Check if the current window or any of its ancestors has the focus 
 	 	 * A window is active even if any of its ancestors has focus
 	 	 * --Amit Kulkarni
 	 	 */	 
 		active = checkHasFocus(window->clientid,focusedwindow);
 		/*
 	 	 * Note that we should also raise the window if its active and behind.
 	 	 * an active window deserves to be on the top :-)
 	 	 */
 		//if(active)
 			//GrRaiseWindow(window->wid);			// FIXME
		nxPaintNCArea(window->wid, info.width, info.height, props.title, active, props.props);
	}

	/* free title returned from GrGetWMProperties*/
	if (props.title)
		free(props.title);
}
コード例 #28
0
ファイル: npanel.c プロジェクト: ghaerr/microwindows
static void
do_buttonup(GR_EVENT_BUTTON *ep)
{
#ifdef SHOW_WINDOW_MOTION
	in_motion = NULL;
#else
	mwin *	mwp;
	GR_WINDOW_INFO winfo;

	if ((mwp = IsDecoration(ep->wid)) != NULL) {
		if (mwp == in_motion) {
			mwp->x = ep->rootx - 1 - move_xoff;
			mwp->y = ep->rooty - 1 - move_yoff;
			GrMoveWindow(mwp->fid, mwp->x + 1, mwp->y + 1);
			GrGetWindowInfo(mwp->wid, &winfo);
			GrMoveWindow(mwp->wid, mwp->x + winfo.bordersize,
				mwp->y + 2 * winfo.bordersize + DEC_HEIGHT);
			in_motion = NULL;
		}
	}
#endif
}
コード例 #29
0
void new_tictactoe_window(void)
{
	
    tictactoe_gc = pz_get_gc(1);       /* Get the graphics context */
	
    /* Open the window: */
    tictactoe_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);
	
	GrGetWindowInfo(tictactoe_wid, &wi); /* Get screen info */	
	
    /* Select the types of events you need for your window: */
    GrSelectEvents (tictactoe_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);
	
    /* Display the window: */
    GrMapWindow (tictactoe_wid);
	
	reset_board(); 
}
コード例 #30
0
ファイル: wmaction.c プロジェクト: ghaerr/microwindows
void wm_container_buttondown(win *window, GR_EVENT_BUTTON *event)
{
	struct pos_size *pos;
	GR_RECT		r;
	GR_COORD	cxborder = 0, cyborder = 0;
	GR_WINDOW_INFO	info;
	GR_WINDOW_INFO	cinfo;
	GR_GC_ID        gc;
	Dprintf("wm_container_buttondown window %d\n", window->wid);

	if(window->active)
		return;

	GrGetWindowInfo(window->wid, &info);
	GrGetWindowInfo(window->clientid, &cinfo);

	/* 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;
	}

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

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

		/* Check mousedn in close box*/
		if (PtInRect(&r, event->x, event->y)) {
			/* close on button up*/
			window->close = GR_TRUE;
      		return;
		}
	}

	/* 
	 * Set focus to the window only if client 
	 * or the container itself is clicked.
	 * if any of the  children (of the client)
	 * are clicked better not take the focus 
	 * away from them. They might require handling
	 * the focus themself.
	 * -- Amit Kulkarni
	 */
	if(window->wid==event->subwid)
		GrSetFocus(window->wid);

	/* check for corner resize */
	r.x = info.width - 5;
	r.y = info.height - 5;
	r.width = 5;
	r.height = 5;

	if (PtInRect(&r,event->x, event->y)
	   && !(info.props & GR_WM_PROPS_NORESIZE) && !(cinfo.props & GR_WM_PROPS_NORESIZE)) {
#if !NO_CORNER_RESIZE
	  struct pos_size * pos;

	  if(!window->data)
	    if(!(window->data = malloc(sizeof(struct pos_size))))
			return;

	  window->sizing = GR_TRUE;
	  
	  /* save off the width/height offset from the window manager */
	  GrGetWindowInfo(window->clientid,&info);
	  pos = (struct pos_size*)window->data;
	  pos->xoff = -info.width;
	  pos->yoff = -info.height;

	  GrGetWindowInfo(window->wid,&info);
	  pos->xoff += info.width;
	  pos->yoff += info.height;

	  gc = GrNewGC();
	  GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN);
	  GrRect(GR_ROOT_WINDOW_ID,gc,info.x, info.y, info.width, info.height);
	  GrDestroyGC(gc);

	  /* save this rectangle's width/height so we can erase it later */
	  pos->width = info.width;
	  pos->height = info.height;
      pos->xorig = event->x;
      pos->yorig = event->y;

	  /*
	   * This window is being resized.
	   * The client should have focus now.
	   * -- Amit Kulkarni
	   */
	  GrSetFocus(window->clientid);	  

	  return;
#endif /* !NO_CORNER_RESIZE*/
	} else
		GrSetWindowCursor(window->wid, 0);

	/* if not in caption, return (FIXME, not calc'd exactly)*/
	if (!(info.props & GR_WM_PROPS_CAPTION))
		return;

	/* Get caption box rect*/
	r.x = cxborder;
	r.y = cyborder;
	r.width = info.width - cxborder*2;
	r.height = CYCAPTION;

	/* Check for mousedn in caption box*/
	if (!PtInRect(&r, event->x, event->y))
		return;
	
	/*
	 * Now we have a click on the caption. 
	 * So window is active. 
	 * Set focus to the client
	 * --Amit Kulkarni
	 */	
	GrSetFocus(window->clientid);

	/* Raise window if mouse down and allowed*/
	if (!(info.props & GR_WM_PROPS_NORAISE) && !(cinfo.props & GR_WM_PROPS_NORAISE))
		GrRaiseWindow(window->wid);

	/* Don't allow window move if NOMOVE property set*/
	if ((info.props & GR_WM_PROPS_NOMOVE) || (cinfo.props & GR_WM_PROPS_NOMOVE))
		return;

	if(!window->data)
		if(!(window->data = malloc(sizeof(struct pos_size))))
			return;

	GrGetWindowInfo(window->wid,&info);
	pos = (struct pos_size *)window->data;
	pos->xoff = event->x;
	pos->yoff = event->y;

#if OUTLINE_MOVE
	pos->xorig = info.x;
	pos->yorig = info.y;
	pos->width = info.width;
	pos->height = info.height;

	gc = GrNewGC();
	GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN);
	GrRect(GR_ROOT_WINDOW_ID, gc,info.x, info.y, info.width, info.height);
	GrDestroyGC(gc);
#endif	
	window->active = GR_TRUE;
}