Merge pull request #5943 from akallabeth/x11_lock

X11 lock recursion checks
This commit is contained in:
Martin Fleisz 2020-03-10 16:03:54 +01:00 committed by GitHub
commit 6313cccb6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 116 deletions

View File

@ -326,17 +326,17 @@ static BOOL xf_sw_end_paint(rdpContext* context)
if (gdi->primary->hdc->hwnd->invalid->null)
return TRUE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h);
xf_draw_screen(xfc, x, y, w, h);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
else
{
if (gdi->primary->hdc->hwnd->ninvalid < 1)
return TRUE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
for (i = 0; i < ninvalid; i++)
{
@ -349,7 +349,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
}
XFlush(xfc->display);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
}
else
@ -357,9 +357,9 @@ static BOOL xf_sw_end_paint(rdpContext* context)
if (gdi->primary->hdc->hwnd->invalid->null)
return TRUE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_rail_paint(xfc, x, y, x + w, y + h);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
gdi->primary->hdc->hwnd->invalid->null = TRUE;
@ -373,7 +373,7 @@ static BOOL xf_sw_desktop_resize(rdpContext* context)
xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
BOOL ret = FALSE;
xf_lock_x11(xfc, TRUE);
xf_lock_x11(xfc);
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
goto out;
@ -395,7 +395,7 @@ static BOOL xf_sw_desktop_resize(rdpContext* context)
xfc->image->bitmap_bit_order = LSBFirst;
ret = xf_desktop_resize(context);
out:
xf_unlock_x11(xfc, TRUE);
xf_unlock_x11(xfc);
return ret;
}
@ -419,9 +419,9 @@ static BOOL xf_hw_end_paint(rdpContext* context)
y = xfc->hdc->hwnd->invalid->y;
w = xfc->hdc->hwnd->invalid->w;
h = xfc->hdc->hwnd->invalid->h;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_draw_screen(xfc, x, y, w, h);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
else
{
@ -434,7 +434,7 @@ static BOOL xf_hw_end_paint(rdpContext* context)
ninvalid = xfc->hdc->hwnd->ninvalid;
cinvalid = xfc->hdc->hwnd->cinvalid;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
for (i = 0; i < ninvalid; i++)
{
@ -446,7 +446,7 @@ static BOOL xf_hw_end_paint(rdpContext* context)
}
XFlush(xfc->display);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
}
else
@ -458,9 +458,9 @@ static BOOL xf_hw_end_paint(rdpContext* context)
y = xfc->hdc->hwnd->invalid->y;
w = xfc->hdc->hwnd->invalid->w;
h = xfc->hdc->hwnd->invalid->h;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_rail_paint(xfc, x, y, x + w, y + h);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
xfc->hdc->hwnd->invalid->null = TRUE;
@ -474,14 +474,14 @@ static BOOL xf_hw_desktop_resize(rdpContext* context)
xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
BOOL ret = FALSE;
xf_lock_x11(xfc, TRUE);
xf_lock_x11(xfc);
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
goto out;
ret = xf_desktop_resize(context);
out:
xf_unlock_x11(xfc, TRUE);
xf_unlock_x11(xfc);
return ret;
}
@ -496,7 +496,7 @@ static BOOL xf_process_x_events(freerdp* instance)
while (pending_status)
{
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
pending_status = XPending(xfc->display);
if (pending_status)
@ -505,7 +505,7 @@ static BOOL xf_process_x_events(freerdp* instance)
XNextEvent(xfc->display, &xevent);
status = xf_event_process(instance, &xevent);
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
if (!status)
break;
}
@ -799,38 +799,31 @@ void xf_encomsp_uninit(xfContext* xfc, EncomspClientContext* encomsp)
xfc->encomsp = NULL;
}
void xf_lock_x11(xfContext* xfc, BOOL display)
void xf_lock_x11_(xfContext* xfc, const char* fkt)
{
if (!xfc->UseXThreads)
{
WaitForSingleObject(xfc->mutex, INFINITE);
}
else
{
if (display)
XLockDisplay(xfc->display);
}
if (xfc->locked)
WLog_WARN(TAG, "X11 trying to lock although already locked!");
xfc->locked = TRUE;
if (!xfc->UseXThreads)
WaitForSingleObject(xfc->mutex, INFINITE);
else
XLockDisplay(xfc->display);
if (xfc->locked)
WLog_WARN(TAG, "%s:\t[%" PRIu32 "] recursive lock from %s", __FUNCTION__, xfc->locked, fkt);
xfc->locked++;
WLog_VRB(TAG, "%s:\t[%" PRIu32 "] from %s", __FUNCTION__, xfc->locked, fkt);
}
void xf_unlock_x11(xfContext* xfc, BOOL display)
void xf_unlock_x11_(xfContext* xfc, const char* fkt)
{
if (!xfc->locked)
if (xfc->locked == 0)
WLog_WARN(TAG, "X11: trying to unlock although not locked!");
WLog_VRB(TAG, "%s:\t[%" PRIu32 "] from %s", __FUNCTION__, xfc->locked - 1, fkt);
if (!xfc->UseXThreads)
{
ReleaseMutex(xfc->mutex);
}
else
{
if (display)
XUnlockDisplay(xfc->display);
}
xfc->locked = FALSE;
XUnlockDisplay(xfc->display);
xfc->locked--;
}
static BOOL xf_get_pixmap_info(xfContext* xfc)
@ -1427,17 +1420,17 @@ static DWORD WINAPI xf_input_thread(LPVOID arg)
{
do
{
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
pending_status = XPending(xfc->display);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
if (pending_status)
{
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
ZeroMemory(&xevent, sizeof(xevent));
XNextEvent(xfc->display, &xevent);
process_status = xf_event_process(instance, &xevent);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
if (!process_status)
break;

View File

@ -273,7 +273,7 @@ static BOOL xf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
{
XRectangle clip;
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (bounds)
{
@ -288,7 +288,7 @@ static BOOL xf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
XSetClipMask(xfc->display, xfc->gc, None);
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return TRUE;
}
@ -296,7 +296,7 @@ static BOOL xf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{
xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (!xf_set_rop3(xfc, gdi_rop3_code(dstblt->bRop)))
goto fail;
@ -312,7 +312,7 @@ static BOOL xf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
fail:
XSetFunction(xfc->display, xfc->gc, GXcopy);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -329,7 +329,7 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
if (!xf_decode_color(xfc, patblt->backColor, &xbg))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
brush = &patblt->brush;
if (!xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)))
@ -405,7 +405,7 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
fail:
XSetFunction(xfc->display, xfc->gc, GXcopy);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -417,7 +417,7 @@ static BOOL xf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
if (!xfc->display || !xfc->drawing)
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (!xf_set_rop3(xfc, gdi_rop3_code(scrblt->bRop)))
goto fail;
@ -432,7 +432,7 @@ static BOOL xf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
XSetFunction(xfc->display, xfc->gc, GXcopy);
fail:
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -445,7 +445,7 @@ static BOOL xf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opa
if (!xf_decode_color(xfc, opaque_rect->color, &color))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
@ -456,7 +456,7 @@ static BOOL xf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opa
ret = gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -471,7 +471,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
if (!xf_decode_color(xfc, multi_opaque_rect->color, &color))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
@ -490,7 +490,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
}
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -503,7 +503,7 @@ static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
if (!xf_decode_color(xfc, line_to->penColor, &color))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_set_rop2(xfc, line_to->bRop2);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
@ -521,7 +521,7 @@ static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -571,7 +571,7 @@ static BOOL xf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
if (!xf_decode_color(xfc, polyline->penColor, &color))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_set_rop2(xfc, polyline->bRop2);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
@ -580,7 +580,7 @@ static BOOL xf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
if (!points)
{
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return FALSE;
}
@ -603,7 +603,7 @@ static BOOL xf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
XSetFunction(xfc->display, xfc->gc, GXcopy);
free(points);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -622,7 +622,7 @@ static BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
if (!bitmap || !xfc || !xfc->display || !xfc->drawing)
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (xf_set_rop3(xfc, gdi_rop3_code(memblt->bRop)))
{
@ -635,7 +635,7 @@ static BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -658,7 +658,7 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
if (!xf_decode_color(xfc, mem3blt->backColor, &backColor))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
brush = &mem3blt->brush;
bitmap = (xfBitmap*)mem3blt->bitmap;
@ -720,7 +720,7 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
fail:
XSetFunction(xfc->display, xfc->gc, GXcopy);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -736,14 +736,14 @@ static BOOL xf_gdi_polygon_sc(rdpContext* context, const POLYGON_SC_ORDER* polyg
if (!xf_decode_color(xfc, polygon_sc->brushColor, &brush_color))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_set_rop2(xfc, polygon_sc->bRop2);
npoints = polygon_sc->numPoints + 1;
points = calloc(npoints, sizeof(XPoint));
if (!points)
{
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return FALSE;
}
@ -783,7 +783,7 @@ static BOOL xf_gdi_polygon_sc(rdpContext* context, const POLYGON_SC_ORDER* polyg
XSetFunction(xfc->display, xfc->gc, GXcopy);
free(points);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -805,7 +805,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
if (!xf_decode_color(xfc, polygon_cb->backColor, &backColor))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
brush = &(polygon_cb->brush);
xf_set_rop2(xfc, polygon_cb->bRop2);
npoints = polygon_cb->numPoints + 1;
@ -813,7 +813,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
if (!points)
{
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return FALSE;
}
@ -888,7 +888,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
XSetFunction(xfc->display, xfc->gc, GXcopy);
free(points);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -899,7 +899,7 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
settings = xfc->context.settings;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
switch (surface_frame_marker->frameAction)
{
@ -928,7 +928,7 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
break;
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -1039,7 +1039,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND*
cmdRect.right = cmdRect.left + cmd->bmp.width;
cmdRect.bottom = cmdRect.top + cmd->bmp.height;
gdi = context->gdi;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
switch (cmd->bmp.codecID)
{
@ -1090,7 +1090,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND*
ret = xf_gdi_update_screen(xfc, gdi->primary_buffer, gdi->stride, &region);
fail:
region16_uninit(&region);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}

View File

@ -81,9 +81,9 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
{
XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image, nXSrc, nYSrc, nXDst,
nYDst, dwidth, dheight);
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xf_rail_paint(xfc, nXDst, nYDst, nXDst + dwidth, nYDst + dheight);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
else
#ifdef WITH_XRENDER

View File

@ -110,7 +110,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
return FALSE;
gdi = context->gdi;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
depth = GetBitsPerPixel(bitmap->format);
xbitmap->pixmap =
XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth);
@ -155,7 +155,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
rc = TRUE;
unlock:
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return rc;
}
@ -167,7 +167,7 @@ static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
if (!xfc || !xbitmap)
return;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (xbitmap->pixmap != 0)
{
@ -182,7 +182,7 @@ static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
xbitmap->image = NULL;
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
_aligned_free(bitmap->data);
free(xbitmap);
}
@ -199,12 +199,12 @@ static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
width = bitmap->right - bitmap->left + 1;
height = bitmap->bottom - bitmap->top + 1;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
XSetFunction(xfc->display, xfc->gc, GXcopy);
XPutImage(xfc->display, xfc->primary, xfc->gc, xbitmap->image, 0, 0, bitmap->left, bitmap->top,
width, height);
ret = gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -215,14 +215,14 @@ static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL pr
if (!context || (!bitmap && !primary))
return FALSE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (primary)
xfc->drawing = xfc->primary;
else
xfc->drawing = ((xfBitmap*)bitmap)->pixmap;
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return TRUE;
}
@ -244,7 +244,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
else
CursorFormat = (!xfc->big_endian) ? PIXEL_FORMAT_BGRA32 : PIXEL_FORMAT_ARGB32;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
ZeroMemory(&ci, sizeof(ci));
ci.version = XCURSOR_IMAGE_VERSION;
ci.size = sizeof(ci);
@ -256,7 +256,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
if (!(ci.pixels = (XcursorPixel*)_aligned_malloc(size, 16)))
{
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return FALSE;
}
@ -266,13 +266,13 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
{
_aligned_free(ci.pixels);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return FALSE;
}
xpointer->cursor = XcursorImageLoadCursor(xfc->display, &ci);
_aligned_free(ci.pixels);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
return TRUE;
}
@ -281,12 +281,12 @@ static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (((xfPointer*)pointer)->cursor)
XFreeCursor(xfc->display, ((xfPointer*)pointer)->cursor);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
}
@ -294,7 +294,7 @@ static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xfc->pointer = (xfPointer*)pointer;
/* in RemoteApp mode, window can be null if none has had focus */
@ -302,7 +302,7 @@ static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
if (xfc->window)
XDefineCursor(xfc->display, xfc->window->handle, xfc->pointer->cursor);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
return TRUE;
}
@ -312,7 +312,7 @@ static BOOL xf_Pointer_SetNull(rdpContext* context)
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*)context;
static Cursor nullcursor = None;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (nullcursor == None)
{
@ -332,7 +332,7 @@ static BOOL xf_Pointer_SetNull(rdpContext* context)
if ((xfc->window) && (nullcursor != None))
XDefineCursor(xfc->display, xfc->window->handle, nullcursor);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
return TRUE;
}
@ -341,13 +341,13 @@ static BOOL xf_Pointer_SetDefault(rdpContext* context)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
xfc->pointer = NULL;
if (xfc->window)
XUndefineCursor(xfc->display, xfc->window->handle);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
return TRUE;
}
@ -362,7 +362,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
if (!xfc->focused || !xfc->window)
return TRUE;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (XGetWindowAttributes(xfc->display, xfc->window->handle, &current) == 0)
goto out;
@ -377,7 +377,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask, &tmp);
ret = TRUE;
out:
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return ret;
}
@ -389,7 +389,7 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
xfGlyph* xf_glyph;
xf_glyph = (xfGlyph*)glyph;
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
scanline = (glyph->cx + 7) / 8;
xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx, glyph->cy, 1);
image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*)glyph->aj, glyph->cx,
@ -401,19 +401,19 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
glyph->cy);
image->data = NULL;
XDestroyImage(image);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return TRUE;
}
static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
{
xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (((xfGlyph*)glyph)->pixmap != 0)
XFreePixmap(xfc->display, ((xfGlyph*)glyph)->pixmap);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
free(glyph->aj);
free(glyph);
}
@ -424,7 +424,7 @@ static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, I
xfGlyph* xf_glyph;
xfContext* xfc = (xfContext*)context;
xf_glyph = (xfGlyph*)glyph;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (!fOpRedundant)
{
@ -441,7 +441,7 @@ static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, I
// XSetClipOrigin(xfc->display, xfc->gc, sx, sy);
XSetTSOrigin(xfc->display, xfc->gc, x, y);
XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, w, h);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return TRUE;
}
@ -462,7 +462,7 @@ static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y, INT32 widt
rect.y = y;
rect.width = width;
rect.height = height;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (!fOpRedundant)
{
@ -474,7 +474,7 @@ static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y, INT32 widt
XSetForeground(xfc->display, xfc->gc, xbgcolor.pixel);
XSetBackground(xfc->display, xfc->gc, xfgcolor.pixel);
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
return TRUE;
}

