-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[client] x11: change to a more visible "dot" cursor
This change alters the small square dot cursor to a more visible 16x16 cursor for X11. A new option `spice:largeDotCursor` can be set to use an alternative 32x32 cursor for the vision impaired.
- Loading branch information
Showing
15 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Looking Glass | ||
* Copyright © 2017-2023 The Looking Glass Authors | ||
* https://looking-glass.io | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#include "cursor.h" | ||
#include "common/util.h" | ||
|
||
#include <string.h> | ||
#include <errno.h> | ||
|
||
struct MemFile | ||
{ | ||
const char * data; | ||
int size; | ||
int pos; | ||
}; | ||
|
||
static int x11cursor_read(XcursorFile *file, unsigned char * buf, int len) | ||
{ | ||
struct MemFile * f = (struct MemFile *)file->closure; | ||
|
||
if (f->pos == f->size) | ||
return 0; | ||
|
||
len = min(f->size - f->pos, len); | ||
memcpy(buf, f->data + f->pos, len); | ||
f->pos += len; | ||
|
||
return len; | ||
} | ||
|
||
static int x11cursor_write(XcursorFile *file, unsigned char * buf, int len) | ||
{ | ||
errno = -EINVAL; | ||
return -1; | ||
} | ||
|
||
static int x11cursor_seek(XcursorFile *file, long offset, int whence) | ||
{ | ||
struct MemFile * f = (struct MemFile *)file->closure; | ||
long target; | ||
|
||
switch(whence) | ||
{ | ||
case SEEK_SET: | ||
target = offset; | ||
break; | ||
|
||
case SEEK_CUR: | ||
target = f->pos + offset; | ||
break; | ||
|
||
case SEEK_END: | ||
target = f->size + offset; | ||
break; | ||
|
||
default: | ||
errno = -EINVAL; | ||
return -1; | ||
} | ||
|
||
if (target < 0 || target > f->size) | ||
{ | ||
errno = -EINVAL; | ||
return -1; | ||
} | ||
f->pos = target; | ||
return target; | ||
} | ||
|
||
XcursorImages * x11cursor_load(const char * cursor, int size) | ||
{ | ||
struct MemFile closure = | ||
{ | ||
.data = cursor, | ||
.size = size, | ||
.pos = 0 | ||
}; | ||
|
||
XcursorFile f = | ||
{ | ||
.closure = &closure, | ||
.read = x11cursor_read, | ||
.write = x11cursor_write, | ||
.seek = x11cursor_seek | ||
}; | ||
|
||
return XcursorXcFileLoadAllImages(&f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Looking Glass | ||
* Copyright © 2017-2023 The Looking Glass Authors | ||
* https://looking-glass.io | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#ifndef _H_X11DS_CURSOR_ | ||
#define _H_X11DS_CURSOR_ | ||
|
||
#include <X11/Xlib.h> | ||
#include <X11/Xcursor/Xcursor.h> | ||
|
||
XcursorImages * x11cursor_load(const char * cursor, int size); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 8 8 16.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
32 16 16 32.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.