mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 11:01:57 +08:00
Do mot check whether joined a layer for request REQID_GETWPSURFACE
This commit is contained in:
@@ -182,6 +182,9 @@ int GUIAPI ClientRequestEx2 (const REQUEST* request,
|
||||
#elif defined(_MGGAL_NEXUS)
|
||||
if ((request->id != REQID_NEXUS_CLIENT_GET_SURFACE)
|
||||
&& (__mg_client_id == 0 && request->id != REQID_JOINLAYER)) {
|
||||
#elif defined(_MGUSE_COMPOSITING)
|
||||
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER &&
|
||||
request->id != REQID_GETWPSURFACE) {
|
||||
#else
|
||||
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER) {
|
||||
#endif
|
||||
|
||||
@@ -370,6 +370,10 @@ GAL_Rect ** GAL_ListModes (GAL_PixelFormat *format, Uint32 flags);
|
||||
GAL_Surface *GAL_SetVideoMode
|
||||
(int width, int height, int bpp, Uint32 flags);
|
||||
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
void GAL_SetVideoModeInfo(GAL_Surface* screen);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Makes sure the given list of rectangles is updated on the given screen.
|
||||
* If 'x', 'y', 'w' and 'h' are all 0, GAL_UpdateRect will update the entire
|
||||
|
||||
@@ -85,6 +85,8 @@ typedef struct tagG_RES {
|
||||
char video_exdriver [LEN_EXDRIVER_NAME + 1];
|
||||
char video_fourcc [LEN_FOURCC_FORMAT + 1];
|
||||
int video_dpi;
|
||||
int video_depth;
|
||||
Uint32 video_rmask, video_gmask, video_bmask, video_amask;
|
||||
|
||||
int nr_layers;
|
||||
int semid_layer;
|
||||
@@ -141,12 +143,17 @@ typedef struct tagG_RES {
|
||||
} G_RES;
|
||||
typedef G_RES* PG_RES;
|
||||
|
||||
#define SHAREDRES_VIDEO_ENGINE (((PG_RES)mgSharedRes)->video_engine)
|
||||
#define SHAREDRES_VIDEO_MODE (((PG_RES)mgSharedRes)->video_mode)
|
||||
#define SHAREDRES_VIDEO_DEVICE (((PG_RES)mgSharedRes)->video_device)
|
||||
#define SHAREDRES_VIDEO_FOURCC (((PG_RES)mgSharedRes)->video_fourcc)
|
||||
#define SHAREDRES_VIDEO_DPI (((PG_RES)mgSharedRes)->video_dpi)
|
||||
#define SHAREDRES_VIDEO_EXDRIVER (((PG_RES)mgSharedRes)->video_exdriver)
|
||||
#define SHAREDRES_VIDEO_ENGINE (((PG_RES)mgSharedRes)->video_engine)
|
||||
#define SHAREDRES_VIDEO_MODE (((PG_RES)mgSharedRes)->video_mode)
|
||||
#define SHAREDRES_VIDEO_DEVICE (((PG_RES)mgSharedRes)->video_device)
|
||||
#define SHAREDRES_VIDEO_FOURCC (((PG_RES)mgSharedRes)->video_fourcc)
|
||||
#define SHAREDRES_VIDEO_DPI (((PG_RES)mgSharedRes)->video_dpi)
|
||||
#define SHAREDRES_VIDEO_EXDRIVER (((PG_RES)mgSharedRes)->video_exdriver)
|
||||
#define SHAREDRES_VIDEO_DEPTH (((PG_RES)mgSharedRes)->video_depth)
|
||||
#define SHAREDRES_VIDEO_RMASK (((PG_RES)mgSharedRes)->video_rmask)
|
||||
#define SHAREDRES_VIDEO_GMASK (((PG_RES)mgSharedRes)->video_gmask)
|
||||
#define SHAREDRES_VIDEO_BMASK (((PG_RES)mgSharedRes)->video_bmask)
|
||||
#define SHAREDRES_VIDEO_AMASK (((PG_RES)mgSharedRes)->video_amask)
|
||||
|
||||
#define SHAREDRES_TIMER_COUNTER (((PG_RES)mgSharedRes)->timer_counter)
|
||||
#define SHAREDRES_TICK_ON_LOCKSEM (((PG_RES)mgSharedRes)->tick_on_locksem)
|
||||
|
||||
@@ -485,7 +485,12 @@ int InitGUI (int argc, const char* agr[])
|
||||
if (GetMgEtcValue (engine, "exdriver", SHAREDRES_VIDEO_EXDRIVER, LEN_EXDRIVER_NAME) < 0)
|
||||
*SHAREDRES_VIDEO_EXDRIVER = 0;
|
||||
|
||||
SHAREDRES_VIDEO_DPI = __gal_screen->dpi;
|
||||
SHAREDRES_VIDEO_DPI = __gal_screen->dpi;
|
||||
SHAREDRES_VIDEO_DEPTH = __gal_screen->format->BytesPerPixel;
|
||||
SHAREDRES_VIDEO_RMASK = __gal_screen->format->Rmask;
|
||||
SHAREDRES_VIDEO_GMASK = __gal_screen->format->Gmask;
|
||||
SHAREDRES_VIDEO_BMASK = __gal_screen->format->Bmask;
|
||||
SHAREDRES_VIDEO_AMASK = __gal_screen->format->Amask;
|
||||
}
|
||||
else {
|
||||
_DBG_PRINTF("Engien info from shared resource: %s %s %d\n",
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _DEBUG
|
||||
#include "common.h"
|
||||
#include "minigui.h"
|
||||
#include "constants.h"
|
||||
@@ -65,6 +66,10 @@
|
||||
|
||||
GAL_Surface* __gal_screen;
|
||||
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
GAL_Surface* __gal_fake_screen;
|
||||
#endif
|
||||
|
||||
RECT GUIAPI GetScreenRect (void)
|
||||
{
|
||||
RECT rc = { 0, 0, __gal_screen->w, __gal_screen->h };
|
||||
@@ -143,10 +148,102 @@ static int get_dpi_from_etc (const char* engine)
|
||||
return dpi;
|
||||
}
|
||||
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
|
||||
#define LEN_WALLPAPER_PATTER_SIZE 31
|
||||
#include "client.h"
|
||||
|
||||
static GAL_Surface* create_wp_surface(GAL_Surface* screen)
|
||||
{
|
||||
GAL_Surface* wp_surf;
|
||||
if (IsServer()) {
|
||||
int size[2];
|
||||
char wp_size [LEN_WALLPAPER_PATTER_SIZE + 1];
|
||||
|
||||
if (GetMgEtcValue ("compositing_schema", "wallpaper_pattern_size",
|
||||
wp_size, LEN_WALLPAPER_PATTER_SIZE) < 0) {
|
||||
strcpy (wp_size, "empty");
|
||||
}
|
||||
|
||||
// parse wallpaper pattern size
|
||||
if (strcasecmp (wp_size, "full") == 0) {
|
||||
size[0] = screen->w;
|
||||
size[1] = screen->h;
|
||||
}
|
||||
else if (strcasecmp (wp_size, "half") == 0) {
|
||||
size[0] = screen->w >> 1;
|
||||
size[1] = screen->h >> 1;
|
||||
}
|
||||
else if (strcasecmp (wp_size, "quarter") == 0) {
|
||||
size[0] = screen->w >> 2;
|
||||
size[1] = screen->h >> 2;
|
||||
}
|
||||
else if (strcasecmp (wp_size, "octant") == 0) {
|
||||
size[0] = screen->w >> 3;
|
||||
size[1] = screen->h >> 3;
|
||||
}
|
||||
else if (strcasecmp (wp_size, "empty") == 0) {
|
||||
size[0] = 0;
|
||||
size[1] = 0;
|
||||
}
|
||||
else if (__mg_extract_integers (wp_size, 'x', size, 2) < 2) {
|
||||
size[0] = 0;
|
||||
size[1] = 0;
|
||||
}
|
||||
|
||||
_DBG_PRINTF ("wallpaper pattern size: %d x %d\n", size[0], size[1]);
|
||||
|
||||
if (size[0] > 0 && size[1] > 0) {
|
||||
wp_surf = GAL_CreateSharedRGBSurface (screen->video,
|
||||
GAL_HWSURFACE, 0666, size[0], size[1],
|
||||
screen->format->BitsPerPixel,
|
||||
screen->format->Rmask, screen->format->Gmask,
|
||||
screen->format->Bmask, screen->format->Amask);
|
||||
}
|
||||
else {
|
||||
goto empty;
|
||||
}
|
||||
|
||||
return wp_surf;
|
||||
}
|
||||
else {
|
||||
REQUEST req;
|
||||
int fd = -1;
|
||||
size_t map_size;
|
||||
|
||||
req.id = REQID_GETWPSURFACE;
|
||||
req.data = &fd;
|
||||
req.len_data = sizeof(int);
|
||||
|
||||
if ((ClientRequestEx2 (&req, NULL, 0, -1,
|
||||
&map_size, sizeof (size_t), &fd) < 0) || (fd < 0))
|
||||
goto empty;
|
||||
|
||||
_DBG_PRINTF ("REQID_GETWPSURFACE: map_size: %lu, fd: %d\n", map_size, fd);
|
||||
assert (map_size > 0);
|
||||
|
||||
wp_surf = GAL_AttachSharedRGBSurface (fd, map_size,
|
||||
GAL_HWSURFACE, TRUE);
|
||||
close (fd);
|
||||
|
||||
return wp_surf;
|
||||
}
|
||||
|
||||
empty:
|
||||
_DBG_PRINTF ("creating an empty wallpaper pattern surface\n");
|
||||
return GAL_CreateRGBSurface (GAL_SWSURFACE, 0, 0,
|
||||
screen->format->BitsPerPixel,
|
||||
screen->format->Rmask, screen->format->Gmask,
|
||||
screen->format->Bmask, screen->format->Amask);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int mg_InitGAL (char* engine, char* mode)
|
||||
{
|
||||
int i;
|
||||
int w, h, depth;
|
||||
BOOL need_set_mode = TRUE;
|
||||
|
||||
LICENSE_CHECK_CUSTIMER_ID ();
|
||||
|
||||
@@ -157,6 +254,13 @@ int mg_InitGAL (char* engine, char* mode)
|
||||
else {
|
||||
strncpy (engine, SHAREDRES_VIDEO_ENGINE, LEN_ENGINE_NAME);
|
||||
engine [LEN_ENGINE_NAME] = '\0';
|
||||
|
||||
strncpy (mode, SHAREDRES_VIDEO_MODE, LEN_VIDEO_MODE);
|
||||
mode [LEN_VIDEO_MODE] = '\0';
|
||||
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
need_set_mode = FALSE;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
get_engine_from_etc (engine);
|
||||
@@ -175,35 +279,41 @@ int mg_InitGAL (char* engine, char* mode)
|
||||
return ERR_NO_MATCH;
|
||||
}
|
||||
|
||||
#ifdef _MGRM_PROCESSES
|
||||
if (IsServer()) {
|
||||
if (need_set_mode) {
|
||||
get_mode_from_etc (engine, mode);
|
||||
}
|
||||
else {
|
||||
strncpy (mode, SHAREDRES_VIDEO_MODE, LEN_VIDEO_MODE);
|
||||
mode [LEN_VIDEO_MODE] = '\0';
|
||||
}
|
||||
#else
|
||||
get_mode_from_etc (engine, mode);
|
||||
#endif /* _MGRM_PROCESSES */
|
||||
|
||||
if (mode[0] == 0) {
|
||||
return ERR_CONFIG_FILE;
|
||||
if (mode[0] == 0) {
|
||||
return ERR_CONFIG_FILE;
|
||||
}
|
||||
|
||||
if (!GAL_ParseVideoMode (mode, &w, &h, &depth)) {
|
||||
GAL_VideoQuit ();
|
||||
_ERR_PRINTF ("NEWGAL: bad video mode parameter: %s.\n", mode);
|
||||
return ERR_CONFIG_FILE;
|
||||
}
|
||||
|
||||
if (!(__gal_screen = GAL_SetVideoMode (w, h, depth, GAL_HWPALETTE))) {
|
||||
GAL_VideoQuit ();
|
||||
_ERR_PRINTF ("NEWGAL: Set video mode failure.\n");
|
||||
return ERR_GFX_ENGINE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GAL_ParseVideoMode (mode, &w, &h, &depth)) {
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
if (!(__gal_fake_screen = create_wp_surface(__gal_screen))) {
|
||||
GAL_VideoQuit ();
|
||||
_ERR_PRINTF ("NEWGAL: bad video mode parameter: %s.\n", mode);
|
||||
return ERR_CONFIG_FILE;
|
||||
}
|
||||
|
||||
if (!(__gal_screen = GAL_SetVideoMode (w, h, depth, GAL_HWPALETTE))) {
|
||||
GAL_VideoQuit ();
|
||||
_ERR_PRINTF ("NEWGAL: Set video mode failure.\n");
|
||||
_ERR_PRINTF ("NEWGAL: Failed to create wallpaper pattern surface.\n");
|
||||
return ERR_GFX_ENGINE;
|
||||
}
|
||||
|
||||
#ifndef _MGRM_THREADS
|
||||
if (!IsServer()) {
|
||||
__gal_screen = __gal_fake_screen;
|
||||
|
||||
GAL_SetVideoModeInfo(__gal_screen);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 /* no need when we use the video infor in shared resource */
|
||||
if (w != __gal_screen->w || h != __gal_screen->h) {
|
||||
_ERR_PRINTF ("The resolution specified in MiniGUI.cfg is not "
|
||||
"the same as the actual resolution: %dx%d.\n"
|
||||
@@ -214,15 +324,13 @@ int mg_InitGAL (char* engine, char* mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MGRM_PROCESSES
|
||||
if (IsServer()) {
|
||||
if (need_set_mode) {
|
||||
__gal_screen->dpi = get_dpi_from_etc (engine);
|
||||
}
|
||||
#ifdef _MGRM_PROCESSES
|
||||
else {
|
||||
__gal_screen->dpi = SHAREDRES_VIDEO_DPI;
|
||||
}
|
||||
#else
|
||||
__gal_screen->dpi = get_dpi_from_etc (engine);
|
||||
#endif /* _MGRM_PROCESSES */
|
||||
|
||||
for (i = 0; i < 17; i++) {
|
||||
|
||||
@@ -174,14 +174,19 @@ void GAL_FreeCursorSurface (GAL_Surface *surface)
|
||||
|
||||
void GAL_SetCursor (GAL_Surface* surface, int hot_x, int hot_y)
|
||||
{
|
||||
GAL_VideoDevice *video = surface->video;
|
||||
if (surface) {
|
||||
GAL_VideoDevice *video = surface->video;
|
||||
|
||||
if (surface->hwdata) {
|
||||
assert (video->SetCursor);
|
||||
video->SetCursor (video, surface, hot_x, hot_y);
|
||||
if (surface->hwdata) {
|
||||
assert (video->SetCursor);
|
||||
video->SetCursor (video, surface, hot_x, hot_y);
|
||||
}
|
||||
else {
|
||||
// TODO: software cursor
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO: software cursor
|
||||
// TODO: hide cursor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,14 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
|
||||
GAL_Surface *screen;
|
||||
GAL_Surface *surface;
|
||||
|
||||
/* Check to see if we desire the surface in video memory */
|
||||
if (video == NULL) {
|
||||
video = __mg_current_video;
|
||||
}
|
||||
|
||||
screen = GAL_PublicSurface;
|
||||
assert (width > 0 && height > 0);
|
||||
|
||||
/* Check to see if we desire the surface in video memory */
|
||||
screen = GAL_PublicSurface;
|
||||
if (screen && ((screen->flags & GAL_HWSURFACE) == GAL_HWSURFACE)) {
|
||||
if ((flags & (GAL_SRCCOLORKEY | GAL_SRCALPHA)) != 0) {
|
||||
flags |= GAL_HWSURFACE;
|
||||
@@ -141,7 +142,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
|
||||
#endif
|
||||
|
||||
/* Get the pixels */
|
||||
if (surface->w && surface->h) {
|
||||
{
|
||||
int fd = -1;
|
||||
size_t buf_size;
|
||||
off_t buf_off;
|
||||
|
||||
@@ -1740,18 +1740,6 @@ void GAL_FreeSurface (GAL_Surface *surface)
|
||||
return;
|
||||
}
|
||||
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
if (surface->shared_header) {
|
||||
if (surface->shared_header->creator == getpid())
|
||||
GAL_FreeSharedSurfaceData(surface);
|
||||
else
|
||||
GAL_DettachSharedSurfaceData(surface);
|
||||
|
||||
surface->hwdata = NULL;
|
||||
surface->pixels = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MGUSE_SYNC_UPDATE
|
||||
EmptyClipRgn (&surface->update_region);
|
||||
#endif
|
||||
@@ -1770,6 +1758,19 @@ void GAL_FreeSurface (GAL_Surface *surface)
|
||||
surface->map = NULL;
|
||||
}
|
||||
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
if (surface->shared_header) {
|
||||
if (surface->shared_header->creator == getpid())
|
||||
GAL_FreeSharedSurfaceData(surface);
|
||||
else
|
||||
GAL_DettachSharedSurfaceData(surface);
|
||||
|
||||
surface->hwdata = NULL;
|
||||
surface->pixels = NULL;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if ((surface->flags & GAL_HWSURFACE) == GAL_HWSURFACE) {
|
||||
GAL_VideoDevice *video = surface->video;
|
||||
|
||||
|
||||
@@ -536,16 +536,17 @@ GAL_Surface * GAL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
||||
video_h = height;
|
||||
video_bpp = bpp;
|
||||
#ifdef _MGRM_PROCESSES
|
||||
if (mgIsServer && !GAL_GetVideoMode(&video_w, &video_h, &video_bpp, flags)){
|
||||
if (mgIsServer && !GAL_GetVideoMode(&video_w, &video_h, &video_bpp, flags)) {
|
||||
#else
|
||||
|
||||
if (!GAL_GetVideoMode(&video_w, &video_h, &video_bpp, flags)) {
|
||||
#endif
|
||||
GAL_SetError ("NEWGAL: GAL_GetVideoMode error, "
|
||||
"not supported video mode: %dx%d-%dbpp.\n",
|
||||
video_w, video_h, video_bpp);
|
||||
return(NULL);
|
||||
}
|
||||
GAL_SetError ("NEWGAL: GAL_GetVideoMode error, "
|
||||
"not supported video mode: %dx%d-%dbpp.\n",
|
||||
video_w, video_h, video_bpp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Check the requested flags */
|
||||
/* There's no palette in > 8 bits-per-pixel mode */
|
||||
if (video_bpp > 8) {
|
||||
@@ -630,6 +631,23 @@ GAL_Surface * GAL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
||||
return(GAL_PublicSurface);
|
||||
}
|
||||
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
void GAL_SetVideoModeInfo(GAL_Surface* screen)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
GAL_VideoSurface = screen;
|
||||
__mg_current_video->info.vfmt = __gal_screen->format;
|
||||
__mg_current_video->offset_x = 0;
|
||||
__mg_current_video->offset_y = 0;
|
||||
|
||||
__gal_screen->video = __mg_current_video;
|
||||
__gal_screen->offset = 0;
|
||||
GAL_SetClipRect(screen, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a surface into the video pixel format.
|
||||
*/
|
||||
@@ -990,7 +1008,6 @@ int GAL_SetColors(GAL_Surface *screen, GAL_Color *colors, int firstcolor,
|
||||
*/
|
||||
void GAL_VideoQuit (void)
|
||||
{
|
||||
GAL_Surface *ready_to_go;
|
||||
|
||||
if (__mg_current_video) {
|
||||
GAL_VideoDevice *video = __mg_current_video;
|
||||
@@ -999,10 +1016,23 @@ void GAL_VideoQuit (void)
|
||||
video->VideoQuit (this);
|
||||
|
||||
if (GAL_VideoSurface != NULL) {
|
||||
#ifdef _MGUSE_COMPOSITING
|
||||
GAL_VideoSurface = NULL;
|
||||
if (IsServer()) {
|
||||
GAL_FreeSurface (__gal_screen);
|
||||
GAL_FreeSurface (__gal_fake_screen);
|
||||
}
|
||||
else {
|
||||
GAL_FreeSurface (__gal_screen);
|
||||
}
|
||||
#else
|
||||
GAL_Surface *ready_to_go;
|
||||
ready_to_go = GAL_VideoSurface;
|
||||
GAL_VideoSurface = NULL;
|
||||
GAL_FreeSurface (ready_to_go);
|
||||
#endif
|
||||
}
|
||||
|
||||
GAL_PublicSurface = NULL;
|
||||
/* Clean up miscellaneous memory */
|
||||
if (video->physpal) {
|
||||
@@ -1016,7 +1046,7 @@ void GAL_VideoQuit (void)
|
||||
__mg_current_video = NULL;
|
||||
|
||||
#ifdef _MGUSE_SYNC_UPDATE
|
||||
DestroyFreeClipRectList (&__mg_free_update_region_list);
|
||||
DestroyFreeClipRectList (&__mg_free_update_region_list);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -702,11 +702,21 @@ extern int clipboard_op (int cli, int clifd, void* buff, size_t len);
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
static int get_wp_surface (int cli, int clifd, void* buff, size_t len)
|
||||
{
|
||||
int fd = 0;
|
||||
size_t map_size;
|
||||
|
||||
/* TODO: get file descriptor of wallpaper pattern surface here */
|
||||
assert (__gal_fake_screen);
|
||||
|
||||
return ServerSendReplyEx (clifd, NULL, 0, fd);
|
||||
if (__gal_fake_screen->shared_header) {
|
||||
map_size = sizeof (GAL_SharedSurfaceHeader);
|
||||
map_size += __gal_fake_screen->shared_header->buf_size;
|
||||
|
||||
return ServerSendReplyEx (clifd, &map_size, sizeof (size_t),
|
||||
__gal_fake_screen->shared_header->fd);
|
||||
}
|
||||
else {
|
||||
map_size = 0;
|
||||
return ServerSendReplyEx (clifd, &map_size, sizeof (size_t), -1);
|
||||
}
|
||||
}
|
||||
#endif /* IS_COMPOSITING_SCHEMA */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user