| 1 | /* |
| 2 | * Copyright 2009, 2010 Red Hat, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
| 8 | * license, and/or sell copies of the Software, and to permit persons to whom |
| 9 | * the Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | */ |
| 23 | /** \file qxl_cursor.c |
| 24 | * \author Søren Sandmann <[email protected]> |
| 25 | */ |
| 26 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:410:9`! |
| 27 | #include "config.h"cxx . . $ `<file>/config.h`/ |
| 28 | #endif |
| 29 | |
| 30 | #include <string.h> |
| 31 | #include "qxl.h"cxx . . $ `<file>/src/qxl.h`/ |
| 32 | #include <cursorstr.h> |
| 33 | |
| 34 | static void |
| 35 | push_cursorcxx . . $ push_cursor(cafdee6b4ac3c810). (qxl_screen_tcxx . . $ qxl_screen_t# *qxl, struct qxl_bocxx . . $ qxl_bo# *cursor_bo) |
| 36 | { |
| 37 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->write_commandcxx . . $ qxl_bo_funcs#write_command. (qxl, QXL_CMD_CURSORcxx . . $ QXL_CMD_CURSOR., cursor_bo); |
| 38 | } |
| 39 | |
| 40 | static struct qxl_bocxx . . $ qxl_bo# * |
| 41 | qxl_alloc_cursor_cmdcxx . . $ qxl_alloc_cursor_cmd(66105c39f0a3be56).(qxl_screen_tcxx . . $ qxl_screen_t# *qxl) |
| 42 | { |
| 43 | struct qxl_bocxx . . $ qxl_bo# *bo = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->cmd_alloccxx . . $ qxl_bo_funcs#cmd_alloc. (qxl, sizeof(struct QXLCursorCmdcxx . . $ QXLCursorCmd#), "cursor command"); |
| 44 | struct QXLCursorCmdcxx . . $ QXLCursorCmd# *cmd = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_mapcxx . . $ qxl_bo_funcs#bo_map.(bo); |
| 45 | |
| 46 | cmd->release_infocxx . . $ QXLCursorCmd#release_info..idcxx . . $ QXLReleaseInfo#id. = pointer_to_u64cxx . . $ pointer_to_u64(751e5d26f8574c32). (bo) | 1; |
| 47 | |
| 48 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_unmapcxx . . $ qxl_bo_funcs#bo_unmap.(bo); |
| 49 | return bo; |
| 50 | } |
| 51 | |
| 52 | static void |
| 53 | qxl_set_cursor_positioncxx . . $ qxl_set_cursor_position(48b75b380e0d3ac6).(ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn, int x, int y) |
| 54 | { |
| 55 | qxl_screen_tcxx . . $ qxl_screen_t# *qxl = pScrn->driverPrivatecxx . . $ _ScrnInfoRec#driverPrivate.; |
| 56 | struct qxl_bocxx . . $ qxl_bo# *cmd_bo = qxl_alloc_cursor_cmdcxx . . $ qxl_alloc_cursor_cmd(66105c39f0a3be56).(qxl); |
| 57 | struct QXLCursorCmdcxx . . $ QXLCursorCmd# *cmd = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_mapcxx . . $ qxl_bo_funcs#bo_map.(cmd_bo); |
| 58 | |
| 59 | qxl->cur_xcxx . . $ _qxl_screen_t#cur_x. = x; |
| 60 | qxl->cur_ycxx . . $ _qxl_screen_t#cur_y. = y; |
| 61 | |
| 62 | cmd->typecxx . . $ QXLCursorCmd#type. = QXL_CURSOR_MOVEcxx . . $ QXL_CURSOR_MOVE.; |
| 63 | cmd->ucxx . . $ QXLCursorCmd#u..positioncxx . . $ QXLCursorCmd#$anonymous_type_8#position..xcxx . . $ QXLPoint16#x. = qxl->cur_xcxx . . $ _qxl_screen_t#cur_x. + qxl->hot_xcxx . . $ _qxl_screen_t#hot_x.; |
| 64 | cmd->ucxx . . $ QXLCursorCmd#u..positioncxx . . $ QXLCursorCmd#$anonymous_type_8#position..ycxx . . $ QXLPoint16#y. = qxl->cur_ycxx . . $ _qxl_screen_t#cur_y. + qxl->hot_ycxx . . $ _qxl_screen_t#hot_y.; |
| 65 | |
| 66 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_unmapcxx . . $ qxl_bo_funcs#bo_unmap.(cmd_bo); |
| 67 | push_cursorcxx . . $ push_cursor(cafdee6b4ac3c810).(qxl, cmd_bo); |
| 68 | } |
| 69 | |
| 70 | static void |
| 71 | qxl_load_cursor_imagecxx . . $ qxl_load_cursor_image(5e83977386480fb7).(ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn, unsigned char *bits) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | static void |
| 76 | qxl_set_cursor_colorscxx . . $ qxl_set_cursor_colors(48b75b380e0d3ac6).(ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn, int bg, int fg) |
| 77 | { |
| 78 | /* Should not be called since UseHWCursor returned FALSE */ |
| 79 | } |
| 80 | |
| 81 | static void |
| 82 | qxl_load_cursor_argbcxx . . $ qxl_load_cursor_argb(42c1441f958dee56). (ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn, CursorPtrcxx . . $ CursorPtr# pCurs) |
| 83 | { |
| 84 | qxl_screen_tcxx . . $ qxl_screen_t# *qxl = pScrn->driverPrivatecxx . . $ _ScrnInfoRec#driverPrivate.; |
| 85 | int w = pCurs->bitscxx . . $ _Cursor#bits.->widthcxx . . $ _CursorBits#width.; |
| 86 | int h = pCurs->bitscxx . . $ _Cursor#bits.->heightcxx . . $ _CursorBits#height.; |
| 87 | int size = w * h * sizeof (CARD32cxx . . $ CARD32#); |
| 88 | |
| 89 | struct qxl_bocxx . . $ qxl_bo# *cmd_bo = qxl_alloc_cursor_cmdcxx . . $ qxl_alloc_cursor_cmd(66105c39f0a3be56).(qxl); |
| 90 | struct QXLCursorCmdcxx . . $ QXLCursorCmd# *cmd; |
| 91 | struct qxl_bocxx . . $ qxl_bo# *cursor_bo = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_alloccxx . . $ qxl_bo_funcs#bo_alloc.(qxl, sizeof(struct QXLCursorcxx . . $ QXLCursor#) + size, "cursor data"); |
| 92 | struct QXLCursorcxx . . $ QXLCursor# *cursor = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_mapcxx . . $ qxl_bo_funcs#bo_map.(cursor_bo); |
| 93 | |
| 94 | cursor->headercxx . . $ QXLCursor#header..uniquecxx . . $ QXLCursorHeader#unique. = 0; |
| 95 | cursor->headercxx . . $ QXLCursor#header..typecxx . . $ QXLCursorHeader#type. = SPICE_CURSOR_TYPE_ALPHAcxx . . $ SPICE_CURSOR_TYPE_ALPHA.; |
| 96 | cursor->headercxx . . $ QXLCursor#header..widthcxx . . $ QXLCursorHeader#width. = w; |
| 97 | cursor->headercxx . . $ QXLCursor#header..heightcxx . . $ QXLCursorHeader#height. = h; |
| 98 | /* I wonder if we can just tell the client that the hotspot is 0, 0 |
| 99 | * always? The coordinates we are getting from X are for 0, 0 anyway, |
| 100 | * so the question is if the client uses the hotspot for anything else? |
| 101 | */ |
| 102 | cursor->headercxx . . $ QXLCursor#header..hot_spot_xcxx . . $ QXLCursorHeader#hot_spot_x. = pCurs->bitscxx . . $ _Cursor#bits.->xhotcxx . . $ _CursorBits#xhot.; |
| 103 | cursor->headercxx . . $ QXLCursor#header..hot_spot_ycxx . . $ QXLCursorHeader#hot_spot_y. = pCurs->bitscxx . . $ _Cursor#bits.->yhotcxx . . $ _CursorBits#yhot.; |
| 104 | |
| 105 | cursor->data_sizecxx . . $ QXLCursor#data_size. = size; |
| 106 | |
| 107 | cursor->chunkcxx . . $ QXLCursor#chunk..next_chunkcxx . . $ QXLDataChunk#next_chunk. = 0; |
| 108 | cursor->chunkcxx . . $ QXLCursor#chunk..prev_chunkcxx . . $ QXLDataChunk#prev_chunk. = 0; |
| 109 | cursor->chunkcxx . . $ QXLCursor#chunk..data_sizecxx . . $ QXLDataChunk#data_size. = size; |
| 110 | |
| 111 | memcpycxx . . $ memcpy(cc817cb175f282d). (cursor->chunkcxx . . $ QXLCursor#chunk..datacxx . . $ QXLDataChunk#data., pCurs->bitscxx . . $ _Cursor#bits.->argbcxx . . $ _CursorBits#argb., size); |
| 112 | |
| 113 | #if 0 |
| 114 | int i, j; |
| 115 | for (j = 0; j < h; ++j) |
| 116 | { |
| 117 | for (i = 0; i < w; ++i) |
| 118 | { |
| 119 | ErrorF ("%c", (pCurs->bits->argb[j * w + i] & 0xff000000) == 0xff000000? '#' : '.'); |
| 120 | } |
| 121 | |
| 122 | ErrorF ("\n"); |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_unmapcxx . . $ qxl_bo_funcs#bo_unmap.(cursor_bo); |
| 127 | |
| 128 | qxl->hot_xcxx . . $ _qxl_screen_t#hot_x. = pCurs->bitscxx . . $ _Cursor#bits.->xhotcxx . . $ _CursorBits#xhot.; |
| 129 | qxl->hot_ycxx . . $ _qxl_screen_t#hot_y. = pCurs->bitscxx . . $ _Cursor#bits.->yhotcxx . . $ _CursorBits#yhot.; |
| 130 | |
| 131 | cmd = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_mapcxx . . $ qxl_bo_funcs#bo_map.(cmd_bo); |
| 132 | cmd->typecxx . . $ QXLCursorCmd#type. = QXL_CURSOR_SETcxx . . $ QXL_CURSOR_SET.; |
| 133 | cmd->ucxx . . $ QXLCursorCmd#u..setcxx . . $ QXLCursorCmd#$anonymous_type_8#set..positioncxx . . $ QXLCursorCmd#$anonymous_type_8#$anonymous_type_9#position..xcxx . . $ QXLPoint16#x. = qxl->cur_xcxx . . $ _qxl_screen_t#cur_x. + qxl->hot_xcxx . . $ _qxl_screen_t#hot_x.; |
| 134 | cmd->ucxx . . $ QXLCursorCmd#u..setcxx . . $ QXLCursorCmd#$anonymous_type_8#set..positioncxx . . $ QXLCursorCmd#$anonymous_type_8#$anonymous_type_9#position..ycxx . . $ QXLPoint16#y. = qxl->cur_ycxx . . $ _qxl_screen_t#cur_y. + qxl->hot_ycxx . . $ _qxl_screen_t#hot_y.; |
| 135 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_output_bo_reloccxx . . $ qxl_bo_funcs#bo_output_bo_reloc.(qxl, offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:431:9`!(struct QXLCursorCmd, u.set.shape), cmd_bo, cursor_bo); |
| 136 | |
| 137 | cmd->ucxx . . $ QXLCursorCmd#u..setcxx . . $ QXLCursorCmd#$anonymous_type_8#set..visiblecxx . . $ QXLCursorCmd#$anonymous_type_8#$anonymous_type_9#visible. = TRUEcxx . . $ `<external>/6164077692963123767/macros.h:110:9`!; |
| 138 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_unmapcxx . . $ qxl_bo_funcs#bo_unmap.(cmd_bo); |
| 139 | |
| 140 | push_cursorcxx . . $ push_cursor(cafdee6b4ac3c810).(qxl, cmd_bo); |
| 141 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_decrefcxx . . $ qxl_bo_funcs#bo_decref.(qxl, cursor_bo); |
| 142 | } |
| 143 | |
| 144 | static Boolcxx . . $ Bool# |
| 145 | qxl_use_hw_cursorcxx . . $ qxl_use_hw_cursor(2e75d4dc26c3f855). (ScreenPtrcxx . . $ ScreenPtr# pScrn, CursorPtrcxx . . $ CursorPtr# pCurs) |
| 146 | { |
| 147 | /* Old-school bitmap cursors are not |
| 148 | * hardware accelerated for now. |
| 149 | */ |
| 150 | return FALSEcxx . . $ `<external>/6164077692963123767/macros.h:106:9`!; |
| 151 | } |
| 152 | |
| 153 | static Boolcxx . . $ Bool# |
| 154 | qxl_use_hw_cursorARGBcxx . . $ qxl_use_hw_cursorARGB(2e75d4dc26c3f855). (ScreenPtrcxx . . $ ScreenPtr# pScrn, CursorPtrcxx . . $ CursorPtr# pCurs) |
| 155 | { |
| 156 | return TRUEcxx . . $ `<external>/6164077692963123767/macros.h:110:9`!; |
| 157 | } |
| 158 | |
| 159 | static void |
| 160 | qxl_hide_cursorcxx . . $ qxl_hide_cursor(f1d66590ec36ebe6).(ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn) |
| 161 | { |
| 162 | qxl_screen_tcxx . . $ qxl_screen_t# *qxl = pScrn->driverPrivatecxx . . $ _ScrnInfoRec#driverPrivate.; |
| 163 | struct qxl_bocxx . . $ qxl_bo# *cmd_bo = qxl_alloc_cursor_cmdcxx . . $ qxl_alloc_cursor_cmd(66105c39f0a3be56).(qxl); |
| 164 | struct QXLCursorCmdcxx . . $ QXLCursorCmd# *cursor = qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_mapcxx . . $ qxl_bo_funcs#bo_map.(cmd_bo); |
| 165 | |
| 166 | cursor->typecxx . . $ QXLCursorCmd#type. = QXL_CURSOR_HIDEcxx . . $ QXL_CURSOR_HIDE.; |
| 167 | |
| 168 | qxl->bo_funcscxx . . $ _qxl_screen_t#bo_funcs.->bo_unmapcxx . . $ qxl_bo_funcs#bo_unmap.(cmd_bo); |
| 169 | push_cursorcxx . . $ push_cursor(cafdee6b4ac3c810).(qxl, cmd_bo); |
| 170 | } |
| 171 | |
| 172 | static void |
| 173 | qxl_show_cursorcxx . . $ qxl_show_cursor(f1d66590ec36ebe6).(ScrnInfoPtrcxx . . $ ScrnInfoPtr# pScrn) |
| 174 | { |
| 175 | /* |
| 176 | * slightly hacky, but there's no QXL_CURSOR_SHOW. Could maybe do |
| 177 | * QXL_CURSOR_SET? |
| 178 | */ |
| 179 | qxl_screen_tcxx . . $ qxl_screen_t# *qxl = pScrn->driverPrivatecxx . . $ _ScrnInfoRec#driverPrivate.; |
| 180 | |
| 181 | qxl_set_cursor_positioncxx . . $ qxl_set_cursor_position(48b75b380e0d3ac6).(pScrn, qxl->cur_xcxx . . $ _qxl_screen_t#cur_x., qxl->cur_ycxx . . $ _qxl_screen_t#cur_y.); |
| 182 | } |
| 183 | |
| 184 | hiddencxx . . $ `src/qxl.h:75:9`! void |
| 185 | qxl_cursor_initcxx . . $ qxl_cursor_init(5ab20fc0890d99f5).(ScreenPtrcxx . . $ ScreenPtr# pScreen) |
| 186 | { |
| 187 | xf86CursorInfoPtrcxx . . $ xf86CursorInfoPtr# cursor; |
| 188 | |
| 189 | cursor = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(xf86CursorInfoReccxx . . $ xf86CursorInfoRec#)); |
| 190 | if (!cursor) |
| 191 | return; |
| 192 | |
| 193 | cursor->MaxWidthcxx . . $ _xf86CursorInfoRec#MaxWidth. = cursor->MaxHeightcxx . . $ _xf86CursorInfoRec#MaxHeight. = 64; |
| 194 | /* cursor->Flags; */ |
| 195 | cursor->SetCursorPositioncxx . . $ _xf86CursorInfoRec#SetCursorPosition. = qxl_set_cursor_positioncxx . . $ qxl_set_cursor_position(48b75b380e0d3ac6).; |
| 196 | cursor->LoadCursorARGBcxx . . $ _xf86CursorInfoRec#LoadCursorARGB. = qxl_load_cursor_argbcxx . . $ qxl_load_cursor_argb(42c1441f958dee56).; |
| 197 | cursor->UseHWCursorcxx . . $ _xf86CursorInfoRec#UseHWCursor. = qxl_use_hw_cursorcxx . . $ qxl_use_hw_cursor(2e75d4dc26c3f855).; |
| 198 | cursor->UseHWCursorARGBcxx . . $ _xf86CursorInfoRec#UseHWCursorARGB. = qxl_use_hw_cursorARGBcxx . . $ qxl_use_hw_cursorARGB(2e75d4dc26c3f855).; |
| 199 | cursor->LoadCursorImagecxx . . $ _xf86CursorInfoRec#LoadCursorImage. = qxl_load_cursor_imagecxx . . $ qxl_load_cursor_image(5e83977386480fb7).; |
| 200 | cursor->SetCursorColorscxx . . $ _xf86CursorInfoRec#SetCursorColors. = qxl_set_cursor_colorscxx . . $ qxl_set_cursor_colors(48b75b380e0d3ac6).; |
| 201 | cursor->HideCursorcxx . . $ _xf86CursorInfoRec#HideCursor. = qxl_hide_cursorcxx . . $ qxl_hide_cursor(f1d66590ec36ebe6).; |
| 202 | cursor->ShowCursorcxx . . $ _xf86CursorInfoRec#ShowCursor. = qxl_show_cursorcxx . . $ qxl_show_cursor(f1d66590ec36ebe6).; |
| 203 | |
| 204 | if (!xf86InitCursorcxx . . $ xf86InitCursor(259b40070345681c).(pScreen, cursor)) |
| 205 | freecxx . . $ free(5d22bdacc48458e8).(cursor); |
| 206 | } |