📄 pw_shared.c
字号:
int planes;#ifdef ecd.cursor short olddata; struct mpr_data *mpds, *mpdd;#endif ecd.cursor #ifdef DEBUG printf("unlocked display\n");#endif /* only draw the cursor if not up, active and want it or * we dont have cursor planes */ if ((shared_cursor->spare3)|| (shared_cursor->cursor_is_up) || (!shared_cursor->cursor_active) || (!(show_cursor(&shared_cursor->cursor) && shared_cursor->pr_data.md_image && shared_cursor->pr.pr_width && shared_cursor->pr.pr_depth && shared_cursor->pr.pr_height))) return; /* Set up full planes */ (void)pr_getattributes(pw->pw_pixrect, &original_planes); planes = PIX_ALL_PLANES;#ifdef planes_fully_implemented pr_putattributes(pw->pw_pixrect, &planes);#else (void)pw_full_putattributes(pw->pw_pixrect, &planes);#endif planes_fully_implemented /* * Get current mouse position. * Race with kernel but not critical. */ shared_cursor->x = wl->mouse_x; shared_cursor->y = wl->mouse_y; /* Note what plane group using */ shared_cursor->plane_group = pw->pw_clipdata->pwcd_plane_group; /* adjust for the hot spot */ shared_cursor->x -= shared_cursor->cursor.cur_xhot; shared_cursor->y -= shared_cursor->cursor.cur_yhot; if (pw->pw_clipdata->pwcd_flags & PWCD_CURSOR_INVERTED) (void)pr_reversevideo(pw->pw_pixrect, 0, 1); /* save the bits under the cursor */ shared_cursor->screen_pr.pr_width = shared_cursor->pr.pr_width; shared_cursor->screen_pr.pr_height = shared_cursor->pr.pr_height; win_lock_prepare_screen_pr(shared_cursor);#ifdef ecd.cursor olddata = ((struct mpr_data *)(pw->pw_pixrect->pr_data))->md_flags; ((struct mpr_data *)(pw->pw_pixrect->pr_data))->md_flags &= ~MP_REVERSEVIDEO;#endif ecd.cursor (void)pr_rop(&shared_cursor->screen_pr, 0, 0, shared_cursor->screen_pr.pr_width, shared_cursor->screen_pr.pr_height, PIX_SRC, pw->pw_pixrect, shared_cursor->x, shared_cursor->y);#ifdef ecd.cursor ((struct mpr_data *)(pw->pw_pixrect->pr_data))->md_flags = olddata;#endif ecd.cursor /* * Reset planes so that will write to foreground and background * of current colormap segment. */#ifdef planes_fully_implemented pr_putattributes(pw->pw_pixrect, &original_planes);#else (void)pw_full_putattributes(pw->pw_pixrect, &original_planes);#endif planes_fully_implemented /* Put cursor on the screen */ win_lock_prepare_cursor_pr(shared_cursor); (void)pr_rop(pw->pw_pixrect, shared_cursor->x, shared_cursor->y, shared_cursor->screen_pr.pr_width, shared_cursor->screen_pr.pr_height, shared_cursor->cursor.cur_function, &shared_cursor->pr, 0, 0); shared_cursor->cursor_is_up = TRUE; if (pw->pw_clipdata->pwcd_flags & PWCD_CURSOR_INVERTED) (void)pr_reversevideo(pw->pw_pixrect, 0, 1);}static intpw_cursor_intersect_exposed(pw, rect_paint) register Pixwin *pw; Rect *rect_paint;{ Win_lock_block *shared_info = pw->pw_clipdata->pwcd_wl; Win_shared_cursor *cursor_info = &shared_info->cursor_info; Rect rect; int have_grabio; /* if the data lock is ours, we can't trust the * screen_x, screen_Y coordinates of the window, since * a win_setrect() could have been done without changing * the clipping id. So play it safe and take down the cursor. */ if (win_lock_data_locked(shared_info) && (shared_info->data.pid == pw_mypid)) return TRUE; rect_construct(&rect, cursor_info->x, cursor_info->y, cursor_info->pr.pr_width, cursor_info->pr.pr_height); /* transform to window space */ rect_passtochild(pw->pw_clipdata->pwcd_screen_x, pw->pw_clipdata->pwcd_screen_y, &rect); /* * Since the clipping list is in the space of the pixwin, * transform the window-space cursor rect to region space. */ if (pw->pw_clipdata->pwcd_regionrect) rect_passtochild(pw->pw_clipdata->pwcd_regionrect->r_left, pw->pw_clipdata->pwcd_regionrect->r_top, &rect); /* cursor must be on the intended paint area to intersect. * Also, either this process must have the grabio lock or * the cursor must be in the exposed rectlist of pw. */ have_grabio = win_lock_grabio_locked(shared_info) && (shared_info->grabio.pid == pw_mypid); return (rect_intersectsrect(&rect, rect_paint) && (have_grabio || rl_rectintersects(&rect, &pw->pw_clipdata->pwcd_clipping)));}/* Defining MAP_FIXED is for compiling under 3.4 environment */#ifndef MAP_FIXED#define MAP_FIXED 0#endifWin_lock_block *pw_get_lock_block(windowfd) int windowfd;{ struct screen screen; register char *dtop_name = screen.scr_fbname; register int i; register Pw_dtop_entry *entry; Pw_dtop_entry *free_entry = 0; Win_lock_block *shared_info; static Win_lock_block *last_valloc; /* = 0 */ static int wrong_version; /* = 0 */ char *strcpy(); if (wrong_version || pw_disable_shared_locking) return 0; pw_mypid = getpid(); (void)win_screenget(windowfd, &screen); /* see if this dtop is already mapped in */ for (i = 0, entry = &pw_dtop_table[i]; i < WIN_LOCK_MAX_DTOP; i++, entry = &pw_dtop_table[i]) if (!entry->shared_info) { if (!free_entry) free_entry = entry; } else if (strcmp(dtop_name, entry->dtop_name) == 0) { entry->ref_count++; return entry->shared_info; } /* not already in the table, so there better be a * free slot. */ if (!free_entry) return 0; /* there is a free slot, so mmap the shared info */ if (!pw_lock_block_bytes) pw_lock_block_bytes = round_to_page(sizeof(Win_lock_block)); /* Note that here we mmap() using the windowfd and that * other windows will share this mmaped memory. * If close(windowfd) is changed to munmap() the storage, * the other windows will be left pointing to invalid storage. */ if (last_valloc) shared_info = last_valloc; else { extern char *valloc(); shared_info = (Win_lock_block *) valloc((u_int)pw_lock_block_bytes); } if ((int)mmap((caddr_t)shared_info, pw_lock_block_bytes, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, windowfd, 0) == -1) { last_valloc = shared_info; return 0; } /* if the kernel has a different version number, * don't use the shared memory. */ if (shared_info->version != WIN_LOCK_VERSION) { wrong_version = TRUE; return 0; } last_valloc = 0; entry = free_entry; entry->shared_info = shared_info; (void) strcpy(entry->dtop_name, dtop_name); entry->ref_count = 1; return shared_info;}voidpw_free_lock_block(shared_info) register Win_lock_block *shared_info;{ if (!shared_info) return;/* Don't free up the shared memory, since this is probably * no big win (and a waste of cycles). for (i = 0, entry = &pw_dtop_table[i]; i < WIN_LOCK_MAX_DTOP; i++, entry = &pw_dtop_table[i]) if (shared_info == entry->shared_info) { entry->ref_count--; if (entry->ref_count <= 0) { munmap(shared_info, pw_lock_block_bytes); free(shared_info); } return; }*/}/* Update process specific data */pw_fork(){ pw_mypid = getpid();}static intround_to_page(bytes) register int bytes;{ register int pagesize = getpagesize(); register int roundup = pagesize-(bytes%pagesize); if (roundup != pagesize) bytes += roundup; return(bytes);}pw_reset_lock(pw) Pixwin *pw;{ Win_lock_block *wl = pw->pw_clipdata->pwcd_wl; if (!wl) return; pw_release_lock(&wl->mutex); pw_release_lock(&wl->display);}/* turn shared locking on or off */pw_set_shared_locking(on) int on;{ /* pw_disable_shared_locking = !on; */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -