double yScalingFactor;
int x2;
int y2;
+ rdpSettings* settings = xfc->context.settings;
if (xfc->scaledWidth <= 0 || xfc->scaledHeight <= 0)
{
return;
}
- if (xfc->sessionWidth <= 0 || xfc->sessionHeight <= 0)
+ if (settings->DesktopWidth <= 0 || settings->DesktopHeight <= 0)
{
WLog_ERR(TAG, "the window dimensions are invalid");
return;
}
- xScalingFactor = xfc->sessionWidth / (double)xfc->scaledWidth;
- yScalingFactor = xfc->sessionHeight / (double)xfc->scaledHeight;
+ xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth;
+ yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight;
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, 0);
/* Black out possible space between desktop and window borders */
BOOL xf_picture_transform_required(xfContext* xfc)
{
+ rdpSettings* settings = xfc->context.settings;
+
if (xfc->offset_x || xfc->offset_y ||
- xfc->scaledWidth != xfc->sessionWidth ||
- xfc->scaledHeight != xfc->sessionHeight)
+ xfc->scaledWidth != settings->DesktopWidth ||
+ xfc->scaledHeight != settings->DesktopHeight)
{
return TRUE;
}
if (!(xfc->primary = XCreatePixmap(
xfc->display, xfc->drawable,
- xfc->sessionWidth, xfc->sessionHeight, xfc->depth)))
+ settings->DesktopWidth,
+ settings->DesktopHeight, xfc->depth)))
return FALSE;
if (same)
if (!xfc->settings->SmartSizing)
{
- xfc->scaledWidth = xfc->sessionWidth;
- xfc->scaledHeight = xfc->sessionHeight;
+ xfc->scaledWidth = settings->DesktopWidth;
+ xfc->scaledHeight = settings->DesktopHeight;
}
#endif
{
/* Update the saved width and height values the window will be
* resized to when toggling out of fullscreen */
- xfc->savedWidth = xfc->sessionWidth;
- xfc->savedHeight = xfc->sessionHeight;
+ xfc->savedWidth = settings->DesktopWidth;
+ xfc->savedHeight = settings->DesktopHeight;
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
{
rdpGdi* gdi = context->gdi;
xfContext* xfc = (xfContext*) context;
+ rdpSettings* settings = context->settings;
BOOL ret = FALSE;
xf_lock_x11(xfc, TRUE);
- xfc->sessionWidth = context->settings->DesktopWidth;
- xfc->sessionHeight = context->settings->DesktopHeight;
- if (!gdi_resize(gdi, xfc->sessionWidth, xfc->sessionHeight))
+ if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
goto out;
if (xfc->image)
static BOOL xf_hw_desktop_resize(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
- rdpSettings* settings = xfc->settings;
BOOL ret;
xf_lock_x11(xfc, TRUE);
- xfc->sessionWidth = settings->DesktopWidth;
- xfc->sessionHeight = settings->DesktopHeight;
ret = xf_desktop_resize(context);
xf_unlock_x11(xfc, TRUE);
return ret;
char* windowTitle;
rdpSettings* settings = xfc->settings;
ZeroMemory(&xevent, sizeof(xevent));
- width = xfc->sessionWidth;
- height = xfc->sessionHeight;
+ width = settings->DesktopWidth;
+ height = settings->DesktopHeight;
if (!xfc->hdc)
if (!(xfc->hdc = gdi_CreateDC(xfc->format)))
xfc->gc = XCreateGC(xfc->display, xfc->drawable, GCGraphicsExposures, &gcv);
if (!xfc->primary)
- xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->sessionWidth,
- xfc->sessionHeight, xfc->depth);
+ xfc->primary = XCreatePixmap(xfc->display, xfc->drawable,
+ settings->DesktopWidth,
+ settings->DesktopHeight, xfc->depth);
xfc->drawing = xfc->primary;
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen));
- XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, xfc->sessionWidth,
- xfc->sessionHeight);
+ XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0,
+ settings->DesktopWidth,
+ settings->DesktopHeight);
XFlush(xfc->display);
if (!xfc->image)
xfc->image = XCreateImage(xfc->display, xfc->visual,
xfc->depth,
ZPixmap, 0, (char*) gdi->primary_buffer,
- xfc->sessionWidth, xfc->sessionHeight,
+ settings->DesktopWidth, settings->DesktopHeight,
xfc->scanline_pad, 0);
}
xf_gdi_register_update_callbacks(update);
}
- xfc->srcBpp = settings->ColorDepth;
- xfc->sessionWidth = settings->DesktopWidth;
- xfc->sessionHeight = settings->DesktopHeight;
#ifdef WITH_XRENDER
- xfc->scaledWidth = xfc->sessionWidth;
- xfc->scaledHeight = xfc->sessionHeight;
+ xfc->scaledWidth = settings->DesktopWidth;
+ xfc->scaledHeight = settings->DesktopHeight;
xfc->offset_x = 0;
xfc->offset_y = 0;
#endif
ZoomingChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
+ rdpSettings* settings = context->settings;
int w = xfc->scaledWidth + e->dx;
int h = xfc->scaledHeight + e->dy;
xfc->scaledWidth = w;
xfc->scaledHeight = h;
- xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
+ xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
}
static void xf_PanningChangeEventHandler(rdpContext* context,
PanningChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
+ rdpSettings* settings = context->settings;
if (e->dx == 0 && e->dy == 0)
return;
xfc->offset_x += e->dx;
xfc->offset_y += e->dy;
- xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
+ xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
}
#endif
FILE* actionScript;
char buffer[1024] = { 0 };
char command[1024] = { 0 };
-
xfc->xevents = ArrayList_New(TRUE);
+
if (!xfc->xevents)
return FALSE;
- ArrayList_Object(xfc->xevents)->fnObjectFree = free;
+ ArrayList_Object(xfc->xevents)->fnObjectFree = free;
sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript);
-
actionScript = popen(command, "r");
if (!actionScript)
{
strtok(buffer, "\n");
xevent = _strdup(buffer);
+
if (!xevent || ArrayList_Add(xfc->xevents, xevent) < 0)
{
ArrayList_Free(xfc->xevents);
}
pclose(actionScript);
-
return TRUE;
}
return FALSE;
xeventName = X11_EVENT_STRINGS[event->type];
-
count = ArrayList_Count(xfc->xevents);
for (index = 0; index < count; index++)
return FALSE;
sprintf_s(command, sizeof(command), "%s xevent %s %d",
- xfc->actionScript, xeventName, (int) xfc->window->handle);
-
+ xfc->actionScript, xeventName, (int) xfc->window->handle);
actionScript = popen(command, "r");
if (!actionScript)
}
pclose(actionScript);
-
return TRUE;
}
-void xf_event_adjust_coordinates(xfContext* xfc, int* x, int *y)
+void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
{
+ rdpSettings* settings;
+
+ if (!xfc || !xfc->context.settings || !y || !x)
+ return;
+
+ settings = xfc->context.settings;
+
if (!xfc->remote_app)
{
#ifdef WITH_XRENDER
+
if (xf_picture_transform_required(xfc))
{
- double xScalingFactor = xfc->sessionWidth / (double)xfc->scaledWidth;
- double yScalingFactor = xfc->sessionHeight / (double)xfc->scaledHeight;
+ double xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth;
+ double yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight;
*x = (int)((*x - xfc->offset_x) * xScalingFactor);
*y = (int)((*y - xfc->offset_y) * yScalingFactor);
}
+
#endif
}
+
CLAMP_COORDINATES(*x, *y);
}
{
int x, y;
int w, h;
+ rdpSettings* settings = xfc->context.settings;
- if (!app && (xfc->settings->SmartSizing || xfc->settings->MultiTouchGestures))
+ if (!app && (settings->SmartSizing || settings->MultiTouchGestures))
{
x = 0;
y = 0;
- w = xfc->sessionWidth;
- h = xfc->sessionHeight;
+ w = settings->DesktopWidth;
+ h = settings->DesktopHeight;
}
else
{
else
{
xfAppWindow* appWindow;
-
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
if (appWindow)
return TRUE;
}
-BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app)
+BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state,
+ Window window, BOOL app)
{
rdpInput* input;
Window childWindow;
-
input = xfc->instance->input;
if (!xfc->settings->MouseMotion)
/* Translate to desktop coordinates */
XTranslateCoordinates(xfc->display, window,
- RootWindowOfScreen(xfc->screen),
- x, y, &x, &y, &childWindow);
+ RootWindowOfScreen(xfc->screen),
+ x, y, &x, &y, &childWindow);
}
xf_event_adjust_coordinates(xfc, &x, &y);
-
input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
if (xfc->fullscreen && !app)
{
- XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot,
+ CurrentTime);
}
return TRUE;
return TRUE;
return xf_generic_MotionNotify(xfc, event->xmotion.x, event->xmotion.y,
- event->xmotion.state, event->xmotion.window, app);
+ event->xmotion.state, event->xmotion.window, app);
}
-BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button, Window window, BOOL app)
+BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button,
+ Window window, BOOL app)
{
int flags;
BOOL wheel;
BOOL extended;
rdpInput* input;
Window childWindow;
-
flags = 0;
wheel = FALSE;
extended = FALSE;
case Button1:
case Button2:
case Button3:
- flags = PTR_FLAGS_DOWN | xfc->button_map[button-BUTTON_BASE];
+ flags = PTR_FLAGS_DOWN | xfc->button_map[button - BUTTON_BASE];
break;
case 4:
case 6: /* wheel left */
wheel = TRUE;
+
if (xfc->settings->HasHorizontalWheel)
flags = PTR_FLAGS_HWHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0078;
+
break;
case 7: /* wheel right */
wheel = TRUE;
+
if (xfc->settings->HasHorizontalWheel)
flags = PTR_FLAGS_HWHEEL | 0x0078;
+
break;
default:
/* Translate to desktop coordinates */
XTranslateCoordinates(xfc->display, window,
- RootWindowOfScreen(xfc->screen),
- x, y, &x, &y, &childWindow);
-
+ RootWindowOfScreen(xfc->screen),
+ x, y, &x, &y, &childWindow);
}
xf_event_adjust_coordinates(xfc, &x, &y);
return TRUE;
return xf_generic_ButtonPress(xfc, event->xbutton.x, event->xbutton.y,
- event->xbutton.button, event->xbutton.window, app);
+ event->xbutton.button, event->xbutton.window, app);
}
-BOOL xf_generic_ButtonRelease(xfContext* xfc, int x, int y, int button, Window window, BOOL app)
+BOOL xf_generic_ButtonRelease(xfContext* xfc, int x, int y, int button,
+ Window window, BOOL app)
{
int flags;
BOOL wheel;
BOOL extended;
rdpInput* input;
Window childWindow;
-
flags = 0;
wheel = FALSE;
extended = FALSE;
case Button1:
case Button2:
case Button3:
- flags = xfc->button_map[button-BUTTON_BASE];
+ flags = xfc->button_map[button - BUTTON_BASE];
break;
case 6:
/* Translate to desktop coordinates */
XTranslateCoordinates(xfc->display, window,
- RootWindowOfScreen(xfc->screen),
- x, y, &x, &y, &childWindow);
+ RootWindowOfScreen(xfc->screen),
+ x, y, &x, &y, &childWindow);
}
xf_event_adjust_coordinates(xfc, &x, &y);
return TRUE;
return xf_generic_ButtonRelease(xfc, event->xbutton.x, event->xbutton.y,
- event->xbutton.button, event->xbutton.window, app);
+ event->xbutton.button, event->xbutton.window, app);
}
static BOOL xf_event_KeyPress(xfContext* xfc, XEvent* event, BOOL app)
{
KeySym keysym;
char str[256];
-
XLookupString((XKeyEvent*) event, str, sizeof(str), &keysym, NULL);
-
xf_keyboard_key_press(xfc, event->xkey.keycode, keysym);
-
return TRUE;
}
}
xf_keyboard_key_release(xfc, event->xkey.keycode);
-
return TRUE;
}
xfc->focused = TRUE;
if (xfc->mouse_active && !app)
- XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync,
+ GrabModeAsync, CurrentTime);
if (app)
{
xfAppWindow* appWindow;
-
xf_rail_send_activate(xfc, event->xany.window, TRUE);
-
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
/* Update the server with any window changes that occurred while the window was not focused. */
}
xf_keyboard_focus_in(xfc);
-
return TRUE;
}
if (app)
{
xfAppWindow* appWindow;
-
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
if (appWindow)
xfc->mouse_active = TRUE;
if (xfc->fullscreen)
- XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot,
+ CurrentTime);
if (xfc->focused)
- XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync,
+ GrabModeAsync, CurrentTime);
}
else
{
xfAppWindow* appWindow;
-
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
/* keep track of which window has focus so that we can apply pointer updates */
{
Window childWindow;
xfAppWindow* appWindow;
+ rdpSettings* settings = xfc->context.settings;
if (!app)
{
xfc->window->top = event->xconfigure.y;
if (xfc->window->width != event->xconfigure.width ||
- xfc->window->height != event->xconfigure.height)
+ xfc->window->height != event->xconfigure.height)
{
xfc->window->width = event->xconfigure.width;
xfc->window->height = event->xconfigure.height;
#ifdef WITH_XRENDER
xfc->offset_x = 0;
xfc->offset_y = 0;
+
if (xfc->settings->SmartSizing || xfc->settings->MultiTouchGestures)
{
xfc->scaledWidth = xfc->window->width;
xfc->scaledHeight = xfc->window->height;
- xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
+ xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
}
else
{
- xfc->scaledWidth = xfc->sessionWidth;
- xfc->scaledHeight = xfc->sessionHeight;
+ xfc->scaledWidth = settings->DesktopWidth;
+ xfc->scaledHeight = settings->DesktopHeight;
}
+
#endif
}
+
return TRUE;
}
* ConfigureNotify coordinates are expressed relative to the window parent.
* Translate these to root window coordinates.
*/
-
XTranslateCoordinates(xfc->display, appWindow->handle,
- RootWindowOfScreen(xfc->screen),
- 0, 0, &appWindow->x, &appWindow->y, &childWindow);
-
+ RootWindowOfScreen(xfc->screen),
+ 0, 0, &appWindow->x, &appWindow->y, &childWindow);
appWindow->width = event->xconfigure.width;
appWindow->height = event->xconfigure.height;
}
else
{
- if ((!event->xconfigure.send_event || appWindow->local_move.state == LMS_NOT_ACTIVE)
- && !appWindow->rail_ignore_configure && xfc->focused)
+ if ((!event->xconfigure.send_event
+ || appWindow->local_move.state == LMS_NOT_ACTIVE)
+ && !appWindow->rail_ignore_configure && xfc->focused)
xf_rail_adjust_position(xfc, appWindow);
}
-
}
return TRUE;
RECTANGLE_16 rect;
xfAppWindow* appWindow;
rdpUpdate* update = xfc->instance->update;
+ rdpSettings* settings = xfc->context.settings;
if (!app)
{
rect.left = 0;
rect.top = 0;
- rect.right = xfc->sessionWidth;
- rect.bottom = xfc->sessionHeight;
-
+ rect.right = settings->DesktopWidth;
+ rect.bottom = settings->DesktopHeight;
update->SuppressOutput((rdpContext*) xfc, 1, &rect);
}
else
if (appWindow)
{
/* local restore event */
-
/* This is now handled as part of the PropertyNotify
* Doing this here would inhibit the ability to restore a maximized window
* that is minimized back to the maximized state
*/
-
//xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
appWindow->is_mapped = TRUE;
}
{
xfAppWindow* appWindow;
rdpUpdate* update = xfc->instance->update;
-
xf_keyboard_release_all_keypress(xfc);
if (!app)
* when the window has been minimized, maximized, restored locally
* ie. not using the buttons on the rail window itself
*/
-
if (app)
{
- xfAppWindow* appWindow;
-
+ xfAppWindow* appWindow;
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
if (!appWindow)
return TRUE;
- if ((((Atom) event->xproperty.atom == xfc->_NET_WM_STATE) && (event->xproperty.state != PropertyDelete)) ||
- (((Atom) event->xproperty.atom == xfc->WM_STATE) && (event->xproperty.state != PropertyDelete)))
- {
- int i;
- BOOL status;
- BOOL maxVert = FALSE;
- BOOL maxHorz = FALSE;
- BOOL minimized = FALSE;
- unsigned long nitems;
- unsigned long bytes;
- unsigned char* prop;
-
- if ((Atom) event->xproperty.atom == xfc->_NET_WM_STATE)
- {
+ if ((((Atom) event->xproperty.atom == xfc->_NET_WM_STATE)
+ && (event->xproperty.state != PropertyDelete)) ||
+ (((Atom) event->xproperty.atom == xfc->WM_STATE)
+ && (event->xproperty.state != PropertyDelete)))
+ {
+ int i;
+ BOOL status;
+ BOOL maxVert = FALSE;
+ BOOL maxHorz = FALSE;
+ BOOL minimized = FALSE;
+ unsigned long nitems;
+ unsigned long bytes;
+ unsigned char* prop;
+
+ if ((Atom) event->xproperty.atom == xfc->_NET_WM_STATE)
+ {
status = xf_GetWindowProperty(xfc, event->xproperty.window,
- xfc->_NET_WM_STATE, 12, &nitems, &bytes, &prop);
+ xfc->_NET_WM_STATE, 12, &nitems, &bytes, &prop);
if (status)
{
for (i = 0; i < nitems; i++)
{
- if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False))
+ if ((Atom)((UINT16**) prop)[i] == XInternAtom(xfc->display,
+ "_NET_WM_STATE_MAXIMIZED_VERT", False))
{
maxVert = TRUE;
}
- if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False))
+ if ((Atom)((UINT16**) prop)[i] == XInternAtom(xfc->display,
+ "_NET_WM_STATE_MAXIMIZED_HORZ", False))
{
maxHorz = TRUE;
}
XFree(prop);
}
- }
+ }
- if ((Atom) event->xproperty.atom == xfc->WM_STATE)
- {
+ if ((Atom) event->xproperty.atom == xfc->WM_STATE)
+ {
status = xf_GetWindowProperty(xfc, event->xproperty.window,
- xfc->WM_STATE, 1, &nitems, &bytes, &prop);
+ xfc->WM_STATE, 1, &nitems, &bytes, &prop);
if (status)
{
XFree(prop);
}
- }
-
- if (maxVert && maxHorz && !minimized && (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED))
- {
- appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
- xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
- }
- else if (minimized && (appWindow->rail_state != WINDOW_SHOW_MINIMIZED))
- {
- appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
- xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
- }
- else if (!minimized && !maxVert && !maxHorz && (appWindow->rail_state != WINDOW_SHOW))
- {
- appWindow->rail_state = WINDOW_SHOW;
- xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
- }
- }
- }
+ }
+
+ if (maxVert && maxHorz && !minimized
+ && (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED))
+ {
+ appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
+ xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
+ }
+ else if (minimized && (appWindow->rail_state != WINDOW_SHOW_MINIMIZED))
+ {
+ appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
+ xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
+ }
+ else if (!minimized && !maxVert && !maxHorz
+ && (appWindow->rail_state != WINDOW_SHOW))
+ {
+ appWindow->rail_state = WINDOW_SHOW;
+ xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
+ }
+ }
+ }
return TRUE;
}
-static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, XEvent* event)
+static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow,
+ XEvent* event)
{
if (!xfc->remote_app)
return FALSE;
switch (appWindow->local_move.state)
{
case LMS_NOT_ACTIVE:
+
/* No local move in progress, nothing to do */
/* Prevent Configure from happening during indeterminant state of Horz or Vert Max only */
-
- if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
- {
- appWindow->rail_ignore_configure = FALSE;
- return TRUE;
- }
+ if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
+ {
+ appWindow->rail_ignore_configure = FALSE;
+ return TRUE;
+ }
break;
case LMS_STARTING:
+
/* Local move initiated by RDP server, but we have not yet seen any updates from the X server */
switch (event->type)
{
case ConfigureNotify:
/* Starting to see move events from the X server. Local move is now in progress. */
appWindow->local_move.state = LMS_ACTIVE;
-
/* Allow these events to be processed during move to keep our state up to date. */
break;
+
case ButtonPress:
case ButtonRelease:
case KeyPress:
case KeyRelease:
case UnmapNotify:
- /*
- * A button release event means the X window server did not grab the
- * mouse before the user released it. In this case we must cancel the
- * local move. The event will be processed below as normal, below.
- */
- break;
+ /*
+ * A button release event means the X window server did not grab the
+ * mouse before the user released it. In this case we must cancel the
+ * local move. The event will be processed below as normal, below.
+ */
+ break;
+
case VisibilityNotify:
case PropertyNotify:
case Expose:
/* Allow these events to pass */
break;
+
default:
/* Eat any other events */
return TRUE;
}
+
break;
case LMS_ACTIVE:
+
/* Local move is in progress */
switch (event->type)
{
case GravityNotify:
/* Keep us up to date on position */
break;
+
default:
/* Any other event terminates move */
xf_rail_end_local_move(xfc, appWindow);
break;
}
+
break;
case LMS_TERMINATING:
xf_event_execute_action_script(xfc, event);
if (event->type != MotionNotify)
- DEBUG_X11("%s Event(%d): wnd=0x%04X", X11_EVENT_STRINGS[event->type], event->type, (UINT32) event->xany.window);
+ DEBUG_X11("%s Event(%d): wnd=0x%04X", X11_EVENT_STRINGS[event->type],
+ event->type, (UINT32) event->xany.window);
switch (event->type)
{
case PropertyNotify:
status = xf_event_PropertyNotify(xfc, event, xfc->remote_app);
break;
-
}
if (!xfc->remote_app)
}
xf_input_handle_event(xfc, event);
-
XSync(xfc->display, FALSE);
-
return status;
}
BOOL xf_gdi_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmapUpdate)
{
- int nXDst;
- int nYDst;
- int nXSrc;
- int nYSrc;
- int nWidth;
- int nHeight;
UINT32 index;
- XImage* image;
- BYTE* pSrcData;
- BYTE* pDstData;
- UINT32 SrcSize;
- BOOL compressed;
- UINT32 SrcFormat;
- BITMAP_DATA* bitmap;
rdpCodecs* codecs = context->codecs;
xfContext* xfc = (xfContext*) context;
+ rdpSettings* settings = context->settings;
BOOL ret = TRUE;
for (index = 0; index < bitmapUpdate->number; index++)
{
- UINT32 bitsPerPixel;
- bitmap = &(bitmapUpdate->rectangles[index]);
- nXSrc = 0;
- nYSrc = 0;
- nXDst = bitmap->destLeft;
- nYDst = bitmap->destTop;
- nWidth = bitmap->width;
- nHeight = bitmap->height;
- pSrcData = bitmap->bitmapDataStream;
- SrcSize = bitmap->bitmapLength;
- compressed = bitmap->compressed;
- bitsPerPixel = bitmap->bitsPerPixel;
- SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
+ BYTE* pDstData;
+ XImage* image;
+ BITMAP_DATA* bitmap = &(bitmapUpdate->rectangles[index]);
+ UINT32 bitsPerPixel = bitmap->bitsPerPixel;
+ UINT32 nXDst = bitmap->destLeft;
+ UINT32 nYDst = bitmap->destTop;
+ UINT32 nWidth = MIN(bitmap->destRight,
+ settings->DesktopWidth - 1) - bitmap->destLeft + 1; /* clip width */
+ UINT32 nHeight = MIN(bitmap->destBottom,
+ settings->DesktopHeight - 1) - bitmap->destTop + 1; /* clip height */
+ const BYTE* pSrcData = bitmap->bitmapDataStream;
+ UINT32 SrcSize = bitmap->bitmapLength;
+ BOOL compressed = bitmap->compressed;
+ UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
if (compressed)
{
{
if (!interleaved_decompress(codecs->interleaved,
pSrcData, SrcSize,
+ bitmap->width, bitmap->height,
bitsPerPixel,
pDstData,
xfc->format, 0,
}
else
{
- if (!planar_decompress(codecs->planar, pSrcData, SrcSize, pDstData,
+ if (!planar_decompress(codecs->planar, pSrcData, SrcSize,
+ bitmap->width, bitmap->height, pDstData,
xfc->format, 0, 0, 0, nWidth, nHeight, TRUE))
return FALSE;
}
if (bpp < 32)
{
if (!interleaved_decompress(context->codecs->interleaved,
- pSrcData, SrcSize, bpp,
+ pSrcData, SrcSize, width, height, bpp,
pDstData, xfc->format,
0, 0, 0, width, height,
&context->gdi->palette))
else
{
if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,
+ width, height,
pDstData, xfc->format, 0, 0, 0, width, height, TRUE))
return FALSE;
}
GC gc;
int xfds;
int depth;
- int sessionWidth;
- int sessionHeight;
- int srcBpp;
+
GC gc_mono;
BOOL invert;
UINT32 format;
FREERDP_API BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
const BYTE* pSrcData, UINT32 SrcSize,
+ UINT32 nSrcWidth, UINT32 nSrcHeight,
UINT32 bpp,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
+ UINT32 nDstWidth, UINT32 nDstHeight,
const gdiPalette* palette);
FREERDP_API BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
const gdiPalette* palette, UINT32 bpp);
-FREERDP_API BOOL bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT*
- interleaved);
+FREERDP_API BOOL bitmap_interleaved_context_reset(
+ BITMAP_INTERLEAVED_CONTEXT* interleaved);
FREERDP_API BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new(
BOOL Compressor);
FREERDP_API BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize,
+ UINT32 nSrcWidth, UINT32 nSrcHeight,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, BOOL vFlip);
+ UINT32 nDstWidth, UINT32 nDstHeight, BOOL vFlip);
#ifdef __cplusplus
}
gdiBitmap* drawing;
UINT32 bitmap_size;
UINT32 bitmap_stride;
- BYTE* bitmap_buffer;
BYTE* primary_buffer;
gdiPalette palette;
gdiBitmap* image;
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
-FREERDP_API BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
-FREERDP_API BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr);
-FREERDP_API BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT *lpPoints, int nCount);
-FREERDP_API BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT *lpPoints, int *lpPolyCounts, int nCount);
-FREERDP_API BOOL gdi_Rectangle(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
-
-typedef BOOL (*p_FillRect)(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr);
+FREERDP_API BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect,
+ int nRightRect, int nBottomRect);
+FREERDP_API BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect,
+ HGDI_BRUSH hbr);
+FREERDP_API BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT* lpPoints, int nCount);
+FREERDP_API BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints,
+ int* lpPolyCounts, int nCount);
+FREERDP_API BOOL gdi_Rectangle(HGDI_DC hdc, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight);
#ifdef __cplusplus
- }
+}
#endif
#endif /* FREERDP_GDI_SHAPE_H */
BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
const BYTE* pSrcData, UINT32 SrcSize,
+ UINT32 nSrcWidth, UINT32 nSrcHeight,
UINT32 bpp,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
+ UINT32 nDstWidth, UINT32 nDstHeight,
const gdiPalette* palette)
{
UINT32 scanline;
return FALSE;
if (nDstStep <= 0)
- nDstStep = nWidth * dstBytesPerPixel;
+ nDstStep = nDstWidth * dstBytesPerPixel;
switch (bpp)
{
case 24:
- scanline = nWidth * 3;
+ scanline = nSrcWidth * 3;
SrcFormat = PIXEL_FORMAT_BGR24_VF;
break;
case 16:
- scanline = nWidth * 2;
+ scanline = nSrcWidth * 2;
SrcFormat = PIXEL_FORMAT_RGB16_VF;
break;
case 15:
- scanline = nWidth * 2;
+ scanline = nSrcWidth * 2;
SrcFormat = PIXEL_FORMAT_RGB15_VF;
break;
case 8:
- scanline = nWidth;
+ scanline = nSrcWidth;
SrcFormat = PIXEL_FORMAT_RGB8_VF;
break;
return FALSE;
}
- BufferSize = scanline * nHeight;
+ BufferSize = scanline * nSrcHeight;
if (BufferSize > interleaved->TempSize)
{
{
case 24:
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
- scanline, nWidth, nHeight);
+ scanline, nSrcWidth, nSrcHeight);
break;
case 16:
case 15:
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
- scanline, nWidth, nHeight);
+ scanline, nSrcWidth, nSrcHeight);
break;
case 8:
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
- scanline, nWidth, nHeight);
+ scanline, nSrcWidth, nSrcHeight);
break;
default:
}
return freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
- nWidth, nHeight, interleaved->TempBuffer,
+ nDstWidth, nDstHeight, interleaved->TempBuffer,
SrcFormat, scanline, 0, 0, palette);
}
BYTE* outPlanes[4]);
static INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
- int nWidth, int nHeight)
+ UINT32 nDstWidth, UINT32 nDstHeight)
{
- int x, y;
+ UINT32 x, y;
int cRawBytes;
int nRunLength;
BYTE controlByte;
BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize,
+ UINT32 nSrcWidth, UINT32 nSrcHeight,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
+ UINT32 nDstWidth, UINT32 nDstHeight, BOOL vFlip)
{
BOOL cs;
BOOL rle;
UINT32 dstBytesPerPixel;
const BYTE* planes[4];
UINT32 UncompressedSize;
+ const UINT32 w = MIN(nSrcWidth, nDstWidth);
+ const UINT32 h = MIN(nSrcHeight, nDstHeight);
const primitives_t* prims = primitives_get();
- if ((nWidth < 0) || (nHeight < 0))
+ if ((nSrcWidth < 0) || (nSrcHeight < 0))
return FALSE;
dstBitsPerPixel = GetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (nDstStep <= 0)
- nDstStep = nWidth * GetBytesPerPixel(DstFormat);
+ nDstStep = nDstWidth * GetBytesPerPixel(DstFormat);
srcp = pSrcData;
- UncompressedSize = nWidth * nHeight * GetBytesPerPixel(DstFormat);
+ UncompressedSize = nSrcWidth * nSrcHeight * GetBytesPerPixel(DstFormat);
if (!pDstData)
{
if (!cll && cs)
return FALSE; /* Chroma subsampling requires YCoCg */
- subWidth = (nWidth / 2) + (nWidth % 2);
- subHeight = (nHeight / 2) + (nHeight % 2);
- planeSize = nWidth * nHeight;
+ subWidth = (nSrcWidth / 2) + (nSrcWidth % 2);
+ subHeight = (nSrcHeight / 2) + (nSrcHeight % 2);
+ planeSize = nSrcWidth * nSrcHeight;
subSize = subWidth * subHeight;
if (!cs)
{
rawSizes[0] = planeSize; /* LumaOrRedPlane */
- rawWidths[0] = nWidth;
- rawHeights[0] = nHeight;
+ rawWidths[0] = nSrcWidth;
+ rawHeights[0] = nSrcHeight;
rawSizes[1] = planeSize; /* OrangeChromaOrGreenPlane */
- rawWidths[1] = nWidth;
- rawHeights[1] = nHeight;
+ rawWidths[1] = nSrcWidth;
+ rawHeights[1] = nSrcHeight;
rawSizes[2] = planeSize; /* GreenChromaOrBluePlane */
- rawWidths[2] = nWidth;
- rawHeights[2] = nHeight;
+ rawWidths[2] = nSrcWidth;
+ rawHeights[2] = nSrcHeight;
rawSizes[3] = planeSize; /* AlphaPlane */
- rawWidths[3] = nWidth;
- rawHeights[3] = nHeight;
+ rawWidths[3] = nSrcWidth;
+ rawHeights[3] = nSrcHeight;
}
else /* Chroma Subsampling */
{
rawSizes[0] = planeSize; /* LumaOrRedPlane */
- rawWidths[0] = nWidth;
- rawHeights[0] = nHeight;
+ rawWidths[0] = nSrcWidth;
+ rawHeights[0] = nSrcHeight;
rawSizes[1] = subSize; /* OrangeChromaOrGreenPlane */
rawWidths[1] = subWidth;
rawHeights[1] = subHeight;
rawWidths[2] = subWidth;
rawHeights[2] = subHeight;
rawSizes[3] = planeSize; /* AlphaPlane */
- rawWidths[3] = nWidth;
- rawHeights[3] = nHeight;
+ rawWidths[3] = nSrcWidth;
+ rawHeights[3] = nSrcHeight;
}
if (!rle) /* RAW */
if (!cll) /* RGB */
{
+ UINT32 TempFormat;
+ BYTE* pTempData = pDstData;
+ UINT32 nTempStep = nDstStep;
+
+ if (alpha)
+ TempFormat = PIXEL_FORMAT_BGRA32;
+ else
+ TempFormat = PIXEL_FORMAT_BGRX32;
+
+ if ((DstFormat != TempFormat) || (nSrcWidth != nDstWidth)
+ || (nSrcHeight != nDstHeight))
+ {
+ pTempData = planar->pTempData;
+ }
+
if (!rle) /* RAW */
{
if (alpha)
{
- if (!planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip))
+ if (!planar_decompress_planes_raw(planes, pTempData, DstFormat, nDstStep,
+ nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
}
else /* NoAlpha */
{
- if (!planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip))
+ if (!planar_decompress_planes_raw(planes, pTempData, DstFormat, nDstStep,
+ nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
}
else /* RLE */
{
- UINT32 TempFormat;
- BYTE* pTempData = pDstData;
- UINT32 nTempStep = nDstStep;
-
- if (alpha)
- TempFormat = PIXEL_FORMAT_BGRA32;
- else
- TempFormat = PIXEL_FORMAT_BGRX32;
-
- if (DstFormat != TempFormat)
- {
- pTempData = planar->pTempData;
- }
-
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3,
vFlip); /* AlphaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* RedPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* GreenPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* BluePlane */
if (status < 0)
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* RedPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* GreenPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* BluePlane */
if (status < 0)
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
}
+ }
- if (pTempData != pDstData)
- {
- if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth,
- nHeight,
- pTempData,
- TempFormat, nTempStep, nXDst, nYDst, NULL))
- return FALSE;
- }
+ if (pTempData != pDstData)
+ {
+ if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, w,
+ h, pTempData,
+ TempFormat, nTempStep, nXDst, nYDst, NULL))
+ return FALSE;
}
}
else /* YCoCg */
if (alpha)
{
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip))
+ nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
else /* NoAlpha */
{
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip))
+ nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE;
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 3,
vFlip); /* AlphaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* LumaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* OrangeChromaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* GreenChromaPlane */
if (status < 0)
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 2,
vFlip); /* LumaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 1,
vFlip); /* OrangeChromaPlane */
if (status < 0)
return FALSE;
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ pTempData, nTempStep, nXDst, nYDst, nSrcWidth, nSrcHeight, 0,
vFlip); /* GreenChromaPlane */
if (status < 0)
}
}
- prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep,
- nWidth, nHeight, cll, alpha);
+ if (prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat,
+ nDstStep,
+ w, h, cll, alpha) != PRIMITIVES_SUCCESS)
+ return FALSE;
}
return (SrcSize == (srcp - pSrcData)) ? TRUE : FALSE;
pDstData = decompressedBitmap;
- if (!planar_decompress(planar, compressedBitmap, dstSize, pDstData,
+ if (!planar_decompress(planar, compressedBitmap, dstSize,
+ width, height, pDstData,
PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, FALSE))
{
printf("failed to decompress white bitmap: width: %d height: %d\n", width,
pDstData = decompressedBitmap;
- if (!planar_decompress(planar, compressedBitmap, dstSize, pDstData,
+ if (!planar_decompress(planar, compressedBitmap, dstSize,
+ width, height, pDstData,
PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, FALSE))
{
printf("failed to decompress black bitmap: width: %d height: %d\n", width,
pDstData = decompressedBitmap;
- if (!planar_decompress(planar, compressedBitmap, dstSize, pDstData,
+ if (!planar_decompress(planar, compressedBitmap, dstSize, width, height,
+ pDstData,
PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, FALSE))
{
printf("failed to decompress experimental bitmap 01: width: %d height: %d\n",
pDstData = decompressedBitmap;
- if (!planar_decompress(planar, compressedBitmap, dstSize, pDstData,
+ if (!planar_decompress(planar, compressedBitmap, dstSize, width, height,
+ pDstData,
PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, FALSE))
{
printf("failed to decompress experimental bitmap 02: width: %d height: %d\n",
pDstData = decompressedBitmap;
- if (!planar_decompress(planar, compressedBitmap, dstSize, pDstData,
+ if (!planar_decompress(planar, compressedBitmap, dstSize, width, height,
+ pDstData,
PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, FALSE))
{
printf("failed to decompress experimental bitmap 03: width: %d height: %d\n",
return TRUE;
}
-BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* bitmapData)
+static BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s,
+ BITMAP_DATA* bitmapData)
{
if (Stream_GetRemainingLength(s) < 18)
return FALSE;
{
if (!(bitmapData->flags & NO_BITMAP_COMPRESSION_HDR))
{
- Stream_Read_UINT16(s, bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
- Stream_Read_UINT16(s, bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
+ Stream_Read_UINT16(s,
+ bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
+ Stream_Read_UINT16(s,
+ bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
Stream_Read_UINT16(s, bitmapData->cbScanWidth); /* cbScanWidth (2 bytes) */
- Stream_Read_UINT16(s, bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
+ Stream_Read_UINT16(s,
+ bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
bitmapData->bitmapLength = bitmapData->cbCompMainBodySize;
}
bitmapData->compressed = TRUE;
- Stream_GetPointer(s, bitmapData->bitmapDataStream);
- Stream_Seek(s, bitmapData->bitmapLength);
}
else
- {
- if (Stream_GetRemainingLength(s) < bitmapData->bitmapLength)
- return FALSE;
-
bitmapData->compressed = FALSE;
- Stream_GetPointer(s, bitmapData->bitmapDataStream);
- Stream_Seek(s, bitmapData->bitmapLength);
- }
+ if (Stream_GetRemainingLength(s) < bitmapData->bitmapLength)
+ return FALSE;
+
+ Stream_GetPointer(s, bitmapData->bitmapDataStream);
+ Stream_Seek(s, bitmapData->bitmapLength);
return TRUE;
}
-BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* bitmapData)
+BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s,
+ BITMAP_DATA* bitmapData)
{
if (!Stream_EnsureRemainingCapacity(s, 64 + bitmapData->bitmapLength))
return FALSE;
{
if (!(bitmapData->flags & NO_BITMAP_COMPRESSION_HDR))
{
- Stream_Write_UINT16(s, bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
- Stream_Write_UINT16(s, bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
+ Stream_Write_UINT16(s,
+ bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
+ Stream_Write_UINT16(s,
+ bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
Stream_Write_UINT16(s, bitmapData->cbScanWidth); /* cbScanWidth (2 bytes) */
- Stream_Write_UINT16(s, bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
+ Stream_Write_UINT16(s,
+ bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
}
Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);
return TRUE;
}
-BOOL update_read_bitmap_update(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bitmapUpdate)
+BOOL update_read_bitmap_update(rdpUpdate* update, wStream* s,
+ BITMAP_UPDATE* bitmapUpdate)
{
- int i;
+ UINT32 i;
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
Stream_Read_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */
-
- WLog_Print(update->log, WLOG_DEBUG, "BitmapUpdate: %d", bitmapUpdate->number);
+ WLog_Print(update->log, WLOG_TRACE, "BitmapUpdate: %d", bitmapUpdate->number);
if (bitmapUpdate->number > bitmapUpdate->count)
{
UINT16 count;
- BITMAP_DATA *newdata;
-
+ BITMAP_DATA* newdata;
count = bitmapUpdate->number * 2;
-
newdata = (BITMAP_DATA*) realloc(bitmapUpdate->rectangles,
- sizeof(BITMAP_DATA) * count);
+ sizeof(BITMAP_DATA) * count);
+
if (!newdata)
return FALSE;
bitmapUpdate->rectangles = newdata;
-
ZeroMemory(&bitmapUpdate->rectangles[bitmapUpdate->count],
- sizeof(BITMAP_DATA) * (count - bitmapUpdate->count));
-
+ sizeof(BITMAP_DATA) * (count - bitmapUpdate->count));
bitmapUpdate->count = count;
}
/* rectangles */
- for (i = 0; i < (int) bitmapUpdate->number; i++)
+ for (i = 0; i < bitmapUpdate->number; i++)
{
if (!update_read_bitmap_data(update, s, &bitmapUpdate->rectangles[i]))
return FALSE;
}
+
return TRUE;
}
static BOOL update_write_bitmap_update(rdpUpdate* update, wStream* s,
- const BITMAP_UPDATE* bitmapUpdate)
+ const BITMAP_UPDATE* bitmapUpdate)
{
int i;
return FALSE;
Stream_Write_UINT16(s, UPDATE_TYPE_BITMAP); /* updateType */
-
Stream_Write_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */
/* rectangles */
return TRUE;
}
-BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_update)
+BOOL update_read_palette(rdpUpdate* update, wStream* s,
+ PALETTE_UPDATE* palette_update)
{
int i;
PALETTE_ENTRY* entry;
return FALSE;
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
- Stream_Read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */
+ Stream_Read_UINT32(s,
+ palette_update->number); /* numberColors (4 bytes), must be set to 256 */
if (palette_update->number > 256)
palette_update->number = 256;
for (i = 0; i < (int) palette_update->number; i++)
{
entry = &palette_update->entries[i];
-
Stream_Read_UINT8(s, entry->red);
Stream_Read_UINT8(s, entry->green);
Stream_Read_UINT8(s, entry->blue);
}
+
return TRUE;
}
void update_read_synchronize(rdpUpdate* update, wStream* s)
{
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
-
/**
* The Synchronize Update is an artifact from the
* T.128 protocol and should be ignored.
Stream_Read_UINT32(s, play_sound->duration); /* duration (4 bytes) */
Stream_Read_UINT32(s, play_sound->frequency); /* frequency (4 bytes) */
-
return TRUE;
}
return TRUE;
}
-BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_position)
+BOOL update_read_pointer_position(wStream* s,
+ POINTER_POSITION_UPDATE* pointer_position)
{
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
return TRUE;
}
-BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_system)
+BOOL update_read_pointer_system(wStream* s,
+ POINTER_SYSTEM_UPDATE* pointer_system)
{
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
return TRUE;
}
-BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color, int xorBpp)
+BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color,
+ int xorBpp)
{
- BYTE *newMask;
+ BYTE* newMask;
int scanlineSize;
if (Stream_GetRemainingLength(s) < 14)
Stream_Read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */
Stream_Read_UINT16(s, pointer_color->xPos); /* xPos (2 bytes) */
Stream_Read_UINT16(s, pointer_color->yPos); /* yPos (2 bytes) */
-
/**
* As stated in 2.2.9.1.1.4.4 Color Pointer Update:
* The maximum allowed pointer width/height is 96 pixels if the client indicated support
*/
Stream_Read_UINT16(s, pointer_color->width); /* width (2 bytes) */
Stream_Read_UINT16(s, pointer_color->height); /* height (2 bytes) */
+
if ((pointer_color->width > 96) || (pointer_color->height > 96))
return FALSE;
- Stream_Read_UINT16(s, pointer_color->lengthAndMask); /* lengthAndMask (2 bytes) */
- Stream_Read_UINT16(s, pointer_color->lengthXorMask); /* lengthXorMask (2 bytes) */
+ Stream_Read_UINT16(s,
+ pointer_color->lengthAndMask); /* lengthAndMask (2 bytes) */
+ Stream_Read_UINT16(s,
+ pointer_color->lengthXorMask); /* lengthXorMask (2 bytes) */
/**
* There does not seem to be any documentation on why
*/
if (pointer_color->xPos >= pointer_color->width)
pointer_color->xPos = 0;
+
if (pointer_color->yPos >= pointer_color->height)
pointer_color->yPos = 0;
scanlineSize = (7 + xorBpp * pointer_color->width) / 8;
scanlineSize = ((scanlineSize + 1) / 2) * 2;
+
if (scanlineSize * pointer_color->height != pointer_color->lengthXorMask)
{
WLog_ERR(TAG, "invalid lengthXorMask: width=%d height=%d, %d instead of %d",
- pointer_color->width, pointer_color->height,
- pointer_color->lengthXorMask, scanlineSize * pointer_color->height);
+ pointer_color->width, pointer_color->height,
+ pointer_color->lengthXorMask, scanlineSize * pointer_color->height);
return FALSE;
}
newMask = realloc(pointer_color->xorMaskData, pointer_color->lengthXorMask);
+
if (!newMask)
return FALSE;
pointer_color->xorMaskData = newMask;
-
Stream_Read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask);
}
scanlineSize = ((7 + pointer_color->width) / 8);
scanlineSize = ((1 + scanlineSize) / 2) * 2;
+
if (scanlineSize * pointer_color->height != pointer_color->lengthAndMask)
{
WLog_ERR(TAG, "invalid lengthAndMask: %d instead of %d",
- pointer_color->lengthAndMask, scanlineSize * pointer_color->height);
+ pointer_color->lengthAndMask, scanlineSize * pointer_color->height);
return FALSE;
}
newMask = realloc(pointer_color->andMaskData, pointer_color->lengthAndMask);
+
if (!newMask)
return FALSE;
pointer_color->andMaskData = newMask;
-
Stream_Read(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
}
return FALSE;
Stream_Read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
+
if ((pointer_new->xorBpp < 1) || (pointer_new->xorBpp > 32))
{
WLog_ERR(TAG, "invalid xorBpp %d", pointer_new->xorBpp);
return FALSE;
}
- return update_read_pointer_color(s, &pointer_new->colorPtrAttr, pointer_new->xorBpp); /* colorPtrAttr */
+
+ return update_read_pointer_color(s, &pointer_new->colorPtrAttr,
+ pointer_new->xorBpp); /* colorPtrAttr */
}
-BOOL update_read_pointer_cached(wStream* s, POINTER_CACHED_UPDATE* pointer_cached)
+BOOL update_read_pointer_cached(wStream* s,
+ POINTER_CACHED_UPDATE* pointer_cached)
{
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
case PTR_MSG_TYPE_POSITION:
if (!update_read_pointer_position(s, &pointer->pointer_position))
return FALSE;
+
IFCALL(pointer->PointerPosition, context, &pointer->pointer_position);
break;
case PTR_MSG_TYPE_SYSTEM:
if (!update_read_pointer_system(s, &pointer->pointer_system))
return FALSE;
+
IFCALL(pointer->PointerSystem, context, &pointer->pointer_system);
break;
case PTR_MSG_TYPE_COLOR:
if (!update_read_pointer_color(s, &pointer->pointer_color, 24))
return FALSE;
+
IFCALL(pointer->PointerColor, context, &pointer->pointer_color);
break;
case PTR_MSG_TYPE_POINTER:
if (!update_read_pointer_new(s, &pointer->pointer_new))
return FALSE;
+
IFCALL(pointer->PointerNew, context, &pointer->pointer_new);
break;
case PTR_MSG_TYPE_CACHED:
if (!update_read_pointer_cached(s, &pointer->pointer_cached))
return FALSE;
+
IFCALL(pointer->PointerCached, context, &pointer->pointer_cached);
break;
default:
break;
}
+
return TRUE;
}
Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */
//WLog_DBG(TAG, "%s Update Data PDU", UPDATE_TYPE_STRINGS[updateType]);
-
IFCALL(update->BeginPaint, context);
switch (updateType)
WLog_ERR(TAG, "UPDATE_TYPE_ORDERS - update_recv_orders() failed");
return FALSE;
}
+
break;
case UPDATE_TYPE_BITMAP:
WLog_ERR(TAG, "UPDATE_TYPE_BITMAP - update_read_bitmap_update() failed");
return FALSE;
}
+
IFCALL(update->BitmapUpdate, context, &update->bitmap_update);
break;
WLog_ERR(TAG, "UPDATE_TYPE_PALETTE - update_read_palette() failed");
return FALSE;
}
+
IFCALL(update->Palette, context, &update->palette_update);
break;
}
IFCALL(update->EndPaint, context);
-
return TRUE;
}
ZeroMemory(&primary->polygon_cb, sizeof(POLYGON_CB_ORDER));
ZeroMemory(&primary->ellipse_sc, sizeof(ELLIPSE_SC_ORDER));
ZeroMemory(&primary->ellipse_cb, sizeof(ELLIPSE_CB_ORDER));
-
primary->order_info.orderType = ORDER_TYPE_PATBLT;
if (!update->initialState)
return FALSE;
update->altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
- IFCALL(update->altsec->SwitchSurface, update->context, &(update->altsec->switch_surface));
-
+ IFCALL(update->altsec->SwitchSurface, update->context,
+ &(update->altsec->switch_surface));
update->initialState = FALSE;
-
return TRUE;
}
update->EndPaint(context);
s = fastpath_update_pdu_init_new(context->rdp->fastpath);
+
if (!s)
return FALSE;
+
Stream_SealLength(s);
Stream_Seek(s, 2); /* numberOrders (2 bytes) */
-
update->combineUpdates = TRUE;
update->numberOrders = 0;
update->us = s;
s = update->us;
headerLength = Stream_Length(s);
Stream_SealLength(s);
-
Stream_SetPosition(s, headerLength);
Stream_Write_UINT16(s, update->numberOrders); /* numberOrders (2 bytes) */
Stream_SetPosition(s, Stream_Length(s));
if (update->numberOrders > 0)
{
WLog_ERR(TAG, "sending %d orders", update->numberOrders);
- fastpath_send_update_pdu(context->rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s, FALSE);
+ fastpath_send_update_pdu(context->rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s,
+ FALSE);
}
update->combineUpdates = FALSE;
update->numberOrders = 0;
update->us = NULL;
-
Stream_Free(s, TRUE);
return TRUE;
}
{
wStream* s;
rdpUpdate* update = context->update;
-
s = update->us;
if (!update->us)
}
static BOOL update_set_bounds(rdpContext* context,
- const rdpBounds* bounds)
+ const rdpBounds* bounds)
{
rdpUpdate* update = context->update;
-
CopyMemory(&update->previousBounds, &update->currentBounds, sizeof(rdpBounds));
if (!bounds)
ZeroMemory(&update->currentBounds, sizeof(rdpBounds));
else
CopyMemory(&update->currentBounds, bounds, sizeof(rdpBounds));
+
return TRUE;
}
BOOL update_bounds_is_null(rdpBounds* bounds)
{
if ((bounds->left == 0) && (bounds->top == 0) &&
- (bounds->right == 0) && (bounds->bottom == 0))
+ (bounds->right == 0) && (bounds->bottom == 0))
return TRUE;
return FALSE;
BOOL update_bounds_equals(rdpBounds* bounds1, rdpBounds* bounds2)
{
if ((bounds1->left == bounds2->left) && (bounds1->top == bounds2->top) &&
- (bounds1->right == bounds2->right) && (bounds1->bottom == bounds2->bottom))
+ (bounds1->right == bounds2->right) && (bounds1->bottom == bounds2->bottom))
return TRUE;
return FALSE;
{
int length = 0;
rdpUpdate* update = context->update;
-
orderInfo->boundsFlags = 0;
if (update_bounds_is_null(&update->currentBounds))
}
static int update_prepare_order_info(rdpContext* context,
- ORDER_INFO* orderInfo, UINT32 orderType)
+ ORDER_INFO* orderInfo, UINT32 orderType)
{
int length = 1;
-
orderInfo->fieldFlags = 0;
orderInfo->orderType = orderType;
-
orderInfo->controlFlags = ORDER_STANDARD;
-
orderInfo->controlFlags |= ORDER_TYPE_CHANGE;
length += 1;
-
length += PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType];
-
length += update_prepare_bounds(context, orderInfo);
-
return length;
}
int update_write_order_info(rdpContext* context, wStream* s,
- ORDER_INFO* orderInfo, int offset)
+ ORDER_INFO* orderInfo, int offset)
{
int position;
-
position = Stream_GetPosition(s);
Stream_SetPosition(s, offset);
-
Stream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */
if (orderInfo->controlFlags & ORDER_TYPE_CHANGE)
Stream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */
update_write_field_flags(s, orderInfo->fieldFlags, orderInfo->controlFlags,
- PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]);
-
+ PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]);
update_write_bounds(s, orderInfo);
-
Stream_SetPosition(s, position);
-
return 0;
}
static void update_write_refresh_rect(wStream* s, BYTE count,
- const RECTANGLE_16* areas)
+ const RECTANGLE_16* areas)
{
int i;
-
Stream_Write_UINT8(s, count); /* numberOfAreas (1 byte) */
Stream_Seek(s, 3); /* pad3Octets (3 bytes) */
}
static BOOL update_send_refresh_rect(rdpContext* context, BYTE count,
- const RECTANGLE_16* areas)
+ const RECTANGLE_16* areas)
{
wStream* s;
rdpRdp* rdp = context->rdp;
{
BOOL ret;
s = rdp_data_pdu_init(rdp);
+
if (!s)
return FALSE;
- update_write_refresh_rect(s, count, areas);
+ update_write_refresh_rect(s, count, areas);
ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_REFRESH_RECT, rdp->mcs->userId);
Stream_Release(s);
return ret;
}
+
return TRUE;
}
static void update_write_suppress_output(wStream* s, BYTE allow,
- const RECTANGLE_16* area)
+ const RECTANGLE_16* area)
{
Stream_Write_UINT8(s, allow); /* allowDisplayUpdates (1 byte) */
/* Use zeros for padding (like mstsc) for compatibility with legacy servers */
}
static BOOL update_send_suppress_output(rdpContext* context, BYTE allow,
- const RECTANGLE_16* area)
+ const RECTANGLE_16* area)
{
wStream* s;
rdpRdp* rdp = context->rdp;
{
BOOL ret;
s = rdp_data_pdu_init(rdp);
+
if (!s)
return FALSE;
- update_write_suppress_output(s, allow, area);
- ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SUPPRESS_OUTPUT, rdp->mcs->userId);
+ update_write_suppress_output(s, allow, area);
+ ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SUPPRESS_OUTPUT,
+ rdp->mcs->userId);
Stream_Release(s);
return ret;
}
+
return TRUE;
}
wStream* update;
rdpRdp* rdp = context->rdp;
BOOL ret;
-
update = fastpath_update_pdu_init(rdp->fastpath);
+
if (!update)
return FALSE;
+
if (!Stream_EnsureRemainingCapacity(update, Stream_GetPosition(s)))
{
ret = FALSE;
goto out;
}
- Stream_Write(update, Stream_Buffer(s), Stream_GetPosition(s));
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update, FALSE);
+ Stream_Write(update, Stream_Buffer(s), Stream_GetPosition(s));
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS,
+ update, FALSE);
out:
Stream_Release(update);
return ret;
}
static BOOL update_send_surface_bits(rdpContext* context,
- const SURFACE_BITS_COMMAND* surfaceBitsCommand)
+ const SURFACE_BITS_COMMAND* surfaceBitsCommand)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
update_force_flush(context);
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
- if (!Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surfaceBitsCommand->bitmapDataLength) ||
- !update_write_surfcmd_surface_bits_header(s, surfaceBitsCommand))
+ if (!Stream_EnsureRemainingCapacity(s,
+ SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surfaceBitsCommand->bitmapDataLength)
+ ||
+ !update_write_surfcmd_surface_bits_header(s, surfaceBitsCommand))
goto out_fail;
- Stream_Write(s, surfaceBitsCommand->bitmapData, surfaceBitsCommand->bitmapDataLength);
+ Stream_Write(s, surfaceBitsCommand->bitmapData,
+ surfaceBitsCommand->bitmapDataLength);
- if (!fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s, surfaceBitsCommand->skipCompression))
+ if (!fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s,
+ surfaceBitsCommand->skipCompression))
goto out_fail;
update_force_flush(context);
-
ret = TRUE;
out_fail:
Stream_Release(s);
}
static BOOL update_send_surface_frame_marker(rdpContext* context,
- const SURFACE_FRAME_MARKER* surfaceFrameMarker)
+ const SURFACE_FRAME_MARKER* surfaceFrameMarker)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
update_force_flush(context);
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
- if (!update_write_surfcmd_frame_marker(s, surfaceFrameMarker->frameAction, surfaceFrameMarker->frameId) ||
- !fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s, FALSE))
+ if (!update_write_surfcmd_frame_marker(s, surfaceFrameMarker->frameAction,
+ surfaceFrameMarker->frameId) ||
+ !fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s,
+ FALSE))
goto out_fail;
update_force_flush(context);
-
ret = TRUE;
out_fail:
Stream_Release(s);
}
static BOOL update_send_surface_frame_bits(rdpContext* context,
- const SURFACE_BITS_COMMAND* cmd,
- BOOL first, BOOL last, UINT32 frameId)
+ const SURFACE_BITS_COMMAND* cmd,
+ BOOL first, BOOL last, UINT32 frameId)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
update_force_flush(context);
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
- if (!Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) cmd->bitmapDataLength + 16))
+ if (!Stream_EnsureRemainingCapacity(s,
+ SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) cmd->bitmapDataLength + 16))
goto out_fail;
if (first)
{
- if (!update_write_surfcmd_frame_marker(s, SURFACECMD_FRAMEACTION_BEGIN, frameId))
+ if (!update_write_surfcmd_frame_marker(s, SURFACECMD_FRAMEACTION_BEGIN,
+ frameId))
goto out_fail;
}
if (!update_write_surfcmd_surface_bits_header(s, cmd))
goto out_fail;
+
Stream_Write(s, cmd->bitmapData, cmd->bitmapDataLength);
if (last)
goto out_fail;
}
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s, cmd->skipCompression);
-
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s,
+ cmd->skipCompression);
update_force_flush(context);
-
out_fail:
Stream_Release(s);
return ret;
{
BOOL ret;
s = rdp_data_pdu_init(rdp);
+
if (!s)
return FALSE;
+
Stream_Write_UINT32(s, frameId);
- ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->userId);
+ ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE,
+ rdp->mcs->userId);
Stream_Release(s);
return ret;
}
+
return TRUE;
}
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
+
Stream_Zero(s, 2); /* pad2Octets (2 bytes) */
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SYNCHRONIZE, s, FALSE);
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SYNCHRONIZE,
+ s, FALSE);
Stream_Release(s);
return ret;
}
}
static BOOL update_send_bitmap_update(rdpContext* context,
- const BITMAP_UPDATE* bitmapUpdate)
+ const BITMAP_UPDATE* bitmapUpdate)
{
wStream* s;
rdpRdp* rdp = context->rdp;
rdpUpdate* update = context->update;
BOOL ret = TRUE;
-
update_force_flush(context);
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
+
if (!update_write_bitmap_update(update, s, bitmapUpdate) ||
- !fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_BITMAP, s, bitmapUpdate->skipCompression))
+ !fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_BITMAP, s,
+ bitmapUpdate->skipCompression))
{
ret = FALSE;
goto out_fail;
}
update_force_flush(context);
-
out_fail:
Stream_Release(s);
return ret;
}
static BOOL update_send_play_sound(rdpContext* context,
- const PLAY_SOUND_UPDATE* play_sound)
+ const PLAY_SOUND_UPDATE* play_sound)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret;
- if (!rdp->settings->ReceivedCapabilities[CAPSET_TYPE_SOUND]) {
+ if (!rdp->settings->ReceivedCapabilities[CAPSET_TYPE_SOUND])
+ {
return TRUE;
}
+
s = rdp_data_pdu_init(rdp);
+
if (!s)
return FALSE;
+
Stream_Write_UINT32(s, play_sound->duration);
Stream_Write_UINT32(s, play_sound->frequency);
ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_PLAY_SOUND, rdp->mcs->userId);
*/
static BOOL update_send_dstblt(rdpContext* context,
- const DSTBLT_ORDER* dstblt)
+ const DSTBLT_ORDER* dstblt)
{
wStream* s;
UINT32 offset;
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_DSTBLT);
inf = update_approximate_dstblt_order(&orderInfo, dstblt);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_dstblt_order(s, &orderInfo, dstblt))
return FALSE;
- update_write_order_info(context, s, &orderInfo, offset);
+ update_write_order_info(context, s, &orderInfo, offset);
update->numberOrders++;
return TRUE;
}
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT);
-
- update_check_flush(context, headerLength + update_approximate_patblt_order(&orderInfo, patblt));
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_PATBLT);
+ update_check_flush(context,
+ headerLength + update_approximate_patblt_order(&orderInfo, patblt));
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_patblt_order(s, &orderInfo, patblt);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_SCRBLT);
inf = update_approximate_scrblt_order(&orderInfo, scrblt);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return TRUE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_scrblt_order(s, &orderInfo, scrblt);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_opaque_rect(rdpContext* context,
- const OPAQUE_RECT_ORDER* opaque_rect)
+ const OPAQUE_RECT_ORDER* opaque_rect)
{
wStream* s;
int offset;
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT);
-
- update_check_flush(context, headerLength + update_approximate_opaque_rect_order(&orderInfo, opaque_rect));
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_OPAQUE_RECT);
+ update_check_flush(context,
+ headerLength + update_approximate_opaque_rect_order(&orderInfo, opaque_rect));
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_opaque_rect_order(s, &orderInfo, opaque_rect);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_line_to(rdpContext* context,
- const LINE_TO_ORDER* line_to)
+ const LINE_TO_ORDER* line_to)
{
wStream* s;
int offset;
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_LINE_TO);
inf = update_approximate_line_to_order(&orderInfo, line_to);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_line_to_order(s, &orderInfo, line_to);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT);
-
- update_check_flush(context, headerLength + update_approximate_memblt_order(&orderInfo, memblt));
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_MEMBLT);
+ update_check_flush(context,
+ headerLength + update_approximate_memblt_order(&orderInfo, memblt));
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_memblt_order(s, &orderInfo, memblt);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_glyph_index(rdpContext* context,
- GLYPH_INDEX_ORDER* glyph_index)
+ GLYPH_INDEX_ORDER* glyph_index)
{
wStream* s;
int offset;
int inf;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
-
- headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
-
+ headerLength = update_prepare_order_info(context, &orderInfo,
+ ORDER_TYPE_GLYPH_INDEX);
inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
offset = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
- Stream_Seek(s, headerLength);
+ Stream_Seek(s, headerLength);
update_write_glyph_index_order(s, &orderInfo, glyph_index);
update_write_order_info(context, s, &orderInfo, offset);
-
update->numberOrders++;
return TRUE;
}
*/
static BOOL update_send_cache_bitmap(rdpContext* context,
- const CACHE_BITMAP_ORDER* cache_bitmap)
+ const CACHE_BITMAP_ORDER* cache_bitmap)
{
wStream* s;
int bm, em;
UINT16 extraFlags;
INT16 orderLength;
rdpUpdate* update = context->update;
-
extraFlags = 0;
headerLength = 6;
-
orderType = cache_bitmap->compressed ?
- ORDER_TYPE_CACHE_BITMAP_COMPRESSED : ORDER_TYPE_BITMAP_UNCOMPRESSED;
-
+ ORDER_TYPE_CACHE_BITMAP_COMPRESSED : ORDER_TYPE_BITMAP_UNCOMPRESSED;
inf = update_approximate_cache_bitmap_order(cache_bitmap,
- cache_bitmap->compressed,
- &extraFlags);
+ cache_bitmap->compressed,
+ &extraFlags);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
Stream_Seek(s, headerLength);
- if (!update_write_cache_bitmap_order(s, cache_bitmap, cache_bitmap->compressed, &extraFlags))
+ if (!update_write_cache_bitmap_order(s, cache_bitmap, cache_bitmap->compressed,
+ &extraFlags))
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
-static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
+static BOOL update_send_cache_bitmap_v2(rdpContext* context,
+ CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
{
wStream* s;
int bm, em;
UINT16 extraFlags;
INT16 orderLength;
rdpUpdate* update = context->update;
-
extraFlags = 0;
headerLength = 6;
-
orderType = cache_bitmap_v2->compressed ?
- ORDER_TYPE_BITMAP_COMPRESSED_V2 : ORDER_TYPE_BITMAP_UNCOMPRESSED_V2;
+ ORDER_TYPE_BITMAP_COMPRESSED_V2 : ORDER_TYPE_BITMAP_UNCOMPRESSED_V2;
if (context->settings->NoBitmapCompressionHeader)
cache_bitmap_v2->flags |= CBR2_NO_BITMAP_COMPRESSION_HDR;
- update_check_flush(context, headerLength + update_approximate_cache_bitmap_v2_order(cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags));
-
+ update_check_flush(context,
+ headerLength + update_approximate_cache_bitmap_v2_order(cache_bitmap_v2,
+ cache_bitmap_v2->compressed, &extraFlags));
s = update->us;
+
if (!s)
return FALSE;
Stream_Seek(s, headerLength);
- if (!update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags))
+ if (!update_write_cache_bitmap_v2_order(s, cache_bitmap_v2,
+ cache_bitmap_v2->compressed, &extraFlags))
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
-static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
+static BOOL update_send_cache_bitmap_v3(rdpContext* context,
+ CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
{
wStream* s;
int bm, em;
UINT16 extraFlags;
INT16 orderLength;
rdpUpdate* update = context->update;
-
extraFlags = 0;
headerLength = 6;
orderType = ORDER_TYPE_BITMAP_COMPRESSED_V3;
-
- update_check_flush(context, headerLength + update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, &extraFlags));
-
+ update_check_flush(context,
+ headerLength + update_approximate_cache_bitmap_v3_order(cache_bitmap_v3,
+ &extraFlags));
s = update->us;
+
if (!s)
return FALSE;
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_cache_color_table(rdpContext* context,
- const CACHE_COLOR_TABLE_ORDER* cache_color_table)
+ const CACHE_COLOR_TABLE_ORDER* cache_color_table)
{
wStream* s;
UINT16 flags;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
-
flags = 0;
headerLength = 6;
-
inf = update_approximate_cache_color_table_order(cache_color_table, &flags);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_COLOR_TABLE); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_cache_glyph(rdpContext* context,
- const CACHE_GLYPH_ORDER* cache_glyph)
+ const CACHE_GLYPH_ORDER* cache_glyph)
{
wStream* s;
UINT16 flags;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
-
flags = 0;
headerLength = 6;
-
inf = update_approximate_cache_glyph_order(cache_glyph, &flags);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_cache_glyph_order(s, cache_glyph, &flags))
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_cache_glyph_v2(rdpContext* context,
- const CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
+ const CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
{
wStream* s;
UINT16 flags;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
-
flags = 0;
headerLength = 6;
-
inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_cache_glyph_v2_order(s, cache_glyph_v2, &flags))
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_cache_brush(rdpContext* context,
- const CACHE_BRUSH_ORDER* cache_brush)
+ const CACHE_BRUSH_ORDER* cache_brush)
{
wStream* s;
UINT16 flags;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
-
flags = 0;
headerLength = 6;
-
inf = update_approximate_cache_brush_order(cache_brush, &flags);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
bm = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_cache_brush_order(s, cache_brush, &flags))
return FALSE;
em = Stream_GetPosition(s);
-
orderLength = (em - bm) - 13;
-
Stream_SetPosition(s, bm);
- Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
+ Stream_Write_UINT8(s, ORDER_STANDARD |
+ ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_BRUSH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
*/
static BOOL update_send_create_offscreen_bitmap_order(
- rdpContext* context,
- const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
+ rdpContext* context,
+ const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
wStream* s;
int bm, em, inf;
BYTE controlFlags;
int headerLength;
rdpUpdate* update = context->update;
-
headerLength = 1;
orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP;
controlFlags = ORDER_SECONDARY | (orderType << 2);
-
- inf = update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap);
+ inf = update_approximate_create_offscreen_bitmap_order(
+ create_offscreen_bitmap);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
bm = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_create_offscreen_bitmap_order(s, create_offscreen_bitmap))
return FALSE;
- em = Stream_GetPosition(s);
+ em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_switch_surface_order(
- rdpContext* context,
- const SWITCH_SURFACE_ORDER* switch_surface)
+ rdpContext* context,
+ const SWITCH_SURFACE_ORDER* switch_surface)
{
wStream* s;
int bm, em, inf;
BYTE controlFlags;
int headerLength;
rdpUpdate* update = context->update;
-
headerLength = 1;
orderType = ORDER_TYPE_SWITCH_SURFACE;
controlFlags = ORDER_SECONDARY | (orderType << 2);
-
inf = update_approximate_switch_surface_order(switch_surface);
update_check_flush(context, headerLength + inf);
-
s = update->us;
+
if (!s)
return FALSE;
+
bm = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
+
Stream_Seek(s, headerLength);
if (!update_write_switch_surface_order(s, switch_surface))
return FALSE;
- em = Stream_GetPosition(s);
+ em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
-
update->numberOrders++;
return TRUE;
}
static BOOL update_send_pointer_system(rdpContext* context,
- const POINTER_SYSTEM_UPDATE* pointer_system)
+ const POINTER_SYSTEM_UPDATE* pointer_system)
{
wStream* s;
BYTE updateCode;
rdpRdp* rdp = context->rdp;
BOOL ret;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
}
static BOOL update_send_pointer_position(rdpContext* context,
- const POINTER_POSITION_UPDATE* pointerPosition)
+ const POINTER_POSITION_UPDATE* pointerPosition)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
Stream_Write_UINT16(s, pointerPosition->xPos); /* xPos (2 bytes) */
Stream_Write_UINT16(s, pointerPosition->yPos); /* yPos (2 bytes) */
-
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_PTR_POSITION, s, FALSE);
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_PTR_POSITION,
+ s, FALSE);
out_fail:
Stream_Release(s);
return ret;
}
static BOOL update_write_pointer_color(wStream* s,
- const POINTER_COLOR_UPDATE* pointer_color)
+ const POINTER_COLOR_UPDATE* pointer_color)
{
- if (!Stream_EnsureRemainingCapacity(s, 32 + pointer_color->lengthAndMask + pointer_color->lengthXorMask))
+ if (!Stream_EnsureRemainingCapacity(s,
+ 32 + pointer_color->lengthAndMask + pointer_color->lengthXorMask))
return FALSE;
Stream_Write_UINT16(s, pointer_color->cacheIndex);
}
static BOOL update_send_pointer_color(rdpContext* context,
- const POINTER_COLOR_UPDATE* pointer_color)
+ const POINTER_COLOR_UPDATE* pointer_color)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
if (!update_write_pointer_color(s, pointer_color))
goto out_fail;
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_COLOR, s, FALSE);
-
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_COLOR, s,
+ FALSE);
out_fail:
Stream_Release(s);
return ret;
}
static BOOL update_send_pointer_new(rdpContext* context,
- const POINTER_NEW_UPDATE* pointer_new)
+ const POINTER_NEW_UPDATE* pointer_new)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret = FALSE;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
Stream_Write_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
update_write_pointer_color(s, &pointer_new->colorPtrAttr);
-
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_POINTER, s, FALSE);
-
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_POINTER, s,
+ FALSE);
out_fail:
Stream_Release(s);
return ret;
}
static BOOL update_send_pointer_cached(rdpContext* context,
- const POINTER_CACHED_UPDATE* pointer_cached)
+ const POINTER_CACHED_UPDATE* pointer_cached)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret;
-
s = fastpath_update_pdu_init(rdp->fastpath);
+
if (!s)
return FALSE;
+
Stream_Write_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */
- ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_CACHED, s, FALSE);
+ ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_CACHED, s,
+ FALSE);
Stream_Release(s);
return ret;
}
return FALSE;
areas = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * numberOfAreas);
+
if (!areas)
return FALSE;
WLog_Print(update->log, WLOG_WARN, "ignoring refresh rect request from client");
free(areas);
-
return TRUE;
}
if (update->context->settings->SuppressOutput)
IFCALL(update->SuppressOutput, update->context, allowDisplayUpdates,
- allowDisplayUpdates > 0 ? (RECTANGLE_16*) Stream_Pointer(s) : NULL);
+ allowDisplayUpdates > 0 ? (RECTANGLE_16*) Stream_Pointer(s) : NULL);
else
- WLog_Print(update->log, WLOG_WARN, "ignoring suppress output request from client");
+ WLog_Print(update->log, WLOG_WARN,
+ "ignoring suppress output request from client");
return TRUE;
}
-static BOOL update_send_set_keyboard_indicators(rdpContext* context, UINT16 led_flags)
+static BOOL update_send_set_keyboard_indicators(rdpContext* context,
+ UINT16 led_flags)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret;
-
s = rdp_data_pdu_init(rdp);
+
if (!s)
return FALSE;
- Stream_Write_UINT16(s, 0); /* unitId should be 0 according to MS-RDPBCGR 2.2.8.2.1.1 */
+
+ Stream_Write_UINT16(s,
+ 0); /* unitId should be 0 according to MS-RDPBCGR 2.2.8.2.1.1 */
Stream_Write_UINT16(s, led_flags); /* ledFlags (2 bytes) */
- ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SET_KEYBOARD_INDICATORS, rdp->mcs->userId);
+ ret = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SET_KEYBOARD_INDICATORS,
+ rdp->mcs->userId);
Stream_Release(s);
return ret;
}
update->secondary->CacheGlyph = update_send_cache_glyph;
update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2;
update->secondary->CacheBrush = update_send_cache_brush;
- update->altsec->CreateOffscreenBitmap = update_send_create_offscreen_bitmap_order;
+ update->altsec->CreateOffscreenBitmap =
+ update_send_create_offscreen_bitmap_order;
update->altsec->SwitchSurface = update_send_switch_surface_order;
update->pointer->PointerSystem = update_send_pointer_system;
update->pointer->PointerPosition = update_send_pointer_position;
return update_message_queue_process_pending_messages(update);
}
-static void update_free_queued_message(void *obj)
+static void update_free_queued_message(void* obj)
{
- wMessage *msg = (wMessage*)obj;
-
+ wMessage* msg = (wMessage*)obj;
update_message_queue_free_message(msg);
}
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
rdpUpdate* update;
OFFSCREEN_DELETE_LIST* deleteList;
+ update = (rdpUpdate*) calloc(1, sizeof(rdpUpdate));
- update = (rdpUpdate *) calloc(1, sizeof(rdpUpdate));
if (!update)
return NULL;
WLog_Init();
update->log = WLog_Get("com.freerdp.core.update");
-
update->bitmap_update.count = 64;
- update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(update->bitmap_update.count, sizeof(BITMAP_DATA));
+ update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(
+ update->bitmap_update.count, sizeof(BITMAP_DATA));
+
if (!update->bitmap_update.rectangles)
goto error_rectangles;
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
+
if (!update->pointer)
goto error_pointer;
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
+
if (!update->primary)
goto error_primary;
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
+
if (!update->secondary)
goto error_secondary;
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
+
if (!update->altsec)
goto error_altsec;
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
+
if (!update->window)
goto error_window;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
deleteList->sIndices = 64;
deleteList->indices = malloc(deleteList->sIndices * 2);
+
if (!deleteList->indices)
goto error_indices;
- deleteList->cIndices = 0;
+ deleteList->cIndices = 0;
update->SuppressOutput = update_send_suppress_output;
-
update->initialState = TRUE;
-
update->queue = MessageQueue_New(&cb);
+
if (!update->queue)
goto error_queue;
- return update;
+ return update;
error_queue:
free(deleteList->indices);
error_indices:
if (update != NULL)
{
OFFSCREEN_DELETE_LIST* deleteList;
-
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
free(deleteList->indices);
-
free(update->bitmap_update.rectangles);
-
free(update->pointer->pointer_color.andMaskData);
free(update->pointer->pointer_color.xorMaskData);
free(update->pointer->pointer_new.colorPtrAttr.andMaskData);
free(update->pointer->pointer_new.colorPtrAttr.xorMaskData);
free(update->pointer);
-
free(update->primary->polyline.points);
free(update->primary->polygon_sc.points);
free(update->primary->fast_glyph.glyphData.aj);
free(update->primary);
-
free(update->secondary);
free(update->altsec);
free(update->window);
-
MessageQueue_Free(update->queue);
-
free(update);
}
}
UINT32 nYSrc = 0;
UINT32 nXDst = bitmap->destLeft;
UINT32 nYDst = bitmap->destTop;
- UINT32 nWidth = bitmap->width;
- UINT32 nHeight = bitmap->height;
+ UINT32 nWidth = MIN(bitmap->destRight,
+ gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
+ UINT32 nHeight = MIN(bitmap->destBottom,
+ gdi->height - 1) - bitmap->destTop + 1; /* clip height */
const BYTE* pSrcData = bitmap->bitmapDataStream;
UINT32 SrcSize = bitmap->bitmapLength;
BOOL compressed = bitmap->compressed;
{
if (!interleaved_decompress(codecs->interleaved,
pSrcData, SrcSize,
+ bitmap->width, bitmap->height,
bitsPerPixel,
gdi->primary_buffer,
gdi->primary->hdc->format,
else
{
if (!planar_decompress(codecs->planar, pSrcData,
- SrcSize, gdi->primary_buffer,
+ SrcSize, bitmap->width, bitmap->height,
+ gdi->primary_buffer,
gdi->primary->hdc->format,
gdi->stride,
nXDst, nYDst, nWidth, nHeight, TRUE))
{
UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
- nWidth = MIN(bitmap->destRight,
- gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
- nHeight = MIN(bitmap->destBottom,
- gdi->height - 1) - bitmap->destTop + 1; /* clip height */
if (!freerdp_image_copy(gdi->primary_buffer, gdi->primary->hdc->format,
gdi->stride,
PIXEL_FORMAT_BGRX32,
cmd->bitmapDataLength,
0, 0,
- gdi->bitmap_buffer, gdi->dstFormat,
+ gdi->primary_buffer, gdi->dstFormat,
cmd->width * GetBytesPerPixel(gdi->dstFormat),
cmd->height, NULL))
{
DstData = surface->data;
if (!planar_decompress(surface->codecs->planar, cmd->data, cmd->length,
+ cmd->width, cmd->height,
DstData, surface->format,
surface->scanline, cmd->left, cmd->top,
cmd->width, cmd->height, FALSE))
UINT32 SrcSize = length;
UINT32 SrcFormat;
UINT32 bytesPerPixel;
+ UINT32 DstWidth = MIN(width, bitmap->width);
+ UINT32 DstHeight = MIN(height, bitmap->height);
rdpGdi* gdi = context->gdi;
bytesPerPixel = (bpp + 7) / 8;
size = width * height * GetBytesPerPixel(gdi->dstFormat);
{
if (!interleaved_decompress(context->codecs->interleaved,
pSrcData, SrcSize,
+ width, height,
bpp,
bitmap->data, bitmap->format,
- 0, 0, 0, width, height,
+ 0, 0, 0, DstWidth, DstHeight,
&gdi->palette))
return FALSE;
}
else
{
if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,
+ width, height,
bitmap->data, bitmap->format, 0, 0, 0,
width, height, TRUE))
return FALSE;
SrcFormat = gdi_get_pixel_format(bpp, TRUE);
if (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,
- width, height, pSrcData, SrcFormat,
+ DstWidth, DstHeight, pSrcData, SrcFormat,
0, 0, 0, &gdi->palette))
return FALSE;
}
*/
static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
{
- UINT32 dstPixel;
- const UINT32 srcPixel = ReadColor(pixelPtr, format);
+ UINT32 pixel = ReadColor(pixelPtr, format);
switch (rop)
{
case GDI_R2_BLACK: /* LineTo_BLACK */
- dstPixel = GetColor(format, 0, 0, 0, 0xFF);
+ pixel = GetColor(format, 0, 0, 0, 0xFF);
break;
case GDI_R2_NOTMERGEPEN: /* LineTo_NOTMERGEPEN */
- dstPixel = ~(srcPixel | pen);
+ pixel = ~(pixel | pen);
break;
case GDI_R2_MASKNOTPEN: /* LineTo_MASKNOTPEN */
- dstPixel = srcPixel & ~pen;
+ pixel &= ~pen;
break;
case GDI_R2_NOTCOPYPEN: /* LineTo_NOTCOPYPEN */
- dstPixel = ~pen;
+ pixel = ~pen;
break;
case GDI_R2_MASKPENNOT: /* LineTo_MASKPENNOT */
- dstPixel = pen & ~srcPixel;
+ pixel = pen & ~pixel;
break;
case GDI_R2_NOT: /* LineTo_NOT */
- dstPixel = ~srcPixel;
+ pixel = ~pixel;
break;
case GDI_R2_XORPEN: /* LineTo_XORPEN */
- dstPixel = srcPixel ^ pen;
+ pixel = pixel ^ pen;
break;
case GDI_R2_NOTMASKPEN: /* LineTo_NOTMASKPEN */
- dstPixel = ~(srcPixel & pen);
+ pixel = ~(pixel & pen);
break;
case GDI_R2_MASKPEN: /* LineTo_MASKPEN */
- dstPixel = srcPixel & pen;
+ pixel &= pen;
break;
case GDI_R2_NOTXORPEN: /* LineTo_NOTXORPEN */
- dstPixel = ~(srcPixel ^ pen);
+ pixel = ~(pixel ^ pen);
break;
case GDI_R2_NOP: /* LineTo_NOP */
break;
case GDI_R2_MERGENOTPEN: /* LineTo_MERGENOTPEN */
- dstPixel = srcPixel | ~pen;
+ pixel |= ~pen;
break;
case GDI_R2_COPYPEN: /* LineTo_COPYPEN */
- dstPixel = pen;
+ pixel = pen;
break;
case GDI_R2_MERGEPENNOT: /* LineTo_MERGEPENNOT */
- dstPixel = srcPixel | ~pen;
+ pixel = pixel | ~pen;
break;
case GDI_R2_MERGEPEN: /* LineTo_MERGEPEN */
- dstPixel = srcPixel | pen;
+ pixel = pixel | pen;
break;
case GDI_R2_WHITE: /* LineTo_WHITE */
- dstPixel = GetColor(format, 0, 0, 0, 0xFF);
+ pixel = GetColor(format, 0, 0, 0, 0);
break;
default:
return FALSE;
}
- WriteColor(pixelPtr, format, dstPixel);
+ WriteColor(pixelPtr, format, pixel);
return TRUE;
}
BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
{
- INT64 e2;
- INT64 bx1, by1;
- INT64 bx2, by2;
- HGDI_BITMAP bmp = (HGDI_BITMAP) hdc->selectedObject;
+ UINT32 x, y;
+ UINT32 x1, y1;
+ UINT32 x2, y2;
+ INT32 e, e2;
+ INT32 dx, dy;
+ INT32 sx, sy;
+ INT32 bx1, by1;
+ INT32 bx2, by2;
+ HGDI_BITMAP bmp;
UINT32 pen;
UINT32 rop2 = gdi_GetROP2(hdc);
- UINT32 x1 = hdc->pen->posX;
- UINT32 y1 = hdc->pen->posY;
- UINT32 x2 = nXEnd;
- UINT32 y2 = nYEnd;
- INT64 dx = (x1 > x2) ? x1 - x2 : x2 - x1;
- INT64 dy = (y1 > y2) ? y1 - y2 : y2 - y1;
- INT64 sx = (x1 < x2) ? 1 : -1;
- INT64 sy = (y1 < y2) ? 1 : -1;
- INT64 e = dx - dy;
- UINT32 x = x1;
- UINT32 y = y1;
+ x1 = hdc->pen->posX;
+ y1 = hdc->pen->posY;
+ x2 = nXEnd;
+ y2 = nYEnd;
+ dx = (x1 > x2) ? x1 - x2 : x2 - x1;
+ dy = (y1 > y2) ? y1 - y2 : y2 - y1;
+ sx = (x1 < x2) ? 1 : -1;
+ sy = (y1 < y2) ? 1 : -1;
+ e = dx - dy;
+ x = x1;
+ y = y1;
+ bmp = (HGDI_BITMAP) hdc->selectedObject;
if (hdc->clip->null)
{
INT32 e, e2;
INT32 dx, dy;
INT32 a, b, c;
-
a = (x1 < x2) ? x2 - x1 : x1 - x2;
b = (y1 < y2) ? y2 - y1 : y1 - y2;
c = b & 1;
-
dx = 4 * (1 - a) * b * b;
dy = 4 * (c + 1) * a * a;
e = dx + dy + c * a * a;
y1 += (b + 1) / 2;
y2 = y1 - c;
-
a *= 8 * a;
c = 8 * b * b;
gdi_SetPixel(hdc, x1, y1, 0);
gdi_SetPixel(hdc, x1, y2, 0);
gdi_SetPixel(hdc, x2, y2, 0);
-
e2 = 2 * e;
if (e2 >= dx)
* @param nBottomRect y2
* @return nonzero if successful, 0 otherwise
*/
-BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
+BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect,
+ int nBottomRect)
{
Ellipse_Bresenham(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
return TRUE;
UINT32 color;
UINT32 nXDest, nYDest;
UINT32 nWidth, nHeight;
-
gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight);
if (!gdi_ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL))
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x,
- nYDest + y);
+ nYDest + y);
+
if (dstp)
WriteColor(dstp, hdc->format, color);
}
* @param nCount number of points
* @return nonzero if successful, 0 otherwise
*/
-BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT *lpPoints, int nCount)
+BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT* lpPoints, int nCount)
{
WLog_ERR(TAG, "Not implemented!");
return FALSE;
* @param nCount count of number of points in lpPolyCounts
* @return nonzero if successful, 0 otherwise
*/
-BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT *lpPoints, int *lpPolyCounts, int nCount)
+BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints, int* lpPolyCounts,
+ int nCount)
{
WLog_ERR(TAG, "Not implemented!");
return FALSE;
}
-/**
- * Draw a rectangle
- * @msdn{dd162898}
- * @param hdc device context
- * @param nLeftRect x1
- * @param nTopRect y1
- * @param nRightRect x2
- * @param nBottomRect y2
- * @return nonzero if successful, 0 otherwise
- */
-BOOL gdi_Rectangle(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
+BOOL gdi_Rectangle(HGDI_DC hdc, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
+ UINT32 nHeight)
{
- WLog_ERR(TAG, "Not implemented!");
+ UINT32 x, y;
+ UINT32 color;
+
+ if (!gdi_ClipCoords(hdc, &nXDst, &nYDst, &nWidth, &nHeight, NULL, NULL))
+ return TRUE;
+
+ color = hdc->textColor;
+ color = GetColor(hdc->format, 0, 0xFF, 0, 0xFF);
+
+ for (y = 0; y < nHeight; y++)
+ {
+ BYTE* dstLeft = gdi_get_bitmap_pointer(hdc, nXDst,
+ nYDst + y);
+ BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1,
+ nYDst + y);
+
+ if (dstLeft)
+ WriteColor(dstLeft, hdc->format, color);
+
+ if (dstRight)
+ WriteColor(dstRight, hdc->format, color);
+ }
+
+ for (x = 0; x < nWidth; x++)
+ {
+ BYTE* dstTop = gdi_get_bitmap_pointer(hdc, nXDst + x,
+ nYDst);
+ BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x,
+ nYDst + nHeight - 1);
+
+ if (dstTop)
+ WriteColor(dstTop, hdc->format, color);
+
+ if (dstBottom)
+ WriteColor(dstBottom, hdc->format, color);
+ }
+
return FALSE;
}