xf86cursors.c
来自「显驱动 Intel英特尔G45G43G41G35G33G31G965Q963Q」· C语言 代码 · 共 648 行 · 第 1/2 页
C
648 行
y -= crtc->y; } /* * Transform position of cursor upper left corner */ xf86_crtc_rotate_coord_back (crtc->rotation, cursor_info->MaxWidth, cursor_info->MaxHeight, 0, 0, &dx, &dy); x -= dx; y -= dy; /* * Disable the cursor when it is outside the viewport */ in_range = TRUE; if (x >= mode->HDisplay || y >= mode->VDisplay || x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) { in_range = FALSE; x = 0; y = 0; } crtc->cursor_in_range = in_range; if (in_range) { crtc->funcs->set_cursor_position (crtc, x, y); xf86_crtc_show_cursor (crtc); } else xf86_crtc_hide_cursor (crtc);}static voidxf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y){ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); int c; /* undo what xf86HWCurs did to the coordinates */ x += scrn->frameX0; y += scrn->frameY0; for (c = 0; c < xf86_config->num_crtc; c++) { xf86CrtcPtr crtc = xf86_config->crtc[c]; if (crtc->enabled) xf86_crtc_set_cursor_position (crtc, x, y); }} /* * Load a two-color cursor into a crtc, performing rotation as needed */static voidxf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src){ ScrnInfoPtr scrn = crtc->scrn; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; CARD8 *cursor_image;#ifdef ARGB_CURSOR crtc->cursor_argb = FALSE;#endif if (crtc->rotation == RR_Rotate_0) cursor_image = src; else { int x, y; int xin, yin; int stride = cursor_info->MaxWidth >> 2; int flags = cursor_info->Flags; cursor_image = xf86_config->cursor_image; memset(cursor_image, 0, cursor_info->MaxWidth * stride); for (y = 0; y < cursor_info->MaxHeight; y++) for (x = 0; x < cursor_info->MaxWidth; x++) { xf86_crtc_rotate_coord (crtc->rotation, cursor_info->MaxWidth, cursor_info->MaxHeight, x, y, &xin, &yin); if (get_bit(src, stride, flags, xin, yin, FALSE)) set_bit(cursor_image, stride, flags, x, y, FALSE); if (get_bit(src, stride, flags, xin, yin, TRUE)) set_bit(cursor_image, stride, flags, x, y, TRUE); } } crtc->funcs->load_cursor_image (crtc, cursor_image);} /* * Load a cursor image into all active CRTCs */static voidxf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src){ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); int c; for (c = 0; c < xf86_config->num_crtc; c++) { xf86CrtcPtr crtc = xf86_config->crtc[c]; if (crtc->enabled) { if (crtc->funcs->load_cursor_image) xf86_crtc_load_cursor_image (crtc, src); else if (crtc->funcs->load_cursor_argb) xf86_crtc_convert_cursor_to_argb (crtc, src); } }}static Boolxf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor){ ScrnInfoPtr scrn = xf86Screens[screen->myNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; if (xf86_config->cursor) FreeCursor (xf86_config->cursor, None); xf86_config->cursor = cursor; ++cursor->refcnt; if (cursor->bits->width > cursor_info->MaxWidth || cursor->bits->height> cursor_info->MaxHeight) return FALSE; return TRUE;}static Boolxf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor){ ScrnInfoPtr scrn = xf86Screens[screen->myNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; if (xf86_config->cursor) FreeCursor (xf86_config->cursor, None); xf86_config->cursor = cursor; ++cursor->refcnt; /* Make sure ARGB support is available */ if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0) return FALSE; if (cursor->bits->width > cursor_info->MaxWidth || cursor->bits->height> cursor_info->MaxHeight) return FALSE; return TRUE;}static voidxf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor){ ScrnInfoPtr scrn = crtc->scrn; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image; CARD32 *cursor_source = (CARD32 *) cursor->bits->argb; int x, y; int xin, yin; CARD32 bits; int source_width = cursor->bits->width; int source_height = cursor->bits->height; int image_width = cursor_info->MaxWidth; int image_height = cursor_info->MaxHeight; for (y = 0; y < image_height; y++) for (x = 0; x < image_width; x++) { xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height, x, y, &xin, &yin); if (xin < source_width && yin < source_height) bits = cursor_source[yin * source_width + xin]; else bits = 0; cursor_image[y * image_width + x] = bits; } crtc->funcs->load_cursor_argb (crtc, cursor_image);}static voidxf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor){ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); int c; for (c = 0; c < xf86_config->num_crtc; c++) { xf86CrtcPtr crtc = xf86_config->crtc[c]; if (crtc->enabled) xf86_crtc_load_cursor_argb (crtc, cursor); }}_X_EXPORT Boolxf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags){ ScrnInfoPtr scrn = xf86Screens[screen->myNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info; cursor_info = xf86CreateCursorInfoRec(); if (!cursor_info) return FALSE; xf86_config->cursor_image = xalloc (max_width * max_height * 4); if (!xf86_config->cursor_image) { xf86DestroyCursorInfoRec (cursor_info); return FALSE; } xf86_config->cursor_info = cursor_info; cursor_info->MaxWidth = max_width; cursor_info->MaxHeight = max_height; cursor_info->Flags = flags; cursor_info->SetCursorColors = xf86_set_cursor_colors; cursor_info->SetCursorPosition = xf86_set_cursor_position; cursor_info->LoadCursorImage = xf86_load_cursor_image; cursor_info->HideCursor = xf86_hide_cursors; cursor_info->ShowCursor = xf86_show_cursors; cursor_info->UseHWCursor = xf86_use_hw_cursor;#ifdef ARGB_CURSOR if (flags & HARDWARE_CURSOR_ARGB) { cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb; cursor_info->LoadCursorARGB = xf86_load_cursor_argb; }#endif xf86_config->cursor = NULL; xf86_hide_cursors (scrn); return xf86InitCursor (screen, cursor_info);}/** * Called when anything on the screen is reconfigured. * * Reloads cursor images as needed, then adjusts cursor positions */_X_EXPORT voidxf86_reload_cursors (ScreenPtr screen){ ScrnInfoPtr scrn; xf86CrtcConfigPtr xf86_config; xf86CursorInfoPtr cursor_info; CursorPtr cursor; int x, y; /* initial mode setting will not have set a screen yet */ if (!screen) return; scrn = xf86Screens[screen->myNum]; xf86_config = XF86_CRTC_CONFIG_PTR(scrn); /* make sure the cursor code has been initialized */ cursor_info = xf86_config->cursor_info; if (!cursor_info) return; cursor = xf86_config->cursor; GetSpritePosition (&x, &y); if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) (*cursor_info->HideCursor)(scrn); if (cursor) {#ifdef ARGB_CURSOR if (cursor->bits->argb && cursor_info->LoadCursorARGB) (*cursor_info->LoadCursorARGB) (scrn, cursor); else#endif (*cursor_info->LoadCursorImage)(cursor_info->pScrn, cursor->devPriv[screen->myNum]); (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); (*cursor_info->ShowCursor)(cursor_info->pScrn); }}/** * Clean up CRTC-based cursor code */_X_EXPORT voidxf86_cursors_fini (ScreenPtr screen){ ScrnInfoPtr scrn = xf86Screens[screen->myNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); if (xf86_config->cursor_info) { xf86DestroyCursorInfoRec (xf86_config->cursor_info); xf86_config->cursor_info = NULL; } if (xf86_config->cursor_image) { xfree (xf86_config->cursor_image); xf86_config->cursor_image = NULL; } if (xf86_config->cursor) { FreeCursor (xf86_config->cursor, None); xf86_config->cursor = NULL; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?