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

📄 win_central.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
}Pixwin *win_get_pixwin(client)	Notify_client client;{	Pixwin_handles *pwh;	Window_handles *win = win_get_handles(client, &pwh);	if (win == WINDOW_HANDLES_NULL)		return((Pixwin *)0);	else		return(pwh->pw);}intpw_set_region_rect(pw, r, use_same_pr)        register Pixwin *pw;        register Rect *r;	int use_same_pr;{	struct pixwin_clipdata *pwcd = pw->pw_clipdata;	/* It is an error if the pixwin is not a region */	if (pwcd->pwcd_regionrect == RECT_NULL)		return (-1);	/* This call is a no op if the existing region & new rect are equal */	if (rect_equal(pwcd->pwcd_regionrect, r))		return (0);	/*	 * Set rect.  Caller is responsible for seeing that r is within any	 * containing regions.	 */	*pwcd->pwcd_regionrect = *r;	/*	 * Reset retained image, if any.  This doesn't work if the	 * retained image is not a primary pixrect.	 */	if (!use_same_pr)		(void)pw_set_retain(pw, r->r_width, r->r_height);	/* Figure new clipping */	(void)pw_getclipping(pw);	return (0);}intpw_get_region_rect(pw, r)        Pixwin *pw;        Rect *r;{	if (pw->pw_clipdata->pwcd_regionrect == RECT_NULL)		return (-1);	*r = *pw->pw_clipdata->pwcd_regionrect;	return (0);}pw_restrict_clipping(pw, rl)        struct  pixwin *pw;        struct  rectlist *rl;{        (void)rl_intersection(&pw->pw_clipdata->pwcd_clipping, rl,            &pw->pw_clipdata->pwcd_clipping);        (void)pw_setup_clippers(pw);	return;}pw_reduce_clipping(pw, rl)        struct  pixwin *pw;        struct  rectlist *rl;{        (void)rl_difference(&pw->pw_clipdata->pwcd_clipping, rl,            &pw->pw_clipdata->pwcd_clipping);        (void)pw_setup_clippers(pw);	return;}pw_setup_clippers(pw)        struct  pixwin *pw;{        struct  rect screenrect;	int saved_clipid, saved_damageid;	Rectlist saved_clipping;	Rect *saved_regionrect;	register struct pixwin_clipdata *pwcd = pw->pw_clipdata;	/* Remember stuff that pwco_reinitclipping destroies */	saved_clipid = pwcd->pwcd_clipid;	saved_damageid = pwcd->pwcd_damagedid;	saved_clipping = rl_null;	(void)rl_copy(&pwcd->pwcd_clipping, &saved_clipping);	/* Free existing clipping */	pwco_reinitclipping(pw);	/* Restore clipping and clipid */	pwcd->pwcd_clipping = saved_clipping;	pwcd->pwcd_damagedid = saved_damageid;	pwcd->pwcd_clipid = saved_clipid;	/* Get screen rect used by _pw_setclippers */	(void)win_getscreenrect(pw->pw_windowfd, &screenrect);	/* Null out stuff that _pw_setclippers only should see once */	saved_regionrect = pwcd->pwcd_regionrect;	pwcd->pwcd_regionrect = RECT_NULL;	/* Do some stuff that _pw_setclippers would do if was region */	if (saved_regionrect) {		Rect regionrect;		/* Trim screenrect to regionrect */		regionrect = *saved_regionrect;		rect_passtoparent(screenrect.r_left, screenrect.r_top,		    &regionrect);		(void)rect_intersection(&regionrect, &screenrect, &screenrect);	}	/* Restore clippers */        (void)_pw_setclippers(pw, &screenrect);	/* Restore nulled out stuff */	pwcd->pwcd_regionrect = saved_regionrect;	return;}win_getscreenrect(windowfd, rect)	int windowfd;	struct rect *rect;{	int left, top;        /* Note: Probably should cache screenrect */	(void)win_getsize(windowfd, rect);	/* Note: Don't use &screenrect.r_left because is a short */	(void)win_getscreenposition(windowfd, &left, &top);	rect->r_left = left;	rect->r_top = top;	return;}win_set_retain(pw, win)	register Pixwin *pw;	register Window_handles *win;{	if (pw->pw_clipdata->pwcd_regionrect == RECT_NULL)		(void)pw_set_retain(pw,		    win->rect.r_width, win->rect.r_height);	else		(void)pw_set_retain(pw,		    pw->pw_clipdata->pwcd_regionrect->r_width,		    pw->pw_clipdata->pwcd_regionrect->r_height);}/* * Change retained image to be width, height, (computed depth) if new * image will be different.  Should be called when resize window or change * colormap segment depth. */pw_set_retain(pw, width, height)	register Pixwin *pw;	int width, height;{	struct colormapseg cms;	register int depth;	register struct pixrect *pr = pw->pw_prretained;	/* Conserve memory on depth > 1 plane pixrects if only need bit map. */	(void)pw_getcmsdata(pw, &cms, (int *)0);	depth = (cms.cms_size == 2 && pw->pw_pixrect->pr_depth<32)	    ? 1: pw->pw_pixrect->pr_depth;	/* Release existing retained image */	if (pr) {		/* See if new pr would be the same as the existing one */		if (pr->pr_width == width && pr->pr_height == height &&		    pr->pr_depth == depth)			return;		(void)pr_destroy(pr);	}	/* Allocate new retained image.  Failure will return NULL pointer. */	pw->pw_prretained = mem_create(width, height, depth);	return;}/* * Referenced across sunwindow modules: */win_getrect_local(windowfd, rect)	int	windowfd;	struct	rect *rect;{	if (wins == WINDOW_HANDLES_NULL ||	    wins[windowfd].next == PIXWIN_HANDLES_NULL)		(void)win_getrect_from_source(windowfd, rect);	else		*rect = wins[windowfd].rect;	return;}win_setrect_local(windowfd, rect)	int	windowfd;	struct	rect *rect;{	register Window_handles *win;	/* Update kernel's notion of rect */	(void)win_setrect_at_source(windowfd, rect);	/* See if this window has a client associated with it */	if (wins != WINDOW_HANDLES_NULL &&	    (win = &wins[windowfd]) && (win->next != PIXWIN_HANDLES_NULL)) {		/* Note if size has changed */		if (rect_sizes_differ(&(win->rect), rect))			win->flags |= WH_SIZE_CHANGED;		/* Update local notion of rect */		win->rect = *rect;	}	return;}win_grabio_local(windowfd)	int 	windowfd;{	if (wins == WINDOW_HANDLES_NULL)		return;	if (wins[windowfd].next)		wins[windowfd].flags |= WH_GRABBED_INPUT;	return;}win_releaseio_local(windowfd)	int 	windowfd;{	if (wins == WINDOW_HANDLES_NULL)		return;	if (wins[windowfd].next)		wins[windowfd].flags &= ~WH_GRABBED_INPUT;	return;}win_is_io_grabbed(windowfd)	int 	windowfd;{	if (wins == WINDOW_HANDLES_NULL)		return (0);	if (wins[windowfd].next && (wins[windowfd].flags & WH_GRABBED_INPUT))		return (1);	return (0);}#ifndef PRE_FLAMINGOwin_getnotifyall(windowfd)        int windowfd;{	return ((wins[windowfd].flags & WH_NOTIFY_ALL) != 0);}win_setnotifyall(windowfd, flag)        int windowfd;        int flag;{	if (flag)		wins[windowfd].flags |= WH_NOTIFY_ALL;	else		wins[windowfd].flags &= ~WH_NOTIFY_ALL;        (void)werror(ioctl(windowfd, WINSETNOTIFYALL, &flag), WINSETNOTIFYALL);}win_clear_cursor_planes(windowfd, rect)        int windowfd;        Rect    *rect;{      (void)werror(ioctl(windowfd, WINCLEARCURSORPLANES, rect),                                     WINCLEARCURSORPLANES);}win_cursor_planes_available(windowfd)        int windowfd;{    struct win_plane_groups_available  available;    if (ioctl(windowfd, WINGETAVAILPLANEGROUPS, &available) == -1)        return (0);    if ((available.plane_groups_available[PIXPG_CURSOR]) &&            (available.plane_groups_available[PIXPG_CURSOR_ENABLE])) {        return (1);    } else {        return (0);    }}#endif/* * Private to this module: *//*ARGSUSED*/static Notify_valueinput_pending(client, fd)	Notify_client client;	int fd;{	Pixwin_handles *pwh;	struct	inputevent *win_event;	/* Validate */	if (wins == WINDOW_HANDLES_NULL)		return(NOTIFY_UNEXPECTED);	/* Read input */	win_event = &wins[fd].event;	if (input_readevent(fd, win_event)) {		perror("input_pending");		return(NOTIFY_IGNORED);	}	/* Find client for this event */	if ((pwh = win_find_consumer(&wins[fd], win_event)) ==	    PIXWIN_HANDLES_NULL)		return(NOTIFY_IGNORED);	/* Send event */	(void) win_send(pwh, win_event, NOTIFY_SAFE, (Notify_arg)0,	    win_copy_event, win_free_event);	return(NOTIFY_DONE);}/* * Pw_change has to be called directly if want to immediately paint * screen before entering the notifier. *//*ARGSUSED*/static Notify_valuepw_change(wins_dummy, sig, mode)	Notify_client wins_dummy;	int sig;	Notify_signal_mode mode;{	register i;	int global_resized;	register Notify_value return_code;	if ((sig != SIGWINCH) || (wins == WINDOW_HANDLES_NULL))		return(NOTIFY_IGNORED);	return_code = NOTIFY_IGNORED;	/* Handle all resizes until there are no more changes */	do {		global_resized = 0;		for (i = 0; i < win_num; i++) {			switch (win_send_resize(&wins[i])) {			case NOTIFY_DONE:				if (return_code == NOTIFY_IGNORED)					return_code = NOTIFY_DONE;				global_resized = 1;				break;			case NOTIFY_IGNORED:				break;			default:				return_code = NOTIFY_UNEXPECTED;			}		}	} while (global_resized);	/* Handle all repainting */	for (i = 0; i < win_num; i++) {		switch (win_send_repaint(&wins[i])) {		case NOTIFY_DONE:			if (return_code == NOTIFY_IGNORED)				return_code = NOTIFY_DONE;			break;		case NOTIFY_IGNORED:			break;		default:			return_code = NOTIFY_UNEXPECTED;		}	}	return (return_code);	}static Notify_valuewin_send_resize(win)	register Window_handles *win;{	register Pixwin_handles *pwh;	Rect rect;	int win_resized;	if (win->next == PIXWIN_HANDLES_NULL)		return (NOTIFY_IGNORED);	/* Get truth about rect size */	(void)win_getrect_from_source(win->next->pw->pw_windowfd, &rect);	/*	 * See if size changed.  If another process changed it	 * then the rects will differ.  If this process did it	 * then the flag is set.	 */	win_resized = ((rect.r_width != win->rect.r_width) ||	    (rect.r_height != win->rect.r_height) ||	    (win->flags & WH_SIZE_CHANGED));	win->flags &= ~WH_SIZE_CHANGED;	/* Update local (user process) notion of rect */	win->rect = rect;	/* Mark a win that is doing its own sigwinch handling */	win->flags &= ~WH_OWN_SIGWINCH;	for (pwh = win->next;pwh; pwh = pwh->next) {		if (notify_get_signal_func(pwh->client,		    SIGWINCH, NOTIFY_SYNC) != NOTIFY_FUNC_NULL) {			win->flags |= WH_OWN_SIGWINCH;			return (NOTIFY_IGNORED);		}	}	if (win_resized) {		/* Send WIN_RESIZE notification to all pwh's of win */		for (pwh = win->next;pwh; pwh = pwh->next) {			switch (win_post_id(pwh->client, WIN_RESIZE,			    NOTIFY_SAFE)) {			case NOTIFY_OK:				pwh->flags |= PW_RESIZED;				/* Change retained image if manager of it */				if (pwh->flags & PW_RETAIN)					win_set_retain(pwh->pw, win);				break;			case NOTIFY_NO_CONDITION:				/*				 * Client may actually be handling SIGWINCHes				 * himself				 */				break;			default:				notify_perror("pw_send_resize");				return (NOTIFY_UNEXPECTED);			}		}		return (NOTIFY_DONE);	} else		return (NOTIFY_IGNORED);}static Notify_valuewin_send_repaint(win)	register Window_handles *win;

⌨️ 快捷键说明

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