diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-11-14 13:35:50 -0500 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil> | 2007-11-14 13:35:50 -0500 |
commit | 1603130236c55ddabc3854d4ba62d544debcf1f5 (patch) | |
tree | 02b1cffad943cb69c2b79118b0ab9a758b9e0f1a /miext | |
parent | f207e69d62bc04c7f254347b03e6d8fa8b569d66 (diff) | |
parent | f7dd0c72b8f861f4d5443a43d1013e3fe3db43ca (diff) |
Merge branch 'master' into XACE-SELINUX
Conflicts:
Xext/xace.c
Xext/xace.h
Diffstat (limited to 'miext')
-rw-r--r-- | miext/rootless/rootless.h | 2 | ||||
-rw-r--r-- | miext/rootless/rootlessGC.c | 50 | ||||
-rw-r--r-- | miext/rootless/rootlessWindow.c | 143 |
3 files changed, 171 insertions, 24 deletions
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h index d9fdb6adb..b4a5b2a3d 100644 --- a/miext/rootless/rootless.h +++ b/miext/rootless/rootless.h @@ -74,6 +74,8 @@ typedef struct _RootlessWindowRec { unsigned int is_drawing :1; // Currently drawing? unsigned int is_reorder_pending :1; + unsigned int is_offscreen :1; + unsigned int is_obscured :1; } RootlessWindowRec, *RootlessWindowPtr; diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c index bf129eadc..c80b11f1d 100644 --- a/miext/rootless/rootlessGC.c +++ b/miext/rootless/rootlessGC.c @@ -413,10 +413,12 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc) #define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \ && IsRoot ((WindowPtr) (pDst))) -#define GC_SKIP_ROOT(pDst) \ +#define GC_SKIP_ROOT(pDst, pGC) \ do { \ - if (GC_IS_ROOT (pDst)) \ + if (GC_IS_ROOT (pDst)) { \ + GCOP_WRAP(pGC); \ return; \ + } \ } while (0) @@ -426,7 +428,7 @@ RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("fill spans start "); if (nInit <= 0) { @@ -482,7 +484,7 @@ RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, int nspans, int sorted) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("set spans start "); if (nspans <= 0) { @@ -533,7 +535,7 @@ RootlessPutImage(DrawablePtr dst, GCPtr pGC, BoxRec box; GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("put image start "); RootlessStartDrawing((WindowPtr) dst); @@ -565,7 +567,10 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, GCOP_UNWRAP(pGC); if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc)) + { + GCOP_WRAP(pGC); return NULL; /* nothing exposed */ + } RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst); @@ -615,7 +620,10 @@ static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst, GCOP_UNWRAP(pGC); if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc)) + { + GCOP_WRAP(pGC); return NULL; /* nothing exposed */ + } RL_DEBUG_MSG("copy plane start "); @@ -652,7 +660,7 @@ static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("polypoint start "); RootlessStartDrawing((WindowPtr) dst); @@ -746,7 +754,7 @@ static void RootlessPolylines(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("poly lines start "); RootlessStartDrawing((WindowPtr) dst); @@ -821,7 +829,7 @@ static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment *pSeg) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("poly segment start (win 0x%x)", dst); RootlessStartDrawing((WindowPtr) dst); @@ -892,7 +900,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("poly rectangle start "); RootlessStartDrawing((WindowPtr) dst); @@ -953,7 +961,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC, static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("poly arc start "); RootlessStartDrawing((WindowPtr) dst); @@ -1009,7 +1017,7 @@ static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst, pGC->fillStyle); @@ -1083,7 +1091,7 @@ static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst, pGC->fillStyle); @@ -1138,7 +1146,7 @@ static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("fill arc start "); if (narcsInit > 0) { @@ -1193,7 +1201,7 @@ static void RootlessImageText8(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("imagetext8 start "); if (count > 0) { @@ -1247,7 +1255,10 @@ static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC, GCOP_UNWRAP(pGC); if (GC_IS_ROOT(dst)) + { + GCOP_WRAP(pGC); return 0; + } RL_DEBUG_MSG("polytext8 start "); @@ -1285,7 +1296,7 @@ static void RootlessImageText16(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("imagetext16 start "); if (count > 0) { @@ -1339,7 +1350,10 @@ static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC, GCOP_UNWRAP(pGC); if (GC_IS_ROOT(dst)) + { + GCOP_WRAP(pGC); return 0; + } RL_DEBUG_MSG("polytext16 start "); @@ -1378,7 +1392,7 @@ static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC, { GC_SAVE(pGC); GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("imageglyph start "); if (nglyphInit > 0) { @@ -1439,7 +1453,7 @@ static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC, CharInfoPtr *ppci, pointer pglyphBase) { GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("polyglyph start "); RootlessStartDrawing((WindowPtr) dst); @@ -1485,7 +1499,7 @@ RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst, BoxRec box; GCOP_UNWRAP(pGC); - GC_SKIP_ROOT(dst); + GC_SKIP_ROOT(dst, pGC); RL_DEBUG_MSG("push pixels start "); RootlessStartDrawing((WindowPtr) dst); diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index e8f7a81a5..16cbb18af 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -36,13 +36,23 @@ #include <stddef.h> /* For NULL */ #include <limits.h> /* For CHAR_BIT */ #include <assert.h> +#ifdef __APPLE__ +//#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include "mi.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include <Xplugin.h> +//#include <X11/extensions/applewm.h> +extern int darwinMainScreenX, darwinMainScreenY; +#endif +#include "fb.h" + +#define AppleWMNumWindowLevels 5 #include "rootlessCommon.h" #include "rootlessWindow.h" -#include "fb.h" - - #ifdef ROOTLESS_GLOBAL_COORDS #define SCREEN_TO_GLOBAL_X \ (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX) @@ -53,6 +63,127 @@ #define SCREEN_TO_GLOBAL_Y 0 #endif +#define DEFINE_ATOM_HELPER(func,atom_name) \ + static Atom func (void) { \ + static unsigned int generation; \ + static Atom atom; \ + if (generation != serverGeneration) { \ + generation = serverGeneration; \ + atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \ + } \ + return atom; \ + } + +DEFINE_ATOM_HELPER (xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN") +DEFINE_ATOM_HELPER (xa_native_window_id, "_NATIVE_WINDOW_ID") +DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN") + +static Bool no_configure_window; +static Bool windows_hidden; +// TODO - abstract xp functions + +static const int normal_window_levels[AppleWMNumWindowLevels+1] = { + 0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29, +}; +static const int rooted_window_levels[AppleWMNumWindowLevels+1] = { + 202, 203, 204, 205, 201, 200 +}; + +static inline int +configure_window (xp_window_id id, unsigned int mask, + const xp_window_changes *values) +{ + if (!no_configure_window) + return xp_configure_window (id, mask, values); + else + return XP_Success; +} + +/*static inline unsigned long +current_time_in_seconds (void) +{ + unsigned long t = 0; + + t += currentTime.milliseconds / 1000; + t += currentTime.months * 4294967; + + return t; + } */ + +static inline Bool +rootlessHasRoot (ScreenPtr pScreen) +{ + return WINREC (WindowTable[pScreen->myNum]) != NULL; +} + +void +RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state) +{ + WindowPtr pWin; + RootlessWindowRec *winRec; + + pWin = xprGetXWindow (id); + if (pWin == NULL) return; + + winRec = WINREC (pWin); + if (winRec == NULL) return; + + winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0); + winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0); + // pWin->rootlessUnhittable = winRec->is_offscreen; +} + +void +RootlessNativeWindowMoved (WindowPtr pWin) +{ + xp_box bounds; + int sx, sy; + XID vlist[2]; + Mask mask; + ClientPtr client; + RootlessWindowRec *winRec = WINREC(pWin); + + if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return; + + sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX; + sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY; + + /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */ + + vlist[0] = (INT16) bounds.x1 - sx; + vlist[1] = (INT16) bounds.y1 - sy; + mask = CWX | CWY; + + /* pretend we're the owner of the window! */ + client = LookupClient (pWin->drawable.id, NullClient); + + /* Don't want to do anything to the physical window (avoids + notification-response feedback loops) */ + + no_configure_window = TRUE; + ConfigureWindow (pWin, mask, vlist, client); + no_configure_window = FALSE; +} + +/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */ +static void +set_screen_origin (WindowPtr pWin) +{ + long data[2]; + + if (!IsRoot (pWin)) + return; + + /* FIXME: move this to an extension? */ + + data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x + + darwinMainScreenX); + data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y + + darwinMainScreenY); + + ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER, + 32, PropModeReplace, 2, data, TRUE); +} /* * RootlessCreateWindow @@ -565,7 +696,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib) RL_DEBUG_MSG("restackwindow end\n"); } - /* * Specialized window copy procedures */ @@ -706,13 +836,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) top = TopLevelParent(pWin); if (top == NULL) { RL_DEBUG_MSG("no parent\n"); - return; + goto out; } winRec = WINREC(top); if (winRec == NULL) { RL_DEBUG_MSG("not framed\n"); - return; + goto out; } /* Move region to window local coords */ @@ -735,6 +865,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) RootlessDamageRegion(pWin, prgnSrc); } +out: REGION_UNINIT(pScreen, &rgnDst); fbValidateDrawable(&pWin->drawable); |