2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Xephyr - A kdrive X server thats runs in a host X window.
|
|
|
|
* Authored by Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright © 2007 OpenedHand Ltd
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of OpenedHand Ltd not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. OpenedHand Ltd makes no
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* This file is heavily copied from hw/xfree86/dri/xf86dri.c
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Dodji Seketeli <dodji@openedhand.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <kdrive-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#define _XF86DRI_SERVER_
|
|
|
|
#include <X11/dri/xf86dri.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/dri/xf86driproto.h>
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "misc.h"
|
|
|
|
#include "privates.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "servermd.h"
|
|
|
|
#include "swaprep.h"
|
|
|
|
#include "ephyrdri.h"
|
|
|
|
#include "ephyrdriext.h"
|
|
|
|
#include "hostx.h"
|
|
|
|
#define _HAVE_XALLOC_DECLS
|
|
|
|
#include "ephyrlog.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int foo;
|
|
|
|
} EphyrDRIWindowPrivRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef EphyrDRIWindowPrivRec *EphyrDRIWindowPrivPtr;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
typedef struct {
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateWindowProcPtr CreateWindow;
|
|
|
|
DestroyWindowProcPtr DestroyWindow;
|
|
|
|
MoveWindowProcPtr MoveWindow;
|
|
|
|
PositionWindowProcPtr PositionWindow;
|
|
|
|
ClipNotifyProcPtr ClipNotify;
|
2008-11-02 08:26:08 -07:00
|
|
|
} EphyrDRIScreenPrivRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef EphyrDRIScreenPrivRec *EphyrDRIScreenPrivPtr;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
static int DRIErrorBase;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool ephyrDRIScreenInit(ScreenPtr a_screen);
|
|
|
|
static Bool ephyrDRICreateWindow(WindowPtr a_win);
|
|
|
|
static Bool ephyrDRIDestroyWindow(WindowPtr a_win);
|
|
|
|
static void ephyrDRIMoveWindow(WindowPtr a_win,
|
|
|
|
int a_x, int a_y,
|
|
|
|
WindowPtr a_siblings, VTKind a_kind);
|
|
|
|
static Bool ephyrDRIPositionWindow(WindowPtr a_win, int x, int y);
|
|
|
|
static void ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y);
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool EphyrMirrorHostVisuals(ScreenPtr a_screen);
|
|
|
|
static Bool destroyHostPeerWindow(const WindowPtr a_win);
|
|
|
|
static Bool findWindowPairFromLocal(WindowPtr a_local,
|
|
|
|
EphyrWindowPair ** a_pair);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
static unsigned char DRIReqCode = 0;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec ephyrDRIWindowKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
|
|
|
|
static DevPrivateKeyRec ephyrDRIScreenKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
|
|
|
|
dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))
|
|
|
|
#define GET_EPHYR_DRI_SCREEN_PRIV(screen) ((EphyrDRIScreenPrivPtr) \
|
|
|
|
dixLookupPrivate(&(screen)->devPrivates, ephyrDRIScreenKey))
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIScreenInit(ScreenPtr a_screen)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_screen, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(a_screen);
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen_priv, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen_priv->CreateWindow = a_screen->CreateWindow;
|
|
|
|
screen_priv->DestroyWindow = a_screen->DestroyWindow;
|
|
|
|
screen_priv->MoveWindow = a_screen->MoveWindow;
|
|
|
|
screen_priv->PositionWindow = a_screen->PositionWindow;
|
|
|
|
screen_priv->ClipNotify = a_screen->ClipNotify;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
a_screen->CreateWindow = ephyrDRICreateWindow;
|
|
|
|
a_screen->DestroyWindow = ephyrDRIDestroyWindow;
|
|
|
|
a_screen->MoveWindow = ephyrDRIMoveWindow;
|
|
|
|
a_screen->PositionWindow = ephyrDRIPositionWindow;
|
|
|
|
a_screen->ClipNotify = ephyrDRIClipNotify;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
is_ok = TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRICreateWindow(WindowPtr a_win)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
|
|
|
|
screen = a_win->drawable.pScreen;
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
|
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->CreateWindow, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter. win:%p\n", a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->CreateWindow = screen_priv->CreateWindow;
|
|
|
|
is_ok = (*screen->CreateWindow) (a_win);
|
|
|
|
screen->CreateWindow = ephyrDRICreateWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (is_ok) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIDestroyWindow(WindowPtr a_win)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
|
|
|
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
|
|
|
|
screen = a_win->drawable.pScreen;
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
|
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->DestroyWindow, FALSE);
|
|
|
|
|
|
|
|
screen->DestroyWindow = screen_priv->DestroyWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->DestroyWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
is_ok = (*screen->DestroyWindow) (a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->DestroyWindow = ephyrDRIDestroyWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (is_ok) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EphyrDRIWindowPrivPtr win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
destroyHostPeerWindow(a_win);
|
|
|
|
free(win_priv);
|
|
|
|
dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
|
|
|
|
EPHYR_LOG("destroyed the remote peer window\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIMoveWindow(WindowPtr a_win,
|
|
|
|
int a_x, int a_y, WindowPtr a_siblings, VTKind a_kind)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
|
|
|
EphyrDRIWindowPrivPtr win_priv = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
EphyrBox geo;
|
2012-06-10 07:21:05 -06:00
|
|
|
int x = 0, y = 0; /*coords relative to parent window */
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_IF_FAIL(a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
screen = a_win->drawable.pScreen;
|
|
|
|
EPHYR_RETURN_IF_FAIL(screen);
|
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
|
|
|
|
EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->MoveWindow);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->MoveWindow = screen_priv->MoveWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->MoveWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->MoveWindow) (a_win, a_x, a_y, a_siblings, a_kind);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->MoveWindow = ephyrDRIMoveWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("window: %p\n", a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!a_win->parent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("cannot move root window\n");
|
|
|
|
is_ok = TRUE;
|
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("not a DRI peered window\n");
|
|
|
|
is_ok = TRUE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get window pair\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*compute position relative to parent window */
|
|
|
|
x = a_win->drawable.x - a_win->parent->drawable.x;
|
|
|
|
y = a_win->drawable.y - a_win->parent->drawable.y;
|
|
|
|
/*set the geometry to pass to hostx_set_window_geometry */
|
|
|
|
memset(&geo, 0, sizeof(geo));
|
|
|
|
geo.x = x;
|
|
|
|
geo.y = y;
|
|
|
|
geo.width = a_win->drawable.width;
|
|
|
|
geo.height = a_win->drawable.height;
|
|
|
|
hostx_set_window_geometry(pair->remote, &geo);
|
|
|
|
is_ok = TRUE;
|
|
|
|
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
|
|
|
|
/*do cleanup here */
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIPositionWindow(WindowPtr a_win, int a_x, int a_y)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
|
|
|
EphyrDRIWindowPrivPtr win_priv = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
EphyrBox geo;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
screen = a_win->drawable.pScreen;
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
|
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->PositionWindow, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->PositionWindow = screen_priv->PositionWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->PositionWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->PositionWindow) (a_win, a_x, a_y);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->PositionWindow = ephyrDRIPositionWindow;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("window: %p\n", a_win);
|
|
|
|
win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("not a DRI peered window\n");
|
|
|
|
is_ok = TRUE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get window pair\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*set the geometry to pass to hostx_set_window_geometry */
|
|
|
|
memset(&geo, 0, sizeof(geo));
|
|
|
|
geo.x = a_x;
|
|
|
|
geo.y = a_y;
|
|
|
|
geo.width = a_win->drawable.width;
|
|
|
|
geo.height = a_win->drawable.height;
|
|
|
|
hostx_set_window_geometry(pair->remote, &geo);
|
|
|
|
is_ok = TRUE;
|
|
|
|
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
|
|
|
|
/*do cleanup here */
|
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
|
|
|
EphyrDRIWindowPrivPtr win_priv = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
|
|
|
EphyrRect *rects = NULL;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
EPHYR_RETURN_IF_FAIL(a_win);
|
|
|
|
|
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
screen = a_win->drawable.pScreen;
|
|
|
|
EPHYR_RETURN_IF_FAIL(screen);
|
|
|
|
screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
|
|
|
|
EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->ClipNotify);
|
|
|
|
|
|
|
|
screen->ClipNotify = screen_priv->ClipNotify;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->ClipNotify) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->ClipNotify) (a_win, a_x, a_y);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->ClipNotify = ephyrDRIClipNotify;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("window: %p\n", a_win);
|
|
|
|
win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("not a DRI peered window\n");
|
|
|
|
is_ok = TRUE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get window pair\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
rects = calloc(RegionNumRects(&a_win->clipList), sizeof(EphyrRect));
|
|
|
|
for (i = 0; i < RegionNumRects(&a_win->clipList); i++) {
|
|
|
|
memmove(&rects[i],
|
|
|
|
&RegionRects(&a_win->clipList)[i], sizeof(EphyrRect));
|
2008-11-02 08:26:08 -07:00
|
|
|
rects[i].x1 -= a_win->drawable.x;
|
|
|
|
rects[i].x2 -= a_win->drawable.x;
|
|
|
|
rects[i].y1 -= a_win->drawable.y;
|
|
|
|
rects[i].y2 -= a_win->drawable.y;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* push the clipping region of this window
|
|
|
|
* to the peer window in the host
|
|
|
|
*/
|
|
|
|
is_ok = hostx_set_window_bounding_rectangles
|
2012-06-10 07:21:05 -06:00
|
|
|
(pair->remote, rects, RegionNumRects(&a_win->clipList));
|
|
|
|
is_ok = TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
|
|
|
free(rects);
|
|
|
|
rects = NULL;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
|
|
|
|
/*do cleanup here */
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicates a visual of a_screen
|
|
|
|
* In screen a_screen, for depth a_depth, find a visual which
|
|
|
|
* bitsPerRGBValue and colormap size equal
|
|
|
|
* a_bits_per_rgb_values and a_colormap_entries.
|
|
|
|
* The ID of that duplicated visual is set to a_new_id.
|
|
|
|
* That duplicated visual is then added to the list of visuals
|
|
|
|
* of the screen.
|
|
|
|
*/
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
EphyrDuplicateVisual(unsigned int a_screen,
|
|
|
|
short a_depth,
|
|
|
|
short a_class,
|
|
|
|
short a_bits_per_rgb_values,
|
|
|
|
short a_colormap_entries,
|
|
|
|
unsigned int a_red_mask,
|
|
|
|
unsigned int a_green_mask,
|
|
|
|
unsigned int a_blue_mask, unsigned int a_new_id)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE, found_visual = FALSE, found_depth = FALSE;
|
|
|
|
ScreenPtr screen = NULL;
|
|
|
|
VisualRec new_visual, *new_visuals = NULL;
|
|
|
|
int i = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-12-21 13:10:44 -07:00
|
|
|
if (a_screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("bad screen number\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
goto out;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
memset(&new_visual, 0, sizeof(VisualRec));
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*get the screen pointed to by a_screen */
|
|
|
|
screen = screenInfo.screens[a_screen];
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In that screen, first look for an existing visual that has the
|
|
|
|
* same characteristics as those passed in parameter
|
|
|
|
* to this function and copy it.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screen->numVisuals; i++) {
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->visuals[i].bitsPerRGBValue == a_bits_per_rgb_values &&
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->visuals[i].ColormapEntries == a_colormap_entries) {
|
|
|
|
/*copy the visual found */
|
|
|
|
memcpy(&new_visual, &screen->visuals[i], sizeof(new_visual));
|
|
|
|
new_visual.vid = a_new_id;
|
|
|
|
new_visual.class = a_class;
|
|
|
|
new_visual.redMask = a_red_mask;
|
|
|
|
new_visual.greenMask = a_green_mask;
|
|
|
|
new_visual.blueMask = a_blue_mask;
|
|
|
|
found_visual = TRUE;
|
|
|
|
EPHYR_LOG("found a visual that matches visual id: %d\n", a_new_id);
|
2008-11-02 08:26:08 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found_visual) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("did not find any visual matching %d\n", a_new_id);
|
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* be prepare to extend screen->visuals to add new_visual to it
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
new_visuals = calloc(screen->numVisuals + 1, sizeof(VisualRec));
|
|
|
|
memmove(new_visuals,
|
|
|
|
screen->visuals, screen->numVisuals * sizeof(VisualRec));
|
|
|
|
memmove(&new_visuals[screen->numVisuals], &new_visual, sizeof(VisualRec));
|
2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Now, in that same screen, update the screen->allowedDepths member.
|
|
|
|
* In that array, each element represents the visuals applicable to
|
|
|
|
* a given depth. So we need to add an entry matching the new visual
|
|
|
|
* that we are going to add to screen->visuals
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screen->numDepths; i++) {
|
|
|
|
VisualID *vids = NULL;
|
|
|
|
DepthPtr cur_depth = NULL;
|
|
|
|
|
|
|
|
/*find the entry matching a_depth */
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->allowedDepths[i].depth != a_depth)
|
2012-06-10 07:21:05 -06:00
|
|
|
continue;
|
2008-11-02 08:26:08 -07:00
|
|
|
cur_depth = &screen->allowedDepths[i];
|
|
|
|
/*
|
|
|
|
* extend the list of visual IDs in that entry,
|
|
|
|
* so to add a_new_id in there.
|
|
|
|
*/
|
2010-12-05 08:36:02 -07:00
|
|
|
vids = realloc(cur_depth->vids,
|
2012-06-10 07:21:05 -06:00
|
|
|
(cur_depth->numVids + 1) * sizeof(VisualID));
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!vids) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to realloc numids\n");
|
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
vids[cur_depth->numVids] = a_new_id;
|
2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Okay now commit our change.
|
|
|
|
* Do really update screen->allowedDepths[i]
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
cur_depth->numVids++;
|
|
|
|
cur_depth->vids = vids;
|
|
|
|
found_depth = TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
if (!found_depth) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to update screen[%d]->allowedDepth\n",
|
|
|
|
a_screen);
|
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Commit our change to screen->visuals
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
free(screen->visuals);
|
|
|
|
screen->visuals = new_visuals;
|
|
|
|
screen->numVisuals++;
|
|
|
|
new_visuals = NULL;
|
|
|
|
|
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
free(new_visuals);
|
|
|
|
new_visuals = NULL;
|
|
|
|
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicates the visuals of the host X server.
|
|
|
|
* This is necessary to have visuals that have the same
|
|
|
|
* ID as those of the host X. It is important to have that for
|
|
|
|
* GLX.
|
|
|
|
*/
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
EphyrMirrorHostVisuals(ScreenPtr a_screen)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
EphyrHostVisualInfo *visuals = NULL;
|
|
|
|
int nb_visuals = 0, i = 0;
|
|
|
|
|
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
if (!hostx_get_visuals_info(&visuals, &nb_visuals)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get host visuals\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
for (i = 0; i < nb_visuals; i++) {
|
|
|
|
if (!EphyrDuplicateVisual(a_screen->myNum,
|
|
|
|
visuals[i].depth,
|
|
|
|
visuals[i].class,
|
|
|
|
visuals[i].bits_per_rgb,
|
|
|
|
visuals[i].colormap_size,
|
|
|
|
visuals[i].red_mask,
|
|
|
|
visuals[i].green_mask,
|
|
|
|
visuals[i].blue_mask, visuals[i].visualid)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to duplicate host visual %d\n",
|
|
|
|
(int) visuals[i].visualid);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return is_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIQueryVersion(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
xXF86DRIQueryVersionReply rep;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
2010-07-27 13:02:24 -06:00
|
|
|
rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
|
|
|
|
rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
|
|
|
|
rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.majorVersion);
|
|
|
|
swaps(&rep.minorVersion);
|
|
|
|
swapl(&rep.patchVersion);
|
|
|
|
}
|
|
|
|
WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *) &rep);
|
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXF86DRIQueryDirectRenderingCapableReply rep;
|
2008-11-02 08:26:08 -07:00
|
|
|
Bool isCapable;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIQueryDirectRenderingCapable(stuff->screen, &isCapable)) {
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
rep.isCapable = isCapable;
|
|
|
|
|
|
|
|
if (!LocalClient(client) || client->swapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.isCapable = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply),
|
|
|
|
(char *) &rep);
|
|
|
|
EPHYR_LOG("leave\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIOpenConnection(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
xXF86DRIOpenConnectionReply rep;
|
2012-06-10 07:21:05 -06:00
|
|
|
drm_handle_t hSAREA;
|
|
|
|
char *busIdString = NULL;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRIOpenConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIOpenConnection(stuff->screen, &hSAREA, &busIdString)) {
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.busIdStringLength = 0;
|
|
|
|
if (busIdString)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.busIdStringLength = strlen(busIdString);
|
|
|
|
rep.length =
|
|
|
|
bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
|
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(rep.busIdStringLength));
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff);
|
2008-11-02 08:26:08 -07:00
|
|
|
#if defined(LONG64) && !defined(__linux__)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.hSAREAHigh = (CARD32) (hSAREA >> 32);
|
2008-11-02 08:26:08 -07:00
|
|
|
#else
|
|
|
|
rep.hSAREAHigh = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *) &rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rep.busIdStringLength)
|
|
|
|
WriteToClient(client, rep.busIdStringLength, busIdString);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(busIdString);
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIAuthConnection(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
xXF86DRIAuthConnectionReply rep;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRIAuthConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.authenticated = 1;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIAuthConnection(stuff->screen, stuff->magic)) {
|
|
|
|
ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
|
2008-11-02 08:26:08 -07:00
|
|
|
rep.authenticated = 0;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *) &rep);
|
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRICloseConnection(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRICloseConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
DRICloseConnection( screenInfo.screens[stuff->screen]);
|
|
|
|
*/
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIGetClientDriverName(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXF86DRIGetClientDriverNameReply rep;
|
|
|
|
char *clientDriverName;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRIGetClientDriverNameReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIGetClientDriverName(stuff->screen,
|
|
|
|
(int *) &rep.ddxDriverMajorVersion,
|
|
|
|
(int *) &rep.ddxDriverMinorVersion,
|
|
|
|
(int *) &rep.ddxDriverPatchVersion,
|
|
|
|
&clientDriverName);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.clientDriverNameLength = 0;
|
|
|
|
if (clientDriverName)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.clientDriverNameLength = strlen(clientDriverName);
|
2010-07-27 13:02:24 -06:00
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
|
2012-06-10 07:21:05 -06:00
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(rep.clientDriverNameLength));
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(xXF86DRIGetClientDriverNameReply), (char *) &rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rep.clientDriverNameLength)
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
|
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRICreateContext(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXF86DRICreateContextReply rep;
|
2008-11-02 08:26:08 -07:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
VisualPtr visual;
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0;
|
|
|
|
unsigned long context_id = 0;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRICreateContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
visual = pScreen->visuals;
|
|
|
|
|
|
|
|
/* Find the requested X visual */
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++, visual++)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (visual->vid == stuff->visual)
|
|
|
|
break;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (i == pScreen->numVisuals) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* No visual found */
|
|
|
|
return BadValue;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
context_id = stuff->context;
|
|
|
|
if (!ephyrDRICreateContext(stuff->screen,
|
|
|
|
stuff->visual,
|
|
|
|
&context_id,
|
|
|
|
(drm_context_t *) & rep.hHWContext)) {
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *) &rep);
|
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIDestroyContext(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIDestroyContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIDestroyContext(stuff->screen, stuff->context)) {
|
|
|
|
return BadValue;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
getWindowVisual(const WindowPtr a_win, VisualPtr * a_visual)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0, visual_id = 0;
|
|
|
|
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win
|
|
|
|
&& a_win->drawable.pScreen
|
|
|
|
&& a_win->drawable.pScreen->visuals, FALSE);
|
|
|
|
|
|
|
|
visual_id = wVisual(a_win);
|
|
|
|
for (i = 0; i < a_win->drawable.pScreen->numVisuals; i++) {
|
2008-11-02 08:26:08 -07:00
|
|
|
if (a_win->drawable.pScreen->visuals[i].vid == visual_id) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*a_visual = &a_win->drawable.pScreen->visuals[i];
|
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define NUM_WINDOW_PAIRS 256
|
2012-06-10 07:21:05 -06:00
|
|
|
static EphyrWindowPair window_pairs[NUM_WINDOW_PAIRS];
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
appendWindowPairToList(WindowPtr a_local, int a_remote)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_local, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("(local,remote):(%p, %d)\n", a_local, a_remote);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
|
2008-11-02 08:26:08 -07:00
|
|
|
if (window_pairs[i].local == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
window_pairs[i].local = a_local;
|
|
|
|
window_pairs[i].remote = a_remote;
|
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
findWindowPairFromLocal(WindowPtr a_local, EphyrWindowPair ** a_pair)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_pair && a_local, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
|
2008-11-02 08:26:08 -07:00
|
|
|
if (window_pairs[i].local == a_local) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*a_pair = &window_pairs[i];
|
|
|
|
EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
|
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_pair, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
|
2008-11-02 08:26:08 -07:00
|
|
|
if (window_pairs[i].remote == a_remote) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*a_pair = &window_pairs[i];
|
|
|
|
EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
|
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
createHostPeerWindow(const WindowPtr a_win, int *a_peer_win)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
VisualPtr visual = NULL;
|
|
|
|
EphyrBox geo;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win && a_peer_win, FALSE);
|
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win->drawable.pScreen, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter. a_win '%p'\n", a_win);
|
|
|
|
if (!getWindowVisual(a_win, &visual)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get window visual\n");
|
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
if (!visual) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to create visual\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
memset(&geo, 0, sizeof(geo));
|
|
|
|
geo.x = a_win->drawable.x;
|
|
|
|
geo.y = a_win->drawable.y;
|
|
|
|
geo.width = a_win->drawable.width;
|
|
|
|
geo.height = a_win->drawable.height;
|
|
|
|
if (!hostx_create_window(a_win->drawable.pScreen->myNum,
|
|
|
|
&geo, visual->vid, a_peer_win)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to create host peer window\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!appendWindowPairToList(a_win, *a_peer_win)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to append window to pair list\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave:remote win%d\n", *a_peer_win);
|
|
|
|
return is_ok;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
destroyHostPeerWindow(const WindowPtr a_win)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
|
|
|
|
if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to find peer to local window\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
goto out;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
hostx_destroy_window(pair->remote);
|
|
|
|
is_ok = TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return is_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRICreateDrawable(ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXF86DRICreateDrawableReply rep;
|
|
|
|
DrawablePtr drawable = NULL;
|
|
|
|
WindowPtr window = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
|
|
|
EphyrDRIWindowPrivPtr win_priv = NULL;
|
|
|
|
int rc = 0, remote_win = 0;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRICreateDrawableReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
|
|
|
|
DixReadAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
if (drawable->type != DRAWABLE_WINDOW) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
|
|
|
|
return BadImplementation;
|
|
|
|
}
|
|
|
|
EPHYR_LOG("lookedup drawable %p\n", drawable);
|
|
|
|
window = (WindowPtr) drawable;
|
|
|
|
if (findWindowPairFromLocal(window, &pair) && pair) {
|
|
|
|
remote_win = pair->remote;
|
|
|
|
EPHYR_LOG("found window '%p' paire with remote '%d'\n",
|
|
|
|
window, remote_win);
|
|
|
|
}
|
|
|
|
else if (!createHostPeerWindow(window, &remote_win)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to create host peer window\n");
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ephyrDRICreateDrawable(stuff->screen,
|
|
|
|
remote_win,
|
|
|
|
(drm_drawable_t *) & rep.hHWDrawable)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to create dri drawable\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
win_priv = GET_EPHYR_DRI_WINDOW_PRIV(window);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
win_priv = calloc(1, sizeof(EphyrDRIWindowPrivRec));
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!win_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to allocate window private\n");
|
|
|
|
return BadAlloc;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv);
|
|
|
|
EPHYR_LOG("paired window '%p' with remote '%d'\n", window, remote_win);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *) &rep);
|
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIDestroyDrawable(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr drawable = NULL;
|
|
|
|
WindowPtr window = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
|
|
|
int rc = 0;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST(xXF86DRIDestroyDrawableReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = dixLookupDrawable(&drawable,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->drawable, client, 0, DixReadAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
if (drawable->type != DRAWABLE_WINDOW) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
|
|
|
|
return BadImplementation;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
window = (WindowPtr) drawable;
|
|
|
|
if (!findWindowPairFromLocal(window, &pair) && pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to find pair window\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadImplementation;
|
|
|
|
}
|
|
|
|
if (!ephyrDRIDestroyDrawable(stuff->screen,
|
2012-06-10 07:21:05 -06:00
|
|
|
pair->remote /*drawable in host x */ )) {
|
|
|
|
EPHYR_LOG_ERROR("failed to destroy dri drawable\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadImplementation;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pair->local = NULL;
|
|
|
|
pair->remote = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIGetDrawableInfo(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
xXF86DRIGetDrawableInfoReply rep;
|
|
|
|
DrawablePtr drawable;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr window = NULL;
|
|
|
|
EphyrWindowPair *pair = NULL;
|
|
|
|
int X = 0, Y = 0, W = 0, H = 0, backX = 0, backY = 0, rc = 0, i = 0;
|
|
|
|
drm_clip_rect_t *clipRects = NULL;
|
|
|
|
drm_clip_rect_t *backClipRects = NULL;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST(xXF86DRIGetDrawableInfoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
memset(&rep, 0, sizeof(rep));
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
|
|
|
rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
|
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success || !drawable) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("could not get drawable\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drawable->type != DRAWABLE_WINDOW) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("non windows type drawables are not yes supported\n");
|
|
|
|
return BadImplementation;
|
|
|
|
}
|
|
|
|
window = (WindowPtr) drawable;
|
|
|
|
memset(&pair, 0, sizeof(pair));
|
|
|
|
if (!findWindowPairFromLocal(window, &pair) || !pair) {
|
|
|
|
EPHYR_LOG_ERROR("failed to find remote peer drawable\n");
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
EPHYR_LOG("clip list of xephyr gl drawable:\n");
|
|
|
|
for (i = 0; i < RegionNumRects(&window->clipList); i++) {
|
|
|
|
EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
|
|
|
|
RegionRects(&window->clipList)[i].x1,
|
|
|
|
RegionRects(&window->clipList)[i].y1,
|
|
|
|
RegionRects(&window->clipList)[i].x2,
|
|
|
|
RegionRects(&window->clipList)[i].y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ephyrDRIGetDrawableInfo(stuff->screen,
|
|
|
|
pair->remote /*the drawable in hostx */ ,
|
|
|
|
(unsigned int *) &rep.drawableTableIndex,
|
|
|
|
(unsigned int *) &rep.drawableTableStamp,
|
|
|
|
(int *) &X,
|
|
|
|
(int *) &Y,
|
|
|
|
(int *) &W,
|
|
|
|
(int *) &H,
|
|
|
|
(int *) &rep.numClipRects,
|
|
|
|
&clipRects,
|
|
|
|
&backX,
|
|
|
|
&backY,
|
|
|
|
(int *) &rep.numBackClipRects,
|
|
|
|
&backClipRects)) {
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("num clip rects:%d, num back clip rects:%d\n",
|
|
|
|
(int) rep.numClipRects, (int) rep.numBackClipRects);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rep.drawableX = X;
|
|
|
|
rep.drawableY = Y;
|
|
|
|
rep.drawableWidth = W;
|
|
|
|
rep.drawableHeight = H;
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rep.backX = backX;
|
|
|
|
rep.backY = backY;
|
|
|
|
|
|
|
|
if (rep.numClipRects) {
|
|
|
|
if (clipRects) {
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
|
2012-06-10 07:21:05 -06:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
EPHYR_LOG("clip list of host gl drawable:\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
for (i = 0; i < rep.numClipRects; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
clipRects[i].x1 = max(clipRects[i].x1, 0);
|
|
|
|
clipRects[i].y1 = max(clipRects[i].y1, 0);
|
|
|
|
clipRects[i].x2 = min(clipRects[i].x2,
|
|
|
|
pScreen->width + clipRects[i].x1);
|
|
|
|
clipRects[i].y2 = min(clipRects[i].y2,
|
|
|
|
pScreen->width + clipRects[i].y1);
|
|
|
|
|
|
|
|
EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
|
|
|
|
clipRects[i].x1, clipRects[i].y1,
|
|
|
|
clipRects[i].x2, clipRects[i].y2);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2008-11-02 08:26:08 -07:00
|
|
|
rep.numClipRects = 0;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
EPHYR_LOG("got zero host gl drawable clipping rects\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
|
2012-06-10 07:21:05 -06:00
|
|
|
backClipRects = clipRects;
|
|
|
|
rep.numBackClipRects = rep.numClipRects;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rep.numBackClipRects)
|
|
|
|
rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("num host clip rects:%d\n", (int) rep.numClipRects);
|
|
|
|
EPHYR_LOG("num host back clip rects:%d\n", (int) rep.numBackClipRects);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rep.length = bytes_to_int32(rep.length);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *) &rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (rep.numClipRects) {
|
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(drm_clip_rect_t) * rep.numClipRects,
|
2012-06-10 07:21:05 -06:00
|
|
|
(char *) clipRects);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rep.numBackClipRects) {
|
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
|
2012-06-10 07:21:05 -06:00
|
|
|
(char *) backClipRects);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(clipRects);
|
2012-06-10 07:21:05 -06:00
|
|
|
clipRects = NULL;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIGetDeviceInfo(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXF86DRIGetDeviceInfoReply rep;
|
2008-11-02 08:26:08 -07:00
|
|
|
drm_handle_t hFrameBuffer;
|
|
|
|
void *pDevPrivate;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xXF86DRIGetDeviceInfoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIGetDeviceInfo(stuff->screen,
|
|
|
|
&hFrameBuffer,
|
|
|
|
(int *) &rep.framebufferOrigin,
|
|
|
|
(int *) &rep.framebufferSize,
|
|
|
|
(int *) &rep.framebufferStride,
|
|
|
|
(int *) &rep.devPrivateSize, &pDevPrivate)) {
|
2008-11-02 08:26:08 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
|
2008-11-02 08:26:08 -07:00
|
|
|
#if defined(LONG64) && !defined(__linux__)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
|
2008-11-02 08:26:08 -07:00
|
|
|
#else
|
|
|
|
rep.hFrameBufferHigh = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rep.length = 0;
|
|
|
|
if (rep.devPrivateSize) {
|
2010-07-27 13:02:24 -06:00
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
|
2012-06-10 07:21:05 -06:00
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(rep.devPrivateSize));
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *) &rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rep.length) {
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, rep.devPrivateSize, (char *) pDevPrivate);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("leave\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXF86DRIDispatch(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
|
|
|
case X_XF86DRIQueryVersion:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIQueryVersion(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIQueryDirectRenderingCapable:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIQueryDirectRenderingCapable(client);
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!LocalClient(client))
|
|
|
|
return DRIErrorBase + XF86DRIClientNotLocal;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
|
|
|
case X_XF86DRIOpenConnection:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIOpenConnection(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRICloseConnection:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRICloseConnection(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIGetClientDriverName:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIGetClientDriverName(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRICreateContext:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRICreateContext(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIDestroyContext:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIDestroyContext(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRICreateDrawable:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRICreateDrawable(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIDestroyDrawable:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIDestroyDrawable(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIGetDrawableInfo:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIGetDrawableInfo(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIGetDeviceInfo:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIGetDeviceInfo(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIAuthConnection:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return ProcXF86DRIAuthConnection(client);
|
|
|
|
}
|
|
|
|
/* {Open,Close}FullScreen are deprecated now */
|
|
|
|
default:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return BadRequest;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXF86DRIQueryVersion(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIQueryVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2008-11-02 08:26:08 -07:00
|
|
|
return ProcXF86DRIQueryVersion(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->screen);
|
2008-11-02 08:26:08 -07:00
|
|
|
return ProcXF86DRIQueryDirectRenderingCapable(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXF86DRIDispatch(register ClientPtr client)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Only local clients are allowed DRI access, but remote clients still need
|
|
|
|
* these requests to find out cleanly.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
|
|
|
case X_XF86DRIQueryVersion:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return SProcXF86DRIQueryVersion(client);
|
|
|
|
}
|
|
|
|
case X_XF86DRIQueryDirectRenderingCapable:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return SProcXF86DRIQueryDirectRenderingCapable(client);
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return DRIErrorBase + XF86DRIClientNotLocal;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ephyrDRIExtensionInit(ScreenPtr a_screen)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
ExtensionEntry *extEntry = NULL;
|
|
|
|
EphyrDRIScreenPrivPtr screen_priv = NULL;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
if (!hostx_has_dri()) {
|
|
|
|
EPHYR_LOG("host does not have DRI extension\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("host X does have DRI extension\n");
|
|
|
|
if (!hostx_has_xshape()) {
|
|
|
|
EPHYR_LOG("host does not have XShape extension\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG("host X does have XShape extension\n");
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
#ifdef XF86DRI_EVENTS
|
2012-06-10 07:21:05 -06:00
|
|
|
EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvents");
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!EventType) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to register DRI event resource type\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((extEntry = AddExtension(XF86DRINAME,
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86DRINumberEvents,
|
|
|
|
XF86DRINumberErrors,
|
|
|
|
ProcXF86DRIDispatch,
|
|
|
|
SProcXF86DRIDispatch,
|
|
|
|
NULL, StandardMinorOpcode))) {
|
|
|
|
DRIReqCode = (unsigned char) extEntry->base;
|
|
|
|
DRIErrorBase = extEntry->errorBase;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
EPHYR_LOG_ERROR("failed to register DRI extension\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
if (!dixRegisterPrivateKey(&ephyrDRIScreenKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!dixRegisterPrivateKey(&ephyrDRIWindowKeyRec, PRIVATE_WINDOW, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
goto out;
|
|
|
|
screen_priv = calloc(1, sizeof(EphyrDRIScreenPrivRec));
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!screen_priv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
EPHYR_LOG_ERROR("failed to allocate screen_priv\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
dixSetPrivate(&a_screen->devPrivates, ephyrDRIScreenKey, screen_priv);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ephyrDRIScreenInit(a_screen)) {
|
|
|
|
EPHYR_LOG_ERROR("ephyrDRIScreenInit() failed\n");
|
|
|
|
goto out;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EphyrMirrorHostVisuals(a_screen);
|
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|