tune for cursor support for compositing schema

This commit is contained in:
Vincent Wei
2020-01-08 19:28:38 +08:00
parent d25d629292
commit dd21dbdde7
4 changed files with 376 additions and 137 deletions
+14 -7
View File
@@ -52,6 +52,8 @@
#ifndef GUI_CURSOR_H
#define GUI_CURSOR_H
#include "constants.h"
/* Struct definitions */
typedef struct _CURSORDIRENTRY {
BYTE bWidth;
@@ -62,27 +64,32 @@ typedef struct _CURSORDIRENTRY {
WORD wYhotspot;
DWORD lBytesInRes;
DWORD dwImageOffset;
}CURSORDIRENTRY;
} CURSORDIRENTRY;
typedef struct _CURSORDIR {
WORD cdReserved;
WORD cdType; // must be 2.
WORD cdType; // must be 2.
WORD cdCount;
}CURSORDIR;
} CURSORDIR;
typedef struct _CURSOR {
int xhotspot;
int yhotspot;
#if IS_COMPOSITING_SCHEMA
/* Since 4.2.0; for compositing schema */
void* surface;
#else
int width;
int height;
void* AndBits;
void* XorBits;
}CURSOR;
#endif
} CURSOR;
typedef CURSOR* PCURSOR;
#define CURSORWIDTH 32
#define CURSORHEIGHT 32
#define MONOSIZE (CURSORWIDTH*CURSORHEIGHT/8)
#define CURSORWIDTH 32
#define CURSORHEIGHT 32
#define MONOSIZE (CURSORWIDTH*CURSORHEIGHT/8)
#define MONOPITCH 4
/* Function definitions */
+5
View File
@@ -116,9 +116,14 @@ typedef struct tagG_RES {
int csr_show_count;
int csrnum;
#ifdef _MGUSE_COMPOSITING
DWORD __align;
HCURSOR sys_cursors[0];
#else
unsigned long svdbitsoffset;
unsigned long csroffset;
#endif
#endif
/*
int sysfontnum;
+293 -130
View File
File diff suppressed because it is too large Load Diff
+64
View File
@@ -92,6 +92,68 @@
#define CURSORSECTION "cursorinfo"
#ifdef _MGUSE_COMPOSITING
static BOOL LoadCursorRes (void)
{
int number;
int i;
char szValue [12];
if (GetMgEtcValue (CURSORSECTION, "cursornumber", szValue, 10) < 0) {
_ERR_PRINTF ("Failed to get number of system cursors\n");
return FALSE;
}
number = atoi (szValue);
if (number < 0) {
_ERR_PRINTF ("Bad number of system cursor: %d\n", number);
return FALSE;
}
number = number < (MAX_SYSCURSORINDEX + 1) ? number : (MAX_SYSCURSORINDEX + 1);
// realloc for shared resource
mgSharedRes = realloc (mgSharedRes, mgSizeRes + number * (sizeof (HCURSOR)));
if (mgSharedRes == NULL) {
_ERR_PRINTF ("Failed to realloc shared memory for system cursor.\n");
return FALSE;
}
// set cursor number
((PG_RES)mgSharedRes)->csrnum = number;
mgSizeRes += number * (sizeof (HCURSOR));
for (i = 0; i < number; i++) {
((PG_RES)mgSharedRes)->sys_cursors[i] = NULL;
}
for (i = 0; i < number; i++) {
PCURSOR tempcsr;
if (!(tempcsr = sysres_load_system_cursor (i)))
goto error;
((PG_RES)mgSharedRes)->sys_cursors[i] = tempcsr;
}
return TRUE;
error:
for (i = 0; i < number; i++) {
PCURSOR tempcsr;
tempcsr = ((PG_RES)mgSharedRes)->sys_cursors[i];
if (tempcsr) {
GAL_FreeCursorSurface (tempcsr->surface);
free (tempcsr);
((PG_RES)mgSharedRes)->sys_cursors[i] = NULL;
}
}
return FALSE;
}
#else /* _MGUSE_COMPOSITING */
extern unsigned int __mg_csrimgpitch;
static BOOL LoadCursorRes (void)
{
@@ -151,6 +213,8 @@ error:
return FALSE;
}
#endif /* _MGUSE_COMPOSITING */
#endif /* _MGHAVE_CURSOR */
inline static key_t get_shm_key (void)