View File

@ -499,7 +499,7 @@ static void xf_input_hide_cursor(xfContext* xfc)
XcursorImage ci;
XcursorPixel xp = 0;
static Cursor nullcursor = None;
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
ZeroMemory(&ci, sizeof(ci));
ci.version = XCURSOR_IMAGE_VERSION;
ci.size = sizeof(ci);
@ -512,7 +512,7 @@ static void xf_input_hide_cursor(xfContext* xfc)
XDefineCursor(xfc->display, xfc->window->handle, nullcursor);
xfc->cursorHidden = TRUE;
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
}
#endif
@ -521,7 +521,7 @@ static void xf_input_hide_cursor(xfContext* xfc)
static void xf_input_show_cursor(xfContext* xfc)
{
#ifdef WITH_XCURSOR
xf_lock_x11(xfc, FALSE);
xf_lock_x11(xfc);
if (xfc->cursorHidden)
{
@ -536,7 +536,7 @@ static void xf_input_show_cursor(xfContext* xfc)
xfc->cursorHidden = FALSE;
}
xf_unlock_x11(xfc, FALSE);
xf_unlock_x11(xfc);
#endif
}

View File

@ -1053,7 +1053,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
if (ay + height > appWindow->windowOffsetY + appWindow->height)
height = (appWindow->windowOffsetY + appWindow->height - 1) - ay;
xf_lock_x11(xfc, TRUE);
xf_lock_x11(xfc);
if (xfc->context.settings->SoftwareGdi)
{
@ -1064,7 +1064,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
XCopyArea(xfc->display, xfc->primary, appWindow->handle, appWindow->gc, ax, ay, width, height,
x, y);
XFlush(xfc->display);
xf_unlock_x11(xfc, TRUE);
xf_unlock_x11(xfc);
}
void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow)

View File

@ -247,7 +247,7 @@ struct xf_context
/* value to be sent over wire for each logical client mouse button */
button_map button_map[NUM_BUTTONS_MAPPED];
BYTE savedMaximizedState;
BOOL locked;
UINT32 locked;
};
BOOL xf_create_window(xfContext* xfc);
@ -300,8 +300,11 @@ enum XF_EXIT_CODE
XF_EXIT_UNKNOWN = 255,
};
void xf_lock_x11(xfContext* xfc, BOOL display);
void xf_unlock_x11(xfContext* xfc, BOOL display);
#define xf_lock_x11(xfc) xf_lock_x11_(xfc, __FUNCTION__);
#define xf_unlock_x11(xfc) xf_unlock_x11_(xfc, __FUNCTION__);
void xf_lock_x11_(xfContext* xfc, const char* fkt);
void xf_unlock_x11_(xfContext* xfc, const char* fkt);
BOOL xf_picture_transform_required(xfContext* xfc);
void xf_draw_screen(xfContext* xfc, int x, int y, int w, int h);