mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-06 02:01:50 +08:00
initial implementation for named shared surface
This commit is contained in:
@@ -41,7 +41,7 @@ which is an mainline release with some major enhancements:
|
||||
|
||||
* ENHANCEMENTS:
|
||||
- Optimize NEWGAL engines: `shadow`, `drm`, and `fbcon` for large resolution.
|
||||
- New APIs: `GetWindowSurfaceBufferFD()` and `CreateMemDCFromSurfaceBufferFD()` for compositing schema.
|
||||
- New APIs: `GetWindowSharedSurfaceFD()` and `CreateMemDCFromSharedSurfaceFD()` for compositing schema.
|
||||
* CHANGES:
|
||||
- The operations for DRM userland driver changed.
|
||||
|
||||
|
||||
250
include/gdi.h
250
include/gdi.h
@@ -1705,24 +1705,260 @@ MG_EXPORT BOOL GUIAPI IsScreenDC (HDC hdc);
|
||||
MG_EXPORT BOOL GUIAPI IsWindowDC (HDC hdc);
|
||||
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
struct GAL_Surface;
|
||||
typedef struct GAL_Surface *HSURF;
|
||||
|
||||
/**
|
||||
* \fn HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd);
|
||||
* \brief Creates a memory DC from a file descriptor of a surface buffer.
|
||||
* \fn HSURF GUIAPI CreateSharedSurface (const char *name, DWORD flags,
|
||||
* int width, int height, int depth,
|
||||
* Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
* \brief Creates a shared surface for specified size and pixel format.
|
||||
*
|
||||
* This function creates a memory DC from the specified file descriptor \a fd,
|
||||
* which represents a surface buffer.
|
||||
* This function creates a shared surface on the current video device with
|
||||
* the specified size and pixel format. This function also registers
|
||||
* the shared surface by using the specified name \a name to the server
|
||||
* if \a name is not NULL. Another client can use the name to retrieve
|
||||
* the shared surface by calling \a RetrieveSharedSurfaceFDByName().
|
||||
|
||||
* \param video The handle to the video; NULL for the current default video.
|
||||
* \param name The gobal unique name for the shared surface.
|
||||
* \param flags The flags, can be one of the following values:
|
||||
* - MEMDC_FLAG_SWSURFACE\n
|
||||
* Creates the surface in the system memory.
|
||||
* - MEMDC_FLAG_HWSURFACE\n
|
||||
* Creates the surface in the video memory.
|
||||
* \param width The expected width of the result surface.
|
||||
* \param height The expected height of the result surface.
|
||||
* \param depth The expected color depth of the surface.
|
||||
* \param Rmask The bit-masks of the red components in a pixel value.
|
||||
* \param Gmask The bit-masks of the green components in a pixel value.
|
||||
* \param Bmask The bit-masks of the blue components in a pixel value.
|
||||
* \param Amask The bit-masks of the alpha components in a pixel value.
|
||||
*
|
||||
* \param fd The file descriptor which represents a surface buffer.
|
||||
* \return The file descriptor which represents the new shared surface buffer;
|
||||
* a value less than 0 indicates an error.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa DestroySharedSurface, RetrieveSharedSurfaceFDByName
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT HSURF GUIAPI CreateSharedSurface (const char *name, DWORD flags,
|
||||
int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI GUIAPI DestroySharedSurface (HSURF surf, const char *name)
|
||||
* \brief Destroies a shared surface.
|
||||
*
|
||||
* This function destroies the specified shared surface \a surf,
|
||||
* and/or revoke the global unique name \a name from the server if \a name
|
||||
* is not NULL.
|
||||
* \param surf The handle to the shared surface.
|
||||
* \param name The gobal unique name for the shared surface.
|
||||
*
|
||||
* \return TRUE on success, otherwise failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa CreateSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI DestroySharedSurface (HSURF surf);
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetSharedSurfaceFDByClientWindow (int client,
|
||||
* HWND hwnd)
|
||||
* \brief Gets the file descriptor of the shared surface of a window created
|
||||
* by another client.
|
||||
*
|
||||
* This function gets the file descriptor of the shared surface of the window
|
||||
* \a hwnd, which is created by another client. If there is one such window
|
||||
* in the system, the server will return a file descriptor which represents
|
||||
* the shared surface of the window to the caller.
|
||||
*
|
||||
* \param client The client identifier.
|
||||
* \param hwnd The handle to the window created by the client.
|
||||
*
|
||||
* \return The file descriptor which represents the shared surface on success;
|
||||
* a value less than 0 for failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa CreateSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetSharedSurfaceFDByClientWindow (int client,
|
||||
HWND hwnd);
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetSharedSurfaceFDByName (const char *name)
|
||||
* \brief Gets the file descriptor of a shared surface by name.
|
||||
*
|
||||
* This function gets the file descriptor of the shared surface created
|
||||
* by \a CreateSharedSurface by another client. If there is one such window
|
||||
* in the system, the server will return a file descriptor which represents
|
||||
* the shared surface.
|
||||
*
|
||||
* \param name The gobal unique name for the shared surface.
|
||||
*
|
||||
* \return The file descriptor which represents the shared surface on success;
|
||||
* a value less than 0 for failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa CreateSharedSurface, AttachToSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetSharedSurfaceFDByName (const char *name);
|
||||
|
||||
/**
|
||||
* \fn HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd)
|
||||
* \brief Attaches to a shared surface.
|
||||
*
|
||||
* This function attaches to the shared surface which is represents by
|
||||
* the given file descriptor \a fd.
|
||||
*
|
||||
* \param video The handle to the video; NULL for the current default video.
|
||||
* \param fd The file descriptor of the shared surface.
|
||||
*
|
||||
* \return The handle to the shared surface on success; NULL for failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa GetSharedSurfaceFDByName, DetachFromSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd);
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
|
||||
* size_t *file_size, size_t *pixel_off)
|
||||
* \brief Gets the file descriptor of a shared surface.
|
||||
*
|
||||
* This function gets the file descriptor of the shared surface. It also
|
||||
* returns the size and the pitch of the surface if \a size or \a pitch is
|
||||
* not NULL.
|
||||
*
|
||||
* \param surf The handle to the shared surface.
|
||||
* \param size The pointer to a buffer of SIZE to return the size of
|
||||
* the shared surface; nullable.
|
||||
* \param pitch The pointer to a buffer of int for value of pitch; nullable.
|
||||
* \param file_size The pointer to a buffer of size_t for the whole file size;
|
||||
* nullable.
|
||||
* \param pixel_off The pointer to a buffer of size_t for the offset of
|
||||
* pixel data; nullable.
|
||||
*
|
||||
* \return The file descriptor of the shared surface on success;
|
||||
* a value less than zero for failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa GetSharedSurfaceFDByName, DetachFromSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
|
||||
size_t *file_size, size_t *pixel_off);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI LockSharedSurfaceIfDirty (HSURF surf,
|
||||
* unsigned old_dirty_age, unsigned *dirty_age,
|
||||
* int *nr_dirty_rects, RECT *const *dirty_rects)
|
||||
* \brief Locks the shared surface if it is dirty.
|
||||
*
|
||||
* This function compares the dirty age of the shared surface with the value
|
||||
* containing in \a dirty_age, and lock the shared surface if it has
|
||||
* a larger dirty age value.
|
||||
*
|
||||
* \param surf The handle to the shared surface.
|
||||
* \param old_dirty_age The old dirty age.
|
||||
* \param dirty_age The pointer to a buffer of unsigned integer to return
|
||||
* the current dirty age of the shared surface.
|
||||
* \param nr_dirty_rects The pointer to a buffer of integer to return the valid
|
||||
* dirty rectangles; nullable.
|
||||
* \param dirty_rects The pointer to a buffer of (const RECT *) for the array
|
||||
* of dirty rectangles; nullable.
|
||||
*
|
||||
* \return TRUE for success and if the value contains in \a dirty_age is larger
|
||||
* than \a old_dirty_age, the surface was locked; otherwise failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa UnlockSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI LockSharedSurfaceIfDirty (HSURF surf,
|
||||
unsigned old_dirty_age, unsigned *dirty_age,
|
||||
int *nr_dirty_rects, RECT *const *dirty_rects);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI UnlockSharedSurface (HSURF surf, BOOL clear_dirty)
|
||||
* \brief Unocks the shared surface and clears the dirty information.
|
||||
*
|
||||
* This function compares the dirty age of the shared surface with the value
|
||||
* containing in \a dirty_age, and lock the shared surface if it has
|
||||
* a larger dirty age value.
|
||||
*
|
||||
* \param surf The handle to the shared surface.
|
||||
* \param clear_dirty A boolean value indicates whether to clear the dirty
|
||||
* information of the shared surface.
|
||||
*
|
||||
* \return TRUE on success; otherwise failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa LockSharedSurfaceIfDirty
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI UnlockSharedSurface (HSURF surf, BOOL clear_dirty);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI DetachFromSharedSurface (HSURF surf)
|
||||
* \brief Detaches from a shared surface.
|
||||
*
|
||||
* This function detaches from the shared surface \a surf and delete the memory
|
||||
* used by the surface.
|
||||
*
|
||||
* \param surf The handle to the shared surface.
|
||||
*
|
||||
* \return TRUE on success; otherwise failure.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa AttachToSharedSurface
|
||||
*
|
||||
* Since 5.2.0
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI DetachFromSharedSurface (HSURF surf);
|
||||
|
||||
/**
|
||||
* \fn HDC GUIAPI CreateMemDCOnSharedSurface (HSURF surf, const RECT *rect);
|
||||
* \brief Creates a memory DC on a shared surface.
|
||||
*
|
||||
* This function creates a memory DC on the specified shared surface \a surf
|
||||
* within the specified rectangle \a rect on the surface.
|
||||
*
|
||||
* \param surf The handle to the shared surface.
|
||||
* \param rect A rectangle in the surface which defines the bounds of memory DC;
|
||||
* NULL for whole surface.
|
||||
*
|
||||
* \return The handle to a new memory DC, HDC_INVALID indicates an error.
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa GetWindowSurfaceBufferFD
|
||||
* \sa DeleteMemDC
|
||||
*
|
||||
* Since 5.0.13
|
||||
*/
|
||||
MG_EXPORT HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd);
|
||||
MG_EXPORT HDC GUIAPI CreateMemDCOnSharedSurface (HSURF surf, const RECT *rect);
|
||||
#endif /* _MGSCHEMA_COMPOSITING */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1958,7 +1958,7 @@ const CompositorOps* __ex_compositor_get (const char* name,
|
||||
*
|
||||
* \sa RegisterRequestHandler
|
||||
*/
|
||||
#define MAX_SYS_REQID 0x0023
|
||||
#define MAX_SYS_REQID 0x0024
|
||||
|
||||
/**
|
||||
* \def MAX_REQID
|
||||
|
||||
@@ -7238,7 +7238,7 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetWindowSurfaceBufferFD (HWND hwnd)
|
||||
* \fn int GUIAPI GetWindowSharedSurfaceFD (HWND hwnd)
|
||||
* \brief Gets the file descriptor of the surface buffer for a window or
|
||||
* the main window it locates.
|
||||
*
|
||||
@@ -7254,11 +7254,11 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
|
||||
*
|
||||
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
|
||||
*
|
||||
* \sa CreateMemDCFromSurfaceBufferFD
|
||||
* \sa CreateMemDCFromSharedSurfaceFD
|
||||
*
|
||||
* Since 5.0.13
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetWindowSurfaceBufferFD (HWND hWnd);
|
||||
MG_EXPORT int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI SetMainWindowCompositing (HWND hWnd,
|
||||
|
||||
@@ -6067,7 +6067,7 @@ error:
|
||||
}
|
||||
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
int GUIAPI GetWindowSurfaceBufferFD (HWND hWnd)
|
||||
int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd)
|
||||
{
|
||||
MG_CHECK_RET (MG_IS_APP_WINDOW (hWnd), -1);
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
#define REQID_GETSHAREDSURFACE 0x001C
|
||||
// for compositing schema
|
||||
#define SYSSF_WALLPAPER_PATTER "syssf-wallpaper-pattern"
|
||||
#define APPSF_NAME_PREFIX "appsf-name-"
|
||||
#define APPSF_NAME_PATTER "appsf-name-%s"
|
||||
#define APPSF_HWND_PREFIX "appsf-hwnd-"
|
||||
#define APPSF_HWND_PATTER "appsf-hwnd-%d-%p"
|
||||
// for sharedfb schema
|
||||
#define SYSSF_REAL_SCREEN "syssf-real-screen"
|
||||
#define SYSSF_SHADOW_SCREEN "syssf-shadow-screen"
|
||||
@@ -126,7 +130,14 @@
|
||||
// Authenticate client
|
||||
#define REQID_AUTHCLIENT 0x0023
|
||||
|
||||
#define REQID_SYS_LAST REQID_AUTHCLIENT
|
||||
/* Since 5.2.0 */
|
||||
// Operate a shared surface to register/revoke the name and set the fd
|
||||
#define REQID_OPERATENAMEDSSURF 0x0024
|
||||
#define ID_NAMEDSSURFOP_REGISTER 1
|
||||
#define ID_NAMEDSSURFOP_SET 2
|
||||
#define ID_NAMEDSSURFOP_REVOKE 3
|
||||
|
||||
#define REQID_SYS_LAST REQID_OPERATENAMEDSSURF
|
||||
|
||||
/*
|
||||
* XXX: To fellows who need to add a new REQID,
|
||||
@@ -142,6 +153,14 @@ MGUI_COMPILE_TIME_ASSERT(sys_request_id, MAX_SYS_REQID >= REQID_SYS_LAST);
|
||||
|
||||
#undef MGUI_COMPILE_TIME_ASSERT
|
||||
|
||||
/* Since 5.2.0 */
|
||||
typedef struct OperateNSSurfInfo
|
||||
{
|
||||
int id_op;
|
||||
char name[NAME_MAX + 1];
|
||||
size_t map_size;
|
||||
} OPERATENSSURFINFO;
|
||||
|
||||
/* Since 5.0.0 */
|
||||
typedef struct _SharedSurfInfo {
|
||||
uint32_t flags; // the flags of the surface
|
||||
|
||||
@@ -83,6 +83,11 @@ static inline int comp_key_string (const void *key1, const void *key2)
|
||||
return strcmp (key1, key2);
|
||||
}
|
||||
|
||||
static inline void free_val_alloc (void *val)
|
||||
{
|
||||
free (val);
|
||||
}
|
||||
|
||||
typedef struct _map_t map_t;
|
||||
typedef struct _map_entry_t {
|
||||
struct rb_node node;
|
||||
|
||||
@@ -132,6 +132,10 @@ void __mg_client_del (int cli);
|
||||
|
||||
void __mg_release_global_res (int cli);
|
||||
|
||||
/* Since 5.2.0 */
|
||||
int __mg_nssurf_map_new(void);
|
||||
void __mg_nssurf_map_delete(void);
|
||||
|
||||
void __mg_remove_client (int cli, int clifd);
|
||||
|
||||
int __mg_handle_request (int clifd, int req_id, int cli);
|
||||
@@ -150,6 +154,7 @@ int __mg_remove_all_znodes_of_client (int cli);
|
||||
|
||||
int __mg_handle_normal_mouse_move (const ZORDERINFO* zi, int x, int y);
|
||||
int __mg_get_znode_at_point (const ZORDERINFO* zi, int x, int y, HWND* hwnd);
|
||||
ZORDERNODE *__mg_find_znode_by_client_hwnd (int cli, HWND hwnd);
|
||||
|
||||
int __mg_do_reghook_operation (int cli, const REGHOOKINFO* info);
|
||||
int __mg_handle_mouse_hook (int message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -1520,6 +1521,33 @@ static BOOL _cb_update_rc_nocli (void* context,
|
||||
}
|
||||
#endif /* not defined _MGSCHEMA_COMPOSITING */
|
||||
|
||||
/* Since 5.2.0 */
|
||||
ZORDERNODE *__mg_find_znode_by_client_hwnd (int cli, HWND hwnd)
|
||||
{
|
||||
ZORDERINFO* zi = get_zorder_info(cli);
|
||||
ZORDERNODE* nodes;
|
||||
|
||||
if (zi == NULL)
|
||||
return NULL;
|
||||
|
||||
int level, slot = -1;
|
||||
nodes = GET_ZORDERNODE(zi);
|
||||
for (level = 0; level < NR_ZORDER_LEVELS; level++) {
|
||||
slot = zi->first_in_levels[level];
|
||||
for (; slot > 0; slot = nodes[slot].next) {
|
||||
if (nodes[slot].cli == cli && nodes[slot].hwnd == hwnd) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
found:
|
||||
assert(slot >= 0);
|
||||
return nodes + slot;
|
||||
}
|
||||
|
||||
int __mg_remove_all_znodes_of_client (int cli)
|
||||
{
|
||||
BOOL has_special = FALSE;
|
||||
|
||||
@@ -3392,7 +3392,7 @@ struct GAL_Surface* GetSurfaceFromDC (HDC hdc)
|
||||
}
|
||||
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd)
|
||||
HDC GUIAPI CreateMemDCFromSharedSurfaceFD (int fd)
|
||||
{
|
||||
HDC memdc = HDC_INVALID;
|
||||
GAL_Surface* surf;
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
#include "server.h"
|
||||
#include "sharedres.h"
|
||||
#include "misc.h"
|
||||
#include "map.h"
|
||||
#include "dc.h"
|
||||
|
||||
typedef void (* ReleaseProc) (void* );
|
||||
|
||||
@@ -778,25 +780,159 @@ extern int __mg_clipboard_op (int cli, int clifd, void* buff, size_t len);
|
||||
#endif
|
||||
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
static map_t *__nssurf_map;
|
||||
|
||||
struct nssurf_info {
|
||||
int creator;
|
||||
int fd;
|
||||
size_t map_size;
|
||||
};
|
||||
|
||||
static void my_free_val(void *val)
|
||||
{
|
||||
struct nssurf_info *nssurf_info = val;
|
||||
if (nssurf_info->fd >= 0)
|
||||
close(nssurf_info->fd);
|
||||
free(val);
|
||||
}
|
||||
|
||||
int __mg_nssurf_map_new(void)
|
||||
{
|
||||
__nssurf_map = __mg_map_create(copy_key_string,
|
||||
free_key_string, NULL, my_free_val, comp_key_string);
|
||||
if (__nssurf_map == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __mg_nssurf_map_delete(void)
|
||||
{
|
||||
assert(__nssurf_map);
|
||||
__mg_map_destroy(__nssurf_map);
|
||||
}
|
||||
|
||||
/* get the fake screen surface (wallpaper pattern surface) */
|
||||
static int get_shared_surface (int cli, int clifd, void* buff, size_t len)
|
||||
{
|
||||
SHAREDSURFINFO info;
|
||||
SHAREDSURFINFO info = {};
|
||||
int fd = -1;
|
||||
|
||||
assert (__gal_fake_screen);
|
||||
|
||||
info.flags = __gal_fake_screen->flags;
|
||||
if (strcmp (buff, SYSSF_WALLPAPER_PATTER) == 0 &&
|
||||
if (strcmp(buff, SYSSF_WALLPAPER_PATTER) == 0 &&
|
||||
__gal_fake_screen->shared_header) {
|
||||
info.flags = __gal_fake_screen->flags;
|
||||
info.size = __gal_fake_screen->shared_header->map_size;
|
||||
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO),
|
||||
__gal_fake_screen->shared_header->fd);
|
||||
fd = __gal_fake_screen->shared_header->fd;
|
||||
}
|
||||
else {
|
||||
info.size = 0;
|
||||
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), -1);
|
||||
else if (strncmp(buff, APPSF_NAME_PREFIX,
|
||||
sizeof(APPSF_NAME_PREFIX) - 1) == 0) {
|
||||
const char *name = buff + sizeof(APPSF_NAME_PREFIX) - 1;
|
||||
map_entry_t *entry = __mg_map_find(__nssurf_map, name);
|
||||
if (entry == NULL)
|
||||
goto failed;
|
||||
|
||||
struct nssurf_info *nssurf_info = entry->val;
|
||||
assert(nssurf_info);
|
||||
info.size = nssurf_info->map_size;
|
||||
fd = nssurf_info->fd;
|
||||
}
|
||||
else if (strncmp(buff, APPSF_HWND_PREFIX,
|
||||
sizeof(APPSF_HWND_PREFIX) - 1) == 0) {
|
||||
int client;
|
||||
HWND hwnd;
|
||||
int ret = sscanf(buff, APPSF_HWND_PATTER, &client, &hwnd);
|
||||
if (ret != 2)
|
||||
goto failed;
|
||||
|
||||
ZORDERNODE *znode = __mg_find_znode_by_client_hwnd(client, hwnd);
|
||||
if (znode == NULL)
|
||||
goto failed;
|
||||
|
||||
PDC pdc = dc_HDC2PDC(znode->mem_dc);
|
||||
assert(pdc->surface->shared_header);
|
||||
info.size = pdc->surface->shared_header->map_size;
|
||||
info.width = pdc->surface->shared_header->width;
|
||||
info.height = pdc->surface->shared_header->height;
|
||||
info.pitch = pdc->surface->shared_header->pitch;
|
||||
info.offset = pdc->surface->shared_header->pixels_off;
|
||||
fd = pdc->surface->shared_header->fd;
|
||||
}
|
||||
|
||||
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), fd);
|
||||
|
||||
failed:
|
||||
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), -1);
|
||||
}
|
||||
|
||||
static int
|
||||
operate_nssurface(int cli, int clifd, void* buff, size_t len, int fd)
|
||||
{
|
||||
int result = -1;
|
||||
map_entry_t *entry;
|
||||
struct nssurf_info *nssurf_info;
|
||||
|
||||
OPERATENSSURFINFO* req_info = (OPERATENSSURFINFO*)buff;
|
||||
switch (req_info->id_op) {
|
||||
case ID_NAMEDSSURFOP_REGISTER:
|
||||
entry = __mg_map_find(__nssurf_map, req_info->name);
|
||||
if (entry)
|
||||
goto done;
|
||||
nssurf_info = malloc(sizeof(*nssurf_info));
|
||||
if (nssurf_info == NULL)
|
||||
goto done;
|
||||
|
||||
nssurf_info->creator = cli;
|
||||
nssurf_info->fd = -1;
|
||||
nssurf_info->map_size = 0;
|
||||
if (__mg_map_insert(__nssurf_map, req_info->name, nssurf_info)) {
|
||||
free(nssurf_info);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_NAMEDSSURFOP_SET:
|
||||
if (fd == -1) {
|
||||
goto done;
|
||||
}
|
||||
entry = __mg_map_find(__nssurf_map, req_info->name);
|
||||
if (entry == NULL)
|
||||
goto done;
|
||||
|
||||
assert(entry->val);
|
||||
nssurf_info = entry->val;
|
||||
if (nssurf_info->creator != cli)
|
||||
goto done;
|
||||
|
||||
nssurf_info->fd = fd;
|
||||
nssurf_info->map_size = req_info->map_size;
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
case ID_NAMEDSSURFOP_REVOKE:
|
||||
entry = __mg_map_find(__nssurf_map, req_info->name);
|
||||
if (entry == NULL)
|
||||
goto done;
|
||||
|
||||
assert(entry->val);
|
||||
nssurf_info = entry->val;
|
||||
if (nssurf_info->creator != cli)
|
||||
goto done;
|
||||
|
||||
if (__mg_map_erase(__nssurf_map, req_info->name))
|
||||
goto done;
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
done:
|
||||
return ServerSendReply(clifd, &result, sizeof(int));
|
||||
}
|
||||
|
||||
#else /* IS_COMPOSITING_SCHEMA */
|
||||
/* get the rendering surface */
|
||||
static int get_shared_surface (int cli, int clifd, void* buff, size_t len)
|
||||
@@ -894,6 +1030,11 @@ static struct req_request {
|
||||
{ move_to_layer, 0 }, // REQID_MOVETOLAYER
|
||||
{ calc_position, 0 }, // REQID_CALCPOSITION
|
||||
{ authenticate_client, 0 }, // REQID_AUTHCLIENT
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
{ operate_nssurface, 1 }, // REQID_OPERATENSSURF
|
||||
#else
|
||||
{ NULL, 0 },
|
||||
#endif
|
||||
};
|
||||
|
||||
BOOL GUIAPI RegisterRequestHandler (int req_id, REQ_HANDLER your_handler)
|
||||
|
||||
@@ -299,9 +299,17 @@ BOOL GUIAPI ServerStartup (int nr_globals,
|
||||
SHAREDRES_DEF_NR_TOPMOSTS = def_nr_topmosts;
|
||||
SHAREDRES_DEF_NR_NORMALS = def_nr_normals;
|
||||
|
||||
/* Since 5.2.0 */
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
if (__mg_nssurf_map_new()) {
|
||||
_ERR_PRINTF ("mginit: failed to initialize map for named shared surface\n");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (__mg_init_layers () == -1) {
|
||||
_ERR_PRINTF ("mginit: failed to initialize layers\n");
|
||||
return FALSE;
|
||||
goto fail_layers;
|
||||
}
|
||||
|
||||
SHAREDRES_NR_LAYSERS = 1;
|
||||
@@ -340,6 +348,10 @@ BOOL GUIAPI ServerStartup (int nr_globals,
|
||||
|
||||
fail:
|
||||
__mg_cleanup_layers ();
|
||||
fail_layers:
|
||||
#ifdef _MGSCHEMA_COMPOSITING
|
||||
__mg_nssurf_map_delete ();
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user