#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "xpr.h"
#define _APPLEWM_SERVER_
#include <X11/extensions/applewmstr.h>
#include "applewmExt.h"
#include "rootless.h"
#include "rootlessCommon.h"
#include <Xplugin.h>
#include <X11/X.h>
#include "quartz.h"
#include "x-hash.h"
static int xprSetWindowLevel(
WindowPtr pWin,
int level)
{
xp_window_id wid;
xp_window_changes wc;
RootlessWindowRec *winRec;
if (level < 0 || level >= AppleWMNumWindowLevels) {
return BadValue;
}
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
if (wid == 0)
return BadWindow;
RootlessStopDrawing (pWin, FALSE);
winRec = WINREC(pWin);
if(!winRec)
return BadWindow;
if(quartzEnableRootless)
wc.window_level = normal_window_levels[level];
else
wc.window_level = rooted_window_levels[level];
if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
return BadValue;
}
winRec->level = level;
return Success;
}
#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
xp_window_id child_wid, parent_wid;
xp_window_changes wc;
child_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinChild, TRUE));
if (child_wid == 0)
return BadWindow;
if(pWinParent) {
parent_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE));
if (parent_wid == 0)
return BadWindow;
} else {
parent_wid = 0;
}
wc.transient_for = parent_wid;
RootlessStopDrawing (pWinChild, FALSE);
if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) {
return BadValue;
}
return Success;
}
#endif
static int xprFrameDraw(
WindowPtr pWin,
int class,
unsigned int attr,
const BoxRec *outer,
const BoxRec *inner,
unsigned int title_len,
const unsigned char *title_bytes)
{
xp_window_id wid;
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE));
if (wid == 0)
return BadWindow;
if (xp_frame_draw (wid, class, attr, outer, inner,
title_len, title_bytes) != Success)
{
return BadValue;
}
return Success;
}
static AppleWMProcsRec xprAppleWMProcs = {
xp_disable_update,
xp_reenable_update,
xprSetWindowLevel,
xp_frame_get_rect,
xp_frame_hit_test,
xprFrameDraw,
#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
xp_set_dock_proxy,
xprAttachTransient
#elif defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 2
xp_set_dock_proxy,
NULL
#else
NULL,
NULL
#endif
};
void xprAppleWMInit(void)
{
AppleWMExtensionInit(&xprAppleWMProcs);
}