📄 wmgr_policy.c
字号:
(root_rect.r_height - TOOL_ICONHEIGHT) / 2; }Found_place: (void)win_setsavedrect(window, candidate); (void)rl_free(rl); free((char *)(LINT_CAST(rl)));}static struct rectlist *wmgr_find_free_space(root, window, policy) Window_handle root; Policy_handle policy;{ struct rectlist *rl; int flag; switch (policy->obstructors) { case Cur_windows: flag = WFS_CURRENT; break; case Icons: flag = WFS_ICONS; break; case Open: flag = WFS_OPEN; break; case All_windows: flag = WFS_BOTH; break; default: flag = WFS_CURRENT; break; } rl = wmgr_findspace(root, flag, window); return rl;}static intwmgr_test_slots(candidate, root_rect, rl, policy) Policy_handle policy; struct rect *root_rect; struct rect *candidate; struct rectlist *rl;{ for (wmgr_place_first_icon(policy->gravity, root_rect, candidate); rect_includesrect(root_rect, candidate); wmgr_advance_icon(policy->gravity, root_rect, candidate) ) { if (wmgr_test_rect(candidate, rl, policy)) { return TRUE; } } return FALSE;}/*ARGSUSED*/intwmgr_init_icon_position(root) Window_handle root;{}/*ARGSUSED*/intwmgr_acquire_next_icon_rect(rect) struct rect rect;{}/*ARGSUSED*/intwmgr_inquire_next_icon_rect(rect) struct rect rect;{}intwmgr_set_icon_rect(rootfd, window, icon_rect) /* ASSUMES window is OPEN */ Window_handle rootfd, window; struct rect *icon_rect;{ struct rect dummy_rect; if (icon_rect == NULL) { icon_rect = &dummy_rect; (void)win_getsavedrect(window, icon_rect); } if (icon_rect->r_left == WMGR_SETPOS) { wmgr_find_icon_slot(rootfd, window, icon_rect, FALSE); } else { wmgr_find_icon_slot(rootfd, window, icon_rect, TRUE); }}static enum win_enumerator_resultwmgr_find_boundary(window, parms) Window_handle window; Level_parms *parms;{ int link; link = win_fdtonumber(window); if (link == parms->self) { return Enum_Normal; } if (wmgr_iswindowopen(window)) { parms->next = link; return Enum_Succeed; } parms->prev = link; return Enum_Normal;}static voidwmgr_findlevel(rootfd, window, parms) Window_handle rootfd, window; Level_parms *parms;{ int self; self = win_fdtonumber(window); switch (parms->level) { case Back: parms->prev = WIN_NULLLINK; parms->next = win_getlink(rootfd, WL_BOTTOMCHILD); if (parms->next == self) { parms->next = win_getlink(window, WL_COVERING); } return; case Front: parms->next = WIN_NULLLINK; parms->prev = win_getlink(rootfd, WL_TOPCHILD); if (parms->prev == self) { parms->prev = win_getlink(window, WL_COVERED); } return; case Boundary: parms->self = win_fdtonumber(window); parms->prev = parms->next = WIN_NULLLINK; (void)win_enumerate_children(rootfd, wmgr_find_boundary, (caddr_t)parms); return; }}voidwmgr_set_icon_level(rootfd, windowfd) Window_handle rootfd, windowfd;{ Policy_handle policy; Level_parms parms; policy = wmgr_get_icon_policy(); if (policy->close_level == Cur_level) { /* Force repaint */ (void)win_remove(windowfd); (void)win_insert(windowfd); return; } parms.level = policy->close_level; wmgr_findlevel(rootfd, windowfd, &parms); wmgr_setlevel(windowfd, parms.prev, parms.next);}static voidwmgr_get_trimmed_bounds(root, bounds) Window_handle root; struct rect *bounds;{ Policy_handle policy; policy = wmgr_get_icon_policy(); (void)win_getrect(root, bounds); switch (policy->gravity) { case North: bounds->r_top += TOOL_ICONHEIGHT; /* FALL THROUGH */ case South: bounds->r_height -= TOOL_ICONHEIGHT; break; case West: bounds->r_left += TOOL_ICONWIDTH; /* FALL THROUGH */ case East: bounds->r_width -= TOOL_ICONWIDTH; break; }}static voidwmgr_adjust_tool(bounds, candidate) register struct rect *bounds, *candidate;{ register int delta;#ifdef NOTDEF Policy_handle policy; policy = wmgr_get_icon_policy(); switch (policy->gravity) { case North: bounds->r_top -= TOOL_ICONHEIGHT; /* FALL THROUGH */ case South: bounds->r_height += TOOL_ICONHEIGHT; break; case West: bounds->r_left -= TOOL_ICONWIDTH; /* FALL THROUGH */ case East: bounds->r_width += TOOL_ICONWIDTH; break; }#endif if (candidate->r_width > bounds->r_width) candidate->r_width = bounds->r_width; if (candidate->r_height > bounds->r_height) candidate->r_height = bounds->r_height; delta = rect_right(bounds) - rect_right(candidate); if (delta < 0) candidate->r_left += delta; if (candidate->r_left < bounds->r_left) candidate->r_left = bounds->r_left; delta = rect_bottom(bounds) - rect_bottom(candidate); if (delta < 0) candidate->r_top += delta; if (candidate->r_top < bounds->r_top) candidate->r_top = bounds->r_top;}static voidwmgr_advance_tool(root, bounds, candidate) Window_handle root; struct rect *bounds, *candidate;{ /* This routine is a bit hairy. Its logic is: * since we've been asked to, bump the tool position. * If that moves off the left edge of the screen, * it's time to start a new diagonal line at the top, * over to the right a ways. * Similarly, if this window extends off the bottom, * but it could fit from a reachable position, start a new * diagonal rank. * If that new rank would put the candidate's right edge out of * bounds (and it could fit), come back to the start of the * first rank. * Whatever position we arrive at, stash it in the rect, * and save any new "next" info in the placeholders tool rect. */ struct rect next_pos, dummy; (void)wmgr_get_placeholders(&next_pos, &dummy); next_pos.r_top += WMGR_ADVANCE_TOOL_Y; next_pos.r_left += WMGR_ADVANCE_TOOL_X; if ((next_pos.r_left < bounds->r_left) || ((next_pos.r_top + candidate->r_height > bounds->r_top + bounds->r_height) && candidate->r_height <= bounds->r_height ) ) { next_pos.r_left = next_pos.r_width; next_pos.r_top = next_pos.r_height; next_pos.r_width += WMGR_ADVANCE_TOOL_XRANK; next_pos.r_height += WMGR_ADVANCE_TOOL_YRANK; } if ( next_pos.r_left + candidate->r_width > bounds->r_left + bounds->r_width ) { if (candidate->r_width <= bounds->r_width) { (void)wmgr_init_tool_position(root); (void)wmgr_get_placeholders(&next_pos, &dummy); next_pos.r_top += WMGR_ADVANCE_TOOL_Y; next_pos.r_left += WMGR_ADVANCE_TOOL_X; } } (void)wmgr_set_placeholders(&next_pos, &dummy); if (candidate->r_left == WMGR_SETPOS) { candidate->r_left = next_pos.r_left; } if (candidate->r_top == WMGR_SETPOS) { candidate->r_top = next_pos.r_top; }}intwmgr_init_tool_position(root) Window_handle root;{ struct rect bounds, rect, dummy; wmgr_get_trimmed_bounds(root, &bounds); (void)wmgr_get_placeholders(&rect, &dummy); rect.r_left = bounds.r_width / 8 + bounds.r_left - WMGR_ADVANCE_TOOL_X; rect.r_top = bounds.r_top - WMGR_ADVANCE_TOOL_Y;; rect.r_width = rect.r_left + WMGR_ADVANCE_TOOL_XRANK; rect.r_height = bounds.r_top + WMGR_ADVANCE_TOOL_YRANK; (void)wmgr_set_placeholders(&rect, &dummy);}intwmgr_acquire_next_tool_rect(rect) struct rect *rect;{ struct rect dummy; (void)wmgr_get_placeholders(rect, &dummy);}intwmgr_inquire_next_tool_rect(rect) struct rect rect;{ struct rect dummy; (void)wmgr_get_placeholders(&rect, &dummy);}intwmgr_set_tool_rect(root, window, candidate) Window_handle root, window; struct rect *candidate;{ struct rect root_rect, dummy_rect; if (candidate == NULL) { candidate = &dummy_rect; (void)win_getrect(window, candidate); } if (candidate->r_width == WMGR_SETPOS || candidate->r_height == WMGR_SETPOS) { (void) pw_pfsysopen(); if (candidate->r_width == WMGR_SETPOS) { candidate->r_width = tool_widthfromcolumns(80); } if (candidate->r_height == WMGR_SETPOS) { candidate->r_height = tool_heightfromlines(34,TRUE); } (void)pw_pfsysclose(); } if (candidate->r_left == WMGR_SETPOS || candidate->r_top == WMGR_SETPOS) { Policy_handle policy; policy = wmgr_get_icon_policy(); wmgr_get_trimmed_bounds(root, &root_rect); if (candidate->r_width > root_rect.r_width) { switch (policy->gravity) { case East: candidate->r_left -= TOOL_ICONWIDTH; case West: candidate->r_width += TOOL_ICONWIDTH; } } if (candidate->r_height > root_rect.r_height) { switch (policy->gravity) { case North: candidate->r_top -= TOOL_ICONHEIGHT; case South: candidate->r_height += TOOL_ICONHEIGHT; } } wmgr_advance_tool(root, &root_rect, candidate); } else { (void)win_getrect(root, &root_rect); } if (!rect_includesrect(&root_rect, candidate)) { wmgr_adjust_tool(&root_rect, candidate); } (void)win_setrect(window, candidate);}voidwmgr_set_tool_level(rootfd, windowfd) Window_handle rootfd, windowfd;{ Policy_handle policy; Level_parms parms; policy = wmgr_get_icon_policy(); if (policy->close_level == Cur_level) { /* Force repaint */ (void)win_remove(windowfd); (void)win_insert(windowfd); return; } parms.level = Front; wmgr_findlevel(rootfd, windowfd, &parms); wmgr_setlevel(windowfd, parms.prev, parms.next);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -