⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmgr_rect.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (grasp_type == -2 || (row == 1 && col == 1 && !is_move)) {		/*  it's in the center; distribute it to a side		 *  according to which side of each diagonal it lies on.		 */		int	ne = 1, nw = 2;		if (y > 0 && (x<<10) / y < (r->r_width<<10) / r->r_height) {			ne = 0;		/* below the main diagonal	*/		}		if (x + y > (r->r_width + r->r_height) / 2 ) {			nw = 0;		/* below the minor diagonal	*/		}		switch (ne + nw)  {		  case 0:	return WM_S;	/* !NE && !NW	*/		  case 1:	return WM_E;	/*  NE && !NW	*/		  case 2:	return WM_W;	/* !NE &&  NW	*/		  case 3:	return WM_N;	/*  NE &&  NW	*/		}		/*NOTREACHED*/	} else {		return grasps[row][col];	}}/*ARGSUSED*/Rectwmgr_set_bounds(w_rect, s_rect, grasp, is_move, offset, min_width, min_height)	register Rect	*w_rect;	/* window rect */	Rect		*s_rect;	/* screen rect */	WM_Direction	 grasp;	int		 is_move;	struct pr_pos	*offset;	int		 min_width, min_height;{	Rect		 bounds;	bounds = *s_rect;	if (is_move) {			/*	move		*/#ifdef notdef /*  This goes back in when menu & paint are fixed to  *  handle partially off-screen windows correctly.  *  (Fix wmgr_move_box, below, at the same time.)  */		rect_marginadjust(&bounds, -min_width);#endif		/* restrict motion to one dimension		 * if not at corner.		 */		switch (grasp) {			case WM_N:			case WM_S:				bounds.r_left = w_rect->r_left;				bounds.r_width = w_rect->r_width;				break;			case WM_W:			case WM_E:				bounds.r_top = w_rect->r_top;				bounds.r_height = w_rect->r_height;				break;			default:				break;		}	} else {			/*	stretch		*/		switch (grasp) {		  case WM_W:		  case WM_NW:		  case WM_SW:			bounds.r_width = rect_right(w_rect) + 1					- min_width					- bounds.r_left;			break;		  case WM_E:		  case WM_NE:		  case WM_SE:			bounds.r_width = rect_right(&bounds) + 1					 - (w_rect->r_left + min_width);			bounds.r_left = w_rect->r_left + min_width;			break;		}		switch (grasp) {		  case WM_N:		  case WM_NE:		  case WM_NW:			bounds.r_height = rect_bottom(w_rect) + 1					 - MIN_TOOL_WIDTH					 - bounds.r_top;			break;		  case WM_S:		  case WM_SE:		  case WM_SW:			bounds.r_height = rect_bottom(&bounds) + 1					 - (w_rect->r_top + min_height);			bounds.r_top = w_rect->r_top + min_height;			break;		}	}	return bounds;}intwmgr_get_placeholders(irect, orect)	struct rect	*irect, *orect;{	return wmgr_do_placeholders(irect, orect,				    (void (*)())win_getrect, 				    (void (*)())win_getsavedrect);}intwmgr_set_placeholders(irect, orect)	struct rect	*irect, *orect;{	return wmgr_do_placeholders(irect, orect,				    (void (*)())win_setrect, 				    (void (*)())win_setsavedrect);}/*ARGSUSED*/intwmgr_figureiconrect(rootfd, rect)	int	rootfd;	struct	rect *rect;{	(void)wmgr_acquire_next_icon_rect(*rect);}/*ARGSUSED*/intwmgr_figuretoolrect(rootfd, rect)	int	rootfd;	struct	rect *rect;{	(void)wmgr_acquire_next_tool_rect(*rect);}/* * Utilities */static struct fullscreen *wmgr_grab_screen(fd)	int		    fd;{	int		    fd_flags;	struct inputmask    im;	struct fullscreen  *fs;	fs = fullscreen_init(fd);	/*  Get fullscreen access  */	/*  but reset to use non-blocking io (fullscreen sets to block)  */	fd_flags = fcntl(fd, F_GETFL, 0);	if (fcntl(fd, F_SETFL, fd_flags|FNDELAY))  {		perror("wmgr_grab_screen (fcntl)");	}	/* Make sure input mask allows tracking cursor motion and buttons	 * (fullscreen has cached current mask, so we don't need to again)	 */	(void)win_getinputmask(fd, &im, (int *) 0);	im.im_flags |= IM_NEGEVENT;	win_setinputcodebit(&im, LOC_MOVEWHILEBUTDOWN);	win_setinputcodebit(&im, MS_LEFT);	win_setinputcodebit(&im, MS_MIDDLE);	win_setinputcodebit(&im, MS_RIGHT);	win_setinputcodebit(&im, WIN_STOP);	(void)win_setinputmask(fd, &im, (struct inputmask *)0, WIN_NULLLINK);	return fs;}static voidwmgr_set_cursor(fs, r, event, is_move, grasp)	struct fullscreen	*fs;	struct rect		*r;	struct inputevent	*event;	int			 is_move;	WM_Direction		 grasp;{	if (is_move) {		switch (grasp) {		    case WM_N:		    case WM_S:			(void)win_setcursor(fs->fs_windowfd, &wmgr_moveV_cursor);			break;		    case WM_E:		    case WM_W:			(void)win_setcursor(fs->fs_windowfd, &wmgr_moveH_cursor);			break;		    default:			(void)win_setcursor(fs->fs_windowfd, &wmgr_move_cursor);		}	} else {		wmgr_attach_cursor(fs->fs_windowfd, grasp, r, event);		(void)win_setcursor(fs->fs_windowfd, stretch_cursors[(int)grasp]);	}}static Event_returnwmgr_get_event(fd, event, activebut)	int		 fd;	Event		*event;{	for (;;) {		if (input_readevent(fd, event)==-1) {			if (errno == EWOULDBLOCK) {				return Valid;			} else {				return Error;			}		}		if (event_action(event) == ACTION_STOP			|| event_id(event) == WIN_STOP) {			return Stop;		}		if (win_inputnegevent(event)) {			if (event_action(event) == activebut) {				return Done;			}		}	}	/*NOTREACHED*/}static voidwmgr_move_box(r, bounds, ie_x, ie_y, offset, is_iconic)	struct rect	*r, *bounds;	int		 ie_x, ie_y, is_iconic;	struct pr_pos	*offset;{	register int	 x, y;	x = ie_x - offset->x;	y = ie_y - offset->y;	if (is_iconic) {	/*	preserve icon alignment	*/		x += WMGR_ICON_GRID_X / 2;		x -= x % WMGR_ICON_GRID_X;		y += WMGR_ICON_GRID_Y / 2;		y -= y % WMGR_ICON_GRID_Y;	}#ifdef notdef/*  restore these when menu & prompt are fixed to paint properly *  with the tool's origin off-screen. *  (Fix wmgr_set_bounds at that point, too.) */	if (!rect_includespoint(bounds, ie_x, ie_y))  {		wmgr_constrain_point(bounds, &ie_x, &ie_y, is_iconic);	}	r->r_left = x;	r->r_top = y;/*  but for now, keep completely in bounds	*/#endif	(void)wmgr_constrainrect(r, bounds, x - r->r_left, y - r->r_top);}static voidwmgr_stretch_box(grasp, r, bounds, x, y)	WM_Direction	 grasp;	int		 x, y;	register Rect	*r;	Rect		*bounds;{	if (!rect_includespoint(bounds, x, y))  {		wmgr_constrain_point(bounds, &x, &y, FALSE);	}	switch (grasp) {	  case WM_NW:	r->r_width += r->r_left - x;			r->r_left = x;	  case WM_N:	r->r_height += r->r_top - y;			r->r_top = y;			break;	  case WM_NE:	r->r_height += r->r_top - y;			r->r_top = y;	  case WM_E:	r->r_width = x - r->r_left;			break;	  case WM_SE:	r->r_width = x - r->r_left + 1;	  case WM_S:	r->r_height = y - r->r_top + 1;			break;	  case WM_SW:	r->r_height = y - r->r_top + 1;	  case WM_W:	r->r_width += r->r_left - x;			r->r_left = x;			break;	}}static voidwmgr_attach_cursor(window, grasp, r, event)	WM_Direction		 grasp;	register struct rect	*r;	struct inputevent	*event;{	register int		 x = event->ie_locx,				 y = event->ie_locy;	if (wmgr_stretch_jump_cursor()) {		/*  this section jumps the cursor to the edge for a stretch		 *  the alternative below pulls the edge to the cursor		 */		switch (grasp) {		  case WM_N:		  case WM_NE:		  case WM_NW:	y = r->r_top;				break;		  case WM_S:		  case WM_SE:		  case WM_SW:	y = rect_bottom(r);				break;		}		switch (grasp) {		  case WM_NW:		  case WM_W:		  case WM_SW:	x = r->r_left;				break;		  case WM_NE:		  case WM_E:		  case WM_SE:	x = rect_right(r);				break;		}		(void)win_setmouseposition(window, x, y);		event->ie_locx = x;		event->ie_locy = y;	} else {		switch (grasp) {		  case WM_N:		  case WM_NE:		  case WM_NW:	r->r_height = rect_bottom(r) - y + 1;				r->r_top = y;				break;		  case WM_S:		  case WM_SE:		  case WM_SW:	r->r_height = y - r->r_top + 1;				break;		}		switch (grasp) {		  case WM_NW:		  case WM_W:		  case WM_SW:	r->r_width = rect_right(r) - x + 1;				r->r_left  = x;				break;		  case WM_NE:		  case WM_E:		  case WM_SE:	r->r_width = x - r->r_left + 1;				break;		}	}}static Boolwmgr_stretch_jump_cursor(){    Bool defaults_get_boolean();    return defaults_get_boolean("/SunView/Jump_cursor_on_resize",     	(Bool) (LINT_CAST(FALSE)), (int *)NULL);}static voidwmgr_constrain_point(bounds, x, y, is_iconic)	register struct rect	*bounds;	register int		*x, *y;{	register int		 dx, dy;	if (is_iconic) {		dx = WMGR_ICON_GRID_X;		dy = WMGR_ICON_GRID_Y;	} else {		dx = 1;		dy = 1;	}	while (*x > rect_right(bounds))		*x -= dx;	while (*x < bounds->r_left)		*x += dx;	while (*y > rect_bottom(bounds))		*y -= dy;	while (*y < bounds->r_top)		*y += dy;}static intwmgr_do_placeholders(irect, orect, proc1, proc2)	struct rect	*irect, *orect;	void		(*proc1)(), (*proc2)();{	char		*filename;	int		 placefd;	if ((filename = getenv("WMGR_ENV_PLACEHOLDER")) == (char *) NULL) {		(void)fprintf(stderr, "No placeholder name in environment?\n");		return 0;	}	if ((placefd = open(filename, O_RDONLY, 0)) == -1) {		perror("Couldn't open window placeholders");		return 0;	}	if  (win_getuserflags(placefd) & WMGR_ICONIC) {		proc1(placefd, irect);		proc2(placefd, orect);	} else {		proc1(placefd, orect);		proc2(placefd, irect);	}	(void)close(placefd);	return 1;}/* *	I'd like to get rid of this, but not until it's cleared out of above */wmgr_constrainrect(rconstrain, rbound, dx, dy)	register struct rect *rconstrain, *rbound;	register dx, dy;{	rconstrain->r_left += dx;	rconstrain->r_top += dy;	/*	 * Bias algorithm to have too big rconstrain fall off right/bottom.	 */	if (rect_right(rconstrain) > rect_right(rbound)) {		rconstrain->r_left = rbound->r_left + rbound->r_width					- rconstrain->r_width;	}	if (rconstrain->r_left < rbound->r_left) {		rconstrain->r_left = rbound->r_left;	}	if (rect_bottom(rconstrain) > rect_bottom(rbound)) {		rconstrain->r_top = rbound->r_top + rbound->r_height					- rconstrain->r_height;	}	if (rconstrain->r_top < rbound->r_top) {		rconstrain->r_top = rbound->r_top;	}}fullscreen_not_draw_box(pixwin, r, w)	register struct	pixwin *pixwin;	register struct rect *r;	register int	w;{/* * The need for the two pr_ioctl calls, is an ugly kludge but necessary * for 8-bit indexed emulation in a 24-bit environment.  The * function is a no-op for all other frame buffers. */#include <sys/ioctl.h>	/* FBIO* */#include <sun/fbio.h>	/* FBIO* */	(void)pw_lock(pixwin, r);	pr_ioctl((Pixrect *) pixwin->pw_opshandle, FBIOSAVWINFD, 0);	/* Draw top, left, right then bottom */	(void)fullscreen_pw_write(	    pixwin, r->r_left, r->r_top, r->r_width, w, PIX_NOT(PIX_DST),	    (struct pixrect *)0, 0, 0);	(void)fullscreen_pw_write(pixwin, r->r_left, r->r_top + w,	    w, r->r_height - 2*w, PIX_NOT(PIX_DST), (struct pixrect *)0, 0, 0);	(void)fullscreen_pw_write(pixwin, r->r_left + r->r_width - w, r->r_top + w,	    w, r->r_height - 2*w, PIX_NOT(PIX_DST), (struct pixrect *)0, 0, 0);	(void)fullscreen_pw_write(pixwin, r->r_left, r->r_top + r->r_height - w,	    r->r_width, w, PIX_NOT(PIX_DST), (struct pixrect *)0, 0, 0);	pr_ioctl((Pixrect *) pixwin->pw_opshandle, FBIORESWINFD, 0);	(void)pw_unlock(pixwin);	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -