From bb78fb16f84f68f7d93d058c6ff7cb29cd1ef6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 12 Jun 2013 18:57:25 -0400 Subject: [PATCH] xfreerdp: refactor to make use of single xfContext* and remove xfInfo* --- client/X11/cli/xfreerdp.c | 16 +- client/X11/xf_channels.c | 4 +- client/X11/xf_cliprdr.c | 248 +++++++------- client/X11/xf_cliprdr.h | 16 +- client/X11/xf_event.c | 330 +++++++++---------- client/X11/xf_event.h | 2 +- client/X11/xf_gdi.c | 523 +++++++++++++++--------------- client/X11/xf_graphics.c | 190 ++++++----- client/X11/xf_input.c | 88 ++--- client/X11/xf_input.h | 6 +- client/X11/xf_interface.c | 657 +++++++++++++++++++------------------- client/X11/xf_interface.h | 19 +- client/X11/xf_keyboard.c | 96 +++--- client/X11/xf_keyboard.h | 24 +- client/X11/xf_monitor.c | 42 +-- client/X11/xf_monitor.h | 4 +- client/X11/xf_rail.c | 171 +++++----- client/X11/xf_rail.h | 18 +- client/X11/xf_tsmf.c | 72 ++--- client/X11/xf_tsmf.h | 6 +- client/X11/xf_window.c | 307 +++++++++--------- client/X11/xf_window.h | 50 +-- client/X11/xfreerdp.h | 19 +- 23 files changed, 1439 insertions(+), 1469 deletions(-) diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index 0fa20b98b..8619fbad2 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -34,28 +34,28 @@ int main(int argc, char* argv[]) { - xfInfo* xfi; + xfContext* xfc; DWORD dwExitCode; freerdp* instance; freerdp_client_global_init(); - xfi = freerdp_client_new(argc, argv); + xfc = freerdp_client_new(argc, argv); - if (xfi == NULL) + if (xfc == NULL) { return 1; } - instance = xfi->instance; + instance = xfc->instance; - freerdp_client_start(xfi); + freerdp_client_start(xfc); - WaitForSingleObject(xfi->thread, INFINITE); + WaitForSingleObject(xfc->thread, INFINITE); - GetExitCodeThread(xfi->thread, &dwExitCode); + GetExitCodeThread(xfc->thread, &dwExitCode); - freerdp_client_free(xfi); + freerdp_client_free(xfc); freerdp_client_global_uninit(); diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index 84a70b106..dd2136fd5 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -28,11 +28,11 @@ int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface) { - xfInfo* xfi = ((xfContext*) instance->context)->xfi; + xfContext* xfc = (xfContext*) instance->context; if (strcmp(name, RDPEI_DVC_CHANNEL_NAME) == 0) { - xfi->rdpei = (RdpeiClientContext*) pInterface; + xfc->rdpei = (RdpeiClientContext*) pInterface; } return 0; diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index d7e0e44f1..19c433279 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -90,7 +90,7 @@ struct clipboard_context int incr_data_length; }; -void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels) +void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels) { int n; UINT32 id; @@ -99,13 +99,13 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels) cb = (clipboardContext*) malloc(sizeof(clipboardContext)); ZeroMemory(cb, sizeof(clipboardContext)); - xfi->clipboard_context = cb; + xfc->clipboard_context = cb; cb->channels = channels; cb->request_index = -1; - cb->root_window = DefaultRootWindow(xfi->display); - cb->clipboard_atom = XInternAtom(xfi->display, "CLIPBOARD", FALSE); + cb->root_window = DefaultRootWindow(xfc->display); + cb->clipboard_atom = XInternAtom(xfc->display, "CLIPBOARD", FALSE); if (cb->clipboard_atom == None) { @@ -113,20 +113,20 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels) } id = 1; - cb->property_atom = XInternAtom(xfi->display, "_FREERDP_CLIPRDR", FALSE); - cb->identity_atom = XInternAtom(xfi->display, "_FREERDP_CLIPRDR_ID", FALSE); + cb->property_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR", FALSE); + cb->identity_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_ID", FALSE); - XChangeProperty(xfi->display, xfi->drawable, cb->identity_atom, + XChangeProperty(xfc->display, xfc->drawable, cb->identity_atom, XA_INTEGER, 32, PropModeReplace, (BYTE*) &id, 1); - XSelectInput(xfi->display, cb->root_window, PropertyChangeMask); + XSelectInput(xfc->display, cb->root_window, PropertyChangeMask); n = 0; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "_FREERDP_RAW", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "_FREERDP_RAW", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_RAW; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "UTF8_STRING", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "UTF8_STRING", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_UNICODETEXT; n++; @@ -134,36 +134,36 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels) cb->format_mappings[n].format_id = CB_FORMAT_TEXT; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "image/png", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "image/png", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_PNG; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "image/jpeg", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "image/jpeg", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_JPEG; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "image/gif", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "image/gif", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_GIF; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "image/bmp", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "image/bmp", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_DIB; n++; - cb->format_mappings[n].target_format = XInternAtom(xfi->display, "text/html", FALSE); + cb->format_mappings[n].target_format = XInternAtom(xfc->display, "text/html", FALSE); cb->format_mappings[n].format_id = CB_FORMAT_HTML; cb->num_format_mappings = n + 1; - cb->targets[0] = XInternAtom(xfi->display, "TIMESTAMP", FALSE); - cb->targets[1] = XInternAtom(xfi->display, "TARGETS", FALSE); + cb->targets[0] = XInternAtom(xfc->display, "TIMESTAMP", FALSE); + cb->targets[1] = XInternAtom(xfc->display, "TARGETS", FALSE); cb->num_targets = 2; - cb->incr_atom = XInternAtom(xfi->display, "INCR", FALSE); + cb->incr_atom = XInternAtom(xfc->display, "INCR", FALSE); } -void xf_cliprdr_uninit(xfInfo* xfi) +void xf_cliprdr_uninit(xfContext* xfc) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (cb) { @@ -172,7 +172,7 @@ void xf_cliprdr_uninit(xfInfo* xfi) free(cb->respond); free(cb->incr_data); free(cb); - xfi->clipboard_context = NULL; + xfc->clipboard_context = NULL; } } @@ -250,20 +250,20 @@ static void be2le(BYTE* data, int size) } } -static BOOL xf_cliprdr_is_self_owned(xfInfo* xfi) +static BOOL xf_cliprdr_is_self_owned(xfContext* xfc) { Atom type; UINT32 id = 0; UINT32* pid = NULL; int format, result = 0; unsigned long length, bytes_left; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - cb->owner = XGetSelectionOwner(xfi->display, cb->clipboard_atom); + cb->owner = XGetSelectionOwner(xfc->display, cb->clipboard_atom); if (cb->owner != None) { - result = XGetWindowProperty(xfi->display, cb->owner, + result = XGetWindowProperty(xfc->display, cb->owner, cb->identity_atom, 0, 4, 0, XA_INTEGER, &type, &format, &length, &bytes_left, (BYTE**) &pid); } @@ -274,7 +274,7 @@ static BOOL xf_cliprdr_is_self_owned(xfInfo* xfi) XFree(pid); } - if ((cb->owner == None) || (cb->owner == xfi->drawable)) + if ((cb->owner == None) || (cb->owner == xfc->drawable)) return FALSE; if (result != Success) @@ -322,16 +322,16 @@ static int xf_cliprdr_select_format_by_atom(clipboardContext* cb, Atom target) return -1; } -static void xf_cliprdr_send_raw_format_list(xfInfo* xfi) +static void xf_cliprdr_send_raw_format_list(xfContext* xfc) { Atom type; BYTE* format_data; int format, result; unsigned long length, bytes_left; RDP_CB_FORMAT_LIST_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - result = XGetWindowProperty(xfi->display, cb->root_window, + result = XGetWindowProperty(xfc->display, cb->root_window, cb->property_atom, 0, 3600, 0, XA_STRING, &type, &format, &length, &bytes_left, (BYTE**) &format_data); @@ -353,10 +353,10 @@ static void xf_cliprdr_send_raw_format_list(xfInfo* xfi) freerdp_channels_send_event(cb->channels, (wMessage*) event); } -static void xf_cliprdr_send_null_format_list(xfInfo* xfi) +static void xf_cliprdr_send_null_format_list(xfContext* xfc) { RDP_CB_FORMAT_LIST_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL); @@ -366,11 +366,11 @@ static void xf_cliprdr_send_null_format_list(xfInfo* xfi) freerdp_channels_send_event(cb->channels, (wMessage*) event); } -static void xf_cliprdr_send_supported_format_list(xfInfo* xfi) +static void xf_cliprdr_send_supported_format_list(xfContext* xfc) { int i; RDP_CB_FORMAT_LIST_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL); @@ -384,30 +384,30 @@ static void xf_cliprdr_send_supported_format_list(xfInfo* xfi) freerdp_channels_send_event(cb->channels, (wMessage*) event); } -static void xf_cliprdr_send_format_list(xfInfo* xfi) +static void xf_cliprdr_send_format_list(xfContext* xfc) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - if (xf_cliprdr_is_self_owned(xfi)) + if (xf_cliprdr_is_self_owned(xfc)) { - xf_cliprdr_send_raw_format_list(xfi); + xf_cliprdr_send_raw_format_list(xfc); } else if (cb->owner == None) { - xf_cliprdr_send_null_format_list(xfi); + xf_cliprdr_send_null_format_list(xfc); } - else if (cb->owner != xfi->drawable) + else if (cb->owner != xfc->drawable) { /* Request the owner for TARGETS, and wait for SelectionNotify event */ - XConvertSelection(xfi->display, cb->clipboard_atom, - cb->targets[1], cb->property_atom, xfi->drawable, CurrentTime); + XConvertSelection(xfc->display, cb->clipboard_atom, + cb->targets[1], cb->property_atom, xfc->drawable, CurrentTime); } } -static void xf_cliprdr_send_data_request(xfInfo* xfi, UINT32 format) +static void xf_cliprdr_send_data_request(xfContext* xfc, UINT32 format) { RDP_CB_DATA_REQUEST_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL); @@ -417,10 +417,10 @@ static void xf_cliprdr_send_data_request(xfInfo* xfi, UINT32 format) freerdp_channels_send_event(cb->channels, (wMessage*) event); } -static void xf_cliprdr_send_data_response(xfInfo* xfi, BYTE* data, int size) +static void xf_cliprdr_send_data_response(xfContext* xfc, BYTE* data, int size) { RDP_CB_DATA_RESPONSE_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataResponse, NULL, NULL); @@ -431,31 +431,31 @@ static void xf_cliprdr_send_data_response(xfInfo* xfi, BYTE* data, int size) freerdp_channels_send_event(cb->channels, (wMessage*) event); } -static void xf_cliprdr_send_null_data_response(xfInfo* xfi) +static void xf_cliprdr_send_null_data_response(xfContext* xfc) { - xf_cliprdr_send_data_response(xfi, NULL, 0); + xf_cliprdr_send_data_response(xfc, NULL, 0); } -static void xf_cliprdr_process_cb_monitor_ready_event(xfInfo* xfi) +static void xf_cliprdr_process_cb_monitor_ready_event(xfContext* xfc) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - xf_cliprdr_send_format_list(xfi); + xf_cliprdr_send_format_list(xfc); cb->sync = TRUE; } -static void xf_cliprdr_process_cb_data_request_event(xfInfo* xfi, RDP_CB_DATA_REQUEST_EVENT* event) +static void xf_cliprdr_process_cb_data_request_event(xfContext* xfc, RDP_CB_DATA_REQUEST_EVENT* event) { int i; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; DEBUG_X11_CLIPRDR("format %d", event->format); - if (xf_cliprdr_is_self_owned(xfi)) + if (xf_cliprdr_is_self_owned(xfc)) { /* CB_FORMAT_RAW */ i = 0; - XChangeProperty(xfi->display, xfi->drawable, cb->property_atom, + XChangeProperty(xfc->display, xfc->drawable, cb->property_atom, XA_INTEGER, 32, PropModeReplace, (BYTE*) &event->format, 1); } else @@ -466,7 +466,7 @@ static void xf_cliprdr_process_cb_data_request_event(xfInfo* xfi, RDP_CB_DATA_RE if (i < 0) { DEBUG_X11_CLIPRDR("unsupported format requested"); - xf_cliprdr_send_null_data_response(xfi); + xf_cliprdr_send_null_data_response(xfc); } else { @@ -474,15 +474,15 @@ static void xf_cliprdr_process_cb_data_request_event(xfInfo* xfi, RDP_CB_DATA_RE DEBUG_X11_CLIPRDR("target=%d", (int) cb->format_mappings[i].target_format); - XConvertSelection(xfi->display, cb->clipboard_atom, + XConvertSelection(xfc->display, cb->clipboard_atom, cb->format_mappings[i].target_format, cb->property_atom, - xfi->drawable, CurrentTime); - XFlush(xfi->display); + xfc->drawable, CurrentTime); + XFlush(xfc->display); /* After this point, we expect a SelectionNotify event from the clipboard owner. */ } } -static void xf_cliprdr_get_requested_targets(xfInfo* xfi) +static void xf_cliprdr_get_requested_targets(xfContext* xfc) { int num; int i, j; @@ -491,9 +491,9 @@ static void xf_cliprdr_get_requested_targets(xfInfo* xfi) BYTE* data = NULL; unsigned long length, bytes_left; RDP_CB_FORMAT_LIST_EVENT* event; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - XGetWindowProperty(xfi->display, xfi->drawable, cb->property_atom, + XGetWindowProperty(xfc->display, xfc->drawable, cb->property_atom, 0, 200, 0, XA_ATOM, &atom, &format, &length, &bytes_left, &data); DEBUG_X11_CLIPRDR("type=%d format=%d length=%d bytes_left=%d", @@ -534,7 +534,7 @@ static void xf_cliprdr_get_requested_targets(xfInfo* xfi) if (data) XFree(data); - xf_cliprdr_send_null_format_list(xfi); + xf_cliprdr_send_null_format_list(xfc); } } @@ -669,17 +669,17 @@ static BYTE* xf_cliprdr_process_requested_html(BYTE* data, int* size) return outbuf; } -static void xf_cliprdr_process_requested_data(xfInfo* xfi, BOOL has_data, BYTE* data, int size) +static void xf_cliprdr_process_requested_data(xfContext* xfc, BOOL has_data, BYTE* data, int size) { BYTE* outbuf; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (cb->incr_starts && has_data) return; if (!has_data || data == NULL) { - xf_cliprdr_send_null_data_response(xfi); + xf_cliprdr_send_null_data_response(xfc); return; } @@ -714,31 +714,31 @@ static void xf_cliprdr_process_requested_data(xfInfo* xfi, BOOL has_data, BYTE* } if (outbuf) - xf_cliprdr_send_data_response(xfi, outbuf, size); + xf_cliprdr_send_data_response(xfc, outbuf, size); else - xf_cliprdr_send_null_data_response(xfi); + xf_cliprdr_send_null_data_response(xfc); /* Resend the format list, otherwise the server won't request again for the next paste */ - xf_cliprdr_send_format_list(xfi); + xf_cliprdr_send_format_list(xfc); } -static BOOL xf_cliprdr_get_requested_data(xfInfo* xfi, Atom target) +static BOOL xf_cliprdr_get_requested_data(xfContext* xfc, Atom target) { Atom type; int format; BYTE* data = NULL; BOOL has_data = FALSE; unsigned long length, bytes_left, dummy; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if ((cb->request_index < 0) || (cb->format_mappings[cb->request_index].target_format != target)) { DEBUG_X11_CLIPRDR("invalid target"); - xf_cliprdr_send_null_data_response(xfi); + xf_cliprdr_send_null_data_response(xfc); return FALSE; } - XGetWindowProperty(xfi->display, xfi->drawable, + XGetWindowProperty(xfc->display, xfc->drawable, cb->property_atom, 0, 0, 0, target, &type, &format, &length, &bytes_left, &data); @@ -780,7 +780,7 @@ static BOOL xf_cliprdr_get_requested_data(xfInfo* xfi, Atom target) DEBUG_X11("INCR finished"); has_data = TRUE; } - else if (XGetWindowProperty(xfi->display, xfi->drawable, + else if (XGetWindowProperty(xfc->display, xfc->drawable, cb->property_atom, 0, bytes_left, 0, target, &type, &format, &length, &dummy, &data) == Success) { @@ -801,9 +801,9 @@ static BOOL xf_cliprdr_get_requested_data(xfInfo* xfi, Atom target) DEBUG_X11_CLIPRDR("XGetWindowProperty failed"); } } - XDeleteProperty(xfi->display, xfi->drawable, cb->property_atom); + XDeleteProperty(xfc->display, xfc->drawable, cb->property_atom); - xf_cliprdr_process_requested_data(xfi, has_data, data, (int) bytes_left); + xf_cliprdr_process_requested_data(xfc, has_data, data, (int) bytes_left); if (data) XFree(data); @@ -827,13 +827,13 @@ static void xf_cliprdr_append_target(clipboardContext* cb, Atom target) cb->targets[cb->num_targets++] = target; } -static void xf_cliprdr_provide_targets(xfInfo* xfi, XEvent* respond) +static void xf_cliprdr_provide_targets(xfContext* xfc, XEvent* respond) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (respond->xselection.property != None) { - XChangeProperty(xfi->display, + XChangeProperty(xfc->display, respond->xselection.requestor, respond->xselection.property, XA_ATOM, 32, PropModeReplace, @@ -841,13 +841,13 @@ static void xf_cliprdr_provide_targets(xfInfo* xfi, XEvent* respond) } } -static void xf_cliprdr_provide_data(xfInfo* xfi, XEvent* respond) +static void xf_cliprdr_provide_data(xfContext* xfc, XEvent* respond) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (respond->xselection.property != None) { - XChangeProperty(xfi->display, + XChangeProperty(xfc->display, respond->xselection.requestor, respond->xselection.property, respond->xselection.target, 8, PropModeReplace, @@ -855,10 +855,10 @@ static void xf_cliprdr_provide_data(xfInfo* xfi, XEvent* respond) } } -static void xf_cliprdr_process_cb_format_list_event(xfInfo* xfi, RDP_CB_FORMAT_LIST_EVENT* event) +static void xf_cliprdr_process_cb_format_list_event(xfContext* xfc, RDP_CB_FORMAT_LIST_EVENT* event) { int i, j; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (cb->data) { @@ -888,16 +888,16 @@ static void xf_cliprdr_process_cb_format_list_event(xfInfo* xfi, RDP_CB_FORMAT_L } } - XSetSelectionOwner(xfi->display, cb->clipboard_atom, xfi->drawable, CurrentTime); + XSetSelectionOwner(xfc->display, cb->clipboard_atom, xfc->drawable, CurrentTime); if (event->raw_format_data) { - XChangeProperty(xfi->display, cb->root_window, cb->property_atom, + XChangeProperty(xfc->display, cb->root_window, cb->property_atom, XA_STRING, 8, PropModeReplace, event->raw_format_data, event->raw_format_data_size); } - XFlush(xfi->display); + XFlush(xfc->display); } static void xf_cliprdr_process_text(clipboardContext* cb, BYTE* data, int size) @@ -979,9 +979,9 @@ static void xf_cliprdr_process_html(clipboardContext* cb, BYTE* data, int size) crlf2lf(cb->data, &cb->data_length); } -static void xf_cliprdr_process_cb_data_response_event(xfInfo* xfi, RDP_CB_DATA_RESPONSE_EVENT* event) +static void xf_cliprdr_process_cb_data_response_event(xfContext* xfc, RDP_CB_DATA_RESPONSE_EVENT* event) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; DEBUG_X11_CLIPRDR("size=%d", event->size); @@ -1035,33 +1035,33 @@ static void xf_cliprdr_process_cb_data_response_event(xfInfo* xfi, RDP_CB_DATA_R cb->respond->xselection.property = None; break; } - xf_cliprdr_provide_data(xfi, cb->respond); + xf_cliprdr_provide_data(xfc, cb->respond); } - XSendEvent(xfi->display, cb->respond->xselection.requestor, 0, 0, cb->respond); - XFlush(xfi->display); + XSendEvent(xfc->display, cb->respond->xselection.requestor, 0, 0, cb->respond); + XFlush(xfc->display); free(cb->respond); cb->respond = NULL; } -void xf_process_cliprdr_event(xfInfo* xfi, wMessage* event) +void xf_process_cliprdr_event(xfContext* xfc, wMessage* event) { switch (GetMessageType(event->id)) { case CliprdrChannel_MonitorReady: - xf_cliprdr_process_cb_monitor_ready_event(xfi); + xf_cliprdr_process_cb_monitor_ready_event(xfc); break; case CliprdrChannel_FormatList: - xf_cliprdr_process_cb_format_list_event(xfi, (RDP_CB_FORMAT_LIST_EVENT*) event); + xf_cliprdr_process_cb_format_list_event(xfc, (RDP_CB_FORMAT_LIST_EVENT*) event); break; case CliprdrChannel_DataRequest: - xf_cliprdr_process_cb_data_request_event(xfi, (RDP_CB_DATA_REQUEST_EVENT*) event); + xf_cliprdr_process_cb_data_request_event(xfc, (RDP_CB_DATA_REQUEST_EVENT*) event); break; case CliprdrChannel_DataResponse: - xf_cliprdr_process_cb_data_response_event(xfi, (RDP_CB_DATA_RESPONSE_EVENT*) event); + xf_cliprdr_process_cb_data_response_event(xfc, (RDP_CB_DATA_RESPONSE_EVENT*) event); break; default: @@ -1070,31 +1070,31 @@ void xf_process_cliprdr_event(xfInfo* xfi, wMessage* event) } } -BOOL xf_cliprdr_process_selection_notify(xfInfo* xfi, XEvent* xevent) +BOOL xf_cliprdr_process_selection_notify(xfContext* xfc, XEvent* xevent) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (xevent->xselection.target == cb->targets[1]) { if (xevent->xselection.property == None) { DEBUG_X11_CLIPRDR("owner not support TARGETS. sending all format."); - xf_cliprdr_send_supported_format_list(xfi); + xf_cliprdr_send_supported_format_list(xfc); } else { - xf_cliprdr_get_requested_targets(xfi); + xf_cliprdr_get_requested_targets(xfc); } return TRUE; } else { - return xf_cliprdr_get_requested_data(xfi, xevent->xselection.target); + return xf_cliprdr_get_requested_data(xfc, xevent->xselection.target); } } -BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) +BOOL xf_cliprdr_process_selection_request(xfContext* xfc, XEvent* xevent) { int i; int fmt; @@ -1105,11 +1105,11 @@ BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) BYTE* data = NULL; BOOL delay_respond; unsigned long length, bytes_left; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; DEBUG_X11_CLIPRDR("target=%d", (int) xevent->xselectionrequest.target); - if (xevent->xselectionrequest.owner != xfi->drawable) + if (xevent->xselectionrequest.owner != xfc->drawable) { DEBUG_X11_CLIPRDR("not owner"); return FALSE; @@ -1138,7 +1138,7 @@ BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) /* Someone else requests our available formats */ DEBUG_X11_CLIPRDR("target: TARGETS"); respond->xselection.property = xevent->xselectionrequest.property; - xf_cliprdr_provide_targets(xfi, respond); + xf_cliprdr_provide_targets(xfc, respond); } else { @@ -1146,14 +1146,14 @@ BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) i = xf_cliprdr_select_format_by_atom(cb, xevent->xselectionrequest.target); - if (i >= 0 && xevent->xselectionrequest.requestor != xfi->drawable) + if (i >= 0 && xevent->xselectionrequest.requestor != xfc->drawable) { format = cb->format_mappings[i].format_id; alt_format = format; if (format == CB_FORMAT_RAW) { - if (XGetWindowProperty(xfi->display, xevent->xselectionrequest.requestor, + if (XGetWindowProperty(xfc->display, xevent->xselectionrequest.requestor, cb->property_atom, 0, 4, 0, XA_INTEGER, &type, &fmt, &length, &bytes_left, &data) != Success) { @@ -1172,7 +1172,7 @@ BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) { /* Cached clipboard data available. Send it now */ respond->xselection.property = xevent->xselectionrequest.property; - xf_cliprdr_provide_data(xfi, respond); + xf_cliprdr_provide_data(xfc, respond); } else if (cb->respond) { @@ -1196,36 +1196,36 @@ BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent) cb->data_alt_format = alt_format; delay_respond = TRUE; - xf_cliprdr_send_data_request(xfi, alt_format); + xf_cliprdr_send_data_request(xfc, alt_format); } } } if (delay_respond == FALSE) { - XSendEvent(xfi->display, xevent->xselectionrequest.requestor, 0, 0, respond); - XFlush(xfi->display); + XSendEvent(xfc->display, xevent->xselectionrequest.requestor, 0, 0, respond); + XFlush(xfc->display); free(respond); } return TRUE; } -BOOL xf_cliprdr_process_selection_clear(xfInfo* xfi, XEvent* xevent) +BOOL xf_cliprdr_process_selection_clear(xfContext* xfc, XEvent* xevent) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; - if (xf_cliprdr_is_self_owned(xfi)) + if (xf_cliprdr_is_self_owned(xfc)) return FALSE; - XDeleteProperty(xfi->display, cb->root_window, cb->property_atom); + XDeleteProperty(xfc->display, cb->root_window, cb->property_atom); return TRUE; } -BOOL xf_cliprdr_process_property_notify(xfInfo* xfi, XEvent* xevent) +BOOL xf_cliprdr_process_property_notify(xfContext* xfc, XEvent* xevent) { - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (!cb) return TRUE; @@ -1236,33 +1236,33 @@ BOOL xf_cliprdr_process_property_notify(xfInfo* xfi, XEvent* xevent) if (xevent->xproperty.window == cb->root_window) { DEBUG_X11_CLIPRDR("root window PropertyNotify"); - xf_cliprdr_send_format_list(xfi); + xf_cliprdr_send_format_list(xfc); } - else if (xevent->xproperty.window == xfi->drawable && + else if (xevent->xproperty.window == xfc->drawable && xevent->xproperty.state == PropertyNewValue && cb->incr_starts && cb->request_index >= 0) { DEBUG_X11_CLIPRDR("cliprdr window PropertyNotify"); - xf_cliprdr_get_requested_data(xfi, + xf_cliprdr_get_requested_data(xfc, cb->format_mappings[cb->request_index].target_format); } return TRUE; } -void xf_cliprdr_check_owner(xfInfo* xfi) +void xf_cliprdr_check_owner(xfContext* xfc) { Window owner; - clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; + clipboardContext* cb = (clipboardContext*) xfc->clipboard_context; if (cb->sync) { - owner = XGetSelectionOwner(xfi->display, cb->clipboard_atom); + owner = XGetSelectionOwner(xfc->display, cb->clipboard_atom); if (cb->owner != owner) { cb->owner = owner; - xf_cliprdr_send_format_list(xfi); + xf_cliprdr_send_format_list(xfc); } } } diff --git a/client/X11/xf_cliprdr.h b/client/X11/xf_cliprdr.h index f2ee57dfd..3f62e3268 100644 --- a/client/X11/xf_cliprdr.h +++ b/client/X11/xf_cliprdr.h @@ -23,13 +23,13 @@ #include "xf_interface.h" #include "xfreerdp.h" -void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman); -void xf_cliprdr_uninit(xfInfo* xfi); -void xf_process_cliprdr_event(xfInfo* xfi, wMessage* event); -BOOL xf_cliprdr_process_selection_notify(xfInfo* xfi, XEvent* xevent); -BOOL xf_cliprdr_process_selection_request(xfInfo* xfi, XEvent* xevent); -BOOL xf_cliprdr_process_selection_clear(xfInfo* xfi, XEvent* xevent); -BOOL xf_cliprdr_process_property_notify(xfInfo* xfi, XEvent* xevent); -void xf_cliprdr_check_owner(xfInfo* xfi); +void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels); +void xf_cliprdr_uninit(xfContext* xfc); +void xf_process_cliprdr_event(xfContext* xfc, wMessage* event); +BOOL xf_cliprdr_process_selection_notify(xfContext* xfc, XEvent* xevent); +BOOL xf_cliprdr_process_selection_request(xfContext* xfc, XEvent* xevent); +BOOL xf_cliprdr_process_selection_clear(xfContext* xfc, XEvent* xevent); +BOOL xf_cliprdr_process_property_notify(xfContext* xfc, XEvent* xevent); +void xf_cliprdr_check_owner(xfContext* xfc); #endif /* __XF_CLIPRDR_H */ diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 95b7a423d..77a24bd68 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -84,7 +84,7 @@ const char* const X11_EVENT_STRINGS[] = #define DEBUG_X11_LMS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -static BOOL xf_event_Expose(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_Expose(xfContext* xfc, XEvent* event, BOOL app) { int x, y; int w, h; @@ -96,51 +96,51 @@ static BOOL xf_event_Expose(xfInfo* xfi, XEvent* event, BOOL app) if (!app) { - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } else { - XCopyArea(xfi->display, xfi->primary, - xfi->window->handle, xfi->gc, x, y, w, h, x, y); + XCopyArea(xfc->display, xfc->primary, + xfc->window->handle, xfc->gc, x, y, w, h, x, y); } } else { xfWindow* xfw; rdpWindow* window; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpRail* rail = ((rdpContext*) xfc)->rail; window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window); if (window != NULL) { xfw = (xfWindow*) window->extra; - xf_UpdateWindowArea(xfi, xfw, x, y, w, h); + xf_UpdateWindowArea(xfc, xfw, x, y, w, h); } } return TRUE; } -static BOOL xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_VisibilityNotify(xfContext* xfc, XEvent* event, BOOL app) { - xfi->unobscured = event->xvisibility.state == VisibilityUnobscured; + xfc->unobscured = event->xvisibility.state == VisibilityUnobscured; return TRUE; } -static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_MotionNotify(xfContext* xfc, XEvent* event, BOOL app) { int x, y; rdpInput* input; Window childWindow; - input = xfi->instance->input; + input = xfc->instance->input; x = event->xmotion.x; y = event->xmotion.y; - if (!xfi->settings->MouseMotion) + if (!xfc->settings->MouseMotion) { if ((event->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) == 0) return TRUE; @@ -149,35 +149,35 @@ static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) if (app) { /* make sure window exists */ - if (xf_rdpWindowFromWindow(xfi, event->xmotion.window) == 0) + if (xf_rdpWindowFromWindow(xfc, event->xmotion.window) == 0) { return TRUE; } /* Translate to desktop coordinates */ - XTranslateCoordinates(xfi->display, event->xmotion.window, - RootWindowOfScreen(xfi->screen), + XTranslateCoordinates(xfc->display, event->xmotion.window, + RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { /* Take scaling in to consideration */ - x = (int) (x * (1.0 / xfi->scale)); - y = (int) (y * (1.0 / xfi->scale)); + x = (int) (x * (1.0 / xfc->scale)); + y = (int) (y * (1.0 / xfc->scale)); } input->MouseEvent(input, PTR_FLAGS_MOVE, x, y); - if (xfi->fullscreen) + if (xfc->fullscreen) { - XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime); + XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime); } return TRUE; } -static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_ButtonPress(xfContext* xfc, XEvent* event, BOOL app) { int x, y; int flags; @@ -186,7 +186,7 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) rdpInput* input; Window childWindow; - input = xfi->instance->input; + input = xfc->instance->input; x = 0; y = 0; @@ -260,21 +260,21 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) if (app) { /* make sure window exists */ - if (xf_rdpWindowFromWindow(xfi, event->xbutton.window) == 0) + if (xf_rdpWindowFromWindow(xfc, event->xbutton.window) == 0) { return TRUE; } /* Translate to desktop coordinates */ - XTranslateCoordinates(xfi->display, event->xbutton.window, - RootWindowOfScreen(xfi->screen), + XTranslateCoordinates(xfc->display, event->xbutton.window, + RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { /* Take scaling in to consideration */ - x = (int) (x * (1.0 / xfi->scale)); - y = (int) (y * (1.0 / xfi->scale)); + x = (int) (x * (1.0 / xfc->scale)); + y = (int) (y * (1.0 / xfc->scale)); } if (extended) @@ -287,7 +287,7 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) return TRUE; } -static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_ButtonRelease(xfContext* xfc, XEvent* event, BOOL app) { int x, y; int flags; @@ -295,7 +295,7 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) rdpInput* input; Window childWindow; - input = xfi->instance->input; + input = xfc->instance->input; x = 0; y = 0; @@ -350,21 +350,21 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) if (app) { /* make sure window exists */ - if (xf_rdpWindowFromWindow(xfi, event->xbutton.window) == NULL) + if (xf_rdpWindowFromWindow(xfc, event->xbutton.window) == NULL) { return TRUE; } /* Translate to desktop coordinates */ - XTranslateCoordinates(xfi->display, event->xbutton.window, - RootWindowOfScreen(xfi->screen), + XTranslateCoordinates(xfc->display, event->xbutton.window, + RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { /* Take scaling in to consideration */ - x = (int) (x * (1.0 / xfi->scale)); - y = (int) (y * (1.0 / xfi->scale)); + x = (int) (x * (1.0 / xfc->scale)); + y = (int) (y * (1.0 / xfc->scale)); } if (extended) @@ -376,31 +376,31 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) return TRUE; } -static BOOL xf_event_KeyPress(xfInfo* xfi, XEvent* event, BOOL 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_kbd_set_keypress(xfi, event->xkey.keycode, keysym); + xf_kbd_set_keypress(xfc, event->xkey.keycode, keysym); - if (xfi->fullscreen_toggle && xf_kbd_handle_special_keys(xfi, keysym)) + if (xfc->fullscreen_toggle && xf_kbd_handle_special_keys(xfc, keysym)) return TRUE; - xf_kbd_send_key(xfi, TRUE, event->xkey.keycode); + xf_kbd_send_key(xfc, TRUE, event->xkey.keycode); return TRUE; } -static BOOL xf_event_KeyRelease(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_KeyRelease(xfContext* xfc, XEvent* event, BOOL app) { XEvent next_event; - if (XPending(xfi->display)) + if (XPending(xfc->display)) { ZeroMemory(&next_event, sizeof(next_event)); - XPeekEvent(xfi->display, &next_event); + XPeekEvent(xfc->display, &next_event); if (next_event.type == KeyPress) { @@ -409,89 +409,89 @@ static BOOL xf_event_KeyRelease(xfInfo* xfi, XEvent* event, BOOL app) } } - xf_kbd_unset_keypress(xfi, event->xkey.keycode); - xf_kbd_send_key(xfi, FALSE, event->xkey.keycode); + xf_kbd_unset_keypress(xfc, event->xkey.keycode); + xf_kbd_send_key(xfc, FALSE, event->xkey.keycode); return TRUE; } -static BOOL xf_event_FocusIn(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app) { if (event->xfocus.mode == NotifyGrab) return TRUE; - xfi->focused = TRUE; + xfc->focused = TRUE; - if (xfi->mouse_active && (!app)) - XGrabKeyboard(xfi->display, xfi->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime); + if (xfc->mouse_active && (!app)) + XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime); if (app) { - xf_rail_send_activate(xfi, event->xany.window, TRUE); + xf_rail_send_activate(xfc, event->xany.window, TRUE); rdpWindow* window; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpRail* rail = ((rdpContext*) xfc)->rail; window = window_list_get_by_extra_id(rail->list, (void*) event->xany.window); /* Update the server with any window changes that occured while the window was not focused. */ if (window != NULL) - xf_rail_adjust_position(xfi, window); + xf_rail_adjust_position(xfc, window); } - xf_kbd_focus_in(xfi); + xf_kbd_focus_in(xfc); if (!app) - xf_cliprdr_check_owner(xfi); + xf_cliprdr_check_owner(xfc); return TRUE; } -static BOOL xf_event_FocusOut(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_FocusOut(xfContext* xfc, XEvent* event, BOOL app) { if (event->xfocus.mode == NotifyUngrab) return TRUE; - xfi->focused = FALSE; + xfc->focused = FALSE; if (event->xfocus.mode == NotifyWhileGrabbed) - XUngrabKeyboard(xfi->display, CurrentTime); + XUngrabKeyboard(xfc->display, CurrentTime); - xf_kbd_clear(xfi); + xf_kbd_clear(xfc); if (app) - xf_rail_send_activate(xfi, event->xany.window, FALSE); + xf_rail_send_activate(xfc, event->xany.window, FALSE); return TRUE; } -static BOOL xf_event_MappingNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_MappingNotify(xfContext* xfc, XEvent* event, BOOL app) { if (event->xmapping.request == MappingModifier) { - XFreeModifiermap(xfi->modifier_map); - xfi->modifier_map = XGetModifierMapping(xfi->display); + XFreeModifiermap(xfc->modifier_map); + xfc->modifier_map = XGetModifierMapping(xfc->display); } return TRUE; } -static BOOL xf_event_ClientMessage(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_ClientMessage(xfContext* xfc, XEvent* event, BOOL app) { - if ((event->xclient.message_type == xfi->WM_PROTOCOLS) - && ((Atom) event->xclient.data.l[0] == xfi->WM_DELETE_WINDOW)) + if ((event->xclient.message_type == xfc->WM_PROTOCOLS) + && ((Atom) event->xclient.data.l[0] == xfc->WM_DELETE_WINDOW)) { if (app) { DEBUG_X11("RAIL window closed"); rdpWindow* window; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpRail* rail = ((rdpContext*) xfc)->rail; window = window_list_get_by_extra_id(rail->list, (void*) event->xclient.window); if (window != NULL) { - xf_rail_send_client_system_command(xfi, window->windowId, SC_CLOSE); + xf_rail_send_client_system_command(xfc, window->windowId, SC_CLOSE); } return TRUE; @@ -506,17 +506,17 @@ static BOOL xf_event_ClientMessage(xfInfo* xfi, XEvent* event, BOOL app) return TRUE; } -static BOOL xf_event_EnterNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_EnterNotify(xfContext* xfc, XEvent* event, BOOL app) { if (!app) { - xfi->mouse_active = TRUE; + xfc->mouse_active = TRUE; - if (xfi->fullscreen) - XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime); + if (xfc->fullscreen) + XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime); - if (xfi->focused) - XGrabKeyboard(xfi->display, xfi->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime); + if (xfc->focused) + XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime); } else { @@ -524,42 +524,42 @@ static BOOL xf_event_EnterNotify(xfInfo* xfi, XEvent* event, BOOL app) xfWindow* xfw; rdpWindow* window; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpRail* rail = ((rdpContext*) xfc)->rail; window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window); if (window != NULL) { xfw = (xfWindow*) window->extra; - xfi->window = xfw; + xfc->window = xfw; } } return TRUE; } -static BOOL xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_LeaveNotify(xfContext* xfc, XEvent* event, BOOL app) { if (!app) { - xfi->mouse_active = FALSE; - XUngrabKeyboard(xfi->display, CurrentTime); + xfc->mouse_active = FALSE; + XUngrabKeyboard(xfc->display, CurrentTime); } return TRUE; } -static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app) { rdpWindow* window; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpRail* rail = ((rdpContext*) xfc)->rail; - if (xfi->width != event->xconfigure.width) + if (xfc->width != event->xconfigure.width) { - xfi->scale = (double) event->xconfigure.width / (double) xfi->originalWidth; - xfi->currentWidth = event->xconfigure.width; - xfi->currentHeight = event->xconfigure.width; + xfc->scale = (double) event->xconfigure.width / (double) xfc->originalWidth; + xfc->currentWidth = event->xconfigure.width; + xfc->currentHeight = event->xconfigure.width; - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window); @@ -575,8 +575,8 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) * Translate these to root window coordinates. */ - XTranslateCoordinates(xfi->display, xfw->handle, - RootWindowOfScreen(xfi->screen), + XTranslateCoordinates(xfc->display, xfw->handle, + RootWindowOfScreen(xfc->screen), 0, 0, &xfw->left, &xfw->top, &childWindow); xfw->width = event->xconfigure.width; @@ -597,7 +597,7 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) if (app && xfw->decorations) { /* moving resizing using window decoration */ - xf_rail_adjust_position(xfi, window); + xf_rail_adjust_position(xfc, window); window->windowOffsetX = xfw->left; window->visibleOffsetX = window->windowOffsetX; window->windowOffsetY = xfw->top; @@ -607,9 +607,9 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) } else { - if (app && (!event->xconfigure.send_event || xfi->window->local_move.state == LMS_NOT_ACTIVE) - && !xfw->rail_ignore_configure && xfi->focused) - xf_rail_adjust_position(xfi, window); + if (app && (!event->xconfigure.send_event || xfc->window->local_move.state == LMS_NOT_ACTIVE) + && !xfw->rail_ignore_configure && xfc->focused) + xf_rail_adjust_position(xfc, window); } } @@ -617,21 +617,21 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) return True; } -static BOOL xf_event_MapNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_MapNotify(xfContext* xfc, XEvent* event, BOOL app) { RECTANGLE_16 rect; rdpWindow* window; - rdpUpdate* update = xfi->instance->update; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpUpdate* update = xfc->instance->update; + rdpRail* rail = ((rdpContext*) xfc)->rail; if (!app) { rect.left = 0; rect.top = 0; - rect.right = xfi->width; - rect.bottom = xfi->height; + rect.right = xfc->width; + rect.bottom = xfc->height; - update->SuppressOutput((rdpContext*) xfi->context, 1, &rect); + update->SuppressOutput((rdpContext*) xfc, 1, &rect); } else { @@ -646,7 +646,7 @@ static BOOL xf_event_MapNotify(xfInfo* xfi, XEvent* event, BOOL app) * that is minimized back to the maximized state */ - //xf_rail_send_client_system_command(xfi, window->windowId, SC_RESTORE); + //xf_rail_send_client_system_command(xfc, window->windowId, SC_RESTORE); xfWindow* xfw = (xfWindow*) window->extra; xfw->is_mapped = TRUE; } @@ -655,17 +655,17 @@ static BOOL xf_event_MapNotify(xfInfo* xfi, XEvent* event, BOOL app) return TRUE; } -static BOOL xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_UnmapNotify(xfContext* xfc, XEvent* event, BOOL app) { rdpWindow* window; - rdpUpdate* update = xfi->instance->update; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; + rdpUpdate* update = xfc->instance->update; + rdpRail* rail = ((rdpContext*) xfc)->rail; - xf_kbd_release_all_keypress(xfi); + xf_kbd_release_all_keypress(xfc); if (!app) { - update->SuppressOutput((rdpContext*) xfi->context, 0, NULL); + update->SuppressOutput((rdpContext*) xfc, 0, NULL); } else { @@ -681,40 +681,40 @@ static BOOL xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, BOOL app) return TRUE; } -static BOOL xf_event_SelectionNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_SelectionNotify(xfContext* xfc, XEvent* event, BOOL app) { if (!app) { - if (xf_cliprdr_process_selection_notify(xfi, event)) + if (xf_cliprdr_process_selection_notify(xfc, event)) return TRUE; } return TRUE; } -static BOOL xf_event_SelectionRequest(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_SelectionRequest(xfContext* xfc, XEvent* event, BOOL app) { if (!app) { - if (xf_cliprdr_process_selection_request(xfi, event)) + if (xf_cliprdr_process_selection_request(xfc, event)) return TRUE; } return TRUE; } -static BOOL xf_event_SelectionClear(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_SelectionClear(xfContext* xfc, XEvent* event, BOOL app) { if (!app) { - if (xf_cliprdr_process_selection_clear(xfi, event)) + if (xf_cliprdr_process_selection_clear(xfc, event)) return TRUE; } return TRUE; } -static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) +static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app) { /* * This section handles sending the appropriate commands to the rail server @@ -726,13 +726,13 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) { rdpWindow* window; - window = xf_rdpWindowFromWindow(xfi, event->xproperty.window); + window = xf_rdpWindowFromWindow(xfc, event->xproperty.window); if (window == NULL) return TRUE; - if ((((Atom) event->xproperty.atom == xfi->_NET_WM_STATE) && (event->xproperty.state != PropertyDelete)) || - (((Atom) event->xproperty.atom == xfi->WM_STATE) && (event->xproperty.state != PropertyDelete))) + 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; @@ -743,10 +743,10 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) unsigned long bytes; unsigned char* prop; - if ((Atom) event->xproperty.atom == xfi->_NET_WM_STATE) + if ((Atom) event->xproperty.atom == xfc->_NET_WM_STATE) { - status = xf_GetWindowProperty(xfi, event->xproperty.window, - xfi->_NET_WM_STATE, 12, &nitems, &bytes, &prop); + status = xf_GetWindowProperty(xfc, event->xproperty.window, + xfc->_NET_WM_STATE, 12, &nitems, &bytes, &prop); if (!status) { @@ -755,12 +755,12 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) for (i = 0; i < nitems; i++) { - if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfi->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(xfi->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False)) + if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False)) { maxHorz = TRUE; } @@ -769,9 +769,9 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) XFree(prop); } - if ((Atom) event->xproperty.atom == xfi->WM_STATE) + if ((Atom) event->xproperty.atom == xfc->WM_STATE) { - status = xf_GetWindowProperty(xfi, event->xproperty.window, xfi->WM_STATE, 1, &nitems, &bytes, &prop); + status = xf_GetWindowProperty(xfc, event->xproperty.window, xfc->WM_STATE, 1, &nitems, &bytes, &prop); if (!status) { @@ -790,51 +790,51 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) } - if (maxVert && maxHorz && !minimized && (xfi->window->rail_state != WINDOW_SHOW_MAXIMIZED)) + if (maxVert && maxHorz && !minimized && (xfc->window->rail_state != WINDOW_SHOW_MAXIMIZED)) { DEBUG_X11_LMS("Send SC_MAXIMIZE command to rail server."); - xfi->window->rail_state = WINDOW_SHOW_MAXIMIZED; - xf_rail_send_client_system_command(xfi, window->windowId, SC_MAXIMIZE); + xfc->window->rail_state = WINDOW_SHOW_MAXIMIZED; + xf_rail_send_client_system_command(xfc, window->windowId, SC_MAXIMIZE); } - else if (minimized && (xfi->window->rail_state != WINDOW_SHOW_MINIMIZED)) + else if (minimized && (xfc->window->rail_state != WINDOW_SHOW_MINIMIZED)) { DEBUG_X11_LMS("Send SC_MINIMIZE command to rail server."); - xfi->window->rail_state = WINDOW_SHOW_MINIMIZED; - xf_rail_send_client_system_command(xfi, window->windowId, SC_MINIMIZE); + xfc->window->rail_state = WINDOW_SHOW_MINIMIZED; + xf_rail_send_client_system_command(xfc, window->windowId, SC_MINIMIZE); } - else if (!minimized && !maxVert && !maxHorz && (xfi->window->rail_state != WINDOW_SHOW)) + else if (!minimized && !maxVert && !maxHorz && (xfc->window->rail_state != WINDOW_SHOW)) { DEBUG_X11_LMS("Send SC_RESTORE command to rail server"); - xfi->window->rail_state = WINDOW_SHOW; - xf_rail_send_client_system_command(xfi, window->windowId, SC_RESTORE); + xfc->window->rail_state = WINDOW_SHOW; + xf_rail_send_client_system_command(xfc, window->windowId, SC_RESTORE); } } } else { - if (xf_cliprdr_process_property_notify(xfi, event)) + if (xf_cliprdr_process_property_notify(xfc, event)) return TRUE; } return TRUE; } -static BOOL xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*event) +static BOOL xf_event_suppress_events(xfContext* xfc, rdpWindow* window, XEvent*event) { - if (!xfi->remote_app) + if (!xfc->remote_app) return FALSE; - switch (xfi->window->local_move.state) + switch (xfc->window->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) && xfi->window->rail_ignore_configure) + if ( (event->type == ConfigureNotify) && xfc->window->rail_ignore_configure) { DEBUG_X11_LMS("ConfigureNotify Event Ignored"); - xfi->window->rail_ignore_configure = FALSE; + xfc->window->rail_ignore_configure = FALSE; return TRUE; } @@ -846,7 +846,7 @@ static BOOL xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*even { case ConfigureNotify: /* Starting to see move events from the X server. Local move is now in progress. */ - xfi->window->local_move.state = LMS_ACTIVE; + xfc->window->local_move.state = LMS_ACTIVE; /* Allow these events to be processed during move to keep our state up to date. */ break; @@ -886,7 +886,7 @@ static BOOL xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*even default: DEBUG_X11_LMS("Event Type to break LMS: %s", X11_EVENT_STRINGS[event->type]); /* Any other event terminates move */ - xf_rail_end_local_move(xfi, window); + xf_rail_end_local_move(xfc, window); break; } break; @@ -903,20 +903,20 @@ static BOOL xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*even BOOL xf_event_process(freerdp* instance, XEvent* event) { BOOL status = TRUE; - xfInfo* xfi = ((xfContext*) instance->context)->xfi; - rdpRail* rail = ((rdpContext*) xfi->context)->rail; rdpWindow* window; + xfContext* xfc = (xfContext*) instance->context; + rdpRail* rail = ((rdpContext*) xfc)->rail; - if (xfi->remote_app) + if (xfc->remote_app) { window = window_list_get_by_extra_id(rail->list, (void*) event->xexpose.window); - if (window) + if (window) { /* Update "current" window for cursor change orders */ - xfi->window = (xfWindow*) window->extra; + xfc->window = (xfWindow*) window->extra; - if (xf_event_suppress_events(xfi, window, event)) + if (xf_event_suppress_events(xfc, window, event)) return TRUE; } } @@ -927,47 +927,47 @@ BOOL xf_event_process(freerdp* instance, XEvent* event) switch (event->type) { case Expose: - status = xf_event_Expose(xfi, event, xfi->remote_app); + status = xf_event_Expose(xfc, event, xfc->remote_app); break; case VisibilityNotify: - status = xf_event_VisibilityNotify(xfi, event, xfi->remote_app); + status = xf_event_VisibilityNotify(xfc, event, xfc->remote_app); break; case MotionNotify: - status = xf_event_MotionNotify(xfi, event, xfi->remote_app); + status = xf_event_MotionNotify(xfc, event, xfc->remote_app); break; case ButtonPress: - status = xf_event_ButtonPress(xfi, event, xfi->remote_app); + status = xf_event_ButtonPress(xfc, event, xfc->remote_app); break; case ButtonRelease: - status = xf_event_ButtonRelease(xfi, event, xfi->remote_app); + status = xf_event_ButtonRelease(xfc, event, xfc->remote_app); break; case KeyPress: - status = xf_event_KeyPress(xfi, event, xfi->remote_app); + status = xf_event_KeyPress(xfc, event, xfc->remote_app); break; case KeyRelease: - status = xf_event_KeyRelease(xfi, event, xfi->remote_app); + status = xf_event_KeyRelease(xfc, event, xfc->remote_app); break; case FocusIn: - status = xf_event_FocusIn(xfi, event, xfi->remote_app); + status = xf_event_FocusIn(xfc, event, xfc->remote_app); break; case FocusOut: - status = xf_event_FocusOut(xfi, event, xfi->remote_app); + status = xf_event_FocusOut(xfc, event, xfc->remote_app); break; case EnterNotify: - status = xf_event_EnterNotify(xfi, event, xfi->remote_app); + status = xf_event_EnterNotify(xfc, event, xfc->remote_app); break; case LeaveNotify: - status = xf_event_LeaveNotify(xfi, event, xfi->remote_app); + status = xf_event_LeaveNotify(xfc, event, xfc->remote_app); break; case NoExpose: @@ -977,48 +977,48 @@ BOOL xf_event_process(freerdp* instance, XEvent* event) break; case ConfigureNotify: - status = xf_event_ConfigureNotify(xfi, event, xfi->remote_app); + status = xf_event_ConfigureNotify(xfc, event, xfc->remote_app); break; case MapNotify: - status = xf_event_MapNotify(xfi, event, xfi->remote_app); + status = xf_event_MapNotify(xfc, event, xfc->remote_app); break; case UnmapNotify: - status = xf_event_UnmapNotify(xfi, event, xfi->remote_app); + status = xf_event_UnmapNotify(xfc, event, xfc->remote_app); break; case ReparentNotify: break; case MappingNotify: - status = xf_event_MappingNotify(xfi, event, xfi->remote_app); + status = xf_event_MappingNotify(xfc, event, xfc->remote_app); break; case ClientMessage: - status = xf_event_ClientMessage(xfi, event, xfi->remote_app); + status = xf_event_ClientMessage(xfc, event, xfc->remote_app); break; case SelectionNotify: - status = xf_event_SelectionNotify(xfi, event, xfi->remote_app); + status = xf_event_SelectionNotify(xfc, event, xfc->remote_app); break; case SelectionRequest: - status = xf_event_SelectionRequest(xfi, event, xfi->remote_app); + status = xf_event_SelectionRequest(xfc, event, xfc->remote_app); break; case SelectionClear: - status = xf_event_SelectionClear(xfi, event, xfi->remote_app); + status = xf_event_SelectionClear(xfc, event, xfc->remote_app); break; case PropertyNotify: - status = xf_event_PropertyNotify(xfi, event, xfi->remote_app); + status = xf_event_PropertyNotify(xfc, event, xfc->remote_app); break; } - xf_input_handle_event(xfi, event); + xf_input_handle_event(xfc, event); - XSync(xfi->display, FALSE); + XSync(xfc->display, FALSE); return status; } diff --git a/client/X11/xf_event.h b/client/X11/xf_event.h index 93e0c7732..8ed250e83 100644 --- a/client/X11/xf_event.h +++ b/client/X11/xf_event.h @@ -26,6 +26,6 @@ #include "xfreerdp.h" BOOL xf_event_process(freerdp* instance, XEvent* event); -void xf_event_SendClientEvent(xfInfo *xfi, xfWindow* window, Atom atom, unsigned int numArgs, ...); +void xf_event_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned int numArgs, ...); #endif /* __XF_EVENT_H */ diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index e21c00762..acdc0da47 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -64,7 +64,7 @@ static const BYTE xf_rop2_table[] = GXset /* 1 */ }; -BOOL xf_set_rop2(xfInfo* xfi, int rop2) +BOOL xf_set_rop2(xfContext* xfc, int rop2) { if ((rop2 < 0x01) || (rop2 > 0x10)) { @@ -72,11 +72,11 @@ BOOL xf_set_rop2(xfInfo* xfi, int rop2) return FALSE; } - XSetFunction(xfi->display, xfi->gc, xf_rop2_table[rop2]); + XSetFunction(xfc->display, xfc->gc, xf_rop2_table[rop2]); return TRUE; } -BOOL xf_set_rop3(xfInfo* xfi, int rop3) +BOOL xf_set_rop3(xfContext* xfc, int rop3) { int function = -1; @@ -205,46 +205,46 @@ BOOL xf_set_rop3(xfInfo* xfi, int rop3) if (function < 0) { fprintf(stderr, "Unsupported ROP3: 0x%08X\n", rop3); - XSetFunction(xfi->display, xfi->gc, GXclear); + XSetFunction(xfc->display, xfc->gc, GXclear); return FALSE; } - XSetFunction(xfi->display, xfi->gc, function); + XSetFunction(xfc->display, xfc->gc, function); return TRUE; } -Pixmap xf_brush_new(xfInfo* xfi, int width, int height, int bpp, BYTE* data) +Pixmap xf_brush_new(xfContext* xfc, int width, int height, int bpp, BYTE* data) { Pixmap bitmap; BYTE* cdata; XImage* image; - bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, xfi->depth); + bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, xfc->depth); if (data != NULL) { GC gc; - cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfi->bpp, xfi->clrconv); + cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfc->bpp, xfc->clrconv); - image = XCreateImage(xfi->display, xfi->visual, xfi->depth, - ZPixmap, 0, (char*) cdata, width, height, xfi->scanline_pad, 0); + image = XCreateImage(xfc->display, xfc->visual, xfc->depth, + ZPixmap, 0, (char*) cdata, width, height, xfc->scanline_pad, 0); - gc = XCreateGC(xfi->display, xfi->drawable, 0, NULL); - XPutImage(xfi->display, bitmap, gc, image, 0, 0, 0, 0, width, height); + gc = XCreateGC(xfc->display, xfc->drawable, 0, NULL); + XPutImage(xfc->display, bitmap, gc, image, 0, 0, 0, 0, width, height); XFree(image); if (cdata != data) free(cdata); - XFreeGC(xfi->display, gc); + XFreeGC(xfc->display, gc); } return bitmap; } -Pixmap xf_mono_bitmap_new(xfInfo* xfi, int width, int height, BYTE* data) +Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height, BYTE* data) { int scanline; XImage* image; @@ -252,12 +252,12 @@ Pixmap xf_mono_bitmap_new(xfInfo* xfi, int width, int height, BYTE* data) scanline = (width + 7) / 8; - bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, 1); + bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, 1); - image = XCreateImage(xfi->display, xfi->visual, 1, + image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*) data, width, height, 8, scanline); - XPutImage(xfi->display, bitmap, xfi->gc_mono, image, 0, 0, 0, 0, width, height); + XPutImage(xfc->display, bitmap, xfc->gc_mono, image, 0, 0, 0, 0, width, height); XFree(image); return bitmap; @@ -265,21 +265,21 @@ Pixmap xf_mono_bitmap_new(xfInfo* xfi, int width, int height, BYTE* data) void xf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - CopyMemory(xfi->clrconv->palette, palette, sizeof(rdpPalette)); + CopyMemory(xfc->clrconv->palette, palette, sizeof(rdpPalette)); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) { XRectangle clip; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (bounds != NULL) { @@ -287,37 +287,37 @@ void xf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) clip.y = bounds->top; clip.width = bounds->right - bounds->left + 1; clip.height = bounds->bottom - bounds->top + 1; - XSetClipRectangles(xfi->display, xfi->gc, 0, 0, &clip, 1, YXBanded); + XSetClipRectangles(xfc->display, xfc->gc, 0, 0, &clip, 1, YXBanded); } else { - XSetClipMask(xfi->display, xfi->gc, None); + XSetClipMask(xfc->display, xfc->gc, None); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_set_rop3(xfi, gdi_rop3_code(dstblt->bRop)); + xf_set_rop3(xfc, gdi_rop3_code(dstblt->bRop)); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight); + gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) @@ -326,71 +326,70 @@ void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) rdpBrush* brush; UINT32 foreColor; UINT32 backColor; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); brush = &patblt->brush; - xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); + xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)); - foreColor = freerdp_color_convert_var(patblt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); - backColor = freerdp_color_convert_var(patblt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + foreColor = freerdp_color_convert_var(patblt->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); + backColor = freerdp_color_convert_var(patblt->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); if (brush->style == GDI_BS_SOLID) { - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, foreColor); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, foreColor); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_HATCHED) { - pattern = xf_mono_bitmap_new(xfi, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); + pattern = xf_mono_bitmap_new(xfc, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); - XSetForeground(xfi->display, xfi->gc, backColor); - XSetBackground(xfi->display, xfi->gc, foreColor); - XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); - XSetStipple(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetForeground(xfc->display, xfc->gc, backColor); + XSetBackground(xfc->display, xfc->gc, foreColor); + XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); + XSetStipple(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); - XFreePixmap(xfi->display, pattern); + XFreePixmap(xfc->display, pattern); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { - pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); + pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); - XSetFillStyle(xfi->display, xfi->gc, FillTiled); - XSetTile(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetFillStyle(xfc->display, xfc->gc, FillTiled); + XSetTile(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); - XSetTile(xfi->display, xfi->gc, xfi->primary); + XSetTile(xfc->display, xfc->gc, xfc->primary); - XFreePixmap(xfi->display, pattern); + XFreePixmap(xfc->display, pattern); } else { - pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); + pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); - XSetForeground(xfi->display, xfi->gc, backColor); - XSetBackground(xfi->display, xfi->gc, foreColor); - XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); - XSetStipple(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetForeground(xfc->display, xfc->gc, backColor); + XSetBackground(xfc->display, xfc->gc, foreColor); + XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); + XSetStipple(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); - XFreePixmap(xfi->display, pattern); + XFreePixmap(xfc->display, pattern); } } else @@ -398,62 +397,61 @@ void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) fprintf(stderr, "unimplemented brush style:%d\n", brush->style); } - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); + gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_set_rop3(xfi, gdi_rop3_code(scrblt->bRop)); + xf_set_rop3(xfc, gdi_rop3_code(scrblt->bRop)); - XCopyArea(xfi->display, xfi->primary, xfi->drawing, xfi->gc, scrblt->nXSrc, scrblt->nYSrc, + XCopyArea(xfc->display, xfc->primary, xfc->drawing, xfc->gc, scrblt->nXSrc, scrblt->nYSrc, scrblt->nWidth, scrblt->nHeight, scrblt->nLeftRect, scrblt->nTopRect); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight); + gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) { UINT32 color; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - color = freerdp_color_convert_var(opaque_rect->color, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + color = freerdp_color_convert_var(opaque_rect->color, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, color); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, color); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect, + gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) @@ -461,32 +459,31 @@ void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult int i; UINT32 color; DELTA_RECT* rectangle; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - color = freerdp_color_convert_var(multi_opaque_rect->color, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + color = freerdp_color_convert_var(multi_opaque_rect->color, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, color); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, color); for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++) { rectangle = &multi_opaque_rect->rectangles[i]; - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, rectangle->left, rectangle->top, rectangle->width, rectangle->height); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height); + gdi_InvalidateRegion(xfc->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height); } } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid) @@ -497,21 +494,20 @@ void xf_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_ void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) { UINT32 color; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_set_rop2(xfi, line_to->bRop2); - color = freerdp_color_convert_var(line_to->penColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + xf_set_rop2(xfc, line_to->bRop2); + color = freerdp_color_convert_var(line_to->penColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, color); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, color); - XDrawLine(xfi->display, xfi->drawing, xfi->gc, + XDrawLine(xfc->display, xfc->drawing, xfc->gc, line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { int width, height; @@ -524,13 +520,13 @@ void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) if (height < 0) height *= (-1); - gdi_InvalidateRegion(xfi->hdc, line_to->nXStart, line_to->nYStart, width, height); + gdi_InvalidateRegion(xfc->hdc, line_to->nXStart, line_to->nYStart, width, height); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) @@ -543,16 +539,15 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) UINT32 color; XPoint* points; int width, height; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_set_rop2(xfi, polyline->bRop2); - color = freerdp_color_convert_var(polyline->penColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + xf_set_rop2(xfc, polyline->bRop2); + color = freerdp_color_convert_var(polyline->penColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, color); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, color); npoints = polyline->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); @@ -566,9 +561,9 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) points[i + 1].y = polyline->points[i].y; } - XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, npoints, CoordModePrevious); + XDrawLines(xfc->display, xfc->drawing, xfc->gc, points, npoints, CoordModePrevious); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { x1 = points[0].x; y1 = points[0].y; @@ -587,38 +582,38 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) x1 = x2; y1 = y2; - gdi_InvalidateRegion(xfi->hdc, x, y, width, height); + gdi_InvalidateRegion(xfc->hdc, x, y, width, height); } } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); free(points); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { xfBitmap* bitmap; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); bitmap = (xfBitmap*) memblt->bitmap; - xf_set_rop3(xfi, gdi_rop3_code(memblt->bRop)); + xf_set_rop3(xfc, gdi_rop3_code(memblt->bRop)); - XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc, + XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, memblt->nXSrc, memblt->nYSrc, memblt->nWidth, memblt->nHeight, memblt->nLeftRect, memblt->nTopRect); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight); + gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) @@ -628,69 +623,68 @@ void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) UINT32 foreColor; UINT32 backColor; Pixmap pattern = 0; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; - xf_set_rop3(xfi, gdi_rop3_code(mem3blt->bRop)); - foreColor = freerdp_color_convert_var(mem3blt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); - backColor = freerdp_color_convert_var(mem3blt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop)); + foreColor = freerdp_color_convert_var(mem3blt->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); + backColor = freerdp_color_convert_var(mem3blt->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { - pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); + pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); - XSetFillStyle(xfi->display, xfi->gc, FillTiled); - XSetTile(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetFillStyle(xfc->display, xfc->gc, FillTiled); + XSetTile(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } else { - pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); + pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); - XSetForeground(xfi->display, xfi->gc, backColor); - XSetBackground(xfi->display, xfi->gc, foreColor); - XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); - XSetStipple(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetForeground(xfc->display, xfc->gc, backColor); + XSetBackground(xfc->display, xfc->gc, foreColor); + XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); + XSetStipple(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } } else if (brush->style == GDI_BS_SOLID) { - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, backColor); - XSetBackground(xfi->display, xfi->gc, foreColor); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, backColor); + XSetBackground(xfc->display, xfc->gc, foreColor); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } else { fprintf(stderr, "Mem3Blt unimplemented brush style:%d\n", brush->style); } - XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc, + XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); + gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); } - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetTSOrigin(xfi->display, xfi->gc, 0, 0); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetTSOrigin(xfc->display, xfc->gc, 0, 0); if (pattern != 0) - XFreePixmap(xfi->display, pattern); + XFreePixmap(xfc->display, pattern); - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) @@ -698,12 +692,12 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) int i, npoints; XPoint* points; UINT32 brush_color; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_set_rop2(xfi, polygon_sc->bRop2); - brush_color = freerdp_color_convert_var(polygon_sc->brushColor, ((xfContext*)context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); + xf_set_rop2(xfc, polygon_sc->bRop2); + brush_color = freerdp_color_convert_var(polygon_sc->brushColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); npoints = polygon_sc->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); @@ -720,11 +714,11 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) switch (polygon_sc->fillMode) { case 1: /* alternate */ - XSetFillRule(xfi->display, xfi->gc, EvenOddRule); + XSetFillRule(xfc->display, xfc->gc, EvenOddRule); break; case 2: /* winding */ - XSetFillRule(xfi->display, xfi->gc, WindingRule); + XSetFillRule(xfc->display, xfc->gc, WindingRule); break; default: @@ -732,22 +726,22 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc) break; } - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, brush_color); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, brush_color); - XFillPolygon(xfi->display, xfi->drawing, xfi->gc, + XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - XFillPolygon(xfi->display, xfi->drawable, xfi->gc, + XFillPolygon(xfc->display, xfc->drawable, xfc->gc, points, npoints, Complex, CoordModePrevious); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); free(points); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) @@ -758,14 +752,14 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) rdpBrush* brush; UINT32 foreColor; UINT32 backColor; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); brush = &(polygon_cb->brush); - xf_set_rop2(xfi, polygon_cb->bRop2); - foreColor = freerdp_color_convert_var(polygon_cb->foreColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); - backColor = freerdp_color_convert_var(polygon_cb->backColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); + xf_set_rop2(xfc, polygon_cb->bRop2); + foreColor = freerdp_color_convert_var(polygon_cb->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); + backColor = freerdp_color_convert_var(polygon_cb->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); npoints = polygon_cb->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); @@ -782,11 +776,11 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) switch (polygon_cb->fillMode) { case 1: /* alternate */ - XSetFillRule(xfi->display, xfi->gc, EvenOddRule); + XSetFillRule(xfc->display, xfc->gc, EvenOddRule); break; case 2: /* winding */ - XSetFillRule(xfi->display, xfi->gc, WindingRule); + XSetFillRule(xfc->display, xfc->gc, WindingRule); break; default: @@ -798,52 +792,52 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { if (brush->bpp > 1) { - pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); + pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); - XSetFillStyle(xfi->display, xfi->gc, FillTiled); - XSetTile(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetFillStyle(xfc->display, xfc->gc, FillTiled); + XSetTile(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); - XFillPolygon(xfi->display, xfi->drawing, xfi->gc, + XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - XFillPolygon(xfi->display, xfi->drawable, xfi->gc, + XFillPolygon(xfc->display, xfc->drawable, xfc->gc, points, npoints, Complex, CoordModePrevious); } - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetTSOrigin(xfi->display, xfi->gc, 0, 0); - XFreePixmap(xfi->display, pattern); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetTSOrigin(xfc->display, xfc->gc, 0, 0); + XFreePixmap(xfc->display, pattern); } else { - pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); + pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); - XSetForeground(xfi->display, xfi->gc, backColor); - XSetBackground(xfi->display, xfi->gc, foreColor); + XSetForeground(xfc->display, xfc->gc, backColor); + XSetBackground(xfc->display, xfc->gc, foreColor); if (polygon_cb->backMode == BACKMODE_TRANSPARENT) - XSetFillStyle(xfi->display, xfi->gc, FillStippled); + XSetFillStyle(xfc->display, xfc->gc, FillStippled); else if (polygon_cb->backMode == BACKMODE_OPAQUE) - XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); + XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); - XSetStipple(xfi->display, xfi->gc, pattern); - XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); + XSetStipple(xfc->display, xfc->gc, pattern); + XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); - XFillPolygon(xfi->display, xfi->drawing, xfi->gc, + XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - XFillPolygon(xfi->display, xfi->drawable, xfi->gc, + XFillPolygon(xfc->display, xfc->drawable, xfc->gc, points, npoints, Complex, CoordModePrevious); } - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetTSOrigin(xfi->display, xfi->gc, 0, 0); - XFreePixmap(xfi->display, pattern); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetTSOrigin(xfc->display, xfc->gc, 0, 0); + XFreePixmap(xfc->display, pattern); } } else @@ -851,10 +845,10 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) fprintf(stderr, "PolygonCB unimplemented brush style:%d\n", brush->style); } - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); free(points); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc) @@ -869,70 +863,69 @@ void xf_gdi_ellipse_cb(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb) void xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker) { - xfInfo* xfi; rdpSettings* settings; + xfContext* xfc = (xfContext*) context; - xfi = ((xfContext*) context)->xfi; - settings = xfi->instance->settings; + settings = xfc->instance->settings; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); switch (surface_frame_marker->frameAction) { case SURFACECMD_FRAMEACTION_BEGIN: - xfi->frame_begin = TRUE; - xfi->frame_x1 = 0; - xfi->frame_y1 = 0; - xfi->frame_x2 = 0; - xfi->frame_y2 = 0; + xfc->frame_begin = TRUE; + xfc->frame_x1 = 0; + xfc->frame_y1 = 0; + xfc->frame_x2 = 0; + xfc->frame_y2 = 0; break; case SURFACECMD_FRAMEACTION_END: - xfi->frame_begin = FALSE; - if ((xfi->frame_x2 > xfi->frame_x1) && (xfi->frame_y2 > xfi->frame_y1)) + xfc->frame_begin = FALSE; + if ((xfc->frame_x2 > xfc->frame_x1) && (xfc->frame_y2 > xfc->frame_y1)) { - gdi_InvalidateRegion(xfi->hdc, xfi->frame_x1, xfi->frame_y1, - xfi->frame_x2 - xfi->frame_x1, xfi->frame_y2 - xfi->frame_y1); + gdi_InvalidateRegion(xfc->hdc, xfc->frame_x1, xfc->frame_y1, + xfc->frame_x2 - xfc->frame_x1, xfc->frame_y2 - xfc->frame_y1); } if (settings->FrameAcknowledge > 0) { - IFCALL(xfi->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId); + IFCALL(xfc->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId); } break; } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } -static void xf_gdi_surface_update_frame(xfInfo* xfi, UINT16 tx, UINT16 ty, UINT16 width, UINT16 height) +static void xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UINT16 width, UINT16 height) { - if (!xfi->remote_app) + if (!xfc->remote_app) { - if (xfi->frame_begin) + if (xfc->frame_begin) { - if (xfi->frame_x2 > xfi->frame_x1 && xfi->frame_y2 > xfi->frame_y1) + if (xfc->frame_x2 > xfc->frame_x1 && xfc->frame_y2 > xfc->frame_y1) { - xfi->frame_x1 = MIN(xfi->frame_x1, tx); - xfi->frame_y1 = MIN(xfi->frame_y1, ty); - xfi->frame_x2 = MAX(xfi->frame_x2, tx + width); - xfi->frame_y2 = MAX(xfi->frame_y2, ty + height); + xfc->frame_x1 = MIN(xfc->frame_x1, tx); + xfc->frame_y1 = MIN(xfc->frame_y1, ty); + xfc->frame_x2 = MAX(xfc->frame_x2, tx + width); + xfc->frame_y2 = MAX(xfc->frame_y2, ty + height); } else { - xfi->frame_x1 = tx; - xfi->frame_y1 = ty; - xfi->frame_x2 = tx + width; - xfi->frame_y2 = ty + height; + xfc->frame_x1 = tx; + xfc->frame_y1 = ty; + xfc->frame_x2 = tx + width; + xfc->frame_y2 = ty + height; } } else { - gdi_InvalidateRegion(xfi->hdc, tx, ty, width, height); + gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height); } } else { - gdi_InvalidateRegion(xfi->hdc, tx, ty, width, height); + gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height); } } @@ -941,34 +934,34 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits int i, tx, ty; XImage* image; RFX_MESSAGE* message; - xfInfo* xfi = ((xfContext*) context)->xfi; - RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) xfi->rfx_context; - NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) xfi->nsc_context; + xfContext* xfc = (xfContext*) context; + RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) xfc->rfx_context; + NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) xfc->nsc_context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (surface_bits_command->codecID == RDP_CODEC_ID_REMOTEFX) { message = rfx_process_message(rfx_context, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); - XSetClipRectangles(xfi->display, xfi->gc, + XSetClipRectangles(xfc->display, xfc->gc, surface_bits_command->destLeft, surface_bits_command->destTop, (XRectangle*) message->rects, message->num_rects, YXBanded); /* Draw the tiles to primary surface, each is 64x64. */ for (i = 0; i < message->num_tiles; i++) { - image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0, + image = XCreateImage(xfc->display, xfc->visual, 24, ZPixmap, 0, (char*) message->tiles[i]->data, 64, 64, 32, 0); tx = message->tiles[i]->x + surface_bits_command->destLeft; ty = message->tiles[i]->y + surface_bits_command->destTop; - XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0, tx, ty, 64, 64); + XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, tx, ty, 64, 64); XFree(image); } @@ -978,10 +971,10 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits tx = message->rects[i].x + surface_bits_command->destLeft; ty = message->rects[i].y + surface_bits_command->destTop; - xf_gdi_surface_update_frame(xfi, tx, ty, message->rects[i].width, message->rects[i].height); + xf_gdi_surface_update_frame(xfc, tx, ty, message->rects[i].width, message->rects[i].height); } - XSetClipMask(xfi->display, xfi->gc, None); + XSetClipMask(xfc->display, xfc->gc, None); rfx_message_free(rfx_context, message); } else if (surface_bits_command->codecID == RDP_CODEC_ID_NSCODEC) @@ -989,56 +982,56 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits nsc_process_message(nsc_context, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); - xfi->bmp_codec_nsc = (BYTE*) realloc(xfi->bmp_codec_nsc, + xfc->bmp_codec_nsc = (BYTE*) realloc(xfc->bmp_codec_nsc, surface_bits_command->width * surface_bits_command->height * 4); - freerdp_image_flip(nsc_context->bmpdata, xfi->bmp_codec_nsc, + freerdp_image_flip(nsc_context->bmpdata, xfc->bmp_codec_nsc, surface_bits_command->width, surface_bits_command->height, 32); - image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0, - (char*) xfi->bmp_codec_nsc, surface_bits_command->width, surface_bits_command->height, 32, 0); + image = XCreateImage(xfc->display, xfc->visual, 24, ZPixmap, 0, + (char*) xfc->bmp_codec_nsc, surface_bits_command->width, surface_bits_command->height, 32, 0); - XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0, + XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height); XFree(image); - xf_gdi_surface_update_frame(xfi, + xf_gdi_surface_update_frame(xfc, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height); - XSetClipMask(xfi->display, xfi->gc, None); + XSetClipMask(xfc->display, xfc->gc, None); } else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE) { - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); /* Validate that the data received is large enough */ if ((surface_bits_command->width * surface_bits_command->height * surface_bits_command->bpp / 8) <= (surface_bits_command->bitmapDataLength)) { - xfi->bmp_codec_none = (BYTE*) realloc(xfi->bmp_codec_none, + xfc->bmp_codec_none = (BYTE*) realloc(xfc->bmp_codec_none, surface_bits_command->width * surface_bits_command->height * 4); - freerdp_image_flip(surface_bits_command->bitmapData, xfi->bmp_codec_none, + freerdp_image_flip(surface_bits_command->bitmapData, xfc->bmp_codec_none, surface_bits_command->width, surface_bits_command->height, 32); - image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0, - (char*) xfi->bmp_codec_none, surface_bits_command->width, surface_bits_command->height, 32, 0); + image = XCreateImage(xfc->display, xfc->visual, 24, ZPixmap, 0, + (char*) xfc->bmp_codec_none, surface_bits_command->width, surface_bits_command->height, 32, 0); - XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0, + XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height); XFree(image); - xf_gdi_surface_update_frame(xfi, + xf_gdi_surface_update_frame(xfc, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height); - XSetClipMask(xfi->display, xfi->gc, None); + XSetClipMask(xfc->display, xfc->gc, None); } else { @@ -1050,7 +1043,7 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits fprintf(stderr, "Unsupported codecID %d\n", surface_bits_command->codecID); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_gdi_register_update_callbacks(rdpUpdate* update) diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index da609790a..96fbf974d 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -43,25 +43,24 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) BYTE* data; Pixmap pixmap; XImage* image; - xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - XSetFunction(xfi->display, xfi->gc, GXcopy); - pixmap = XCreatePixmap(xfi->display, xfi->drawable, bitmap->width, bitmap->height, xfi->depth); + XSetFunction(xfc->display, xfc->gc, GXcopy); + pixmap = XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth); if (bitmap->data != NULL) { data = freerdp_image_convert(bitmap->data, NULL, - bitmap->width, bitmap->height, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + bitmap->width, bitmap->height, context->settings->ColorDepth, xfc->bpp, xfc->clrconv); if (bitmap->ephemeral != TRUE) { - image = XCreateImage(xfi->display, xfi->visual, xfi->depth, - ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfi->scanline_pad, 0); + image = XCreateImage(xfc->display, xfc->visual, xfc->depth, + ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfc->scanline_pad, 0); - XPutImage(xfi->display, pixmap, xfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height); + XPutImage(xfc->display, pixmap, xfc->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height); XFree(image); if (data != bitmap->data) @@ -78,45 +77,45 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) ((xfBitmap*) bitmap)->pixmap = pixmap; - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (((xfBitmap*) bitmap)->pixmap != 0) - XFreePixmap(xfi->display, ((xfBitmap*) bitmap)->pixmap); + XFreePixmap(xfc->display, ((xfBitmap*) bitmap)->pixmap); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) { XImage* image; int width, height; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; width = bitmap->right - bitmap->left + 1; height = bitmap->bottom - bitmap->top + 1; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - XSetFunction(xfi->display, xfi->gc, GXcopy); + XSetFunction(xfc->display, xfc->gc, GXcopy); - image = XCreateImage(xfi->display, xfi->visual, xfi->depth, - ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfi->scanline_pad, 0); + image = XCreateImage(xfc->display, xfc->visual, xfc->depth, + ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfc->scanline_pad, 0); - XPutImage(xfi->display, xfi->primary, xfi->gc, + XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, bitmap->left, bitmap->top, width, height); XFree(image); - gdi_InvalidateRegion(xfi->hdc, bitmap->left, bitmap->top, width, height); + gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, @@ -128,11 +127,9 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, BYTE* dst; int yindex; int xindex; - xfInfo* xfi; BOOL status; RFX_MESSAGE* msg; - - xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; size = width * height * (bpp + 7) / 8; @@ -148,8 +145,8 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, break; case RDP_CODEC_ID_REMOTEFX: - rfx_context_set_pixel_format(xfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); - msg = rfx_process_message(xfi->rfx_context, data, length); + rfx_context_set_pixel_format(xfc->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); + msg = rfx_process_message(xfc->rfx_context, data, length); if (msg == NULL) { @@ -169,7 +166,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, src++; } } - rfx_message_free(xfi->rfx_context, msg); + rfx_message_free(xfc->rfx_context, msg); } break; @@ -204,16 +201,16 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, void xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (primary) - xfi->drawing = xfi->primary; + xfc->drawing = xfc->primary; else - xfi->drawing = ((xfBitmap*) bitmap)->pixmap; + xfc->drawing = ((xfBitmap*) bitmap)->pixmap; - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } /* Pointer Class */ @@ -222,9 +219,9 @@ void xf_Pointer_New(rdpContext* context, rdpPointer* pointer) { #ifdef WITH_XCURSOR XcursorImage ci; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); ZeroMemory(&ci, sizeof(ci)); ci.version = XCURSOR_IMAGE_VERSION; @@ -240,54 +237,54 @@ void xf_Pointer_New(rdpContext* context, rdpPointer* pointer) if ((pointer->andMaskData != 0) && (pointer->xorMaskData != 0)) { freerdp_alpha_cursor_convert((BYTE*) (ci.pixels), pointer->xorMaskData, pointer->andMaskData, - pointer->width, pointer->height, pointer->xorBpp, xfi->clrconv); + pointer->width, pointer->height, pointer->xorBpp, xfc->clrconv); } - ((xfPointer*) pointer)->cursor = XcursorImageLoadCursor(xfi->display, &ci); + ((xfPointer*) pointer)->cursor = XcursorImageLoadCursor(xfc->display, &ci); free(ci.pixels); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); #endif } void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) { #ifdef WITH_XCURSOR - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (((xfPointer*) pointer)->cursor != 0) - XFreeCursor(xfi->display, ((xfPointer*) pointer)->cursor); + XFreeCursor(xfc->display, ((xfPointer*) pointer)->cursor); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); #endif } void xf_Pointer_Set(rdpContext* context, rdpPointer* pointer) { #ifdef WITH_XCURSOR - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); /* in RemoteApp mode, window can be null if none has had focus */ - if (xfi->window != NULL) - XDefineCursor(xfi->display, xfi->window->handle, ((xfPointer*) pointer)->cursor); + if (xfc->window != NULL) + XDefineCursor(xfc->display, xfc->window->handle, ((xfPointer*) pointer)->cursor); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); #endif } void xf_Pointer_SetNull(rdpContext* context) { #ifdef WITH_XCURSOR - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; static Cursor nullcursor = None; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (nullcursor == None) { @@ -299,27 +296,27 @@ void xf_Pointer_SetNull(rdpContext* context) ci.width = ci.height = 1; ci.xhot = ci.yhot = 0; ci.pixels = &xp; - nullcursor = XcursorImageLoadCursor(xfi->display, &ci); + nullcursor = XcursorImageLoadCursor(xfc->display, &ci); } - if (xfi->window != NULL && nullcursor != None) - XDefineCursor(xfi->display, xfi->window->handle, nullcursor); + if (xfc->window != NULL && nullcursor != None) + XDefineCursor(xfc->display, xfc->window->handle, nullcursor); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); #endif } void xf_Pointer_SetDefault(rdpContext* context) { #ifdef WITH_XCURSOR - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - if (xfi->window != NULL) - XUndefineCursor(xfi->display, xfi->window->handle); + if (xfc->window != NULL) + XUndefineCursor(xfc->display, xfc->window->handle); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); #endif } @@ -327,101 +324,100 @@ void xf_Pointer_SetDefault(rdpContext* context) void xf_Glyph_New(rdpContext* context, rdpGlyph* glyph) { - xfInfo* xfi; int scanline; XImage* image; xfGlyph* xf_glyph; xf_glyph = (xfGlyph*) glyph; - xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); scanline = (glyph->cx + 7) / 8; - xf_glyph->pixmap = XCreatePixmap(xfi->display, xfi->drawing, glyph->cx, glyph->cy, 1); + xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx, glyph->cy, 1); - image = XCreateImage(xfi->display, xfi->visual, 1, + image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); - XPutImage(xfi->display, xf_glyph->pixmap, xfi->gc_mono, image, 0, 0, 0, 0, glyph->cx, glyph->cy); + XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0, glyph->cx, glyph->cy); XFree(image); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); if (((xfGlyph*) glyph)->pixmap != 0) - XFreePixmap(xfi->display, ((xfGlyph*) glyph)->pixmap); + XFreePixmap(xfc->display, ((xfGlyph*) glyph)->pixmap); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) { xfGlyph* xf_glyph; - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; xf_glyph = (xfGlyph*) glyph; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - XSetStipple(xfi->display, xfi->gc, xf_glyph->pixmap); - XSetTSOrigin(xfi->display, xfi->gc, x, y); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, glyph->cx, glyph->cy); - XSetStipple(xfi->display, xfi->gc, xfi->bitmap_mono); + XSetStipple(xfc->display, xfc->gc, xf_glyph->pixmap); + XSetTSOrigin(xfc->display, xfc->gc, x, y); + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, glyph->cx, glyph->cy); + XSetStipple(xfc->display, xfc->gc, xfc->bitmap_mono); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor) { xfContext* context_ = (xfContext*) context; - xfInfo* xfi = context_->xfi; + xfContext* xfc = (xfContext*) context; - bgcolor = (xfi->clrconv->invert)? - freerdp_color_convert_var_bgr(bgcolor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv): - freerdp_color_convert_var_rgb(bgcolor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + bgcolor = (xfc->clrconv->invert)? + freerdp_color_convert_var_bgr(bgcolor, context_->settings->ColorDepth, xfc->bpp, xfc->clrconv): + freerdp_color_convert_var_rgb(bgcolor, context_->settings->ColorDepth, xfc->bpp, xfc->clrconv); - fgcolor = (xfi->clrconv->invert)? - freerdp_color_convert_var_bgr(fgcolor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv): - freerdp_color_convert_var_rgb(fgcolor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); + fgcolor = (xfc->clrconv->invert)? + freerdp_color_convert_var_bgr(fgcolor, context_->settings->ColorDepth, xfc->bpp, xfc->clrconv): + freerdp_color_convert_var_rgb(fgcolor, context_->settings->ColorDepth, xfc->bpp, xfc->clrconv); - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, fgcolor); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, width, height); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, fgcolor); + XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, width, height); - XSetForeground(xfi->display, xfi->gc, bgcolor); - XSetBackground(xfi->display, xfi->gc, fgcolor); - XSetFillStyle(xfi->display, xfi->gc, FillStippled); + XSetForeground(xfc->display, xfc->gc, bgcolor); + XSetBackground(xfc->display, xfc->gc, fgcolor); + XSetFillStyle(xfc->display, xfc->gc, FillStippled); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } void xf_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor) { - xfInfo* xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - if (xfi->drawing == xfi->primary) + if (xfc->drawing == xfc->primary) { - gdi_InvalidateRegion(xfi->hdc, x, y, width, height); + gdi_InvalidateRegion(xfc->hdc, x, y, width, height); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } /* Graphics Module */ diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index a0d7e5a04..c61defc8b 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -54,7 +54,7 @@ double z_vector; int xinput_opcode; int scale_cnt; -int xf_input_init(xfInfo* xfi, Window window) +int xf_input_init(xfContext* xfc, Window window) { int i, j; int nmasks; @@ -72,15 +72,15 @@ int xf_input_init(xfInfo* xfi, Window window) active_contacts = 0; ZeroMemory(contacts, sizeof(touchContact) * MAX_CONTACTS); - if (!XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error)) + if (!XQueryExtension(xfc->display, "XInputExtension", &opcode, &event, &error)) { printf("XInput extension not available.\n"); return -1; } - xfi->XInputOpcode = opcode; + xfc->XInputOpcode = opcode; - XIQueryVersion(xfi->display, &major, &minor); + XIQueryVersion(xfc->display, &major, &minor); if (major * 1000 + minor < 2002) { @@ -88,7 +88,7 @@ int xf_input_init(xfInfo* xfi, Window window) return -1; } - info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices); + info = XIQueryDevice(xfc->display, XIAllDevices, &ndevices); for (i = 0; i < ndevices; i++) { @@ -125,7 +125,7 @@ int xf_input_init(xfInfo* xfi, Window window) } if (nmasks > 0) - xstatus = XISelectEvents(xfi->display, window, evmasks, nmasks); + xstatus = XISelectEvents(xfc->display, window, evmasks, nmasks); return 0; } @@ -151,7 +151,7 @@ void xf_input_save_last_event(XIDeviceEvent* event) lastEvent.event_y = event->event_y; } -void xf_input_detect_pinch(xfInfo* xfi) +void xf_input_detect_pinch(xfContext* xfc) { double dist; double zoom; @@ -189,33 +189,33 @@ void xf_input_detect_pinch(xfInfo* xfi) if (z_vector > 10) { - xfi->scale -= 0.05; + xfc->scale -= 0.05; - if (xfi->scale < 0.5) - xfi->scale = 0.5; + if (xfc->scale < 0.5) + xfc->scale = 0.5; - XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); - IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); z_vector = 0; } if (z_vector < -10) { - xfi->scale += 0.05; + xfc->scale += 0.05; - if (xfi->scale > 1.5) - xfi->scale = 1.5; + if (xfc->scale > 1.5) + xfc->scale = 1.5; - XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); - IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); z_vector = 0; } } } -void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event) +void xf_input_touch_begin(xfContext* xfc, XIDeviceEvent* event) { int i; @@ -234,7 +234,7 @@ void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event) } } -void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event) +void xf_input_touch_update(xfContext* xfc, XIDeviceEvent* event) { int i; @@ -248,14 +248,14 @@ void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event) contacts[i].pos_x = event->event_x; contacts[i].pos_y = event->event_y; - xf_input_detect_pinch(xfi); + xf_input_detect_pinch(xfc); break; } } } -void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) +void xf_input_touch_end(xfContext* xfc, XIDeviceEvent* event) { int i; @@ -274,31 +274,31 @@ void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) } } -int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) +int xf_input_handle_event_local(xfContext* xfc, XEvent* event) { XGenericEventCookie* cookie = &event->xcookie; - XGetEventData(xfi->display, cookie); + XGetEventData(xfc->display, cookie); - if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) + if ((cookie->type == GenericEvent) && (cookie->extension == xfc->XInputOpcode)) { switch (cookie->evtype) { case XI_TouchBegin: if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_begin(xfi, cookie->data); + xf_input_touch_begin(xfc, cookie->data); xf_input_save_last_event(cookie->data); break; case XI_TouchUpdate: if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_update(xfi, cookie->data); + xf_input_touch_update(xfc, cookie->data); xf_input_save_last_event(cookie->data); break; case XI_TouchEnd: if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_end(xfi, cookie->data); + xf_input_touch_end(xfc, cookie->data); xf_input_save_last_event(cookie->data); break; @@ -308,7 +308,7 @@ int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) } } - XFreeEventData(xfi->display,cookie); + XFreeEventData(xfc->display,cookie); return 0; } @@ -325,12 +325,12 @@ char* xf_input_touch_state_string(DWORD flags) return "TouchUnknown"; } -int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, int evtype) +int xf_input_touch_remote(xfContext* xfc, XIDeviceEvent* event, int evtype) { int x, y; int touchId; int contactId; - RdpeiClientContext* rdpei = xfi->rdpei; + RdpeiClientContext* rdpei = xfc->rdpei; if (!rdpei) return 0; @@ -358,26 +358,26 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, int evtype) return 0; } -int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) +int xf_input_handle_event_remote(xfContext* xfc, XEvent* event) { XGenericEventCookie* cookie = &event->xcookie; - XGetEventData(xfi->display, cookie); + XGetEventData(xfc->display, cookie); - if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) + if ((cookie->type == GenericEvent) && (cookie->extension == xfc->XInputOpcode)) { switch (cookie->evtype) { case XI_TouchBegin: - xf_input_touch_remote(xfi, cookie->data, XI_TouchBegin); + xf_input_touch_remote(xfc, cookie->data, XI_TouchBegin); break; case XI_TouchUpdate: - xf_input_touch_remote(xfi, cookie->data, XI_TouchUpdate); + xf_input_touch_remote(xfc, cookie->data, XI_TouchUpdate); break; case XI_TouchEnd: - xf_input_touch_remote(xfi, cookie->data, XI_TouchEnd); + xf_input_touch_remote(xfc, cookie->data, XI_TouchEnd); break; default: @@ -385,21 +385,21 @@ int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) } } - XFreeEventData(xfi->display,cookie); + XFreeEventData(xfc->display,cookie); return 0; } #else -int xf_input_init(xfInfo* xfi, Window window) +int xf_input_init(xfContext* xfc, Window window) { return 0; } #endif -void xf_process_rdpei_event(xfInfo* xfi, wMessage* event) +void xf_process_rdpei_event(xfContext* xfc, wMessage* event) { switch (GetMessageType(event->id)) { @@ -414,16 +414,16 @@ void xf_process_rdpei_event(xfInfo* xfi, wMessage* event) } } -int xf_input_handle_event(xfInfo* xfi, XEvent* event) +int xf_input_handle_event(xfContext* xfc, XEvent* event) { #ifdef WITH_XI - if (xfi->settings->MultiTouchInput) + if (xfc->settings->MultiTouchInput) { - return xf_input_handle_event_remote(xfi, event); + return xf_input_handle_event_remote(xfc, event); } - if (xfi->enableScaling) - return xf_input_handle_event_local(xfi, event); + if (xfc->enableScaling) + return xf_input_handle_event_local(xfc, event); #endif return 0; diff --git a/client/X11/xf_input.h b/client/X11/xf_input.h index 9803193bd..26498505b 100644 --- a/client/X11/xf_input.h +++ b/client/X11/xf_input.h @@ -27,9 +27,9 @@ #include #endif -int xf_input_init(xfInfo* xfi, Window window); +int xf_input_init(xfContext* xfc, Window window); -int xf_input_handle_event(xfInfo* xfi, XEvent* event); -void xf_process_rdpei_event(xfInfo* xfi, wMessage* event); +int xf_input_handle_event(xfContext* xfc, XEvent* event); +void xf_process_rdpei_event(xfContext* xfc, wMessage* event); #endif diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 5741e1a0e..5465eff69 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -90,7 +90,7 @@ static long xv_port = 0; static const size_t password_size = 512; -void xf_draw_screen_scaled(xfInfo* xfi) +void xf_draw_screen_scaled(xfContext* xfc) { #ifdef WITH_XRENDER XTransform transform; @@ -99,10 +99,10 @@ void xf_draw_screen_scaled(xfInfo* xfi) XRenderPictureAttributes pa; XRenderPictFormat* picFormat; - picFormat = XRenderFindStandardFormat(xfi->display, PictStandardRGB24); + picFormat = XRenderFindStandardFormat(xfc->display, PictStandardRGB24); pa.subwindow_mode = IncludeInferiors; - primaryPicture = XRenderCreatePicture(xfi->display, xfi->primary, picFormat, CPSubwindowMode, &pa); - windowPicture = XRenderCreatePicture(xfi->display, xfi->window->handle, picFormat, CPSubwindowMode, &pa); + primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat, CPSubwindowMode, &pa); + windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle, picFormat, CPSubwindowMode, &pa); transform.matrix[0][0] = XDoubleToFixed(1); transform.matrix[0][1] = XDoubleToFixed(0); @@ -114,10 +114,10 @@ void xf_draw_screen_scaled(xfInfo* xfi) transform.matrix[2][0] = XDoubleToFixed(0); transform.matrix[2][1] = XDoubleToFixed(0); - transform.matrix[2][2] = XDoubleToFixed(xfi->scale); + transform.matrix[2][2] = XDoubleToFixed(xfc->scale); - XRenderSetPictureTransform(xfi->display, primaryPicture, &transform); - XRenderComposite(xfi->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, 0, 0, xfi->currentWidth, xfi->currentHeight); + XRenderSetPictureTransform(xfc->display, primaryPicture, &transform); + XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, 0, 0, xfc->currentWidth, xfc->currentHeight); #endif } @@ -141,16 +141,15 @@ void xf_sw_begin_paint(rdpContext* context) void xf_sw_end_paint(rdpContext* context) { rdpGdi* gdi; - xfInfo* xfi; INT32 x, y; UINT32 w, h; + xfContext* xfc = (xfContext*) context; - xfi = ((xfContext*) context)->xfi; gdi = context->gdi; - if (!xfi->remote_app) + if (!xfc->remote_app) { - if (!xfi->complex_regions) + if (!xfc->complex_regions) { if (gdi->primary->hdc->hwnd->invalid->null) return; @@ -160,20 +159,20 @@ void xf_sw_end_paint(rdpContext* context) w = gdi->primary->hdc->hwnd->invalid->w; h = gdi->primary->hdc->hwnd->invalid->h; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - XPutImage(xfi->display, xfi->primary, xfi->gc, xfi->image, x, y, x, y, w, h); + XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h); - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } else { - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y, w, h, x, y); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } else { @@ -187,7 +186,7 @@ void xf_sw_end_paint(rdpContext* context) ninvalid = gdi->primary->hdc->hwnd->ninvalid; cinvalid = gdi->primary->hdc->hwnd->cinvalid; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); for (i = 0; i < ninvalid; i++) { @@ -196,21 +195,21 @@ void xf_sw_end_paint(rdpContext* context) w = cinvalid[i].w; h = cinvalid[i].h; - XPutImage(xfi->display, xfi->primary, xfi->gc, xfi->image, x, y, x, y, w, h); + XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h); - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } else { - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y, w, h, x, y); } } - XFlush(xfi->display); + XFlush(xfc->display); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } } else @@ -223,82 +222,78 @@ void xf_sw_end_paint(rdpContext* context) w = gdi->primary->hdc->hwnd->invalid->w; h = gdi->primary->hdc->hwnd->invalid->h; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_rail_paint(xfi, context->rail, x, y, x + w - 1, y + h - 1); + xf_rail_paint(xfc, context->rail, x, y, x + w - 1, y + h - 1); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } } void xf_sw_desktop_resize(rdpContext* context) { - xfInfo* xfi; rdpSettings* settings; + xfContext* xfc = (xfContext*) context; - xfi = ((xfContext*) context)->xfi; - settings = xfi->instance->settings; + settings = xfc->instance->settings; - xf_lock_x11(xfi, TRUE); + xf_lock_x11(xfc, TRUE); - if (!xfi->fullscreen) + if (!xfc->fullscreen) { rdpGdi* gdi = context->gdi; - gdi_resize(gdi, xfi->width, xfi->height); + gdi_resize(gdi, xfc->width, xfc->height); - if (xfi->image) + if (xfc->image) { - xfi->image->data = NULL; - XDestroyImage(xfi->image); - xfi->image = XCreateImage(xfi->display, xfi->visual, xfi->depth, ZPixmap, 0, - (char*) gdi->primary_buffer, gdi->width, gdi->height, xfi->scanline_pad, 0); + xfc->image->data = NULL; + XDestroyImage(xfc->image); + xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, + (char*) gdi->primary_buffer, gdi->width, gdi->height, xfc->scanline_pad, 0); } } - xf_unlock_x11(xfi, TRUE); + xf_unlock_x11(xfc, TRUE); } void xf_hw_begin_paint(rdpContext* context) { - xfInfo* xfi; - xfi = ((xfContext*) context)->xfi; + xfContext* xfc = (xfContext*) context; - xfi->hdc->hwnd->invalid->null = 1; - xfi->hdc->hwnd->ninvalid = 0; + xfc->hdc->hwnd->invalid->null = 1; + xfc->hdc->hwnd->ninvalid = 0; } void xf_hw_end_paint(rdpContext* context) { - xfInfo* xfi; INT32 x, y; UINT32 w, h; + xfContext* xfc = (xfContext*) context; - xfi = ((xfContext*) context)->xfi; - - if (!xfi->remote_app) + if (!xfc->remote_app) { - if (!xfi->complex_regions) + if (!xfc->complex_regions) { - if (xfi->hdc->hwnd->invalid->null) + if (xfc->hdc->hwnd->invalid->null) return; - x = xfi->hdc->hwnd->invalid->x; - y = xfi->hdc->hwnd->invalid->y; - w = xfi->hdc->hwnd->invalid->w; - h = xfi->hdc->hwnd->invalid->h; + x = xfc->hdc->hwnd->invalid->x; + y = xfc->hdc->hwnd->invalid->y; + w = xfc->hdc->hwnd->invalid->w; + h = xfc->hdc->hwnd->invalid->h; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } else { - XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + XCopyArea(xfc->display, xfc->primary, xfc->drawable, xfc->gc, x, y, w, h, x, y); } - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } else { @@ -306,13 +301,13 @@ void xf_hw_end_paint(rdpContext* context) int ninvalid; HGDI_RGN cinvalid; - if (xfi->hdc->hwnd->ninvalid < 1) + if (xfc->hdc->hwnd->ninvalid < 1) return; - ninvalid = xfi->hdc->hwnd->ninvalid; - cinvalid = xfi->hdc->hwnd->cinvalid; + ninvalid = xfc->hdc->hwnd->ninvalid; + cinvalid = xfc->hdc->hwnd->cinvalid; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); for (i = 0; i < ninvalid; i++) { @@ -321,87 +316,86 @@ void xf_hw_end_paint(rdpContext* context) w = cinvalid[i].w; h = cinvalid[i].h; - if (xfi->scale != 1.0) + if (xfc->scale != 1.0) { - xf_draw_screen_scaled(xfi); + xf_draw_screen_scaled(xfc); } else { - XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + XCopyArea(xfc->display, xfc->primary, xfc->drawable, xfc->gc, x, y, w, h, x, y); } } - XFlush(xfi->display); + XFlush(xfc->display); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } } else { - if (xfi->hdc->hwnd->invalid->null) + if (xfc->hdc->hwnd->invalid->null) return; - x = xfi->hdc->hwnd->invalid->x; - y = xfi->hdc->hwnd->invalid->y; - w = xfi->hdc->hwnd->invalid->w; - h = xfi->hdc->hwnd->invalid->h; + x = xfc->hdc->hwnd->invalid->x; + y = xfc->hdc->hwnd->invalid->y; + w = xfc->hdc->hwnd->invalid->w; + h = xfc->hdc->hwnd->invalid->h; - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - xf_rail_paint(xfi, context->rail, x, y, x + w - 1, y + h - 1); + xf_rail_paint(xfc, context->rail, x, y, x + w - 1, y + h - 1); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); } } void xf_hw_desktop_resize(rdpContext* context) { - xfInfo* xfi; BOOL same; rdpSettings* settings; + xfContext* xfc = (xfContext*) context; - xfi = ((xfContext*) context)->xfi; - settings = xfi->instance->settings; + settings = xfc->instance->settings; - xf_lock_x11(xfi, TRUE); + xf_lock_x11(xfc, TRUE); - if (!xfi->fullscreen) + if (!xfc->fullscreen) { - xfi->width = settings->DesktopWidth; - xfi->height = settings->DesktopHeight; + xfc->width = settings->DesktopWidth; + xfc->height = settings->DesktopHeight; - if (xfi->window) - xf_ResizeDesktopWindow(xfi, xfi->window, settings->DesktopWidth, settings->DesktopHeight); + if (xfc->window) + xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth, settings->DesktopHeight); - if (xfi->primary) + if (xfc->primary) { - same = (xfi->primary == xfi->drawing) ? TRUE : FALSE; + same = (xfc->primary == xfc->drawing) ? TRUE : FALSE; - XFreePixmap(xfi->display, xfi->primary); + XFreePixmap(xfc->display, xfc->primary); - xfi->primary = XCreatePixmap(xfi->display, xfi->drawable, - xfi->width, xfi->height, xfi->depth); + xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, + xfc->width, xfc->height, xfc->depth); if (same) - xfi->drawing = xfi->primary; + xfc->drawing = xfc->primary; } } else { - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, 0); - XFillRectangle(xfi->display, xfi->drawable, xfi->gc, 0, 0, xfi->width, xfi->height); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, 0); + XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, xfc->width, xfc->height); } - xf_unlock_x11(xfi, TRUE); + xf_unlock_x11(xfc, TRUE); } BOOL xf_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount) { - xfInfo* xfi = ((xfContext*) instance->context)->xfi; + xfContext* xfc = (xfContext*) instance->context; - rfds[*rcount] = (void*)(long)(xfi->xfds); + rfds[*rcount] = (void*)(long)(xfc->xfds); (*rcount)++; return TRUE; @@ -412,24 +406,24 @@ BOOL xf_process_x_events(freerdp* instance) BOOL status; XEvent xevent; int pending_status; - xfInfo* xfi = ((xfContext*) instance->context)->xfi; + xfContext* xfc = (xfContext*) instance->context; status = TRUE; pending_status = TRUE; while (pending_status) { - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - pending_status = XPending(xfi->display); + pending_status = XPending(xfc->display); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); if (pending_status) { ZeroMemory(&xevent, sizeof(xevent)); - XNextEvent(xfi->display, &xevent); + XNextEvent(xfc->display, &xevent); status = xf_event_process(instance, &xevent); if (!status) @@ -440,7 +434,7 @@ BOOL xf_process_x_events(freerdp* instance) return status; } -void xf_create_window(xfInfo* xfi) +void xf_create_window(xfContext* xfc) { XEvent xevent; int width, height; @@ -448,100 +442,100 @@ void xf_create_window(xfInfo* xfi) ZeroMemory(&xevent, sizeof(xevent)); - width = xfi->width; - height = xfi->height; + width = xfc->width; + height = xfc->height; - if (!xfi->remote_app) + if (!xfc->remote_app) { - xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen); - xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen); - xfi->attribs.backing_store = xfi->primary ? NotUseful : Always; - xfi->attribs.override_redirect = xfi->grab_keyboard ? xfi->fullscreen : False; - xfi->attribs.colormap = xfi->colormap; - xfi->attribs.bit_gravity = NorthWestGravity; - xfi->attribs.win_gravity = NorthWestGravity; + xfc->attribs.background_pixel = BlackPixelOfScreen(xfc->screen); + xfc->attribs.border_pixel = WhitePixelOfScreen(xfc->screen); + xfc->attribs.backing_store = xfc->primary ? NotUseful : Always; + xfc->attribs.override_redirect = xfc->grab_keyboard ? xfc->fullscreen : False; + xfc->attribs.colormap = xfc->colormap; + xfc->attribs.bit_gravity = NorthWestGravity; + xfc->attribs.win_gravity = NorthWestGravity; - if (xfi->instance->settings->WindowTitle) + if (xfc->instance->settings->WindowTitle) { - windowTitle = _strdup(xfi->instance->settings->WindowTitle); + windowTitle = _strdup(xfc->instance->settings->WindowTitle); } - else if (xfi->instance->settings->ServerPort == 3389) + else if (xfc->instance->settings->ServerPort == 3389) { - windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->ServerHostname)); - sprintf(windowTitle, "FreeRDP: %s", xfi->instance->settings->ServerHostname); + windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname)); + sprintf(windowTitle, "FreeRDP: %s", xfc->instance->settings->ServerHostname); } else { - windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->ServerHostname) + sizeof(":00000")); - sprintf(windowTitle, "FreeRDP: %s:%i", xfi->instance->settings->ServerHostname, xfi->instance->settings->ServerPort); + windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname) + sizeof(":00000")); + sprintf(windowTitle, "FreeRDP: %s:%i", xfc->instance->settings->ServerHostname, xfc->instance->settings->ServerPort); } - xfi->window = xf_CreateDesktopWindow(xfi, windowTitle, width, height, xfi->settings->Decorations); + xfc->window = xf_CreateDesktopWindow(xfc, windowTitle, width, height, xfc->settings->Decorations); free(windowTitle); - if (xfi->fullscreen) - xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen); + if (xfc->fullscreen) + xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen); - xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured); + xfc->unobscured = (xevent.xvisibility.state == VisibilityUnobscured); - XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1); - xfi->drawable = xfi->window->handle; + XSetWMProtocols(xfc->display, xfc->window->handle, &(xfc->WM_DELETE_WINDOW), 1); + xfc->drawable = xfc->window->handle; } else { - xfi->drawable = DefaultRootWindow(xfi->display); + xfc->drawable = DefaultRootWindow(xfc->display); } } -void xf_toggle_fullscreen(xfInfo* xfi) +void xf_toggle_fullscreen(xfContext* xfc) { Pixmap contents = 0; - xf_lock_x11(xfi, TRUE); + xf_lock_x11(xfc, TRUE); - contents = XCreatePixmap(xfi->display, xfi->window->handle, xfi->width, xfi->height, xfi->depth); - XCopyArea(xfi->display, xfi->primary, contents, xfi->gc, 0, 0, xfi->width, xfi->height, 0, 0); + contents = XCreatePixmap(xfc->display, xfc->window->handle, xfc->width, xfc->height, xfc->depth); + XCopyArea(xfc->display, xfc->primary, contents, xfc->gc, 0, 0, xfc->width, xfc->height, 0, 0); - XDestroyWindow(xfi->display, xfi->window->handle); - xfi->fullscreen = (xfi->fullscreen) ? FALSE : TRUE; - xf_create_window(xfi); + XDestroyWindow(xfc->display, xfc->window->handle); + xfc->fullscreen = (xfc->fullscreen) ? FALSE : TRUE; + xf_create_window(xfc); - XCopyArea(xfi->display, contents, xfi->primary, xfi->gc, 0, 0, xfi->width, xfi->height, 0, 0); - XFreePixmap(xfi->display, contents); + XCopyArea(xfc->display, contents, xfc->primary, xfc->gc, 0, 0, xfc->width, xfc->height, 0, 0); + XFreePixmap(xfc->display, contents); - xf_unlock_x11(xfi, TRUE); + xf_unlock_x11(xfc, TRUE); - IFCALL(xfi->client->OnWindowStateChange, xfi->instance, - xfi->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0); + IFCALL(xfc->client->OnWindowStateChange, xfc->instance, + xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0); } -void xf_lock_x11(xfInfo* xfi, BOOL display) +void xf_lock_x11(xfContext* xfc, BOOL display) { - if (!xfi->UseXThreads) + if (!xfc->UseXThreads) { - WaitForSingleObject(xfi->mutex, INFINITE); + WaitForSingleObject(xfc->mutex, INFINITE); } else { if (display) - XLockDisplay(xfi->display); + XLockDisplay(xfc->display); } } -void xf_unlock_x11(xfInfo* xfi, BOOL display) +void xf_unlock_x11(xfContext* xfc, BOOL display) { - if (!xfi->UseXThreads) + if (!xfc->UseXThreads) { - ReleaseMutex(xfi->mutex); + ReleaseMutex(xfc->mutex); } else { if (display) - XUnlockDisplay(xfi->display); + XUnlockDisplay(xfc->display); } } -BOOL xf_get_pixmap_info(xfInfo* xfi) +BOOL xf_get_pixmap_info(xfContext* xfc) { int i; int vi_count; @@ -553,7 +547,7 @@ BOOL xf_get_pixmap_info(xfInfo* xfi) XPixmapFormatValues* pfs; XWindowAttributes window_attributes; - pfs = XListPixmapFormats(xfi->display, &pf_count); + pfs = XListPixmapFormats(xfc->display, &pf_count); if (pfs == NULL) { @@ -565,10 +559,10 @@ BOOL xf_get_pixmap_info(xfInfo* xfi) { pf = pfs + i; - if (pf->depth == xfi->depth) + if (pf->depth == xfc->depth) { - xfi->bpp = pf->bits_per_pixel; - xfi->scanline_pad = pf->scanline_pad; + xfc->bpp = pf->bits_per_pixel; + xfc->scanline_pad = pf->scanline_pad; break; } } @@ -576,15 +570,15 @@ BOOL xf_get_pixmap_info(xfInfo* xfi) ZeroMemory(&template, sizeof(template)); template.class = TrueColor; - template.screen = xfi->screen_number; + template.screen = xfc->screen_number; - if (XGetWindowAttributes(xfi->display, RootWindowOfScreen(xfi->screen), &window_attributes) == 0) + if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), &window_attributes) == 0) { fprintf(stderr, "xf_get_pixmap_info: XGetWindowAttributes failed\n"); return FALSE; } - vis = XGetVisualInfo(xfi->display, VisualClassMask | VisualScreenMask, &template, &vi_count); + vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask, &template, &vi_count); if (vis == NULL) { @@ -599,7 +593,7 @@ BOOL xf_get_pixmap_info(xfInfo* xfi) if (vi->visual == window_attributes.visual) { - xfi->visual = vi->visual; + xfc->visual = vi->visual; break; } } @@ -613,13 +607,13 @@ BOOL xf_get_pixmap_info(xfInfo* xfi) if (vi->red_mask & 0xFF) { - xfi->clrconv->invert = TRUE; + xfc->clrconv->invert = TRUE; } } XFree(vis); - if ((xfi->visual == NULL) || (xfi->scanline_pad == 0)) + if ((xfc->visual == NULL) || (xfc->scanline_pad == 0)) { return FALSE; } @@ -668,18 +662,15 @@ int _xf_error_handler(Display* d, XErrorEvent* ev) */ BOOL xf_pre_connect(freerdp* instance) { - xfInfo* xfi; rdpChannels* channels; rdpSettings* settings; + xfContext* xfc = (xfContext*) instance->context; - xfi = ((xfContext*) instance->context)->xfi; + xfc->mutex = CreateMutex(NULL, FALSE, NULL); - xfi->mutex = CreateMutex(NULL, FALSE, NULL); + xfc->settings = instance->settings; + xfc->instance = instance; - xfi->_context = instance->context; - xfi->context = (xfContext*) instance->context; - xfi->context->settings = instance->settings; - xfi->instance = instance; settings = instance->settings; channels = instance->context->channels; @@ -711,73 +702,73 @@ BOOL xf_pre_connect(freerdp* instance) return TRUE; } - xfi->UseXThreads = TRUE; + xfc->UseXThreads = TRUE; - if (xfi->UseXThreads) + if (xfc->UseXThreads) { if (!XInitThreads()) { fprintf(stderr, "warning: XInitThreads() failure\n"); - xfi->UseXThreads = FALSE; + xfc->UseXThreads = FALSE; } } - xfi->display = XOpenDisplay(NULL); + xfc->display = XOpenDisplay(NULL); - if (!xfi->display) + if (!xfc->display) { fprintf(stderr, "xf_pre_connect: failed to open display: %s\n", XDisplayName(NULL)); fprintf(stderr, "Please check that the $DISPLAY environment variable is properly set.\n"); return FALSE; } - if (xfi->debug) + if (xfc->debug) { fprintf(stderr, "Enabling X11 debug mode.\n"); - XSynchronize(xfi->display, TRUE); + XSynchronize(xfc->display, TRUE); _def_error_handler = XSetErrorHandler(_xf_error_handler); } - xfi->_NET_WM_ICON = XInternAtom(xfi->display, "_NET_WM_ICON", False); - xfi->_MOTIF_WM_HINTS = XInternAtom(xfi->display, "_MOTIF_WM_HINTS", False); - xfi->_NET_CURRENT_DESKTOP = XInternAtom(xfi->display, "_NET_CURRENT_DESKTOP", False); - xfi->_NET_WORKAREA = XInternAtom(xfi->display, "_NET_WORKAREA", False); - xfi->_NET_WM_STATE = XInternAtom(xfi->display, "_NET_WM_STATE", False); - xfi->_NET_WM_STATE_FULLSCREEN = XInternAtom(xfi->display, "_NET_WM_STATE_FULLSCREEN", False); - xfi->_NET_WM_WINDOW_TYPE = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE", False); + xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False); + xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False); + xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP", False); + xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False); + xfc->_NET_WM_STATE = XInternAtom(xfc->display, "_NET_WM_STATE", False); + xfc->_NET_WM_STATE_FULLSCREEN = XInternAtom(xfc->display, "_NET_WM_STATE_FULLSCREEN", False); + xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE", False); - xfi->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE_NORMAL", False); - xfi->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE_DIALOG", False); - xfi->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE_POPUP", False); - xfi->_NET_WM_WINDOW_TYPE_UTILITY = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE_UTILITY", False); - xfi->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = XInternAtom(xfi->display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); - xfi->_NET_WM_STATE_SKIP_TASKBAR = XInternAtom(xfi->display, "_NET_WM_STATE_SKIP_TASKBAR", False); - xfi->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfi->display, "_NET_WM_STATE_SKIP_PAGER", False); - xfi->_NET_WM_MOVERESIZE = XInternAtom(xfi->display, "_NET_WM_MOVERESIZE", False); - xfi->_NET_MOVERESIZE_WINDOW = XInternAtom(xfi->display, "_NET_MOVERESIZE_WINDOW", False); + xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_POPUP", False); + xfc->_NET_WM_WINDOW_TYPE_UTILITY = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_UTILITY", False); + xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); + xfc->_NET_WM_STATE_SKIP_TASKBAR = XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_TASKBAR", False); + xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_PAGER", False); + xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE", False); + xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display, "_NET_MOVERESIZE_WINDOW", False); - xfi->WM_PROTOCOLS = XInternAtom(xfi->display, "WM_PROTOCOLS", False); - xfi->WM_DELETE_WINDOW = XInternAtom(xfi->display, "WM_DELETE_WINDOW", False); - xfi->WM_STATE = XInternAtom(xfi->display, "WM_STATE", False); + xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False); + xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False); + xfc->WM_STATE = XInternAtom(xfc->display, "WM_STATE", False); - xf_kbd_init(xfi); + xf_kbd_init(xfc); - xfi->clrconv = freerdp_clrconv_new(CLRCONV_ALPHA); + xfc->clrconv = freerdp_clrconv_new(CLRCONV_ALPHA); instance->context->cache = cache_new(instance->settings); - xfi->xfds = ConnectionNumber(xfi->display); - xfi->screen_number = DefaultScreen(xfi->display); - xfi->screen = ScreenOfDisplay(xfi->display, xfi->screen_number); - xfi->depth = DefaultDepthOfScreen(xfi->screen); - xfi->big_endian = (ImageByteOrder(xfi->display) == MSBFirst); + xfc->xfds = ConnectionNumber(xfc->display); + xfc->screen_number = DefaultScreen(xfc->display); + xfc->screen = ScreenOfDisplay(xfc->display, xfc->screen_number); + xfc->depth = DefaultDepthOfScreen(xfc->screen); + xfc->big_endian = (ImageByteOrder(xfc->display) == MSBFirst); - xfi->complex_regions = TRUE; - xfi->fullscreen = settings->Fullscreen; - xfi->grab_keyboard = settings->GrabKeyboard; - xfi->fullscreen_toggle = settings->ToggleFullscreen; + xfc->complex_regions = TRUE; + xfc->fullscreen = settings->Fullscreen; + xfc->grab_keyboard = settings->GrabKeyboard; + xfc->fullscreen_toggle = settings->ToggleFullscreen; - xf_detect_monitors(xfi, settings); + xf_detect_monitors(xfc, settings); return TRUE; } @@ -789,98 +780,97 @@ BOOL xf_pre_connect(freerdp* instance) */ BOOL xf_post_connect(freerdp* instance) { - xfInfo* xfi; XGCValues gcv; rdpCache* cache; rdpChannels* channels; rdpSettings* settings; RFX_CONTEXT* rfx_context = NULL; NSC_CONTEXT* nsc_context = NULL; + xfContext* xfc = (xfContext*) instance->context; - xfi = ((xfContext*) instance->context)->xfi; cache = instance->context->cache; - channels = xfi->_context->channels; + channels = instance->context->channels; settings = instance->settings; - if (!xf_get_pixmap_info(xfi)) + if (!xf_get_pixmap_info(xfc)) return FALSE; xf_register_graphics(instance->context->graphics); - if (xfi->settings->SoftwareGdi) + if (xfc->settings->SoftwareGdi) { rdpGdi* gdi; UINT32 flags; flags = CLRCONV_ALPHA; - if (xfi->bpp > 16) + if (xfc->bpp > 16) flags |= CLRBUF_32BPP; else flags |= CLRBUF_16BPP; gdi_init(instance, flags, NULL); gdi = instance->context->gdi; - xfi->primary_buffer = gdi->primary_buffer; + xfc->primary_buffer = gdi->primary_buffer; rfx_context = gdi->rfx_context; } else { - xfi->srcBpp = instance->settings->ColorDepth; + xfc->srcBpp = instance->settings->ColorDepth; xf_gdi_register_update_callbacks(instance->update); - xfi->hdc = gdi_CreateDC(xfi->clrconv, xfi->bpp); + xfc->hdc = gdi_CreateDC(xfc->clrconv, xfc->bpp); if (instance->settings->RemoteFxCodec) { rfx_context = (void*) rfx_context_new(); - xfi->rfx_context = rfx_context; + xfc->rfx_context = rfx_context; } if (instance->settings->NSCodec) { nsc_context = (void*) nsc_context_new(); - xfi->nsc_context = nsc_context; + xfc->nsc_context = nsc_context; } } - xfi->originalWidth = settings->DesktopWidth; - xfi->originalHeight = settings->DesktopHeight; - xfi->currentWidth = xfi->originalWidth; - xfi->currentHeight = xfi->originalWidth; - xfi->scale = 1.0; + xfc->originalWidth = settings->DesktopWidth; + xfc->originalHeight = settings->DesktopHeight; + xfc->currentWidth = xfc->originalWidth; + xfc->currentHeight = xfc->originalWidth; + xfc->scale = 1.0; - xfi->width = settings->DesktopWidth; - xfi->height = settings->DesktopHeight; + xfc->width = settings->DesktopWidth; + xfc->height = settings->DesktopHeight; if (settings->RemoteApplicationMode) - xfi->remote_app = TRUE; + xfc->remote_app = TRUE; - xf_create_window(xfi); + xf_create_window(xfc); ZeroMemory(&gcv, sizeof(gcv)); - xfi->modifier_map = XGetModifierMapping(xfi->display); + xfc->modifier_map = XGetModifierMapping(xfc->display); - xfi->gc = XCreateGC(xfi->display, xfi->drawable, GCGraphicsExposures, &gcv); - xfi->primary = XCreatePixmap(xfi->display, xfi->drawable, xfi->width, xfi->height, xfi->depth); - xfi->drawing = xfi->primary; + xfc->gc = XCreateGC(xfc->display, xfc->drawable, GCGraphicsExposures, &gcv); + xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, xfc->width, xfc->height, xfc->depth); + xfc->drawing = xfc->primary; - xfi->bitmap_mono = XCreatePixmap(xfi->display, xfi->drawable, 8, 8, 1); - xfi->gc_mono = XCreateGC(xfi->display, xfi->bitmap_mono, GCGraphicsExposures, &gcv); + xfc->bitmap_mono = XCreatePixmap(xfc->display, xfc->drawable, 8, 8, 1); + xfc->gc_mono = XCreateGC(xfc->display, xfc->bitmap_mono, GCGraphicsExposures, &gcv); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, BlackPixelOfScreen(xfi->screen)); - XFillRectangle(xfi->display, xfi->primary, xfi->gc, 0, 0, xfi->width, xfi->height); - XFlush(xfi->display); + 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->width, xfc->height); + XFlush(xfc->display); - xfi->image = XCreateImage(xfi->display, xfi->visual, xfi->depth, ZPixmap, 0, - (char*) xfi->primary_buffer, xfi->width, xfi->height, xfi->scanline_pad, 0); + xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, + (char*) xfc->primary_buffer, xfc->width, xfc->height, xfc->scanline_pad, 0); - xfi->bmp_codec_none = (BYTE*) malloc(64 * 64 * 4); + xfc->bmp_codec_none = (BYTE*) malloc(64 * 64 * 4); - if (xfi->settings->SoftwareGdi) + if (xfc->settings->SoftwareGdi) { instance->update->BeginPaint = xf_sw_begin_paint; instance->update->EndPaint = xf_sw_end_paint; @@ -895,7 +885,7 @@ BOOL xf_post_connect(freerdp* instance) pointer_cache_register_callbacks(instance->update); - if (!xfi->settings->SoftwareGdi) + if (!xfc->settings->SoftwareGdi) { glyph_cache_register_callbacks(instance->update); brush_cache_register_callbacks(instance->update); @@ -906,15 +896,15 @@ BOOL xf_post_connect(freerdp* instance) instance->context->rail = rail_new(instance->settings); rail_register_update_callbacks(instance->context->rail, instance->update); - xf_rail_register_callbacks(xfi, instance->context->rail); + xf_rail_register_callbacks(xfc, instance->context->rail); freerdp_channels_post_connect(channels, instance); - xf_tsmf_init(xfi, xv_port); + xf_tsmf_init(xfc, xv_port); - xf_cliprdr_init(xfi, channels); + xf_cliprdr_init(xfc, channels); - IFCALL(xfi->client->OnResizeWindow, instance, settings->DesktopWidth, settings->DesktopHeight); + IFCALL(xfc->client->OnResizeWindow, instance, settings->DesktopWidth, settings->DesktopHeight); return TRUE; } @@ -995,11 +985,9 @@ BOOL xf_verify_certificate(freerdp* instance, char* subject, char* issuer, char* int xf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type) { - xfInfo* xfi; + xfContext* xfc = (xfContext*) instance->context; - xfi = ((xfContext*) instance->context)->xfi; - - xf_rail_disable_remoteapp_mode(xfi); + xf_rail_disable_remoteapp_mode(xfc); return 1; } @@ -1011,10 +999,10 @@ int xf_receive_channel_data(freerdp* instance, int channelId, BYTE* data, int si void xf_process_channel_event(rdpChannels* channels, freerdp* instance) { - xfInfo* xfi; + xfContext* xfc; wMessage* event; - xfi = ((xfContext*) instance->context)->xfi; + xfc = (xfContext*) instance->context; event = freerdp_channels_pop_event(channels); @@ -1023,19 +1011,19 @@ void xf_process_channel_event(rdpChannels* channels, freerdp* instance) switch (GetMessageClass(event->id)) { case RailChannel_Class: - xf_process_rail_event(xfi, channels, event); + xf_process_rail_event(xfc, channels, event); break; case TsmfChannel_Class: - xf_process_tsmf_event(xfi, event); + xf_process_tsmf_event(xfc, event); break; case CliprdrChannel_Class: - xf_process_cliprdr_event(xfi, event); + xf_process_cliprdr_event(xfc, event); break; case RdpeiChannel_Class: - xf_process_rdpei_event(xfi, event); + xf_process_rdpei_event(xfc, event); break; default: @@ -1046,48 +1034,48 @@ void xf_process_channel_event(rdpChannels* channels, freerdp* instance) } } -void xf_window_free(xfInfo* xfi) +void xf_window_free(xfContext* xfc) { - rdpContext* context = xfi->instance->context; + rdpContext* context = xfc->instance->context; - XFreeModifiermap(xfi->modifier_map); - xfi->modifier_map = 0; + XFreeModifiermap(xfc->modifier_map); + xfc->modifier_map = 0; - if (xfi->gc) + if (xfc->gc) { - XFreeGC(xfi->display, xfi->gc); - xfi->gc = 0; + XFreeGC(xfc->display, xfc->gc); + xfc->gc = 0; } - if (xfi->gc_mono) + if (xfc->gc_mono) { - XFreeGC(xfi->display, xfi->gc_mono); - xfi->gc_mono = 0; + XFreeGC(xfc->display, xfc->gc_mono); + xfc->gc_mono = 0; } - if (xfi->window) + if (xfc->window) { - xf_DestroyWindow(xfi, xfi->window); - xfi->window = NULL; + xf_DestroyWindow(xfc, xfc->window); + xfc->window = NULL; } - if (xfi->primary) + if (xfc->primary) { - XFreePixmap(xfi->display, xfi->primary); - xfi->primary = 0; + XFreePixmap(xfc->display, xfc->primary); + xfc->primary = 0; } - if (xfi->bitmap_mono) + if (xfc->bitmap_mono) { - XFreePixmap(xfi->display, xfi->bitmap_mono); - xfi->bitmap_mono = 0; + XFreePixmap(xfc->display, xfc->bitmap_mono); + xfc->bitmap_mono = 0; } - if (xfi->image) + if (xfc->image) { - xfi->image->data = NULL; - XDestroyImage(xfi->image); - xfi->image = NULL; + xfc->image->data = NULL; + XDestroyImage(xfc->image); + xfc->image = NULL; } if (context) @@ -1099,26 +1087,26 @@ void xf_window_free(xfInfo* xfi) context->rail = NULL; } - if (xfi->rfx_context) + if (xfc->rfx_context) { - rfx_context_free(xfi->rfx_context); - xfi->rfx_context = NULL; + rfx_context_free(xfc->rfx_context); + xfc->rfx_context = NULL; } - if (xfi->nsc_context) + if (xfc->nsc_context) { - nsc_context_free(xfi->nsc_context); - xfi->nsc_context = NULL; + nsc_context_free(xfc->nsc_context); + xfc->nsc_context = NULL; } - freerdp_clrconv_free(xfi->clrconv); - xfi->clrconv = NULL; + freerdp_clrconv_free(xfc->clrconv); + xfc->clrconv = NULL; - if (xfi->hdc) - gdi_DeleteDC(xfi->hdc); + if (xfc->hdc) + gdi_DeleteDC(xfc->hdc); - xf_tsmf_uninit(xfi); - xf_cliprdr_uninit(xfi); + xf_tsmf_uninit(xfc); + xf_cliprdr_uninit(xfc); } void* xf_update_thread(void* arg) @@ -1150,7 +1138,7 @@ void* xf_update_thread(void* arg) void* xf_input_thread(void* arg) { - xfInfo* xfi; + xfContext* xfc; HANDLE event; XEvent xevent; wMessageQueue* queue; @@ -1158,29 +1146,29 @@ void* xf_input_thread(void* arg) int process_status = 1; freerdp* instance = (freerdp*) arg; - xfi = ((xfContext*) instance->context)->xfi; + xfc = (xfContext*) instance->context; - event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds); + event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds); while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0) { do { - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); - pending_status = XPending(xfi->display); + pending_status = XPending(xfc->display); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); if (pending_status) { - xf_lock_x11(xfi, FALSE); + xf_lock_x11(xfc, FALSE); ZeroMemory(&xevent, sizeof(xevent)); - XNextEvent(xfi->display, &xevent); + XNextEvent(xfc->display, &xevent); process_status = xf_event_process(instance, &xevent); - xf_unlock_x11(xfi, FALSE); + xf_unlock_x11(xfc, FALSE); if (!process_status) break; @@ -1201,12 +1189,12 @@ void* xf_input_thread(void* arg) void* xf_channels_thread(void* arg) { int status; - xfInfo* xfi; + xfContext* xfc; HANDLE event; rdpChannels* channels; freerdp* instance = (freerdp*) arg; - xfi = ((xfContext*) instance->context)->xfi; + xfc = (xfContext*) instance->context; channels = instance->context->channels; event = freerdp_channels_get_event_handle(instance); @@ -1231,7 +1219,7 @@ void* xf_thread(void* param) { int i; int fds; - xfInfo* xfi; + xfContext* xfc; int max_fds; int rcount; int wcount; @@ -1267,7 +1255,7 @@ void* xf_thread(void* param) status = freerdp_connect(instance); - xfi = ((xfContext*) instance->context)->xfi; + xfc = (xfContext*) instance->context; /* Connection succeeded. --authonly ? */ if (instance->settings->AuthenticationOnly) @@ -1305,14 +1293,14 @@ void* xf_thread(void* param) channels_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_channels_thread, instance, 0, NULL); } - while (!xfi->disconnect && !freerdp_shall_disconnect(instance)) + while (!xfc->disconnect && !freerdp_shall_disconnect(instance)) { rcount = 0; wcount = 0; if (freerdp_focus_required(instance)) { - xf_kbd_focus_in(xfi); + xf_kbd_focus_in(xfc); } if (!async_transport) @@ -1423,7 +1411,7 @@ void* xf_thread(void* param) if (!freerdp_message_queue_process_pending_messages(instance, FREERDP_INPUT_MESSAGE_QUEUE)) { fprintf(stderr, "User Disconnect\n"); - xfi->disconnect = TRUE; + xfc->disconnect = TRUE; break; } } @@ -1522,9 +1510,9 @@ int freerdp_client_global_uninit() return 0; } -int freerdp_client_start(xfInfo* xfi) +int freerdp_client_start(xfContext* xfc) { - rdpSettings* settings = xfi->settings; + rdpSettings* settings = xfc->settings; if (!settings->ServerHostname) { @@ -1532,22 +1520,22 @@ int freerdp_client_start(xfInfo* xfi) return -1; } - xfi->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) xfi->instance, 0, NULL); + xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) xfc->instance, 0, NULL); return 0; } -int freerdp_client_stop(xfInfo* xfi) +int freerdp_client_stop(xfContext* xfc) { - if (xfi->instance->settings->AsyncInput) + if (xfc->instance->settings->AsyncInput) { wMessageQueue* queue; - queue = freerdp_get_message_queue(xfi->instance, FREERDP_INPUT_MESSAGE_QUEUE); + queue = freerdp_get_message_queue(xfc->instance, FREERDP_INPUT_MESSAGE_QUEUE); MessageQueue_PostQuit(queue, 0); } else { - xfi->disconnect = TRUE; + xfc->disconnect = TRUE; } return 0; @@ -1568,25 +1556,25 @@ rdpClient* freerdp_client_get_interface(cfInfo* cfi) return cfi->client; } -double freerdp_client_get_scale(xfInfo* xfi) +double freerdp_client_get_scale(xfContext* xfc) { - return xfi->scale; + return xfc->scale; } -void freerdp_client_reset_scale(xfInfo* xfi) +void freerdp_client_reset_scale(xfContext* xfc) { - xfi->scale = 1.0; + xfc->scale = 1.0; - XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); - IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); - xf_draw_screen_scaled(xfi); + XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale); + xf_draw_screen_scaled(xfc); } xfInfo* freerdp_client_new(int argc, char** argv) { int index; int status; - xfInfo* xfi; + xfContext* xfc; rdpFile* file; freerdp* instance; rdpSettings* settings; @@ -1610,21 +1598,20 @@ xfInfo* freerdp_client_new(int argc, char** argv) for (index = 0; index < argc; index++) instance->context->argv[index] = _strdup(argv[index]); - xfi = (xfInfo*) instance->context; - ((xfContext*) instance->context)->xfi = xfi; + xfc = (xfContext*) instance->context; - xfi->instance = instance; + xfc->instance = instance; settings = instance->settings; - xfi->client = instance->context->client; - xfi->settings = instance->context->settings; + xfc->client = instance->context->client; + xfc->settings = instance->context->settings; status = freerdp_client_parse_command_line_arguments(instance->context->argc, instance->context->argv, settings); if (status < 0) { - freerdp_context_free(xfi->instance); - freerdp_free(xfi->instance); - free(xfi); + freerdp_context_free(xfc->instance); + freerdp_free(xfc->instance); + free(xfc); return NULL; } @@ -1672,28 +1659,28 @@ xfInfo* freerdp_client_new(int argc, char** argv) if (settings->ListMonitors) { - xf_list_monitors(xfi); + xf_list_monitors(xfc); } - return xfi; + return xfc; } -void freerdp_client_free(xfInfo* xfi) +void freerdp_client_free(xfContext* xfc) { - if (xfi) + if (xfc) { int index; freerdp* instance; rdpContext* context; - context = (rdpContext*) xfi->context; + context = (rdpContext*) xfc; instance = context->instance; - xf_window_free(xfi); + xf_window_free(xfc); - free(xfi->bmp_codec_none); + free(xfc->bmp_codec_none); - XCloseDisplay(xfi->display); + XCloseDisplay(xfc->display); for (index = 0; index < context->argc; index++) free(context->argv[index]); diff --git a/client/X11/xf_interface.h b/client/X11/xf_interface.h index d584808b7..e6d8cbcd1 100644 --- a/client/X11/xf_interface.h +++ b/client/X11/xf_interface.h @@ -35,6 +35,7 @@ #include typedef struct xf_context xfInfo; +typedef struct xf_context xfContext; #ifdef __cplusplus extern "C" { @@ -44,22 +45,22 @@ extern "C" { * Client Interface */ -#define cfInfo xfInfo +#define cfInfo xfContext FREERDP_API int freerdp_client_global_init(); FREERDP_API int freerdp_client_global_uninit(); -FREERDP_API int freerdp_client_start(cfInfo* cfi); -FREERDP_API int freerdp_client_stop(cfInfo* cfi); +FREERDP_API int freerdp_client_start(cfInfo* cfc); +FREERDP_API int freerdp_client_stop(cfInfo* cfc); -FREERDP_API freerdp* freerdp_client_get_instance(cfInfo* cfi); -FREERDP_API HANDLE freerdp_client_get_thread(cfInfo* cfi); -FREERDP_API rdpClient* freerdp_client_get_interface(cfInfo* cfi); -FREERDP_API double freerdp_client_get_scale(xfInfo* xfi); -FREERDP_API void freerdp_client_reset_scale(xfInfo* xfi); +FREERDP_API freerdp* freerdp_client_get_instance(cfInfo* cfc); +FREERDP_API HANDLE freerdp_client_get_thread(cfInfo* cfc); +FREERDP_API rdpClient* freerdp_client_get_interface(cfInfo* cfc); +FREERDP_API double freerdp_client_get_scale(cfInfo* cfc); +FREERDP_API void freerdp_client_reset_scale(cfInfo* cfc); FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv); -FREERDP_API void freerdp_client_free(cfInfo* cfi); +FREERDP_API void freerdp_client_free(cfInfo* cfc); #ifdef __cplusplus } diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index e7db12cc6..0c85119c8 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -35,64 +35,64 @@ #include "xf_keyboard.h" -void xf_kbd_init(xfInfo* xfi) +void xf_kbd_init(xfContext* xfc) { - xf_kbd_clear(xfi); - xfi->keyboard_layout_id = xfi->instance->settings->KeyboardLayout; - xfi->keyboard_layout_id = freerdp_keyboard_init(xfi->keyboard_layout_id); - xfi->instance->settings->KeyboardLayout = xfi->keyboard_layout_id; - xfi->modifier_map = XGetModifierMapping(xfi->display); + xf_kbd_clear(xfc); + xfc->keyboard_layout_id = xfc->instance->settings->KeyboardLayout; + xfc->keyboard_layout_id = freerdp_keyboard_init(xfc->keyboard_layout_id); + xfc->instance->settings->KeyboardLayout = xfc->keyboard_layout_id; + xfc->modifier_map = XGetModifierMapping(xfc->display); } -void xf_kbd_clear(xfInfo* xfi) +void xf_kbd_clear(xfContext* xfc) { - ZeroMemory(xfi->pressed_keys, 256 * sizeof(BOOL)); + ZeroMemory(xfc->pressed_keys, 256 * sizeof(BOOL)); } -void xf_kbd_set_keypress(xfInfo* xfi, BYTE keycode, KeySym keysym) +void xf_kbd_set_keypress(xfContext* xfc, BYTE keycode, KeySym keysym) { if (keycode >= 8) - xfi->pressed_keys[keycode] = keysym; + xfc->pressed_keys[keycode] = keysym; else return; } -void xf_kbd_unset_keypress(xfInfo* xfi, BYTE keycode) +void xf_kbd_unset_keypress(xfContext* xfc, BYTE keycode) { if (keycode >= 8) - xfi->pressed_keys[keycode] = NoSymbol; + xfc->pressed_keys[keycode] = NoSymbol; else return; } -void xf_kbd_release_all_keypress(xfInfo* xfi) +void xf_kbd_release_all_keypress(xfContext* xfc) { int keycode; DWORD rdp_scancode; - for (keycode = 0; keycode < ARRAYSIZE(xfi->pressed_keys); keycode++) + for (keycode = 0; keycode < ARRAYSIZE(xfc->pressed_keys); keycode++) { - if (xfi->pressed_keys[keycode] != NoSymbol) + if (xfc->pressed_keys[keycode] != NoSymbol) { rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode); - freerdp_input_send_keyboard_event_ex(xfi->instance->input, FALSE, rdp_scancode); - xfi->pressed_keys[keycode] = NoSymbol; + freerdp_input_send_keyboard_event_ex(xfc->instance->input, FALSE, rdp_scancode); + xfc->pressed_keys[keycode] = NoSymbol; } } } -BOOL xf_kbd_key_pressed(xfInfo* xfi, KeySym keysym) +BOOL xf_kbd_key_pressed(xfContext* xfc, KeySym keysym) { - KeyCode keycode = XKeysymToKeycode(xfi->display, keysym); - return (xfi->pressed_keys[keycode] == keysym); + KeyCode keycode = XKeysymToKeycode(xfc->display, keysym); + return (xfc->pressed_keys[keycode] == keysym); } -void xf_kbd_send_key(xfInfo* xfi, BOOL down, BYTE keycode) +void xf_kbd_send_key(xfContext* xfc, BOOL down, BYTE keycode) { DWORD rdp_scancode; rdpInput* input; - input = xfi->instance->input; + input = xfc->instance->input; rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode); if (rdp_scancode == RDP_SCANCODE_UNKNOWN) @@ -100,7 +100,7 @@ void xf_kbd_send_key(xfInfo* xfi, BOOL down, BYTE keycode) fprintf(stderr, "Unknown key with X keycode 0x%02x\n", keycode); } else if (rdp_scancode == RDP_SCANCODE_PAUSE && - !xf_kbd_key_pressed(xfi, XK_Control_L) && !xf_kbd_key_pressed(xfi, XK_Control_R)) + !xf_kbd_key_pressed(xfc, XK_Control_L) && !xf_kbd_key_pressed(xfc, XK_Control_R)) { /* Pause without Ctrl has to be sent as Ctrl + NumLock. */ if (down) @@ -118,47 +118,47 @@ void xf_kbd_send_key(xfInfo* xfi, BOOL down, BYTE keycode) if ((rdp_scancode == RDP_SCANCODE_CAPSLOCK) && (down == FALSE)) { UINT32 syncFlags; - syncFlags = xf_kbd_get_toggle_keys_state(xfi); + syncFlags = xf_kbd_get_toggle_keys_state(xfc); input->SynchronizeEvent(input, syncFlags); } } } -int xf_kbd_read_keyboard_state(xfInfo* xfi) +int xf_kbd_read_keyboard_state(xfContext* xfc) { int dummy; Window wdummy; UINT32 state = 0; - if (!xfi->remote_app) + if (!xfc->remote_app) { - XQueryPointer(xfi->display, xfi->window->handle, + XQueryPointer(xfc->display, xfc->window->handle, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state); } else { - XQueryPointer(xfi->display, DefaultRootWindow(xfi->display), + XQueryPointer(xfc->display, DefaultRootWindow(xfc->display), &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state); } return state; } -BOOL xf_kbd_get_key_state(xfInfo* xfi, int state, int keysym) +BOOL xf_kbd_get_key_state(xfContext* xfc, int state, int keysym) { int offset; int modifierpos, key, keysymMask = 0; - KeyCode keycode = XKeysymToKeycode(xfi->display, keysym); + KeyCode keycode = XKeysymToKeycode(xfc->display, keysym); if (keycode == NoSymbol) return FALSE; for (modifierpos = 0; modifierpos < 8; modifierpos++) { - offset = xfi->modifier_map->max_keypermod * modifierpos; + offset = xfc->modifier_map->max_keypermod * modifierpos; - for (key = 0; key < xfi->modifier_map->max_keypermod; key++) + for (key = 0; key < xfc->modifier_map->max_keypermod; key++) { - if (xfi->modifier_map->modifiermap[offset + key] == keycode) + if (xfc->modifier_map->modifiermap[offset + key] == keycode) { keysymMask |= 1 << modifierpos; } @@ -168,26 +168,26 @@ BOOL xf_kbd_get_key_state(xfInfo* xfi, int state, int keysym) return (state & keysymMask) ? TRUE : FALSE; } -int xf_kbd_get_toggle_keys_state(xfInfo* xfi) +int xf_kbd_get_toggle_keys_state(xfContext* xfc) { int state; int toggle_keys_state = 0; - state = xf_kbd_read_keyboard_state(xfi); + state = xf_kbd_read_keyboard_state(xfc); - if (xf_kbd_get_key_state(xfi, state, XK_Scroll_Lock)) + if (xf_kbd_get_key_state(xfc, state, XK_Scroll_Lock)) toggle_keys_state |= KBD_SYNC_SCROLL_LOCK; - if (xf_kbd_get_key_state(xfi, state, XK_Num_Lock)) + if (xf_kbd_get_key_state(xfc, state, XK_Num_Lock)) toggle_keys_state |= KBD_SYNC_NUM_LOCK; - if (xf_kbd_get_key_state(xfi, state, XK_Caps_Lock)) + if (xf_kbd_get_key_state(xfc, state, XK_Caps_Lock)) toggle_keys_state |= KBD_SYNC_CAPS_LOCK; - if (xf_kbd_get_key_state(xfi, state, XK_Kana_Lock)) + if (xf_kbd_get_key_state(xfc, state, XK_Kana_Lock)) toggle_keys_state |= KBD_SYNC_KANA_LOCK; return toggle_keys_state; } -void xf_kbd_focus_in(xfInfo* xfi) +void xf_kbd_focus_in(xfContext* xfc) { rdpInput* input; UINT32 syncFlags; @@ -195,24 +195,24 @@ void xf_kbd_focus_in(xfInfo* xfi) Window wdummy; UINT32 state = 0; - if (xfi->display && xfi->window) + if (xfc->display && xfc->window) { - input = xfi->instance->input; - syncFlags = xf_kbd_get_toggle_keys_state(xfi); - XQueryPointer(xfi->display, xfi->window->handle, &wdummy, &wdummy, &mouseX, &mouseY, &dummy, &dummy, &state); + input = xfc->instance->input; + syncFlags = xf_kbd_get_toggle_keys_state(xfc); + XQueryPointer(xfc->display, xfc->window->handle, &wdummy, &wdummy, &mouseX, &mouseY, &dummy, &dummy, &state); input->FocusInEvent(input, syncFlags, mouseX, mouseY); } } -BOOL xf_kbd_handle_special_keys(xfInfo* xfi, KeySym keysym) +BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym) { if (keysym == XK_Return) { - if ((xf_kbd_key_pressed(xfi, XK_Alt_L) || xf_kbd_key_pressed(xfi, XK_Alt_R)) - && (xf_kbd_key_pressed(xfi, XK_Control_L) || xf_kbd_key_pressed(xfi, XK_Control_R))) + if ((xf_kbd_key_pressed(xfc, XK_Alt_L) || xf_kbd_key_pressed(xfc, XK_Alt_R)) + && (xf_kbd_key_pressed(xfc, XK_Control_L) || xf_kbd_key_pressed(xfc, XK_Control_R))) { /* Ctrl-Alt-Enter: toggle full screen */ - xf_toggle_fullscreen(xfi); + xf_toggle_fullscreen(xfc); return TRUE; } } diff --git a/client/X11/xf_keyboard.h b/client/X11/xf_keyboard.h index 493a67cb5..65732ced8 100644 --- a/client/X11/xf_keyboard.h +++ b/client/X11/xf_keyboard.h @@ -25,17 +25,17 @@ #include "xf_interface.h" #include "xfreerdp.h" -void xf_kbd_init(xfInfo* xfi); -void xf_kbd_clear(xfInfo* xfi); -void xf_kbd_set_keypress(xfInfo* xfi, BYTE keycode, KeySym keysym); -void xf_kbd_unset_keypress(xfInfo* xfi, BYTE keycode); -void xf_kbd_release_all_keypress(xfInfo* xfi); -BOOL xf_kbd_key_pressed(xfInfo* xfi, KeySym keysym); -void xf_kbd_send_key(xfInfo* xfi, BOOL down, BYTE keycode); -int xf_kbd_read_keyboard_state(xfInfo* xfi); -BOOL xf_kbd_get_key_state(xfInfo* xfi, int state, int keysym); -int xf_kbd_get_toggle_keys_state(xfInfo* xfi); -void xf_kbd_focus_in(xfInfo* xfi); -BOOL xf_kbd_handle_special_keys(xfInfo* xfi, KeySym keysym); +void xf_kbd_init(xfContext* xfc); +void xf_kbd_clear(xfContext* xfc); +void xf_kbd_set_keypress(xfContext* xfc, BYTE keycode, KeySym keysym); +void xf_kbd_unset_keypress(xfContext* xfc, BYTE keycode); +void xf_kbd_release_all_keypress(xfContext* xfc); +BOOL xf_kbd_key_pressed(xfContext* xfc, KeySym keysym); +void xf_kbd_send_key(xfContext* xfc, BOOL down, BYTE keycode); +int xf_kbd_read_keyboard_state(xfContext* xfc); +BOOL xf_kbd_get_key_state(xfContext* xfc, int state, int keysym); +int xf_kbd_get_toggle_keys_state(xfContext* xfc); +void xf_kbd_focus_in(xfContext* xfc); +BOOL xf_kbd_handle_special_keys(xfContext* xfc, KeySym keysym); #endif /* __XF_KEYBOARD_H */ diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 0667e354c..cd9301681 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -37,7 +37,7 @@ /* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */ -int xf_list_monitors(xfInfo* xfi) +int xf_list_monitors(xfContext* xfc) { #ifdef WITH_XINERAMA Display* display; @@ -81,7 +81,7 @@ int xf_list_monitors(xfInfo* xfi) return 0; } -BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) +BOOL xf_detect_monitors(xfContext* xfc, rdpSettings* settings) { int i, j; int nmonitors; @@ -95,14 +95,14 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) XineramaScreenInfo* screen_info = NULL; #endif - vscreen = &xfi->vscreen; + vscreen = &xfc->vscreen; #ifdef WITH_XINERAMA - if (XineramaQueryExtension(xfi->display, &ignored, &ignored2)) + if (XineramaQueryExtension(xfc->display, &ignored, &ignored2)) { - if (XineramaIsActive(xfi->display)) + if (XineramaIsActive(xfc->display)) { - screen_info = XineramaQueryScreens(xfi->display, &vscreen->nmonitors); + screen_info = XineramaQueryScreens(xfc->display, &vscreen->nmonitors); if (vscreen->nmonitors > 16) vscreen->nmonitors = 0; @@ -129,39 +129,39 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) } #endif - if (!xf_GetWorkArea(xfi)) + if (!xf_GetWorkArea(xfc)) { - xfi->workArea.x = 0; - xfi->workArea.y = 0; - xfi->workArea.width = WidthOfScreen(xfi->screen); - xfi->workArea.height = HeightOfScreen(xfi->screen); + xfc->workArea.x = 0; + xfc->workArea.y = 0; + xfc->workArea.width = WidthOfScreen(xfc->screen); + xfc->workArea.height = HeightOfScreen(xfc->screen); } if (settings->Fullscreen) { - settings->DesktopWidth = WidthOfScreen(xfi->screen); - settings->DesktopHeight = HeightOfScreen(xfi->screen); + settings->DesktopWidth = WidthOfScreen(xfc->screen); + settings->DesktopHeight = HeightOfScreen(xfc->screen); maxWidth = settings->DesktopWidth; maxHeight = settings->DesktopHeight; } else if (settings->Workarea) { - settings->DesktopWidth = xfi->workArea.width; - settings->DesktopHeight = xfi->workArea.height; + settings->DesktopWidth = xfc->workArea.width; + settings->DesktopHeight = xfc->workArea.height; maxWidth = settings->DesktopWidth; maxHeight = settings->DesktopHeight; } else if (settings->PercentScreen) { - settings->DesktopWidth = (xfi->workArea.width * settings->PercentScreen) / 100; - settings->DesktopHeight = (xfi->workArea.height * settings->PercentScreen) / 100; + settings->DesktopWidth = (xfc->workArea.width * settings->PercentScreen) / 100; + settings->DesktopHeight = (xfc->workArea.height * settings->PercentScreen) / 100; maxWidth = settings->DesktopWidth; maxHeight = settings->DesktopHeight; } else { - maxWidth = WidthOfScreen(xfi->screen); - maxHeight = HeightOfScreen(xfi->screen); + maxWidth = WidthOfScreen(xfc->screen); + maxHeight = HeightOfScreen(xfc->screen); } if (!settings->Fullscreen && !settings->Workarea && !settings->UseMultimon) @@ -240,8 +240,8 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) if (settings->Workarea) { - vscreen->area.top = xfi->workArea.y; - vscreen->area.bottom = (vHeight - (vHeight - (xfi->workArea.height + xfi->workArea.y))) - 1; + vscreen->area.top = xfc->workArea.y; + vscreen->area.bottom = (vHeight - (vHeight - (xfc->workArea.height + xfc->workArea.y))) - 1; } if (nmonitors && !primaryMonitor) diff --git a/client/X11/xf_monitor.h b/client/X11/xf_monitor.h index 4f3b1de8e..58d465024 100644 --- a/client/X11/xf_monitor.h +++ b/client/X11/xf_monitor.h @@ -43,7 +43,7 @@ typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN; #include "xf_interface.h" #include "xfreerdp.h" -int xf_list_monitors(xfInfo* xfi); -BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings); +int xf_list_monitors(xfContext* xfc); +BOOL xf_detect_monitors(xfContext* xfc, rdpSettings* settings); #endif /* __XF_MONITOR_H */ diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 66ec20dae..459d0f911 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -38,27 +38,27 @@ #define DEBUG_X11_LMS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -void xf_rail_enable_remoteapp_mode(xfInfo* xfi) +void xf_rail_enable_remoteapp_mode(xfContext* xfc) { - if (!xfi->remote_app) + if (!xfc->remote_app) { - xfi->remote_app = TRUE; - xfi->drawable = DefaultRootWindow(xfi->display); - xf_DestroyWindow(xfi, xfi->window); - xfi->window = NULL; + xfc->remote_app = TRUE; + xfc->drawable = DefaultRootWindow(xfc->display); + xf_DestroyWindow(xfc, xfc->window); + xfc->window = NULL; } } -void xf_rail_disable_remoteapp_mode(xfInfo* xfi) +void xf_rail_disable_remoteapp_mode(xfContext* xfc) { - if (xfi->remote_app) + if (xfc->remote_app) { - xfi->remote_app = FALSE; - xf_create_window(xfi); + xfc->remote_app = FALSE; + xf_create_window(xfc); } } -void xf_rail_paint(xfInfo* xfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom) +void xf_rail_paint(xfContext* xfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom) { xfWindow* xfw; rdpWindow* window; @@ -100,36 +100,35 @@ void xf_rail_paint(xfInfo* xfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 u if (intersect) { - xf_UpdateWindowArea(xfi, xfw, ileft - wleft, itop - wtop, iwidth, iheight); + xf_UpdateWindowArea(xfc, xfw, ileft - wleft, itop - wtop, iwidth, iheight); } } } void xf_rail_DesktopNonMonitored(rdpRail *rail, rdpWindow* window) { - xfInfo* xfi; + xfContext* xfc; - xfi = (xfInfo*) rail->extra; - xf_rail_disable_remoteapp_mode(xfi); + xfc = (xfContext*) rail->extra; + xf_rail_disable_remoteapp_mode(xfc); } static void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; - xf_rail_enable_remoteapp_mode(xfi); + xf_rail_enable_remoteapp_mode(xfc); - xfw = xf_CreateWindow((xfInfo*) rail->extra, window, + xfw = xf_CreateWindow(xfc, window, window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight, - window->windowId); + window->windowWidth, window->windowHeight, window->windowId); - xf_SetWindowStyle(xfi, xfw, window->style, window->extendedStyle); + xf_SetWindowStyle(xfc, xfw, window->style, window->extendedStyle); - xf_SetWindowText(xfi, xfw, window->title); + xf_SetWindowText(xfc, xfw, window->title); window->extra = (void*) xfw; window->extraId = (void*) xfw->handle; @@ -137,10 +136,10 @@ static void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window) static void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; /* @@ -161,83 +160,87 @@ static void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window) * Just ensure entire window area is updated to handle cases where we * have drawn locally before getting new bitmap from the server */ - xf_UpdateWindowArea(xfi, xfw, 0, 0, window->windowWidth, window->windowHeight); + xf_UpdateWindowArea(xfc, xfw, 0, 0, window->windowWidth, window->windowHeight); return; } - xf_MoveWindow(xfi, xfw, + xf_MoveWindow(xfc, xfw, window->visibleOffsetX, window->visibleOffsetY, window->windowWidth, window->windowHeight); } static void xf_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; - xf_ShowWindow(xfi, xfw, state); + xf_ShowWindow(xfc, xfw, state); } static void xf_rail_SetWindowText(rdpRail* rail, rdpWindow* window) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; - xf_SetWindowText(xfi, xfw, window->title); + xf_SetWindowText(xfc, xfw, window->title); } static void xf_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; icon->extra = freerdp_icon_convert(icon->entry->bitsColor, NULL, icon->entry->bitsMask, icon->entry->width, icon->entry->height, icon->entry->bpp, rail->clrconv); - xf_SetWindowIcon(xfi, xfw, icon); + xf_SetWindowIcon(xfc, xfw, icon); } static void xf_rail_SetWindowRects(rdpRail* rail, rdpWindow* window) { - xfInfo* xfi; + xfContext* xfc; xfWindow* xfw; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; - xf_SetWindowRects(xfi, xfw, window->windowRects, window->numWindowRects); + xf_SetWindowRects(xfc, xfw, window->windowRects, window->numWindowRects); } static void xf_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window) { - xfInfo* xfi; xfWindow* xfw; + xfContext* xfc; - xfi = (xfInfo*) rail->extra; + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; - xf_SetWindowVisibilityRects(xfi, xfw, window->windowRects, window->numWindowRects); + xf_SetWindowVisibilityRects(xfc, xfw, window->windowRects, window->numWindowRects); } static void xf_rail_DestroyWindow(rdpRail* rail, rdpWindow* window) { xfWindow* xfw; + xfContext* xfc; + + xfc = (xfContext*) rail->extra; xfw = (xfWindow*) window->extra; - xf_DestroyWindow((xfInfo*) rail->extra, xfw); + + xf_DestroyWindow(xfc, xfw); } -void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail) +void xf_rail_register_callbacks(xfContext* xfc, rdpRail* rail) { - rail->extra = (void*) xfi; + rail->extra = (void*) xfc; rail->rail_CreateWindow = xf_rail_CreateWindow; rail->rail_MoveWindow = xf_rail_MoveWindow; rail->rail_ShowWindow = xf_rail_ShowWindow; @@ -270,15 +273,15 @@ static void xf_send_rail_client_event(rdpChannels* channels, UINT16 event_type, } } -void xf_rail_send_activate(xfInfo* xfi, Window xwindow, BOOL enabled) +void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled) { rdpRail* rail; rdpChannels* channels; rdpWindow* rail_window; RAIL_ACTIVATE_ORDER activate; - rail = xfi->_context->rail; - channels = xfi->_context->channels; + rail = ((rdpContext*) xfc)->rail; + channels = ((rdpContext*) xfc)->channels; rail_window = window_list_get_by_extra_id(rail->list, (void*) xwindow); @@ -291,12 +294,12 @@ void xf_rail_send_activate(xfInfo* xfi, Window xwindow, BOOL enabled) xf_send_rail_client_event(channels, RailChannel_ClientActivate, &activate); } -void xf_rail_send_client_system_command(xfInfo* xfi, UINT32 windowId, UINT16 command) +void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, UINT16 command) { rdpChannels* channels; RAIL_SYSCOMMAND_ORDER syscommand; - channels = xfi->_context->channels; + channels = ((rdpContext*) xfc)->channels; syscommand.windowId = windowId; syscommand.command = command; @@ -310,14 +313,14 @@ void xf_rail_send_client_system_command(xfInfo* xfi, UINT32 windowId, UINT16 com * send an update to the RDP server informing it of the new window position * and size. */ -void xf_rail_adjust_position(xfInfo* xfi, rdpWindow* window) +void xf_rail_adjust_position(xfContext* xfc, rdpWindow* window) { xfWindow* xfw; rdpChannels* channels; RAIL_WINDOW_MOVE_ORDER window_move; xfw = (xfWindow*) window->extra; - channels = xfi->_context->channels; + channels = ((rdpContext*) xfc)->channels; if (! xfw->is_mapped || xfw->local_move.state != LMS_NOT_ACTIVE) return; @@ -371,12 +374,12 @@ void xf_rail_adjust_position(xfInfo* xfi, rdpWindow* window) } } -void xf_rail_end_local_move(xfInfo* xfi, rdpWindow *window) +void xf_rail_end_local_move(xfContext* xfc, rdpWindow *window) { xfWindow* xfw; rdpChannels* channels; RAIL_WINDOW_MOVE_ORDER window_move; - rdpInput* input = xfi->instance->input; + rdpInput* input = xfc->instance->input; int x,y; Window root_window; Window child_window; @@ -385,7 +388,7 @@ void xf_rail_end_local_move(xfInfo* xfi, rdpWindow *window) int child_y; xfw = (xfWindow*) window->extra; - channels = xfi->_context->channels; + channels = ((rdpContext*) xfc)->channels; DEBUG_X11_LMS("window=0x%X rc={l=%d t=%d r=%d b=%d} w=%d h=%d", (UINT32) xfw->handle, @@ -427,7 +430,7 @@ void xf_rail_end_local_move(xfInfo* xfi, rdpWindow *window) * Simulate button up at new position to end the local move (per RDP spec) */ - XQueryPointer(xfi->display, xfw->handle, + XQueryPointer(xfc->display, xfw->handle, &root_window, &child_window, &x, &y, &child_x, &child_y, &mask); input->MouseEvent(input, PTR_FLAGS_BUTTON1, x, y); @@ -454,16 +457,16 @@ void xf_rail_end_local_move(xfInfo* xfi, rdpWindow *window) xfw->local_move.state = LMS_TERMINATING; } -void xf_process_rail_get_sysparams_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_get_sysparams_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { RAIL_SYSPARAM_ORDER* sysparam; sysparam = (RAIL_SYSPARAM_ORDER*) event->wParam; - sysparam->workArea.left = xfi->workArea.x; - sysparam->workArea.top = xfi->workArea.y; - sysparam->workArea.right = xfi->workArea.x + xfi->workArea.width; - sysparam->workArea.bottom = xfi->workArea.y + xfi->workArea.height; + sysparam->workArea.left = xfc->workArea.x; + sysparam->workArea.top = xfc->workArea.y; + sysparam->workArea.right = xfc->workArea.x + xfc->workArea.width; + sysparam->workArea.bottom = xfc->workArea.y + xfc->workArea.height; sysparam->taskbarPos.left = 0; sysparam->taskbarPos.top = 0; @@ -486,7 +489,7 @@ const char* error_code_names[] = "RAIL_EXEC_E_SESSION_LOCKED" }; -void xf_process_rail_exec_result_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_exec_result_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { RAIL_EXEC_RESULT_ORDER* exec_result; @@ -496,15 +499,15 @@ void xf_process_rail_exec_result_event(xfInfo* xfi, rdpChannels* channels, wMess { fprintf(stderr, "RAIL exec error: execResult=%s NtError=0x%X\n", error_code_names[exec_result->execResult], exec_result->rawResult); - xfi->disconnect = True; + xfc->disconnect = True; } else { - xf_rail_enable_remoteapp_mode(xfi); + xf_rail_enable_remoteapp_mode(xfc); } } -void xf_process_rail_server_sysparam_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_server_sysparam_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { RAIL_SYSPARAM_ORDER* sysparam = (RAIL_SYSPARAM_ORDER*) event->wParam; @@ -518,13 +521,13 @@ void xf_process_rail_server_sysparam_event(xfInfo* xfi, rdpChannels* channels, w } } -void xf_process_rail_server_minmaxinfo_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_server_minmaxinfo_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { rdpRail* rail; rdpWindow* rail_window = NULL; RAIL_MINMAXINFO_ORDER* minmax = (RAIL_MINMAXINFO_ORDER*) event->wParam; - rail = ((rdpContext*) xfi->context)->rail; + rail = ((rdpContext*) xfc)->rail; rail_window = window_list_get_by_id(rail->list, minmax->windowId); if (rail_window != NULL) @@ -539,7 +542,7 @@ void xf_process_rail_server_minmaxinfo_event(xfInfo* xfi, rdpChannels* channels, minmax->minTrackWidth, minmax->minTrackHeight, minmax->maxTrackWidth, minmax->maxTrackHeight); - xf_SetWindowMinMaxInfo(xfi, window, minmax->maxWidth, minmax->maxHeight, minmax->maxPosX, minmax->maxPosY, + xf_SetWindowMinMaxInfo(xfc, window, minmax->maxWidth, minmax->maxHeight, minmax->maxPosX, minmax->maxPosY, minmax->minTrackWidth, minmax->minTrackHeight, minmax->maxTrackWidth, minmax->maxTrackHeight); } } @@ -560,7 +563,7 @@ const char* movetype_names[] = "RAIL_WMSZ_KEYSIZE" }; -void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_server_localmovesize_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { int x, y; rdpRail* rail; @@ -569,7 +572,7 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channe rdpWindow* rail_window = NULL; RAIL_LOCALMOVESIZE_ORDER* movesize = (RAIL_LOCALMOVESIZE_ORDER*) event->wParam; - rail = ((rdpContext*) xfi->context)->rail; + rail = ((rdpContext*) xfc)->rail; rail_window = window_list_get_by_id(rail->list, movesize->windowId); if (rail_window != NULL) @@ -625,8 +628,8 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channe break; case RAIL_WMSZ_MOVE: //0x9 direction = _NET_WM_MOVERESIZE_MOVE; - XTranslateCoordinates(xfi->display, xfw->handle, - RootWindowOfScreen(xfi->screen), + XTranslateCoordinates(xfc->display, xfw->handle, + RootWindowOfScreen(xfc->screen), movesize->posX, movesize->posY, &x, &y, &child_window); break; case RAIL_WMSZ_KEYMOVE: //0xA @@ -645,14 +648,14 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channe if (movesize->isMoveSizeStart) { - xf_StartLocalMoveSize(xfi, xfw, direction, x, y); + xf_StartLocalMoveSize(xfc, xfw, direction, x, y); } else { - xf_EndLocalMoveSize(xfi, xfw); + xf_EndLocalMoveSize(xfc, xfw); } } } -void xf_process_rail_appid_resp_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_appid_resp_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { RAIL_GET_APPID_RESP_ORDER* appid_resp = (RAIL_GET_APPID_RESP_ORDER*) event->wParam; @@ -664,7 +667,7 @@ void xf_process_rail_appid_resp_event(xfInfo* xfi, rdpChannels* channels, wMessa winpr_HexDump(appid_resp->applicationId.string, appid_resp->applicationId.length); } -void xf_process_rail_langbarinfo_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_langbarinfo_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { RAIL_LANGBAR_INFO_ORDER* langbar = (RAIL_LANGBAR_INFO_ORDER*) event->wParam; @@ -673,36 +676,36 @@ void xf_process_rail_langbarinfo_event(xfInfo* xfi, rdpChannels* channels, wMess langbar->languageBarStatus); } -void xf_process_rail_event(xfInfo* xfi, rdpChannels* channels, wMessage* event) +void xf_process_rail_event(xfContext* xfc, rdpChannels* channels, wMessage* event) { switch (GetMessageType(event->id)) { case RailChannel_GetSystemParam: - xf_process_rail_get_sysparams_event(xfi, channels, event); + xf_process_rail_get_sysparams_event(xfc, channels, event); break; case RailChannel_ServerExecuteResult: - xf_process_rail_exec_result_event(xfi, channels, event); + xf_process_rail_exec_result_event(xfc, channels, event); break; case RailChannel_ServerSystemParam: - xf_process_rail_server_sysparam_event(xfi, channels, event); + xf_process_rail_server_sysparam_event(xfc, channels, event); break; case RailChannel_ServerMinMaxInfo: - xf_process_rail_server_minmaxinfo_event(xfi, channels, event); + xf_process_rail_server_minmaxinfo_event(xfc, channels, event); break; case RailChannel_ServerLocalMoveSize: - xf_process_rail_server_localmovesize_event(xfi, channels, event); + xf_process_rail_server_localmovesize_event(xfc, channels, event); break; case RailChannel_ServerGetAppIdResponse: - xf_process_rail_appid_resp_event(xfi, channels, event); + xf_process_rail_appid_resp_event(xfc, channels, event); break; case RailChannel_ServerLanguageBarInfo: - xf_process_rail_langbarinfo_event(xfi, channels, event); + xf_process_rail_langbarinfo_event(xfc, channels, event); break; default: diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h index 29e24b8e9..3518e0388 100644 --- a/client/X11/xf_rail.h +++ b/client/X11/xf_rail.h @@ -23,14 +23,14 @@ #include "xf_interface.h" #include "xfreerdp.h" -void xf_rail_paint(xfInfo* xfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom); -void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail); -void xf_rail_send_client_system_command(xfInfo* xfi, UINT32 windowId, UINT16 command); -void xf_rail_send_activate(xfInfo* xfi, Window xwindow, BOOL enabled); -void xf_process_rail_event(xfInfo* xfi, rdpChannels* channels, wMessage* event); -void xf_rail_adjust_position(xfInfo* xfi, rdpWindow* window); -void xf_rail_end_local_move(xfInfo* xfi, rdpWindow* window); -void xf_rail_enable_remoteapp_mode(xfInfo* xfi); -void xf_rail_disable_remoteapp_mode(xfInfo* xfi); +void xf_rail_paint(xfContext* xfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom); +void xf_rail_register_callbacks(xfContext* xfc, rdpRail* rail); +void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, UINT16 command); +void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled); +void xf_process_rail_event(xfContext* xfc, rdpChannels* channels, wMessage* event); +void xf_rail_adjust_position(xfContext* xfc, rdpWindow* window); +void xf_rail_end_local_move(xfContext* xfc, rdpWindow* window); +void xf_rail_enable_remoteapp_mode(xfContext* xfc); +void xf_rail_disable_remoteapp_mode(xfContext* xfc); #endif /* __XF_RAIL_H */ diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index 420ff818f..131d2ea2b 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -63,7 +63,7 @@ struct xf_xv_context #define DEBUG_XV(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -void xf_tsmf_init(xfInfo* xfi, long xv_port) +void xf_tsmf_init(xfContext* xfc, long xv_port) { int ret; unsigned int i; @@ -81,19 +81,19 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) xv = (xfXvContext*) malloc(sizeof(xfXvContext)); ZeroMemory(xv, sizeof(xfXvContext)); - xfi->xv_context = xv; + xfc->xv_context = xv; xv->xv_colorkey_atom = None; xv->xv_image_size = 0; xv->xv_port = xv_port; - if (!XShmQueryExtension(xfi->display)) + if (!XShmQueryExtension(xfc->display)) { DEBUG_XV("no shmem available."); return; } - ret = XvQueryExtension(xfi->display, &version, &release, &request_base, &event_base, &error_base); + ret = XvQueryExtension(xfc->display, &version, &release, &request_base, &event_base, &error_base); if (ret != Success) { DEBUG_XV("XvQueryExtension failed %d.", ret); @@ -101,7 +101,7 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) } DEBUG_XV("version %u release %u", version, release); - ret = XvQueryAdaptors(xfi->display, DefaultRootWindow(xfi->display), + ret = XvQueryAdaptors(xfc->display, DefaultRootWindow(xfc->display), &num_adaptors, &ai); if (ret != Success) { @@ -127,13 +127,13 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) } DEBUG_XV("selected %ld", xv->xv_port); - attr = XvQueryPortAttributes(xfi->display, xv->xv_port, &ret); + attr = XvQueryPortAttributes(xfc->display, xv->xv_port, &ret); for (i = 0; i < (unsigned int)ret; i++) { if (strcmp(attr[i].name, "XV_COLORKEY") == 0) { - xv->xv_colorkey_atom = XInternAtom(xfi->display, "XV_COLORKEY", FALSE); - XvSetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1); + xv->xv_colorkey_atom = XInternAtom(xfc->display, "XV_COLORKEY", FALSE); + XvSetPortAttribute(xfc->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1); break; } } @@ -142,7 +142,7 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) #ifdef WITH_DEBUG_XV fprintf(stderr, "xf_tsmf_init: pixel format "); #endif - fo = XvListImageFormats(xfi->display, xv->xv_port, &ret); + fo = XvListImageFormats(xfc->display, xv->xv_port, &ret); if (ret > 0) { xv->xv_pixfmts = (UINT32*) malloc((ret + 1) * sizeof(UINT32)); @@ -164,9 +164,9 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) #endif } -void xf_tsmf_uninit(xfInfo* xfi) +void xf_tsmf_uninit(xfContext* xfc) { - xfXvContext* xv = (xfXvContext*) xfi->xv_context; + xfXvContext* xv = (xfXvContext*) xfc->xv_context; if (xv) { @@ -181,7 +181,7 @@ void xf_tsmf_uninit(xfInfo* xfi) xv->xv_pixfmts = NULL; } free(xv); - xfi->xv_context = NULL; + xfc->xv_context = NULL; } } @@ -202,7 +202,7 @@ xf_tsmf_is_format_supported(xfXvContext* xv, UINT32 pixfmt) return FALSE; } -static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT* vevent) +static void xf_process_tsmf_video_frame_event(xfContext* xfc, RDP_VIDEO_FRAME_EVENT* vevent) { int i; BYTE* data1; @@ -213,7 +213,7 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT XvImage * image; int colorkey = 0; XShmSegmentInfo shminfo; - xfXvContext* xv = (xfXvContext*) xfi->xv_context; + xfXvContext* xv = (xfXvContext*) xfc->xv_context; if (xv->xv_port == 0) return; @@ -224,13 +224,13 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT if (xv->xv_colorkey_atom != None) { - XvGetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, &colorkey); - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XSetForeground(xfi->display, xfi->gc, colorkey); + XvGetPortAttribute(xfc->display, xv->xv_port, xv->xv_colorkey_atom, &colorkey); + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XSetForeground(xfc->display, xfc->gc, colorkey); for (i = 0; i < vevent->num_visible_rects; i++) { - XFillRectangle(xfi->display, xfi->window->handle, xfi->gc, + XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, vevent->x + vevent->visible_rects[i].x, vevent->y + vevent->visible_rects[i].y, vevent->visible_rects[i].width, @@ -239,7 +239,7 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT } else { - XSetClipRectangles(xfi->display, xfi->gc, vevent->x, vevent->y, + XSetClipRectangles(xfc->display, xfc->gc, vevent->x, vevent->y, (XRectangle*) vevent->visible_rects, vevent->num_visible_rects, YXBanded); } @@ -265,7 +265,7 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT return; } - image = XvShmCreateImage(xfi->display, xv->xv_port, + image = XvShmCreateImage(xfc->display, xv->xv_port, xvpixfmt, 0, vevent->frame_width, vevent->frame_height, &shminfo); if (xv->xv_image_size != image->data_size) @@ -283,7 +283,7 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT shminfo.shmaddr = image->data = xv->xv_shmaddr; shminfo.readOnly = FALSE; - if (!XShmAttach(xfi->display, &shminfo)) + if (!XShmAttach(xfc->display, &shminfo)) { XFree(image); DEBUG_XV("XShmAttach failed."); @@ -356,35 +356,35 @@ static void xf_process_tsmf_video_frame_event(xfInfo* xfi, RDP_VIDEO_FRAME_EVENT break; } - XvShmPutImage(xfi->display, xv->xv_port, xfi->window->handle, xfi->gc, image, + XvShmPutImage(xfc->display, xv->xv_port, xfc->window->handle, xfc->gc, image, 0, 0, image->width, image->height, vevent->x, vevent->y, vevent->width, vevent->height, FALSE); if (xv->xv_colorkey_atom == None) - XSetClipMask(xfi->display, xfi->gc, None); - XSync(xfi->display, FALSE); + XSetClipMask(xfc->display, xfc->gc, None); + XSync(xfc->display, FALSE); - XShmDetach(xfi->display, &shminfo); + XShmDetach(xfc->display, &shminfo); XFree(image); } -static void xf_process_tsmf_redraw_event(xfInfo* xfi, RDP_REDRAW_EVENT* revent) +static void xf_process_tsmf_redraw_event(xfContext* xfc, RDP_REDRAW_EVENT* revent) { - XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, + XSetFunction(xfc->display, xfc->gc, GXcopy); + XSetFillStyle(xfc->display, xfc->gc, FillSolid); + XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, revent->x, revent->y, revent->width, revent->height, revent->x, revent->y); } -void xf_process_tsmf_event(xfInfo* xfi, wMessage* event) +void xf_process_tsmf_event(xfContext* xfc, wMessage* event) { switch (GetMessageType(event->id)) { case TsmfChannel_VideoFrame: - xf_process_tsmf_video_frame_event(xfi, (RDP_VIDEO_FRAME_EVENT*) event); + xf_process_tsmf_video_frame_event(xfc, (RDP_VIDEO_FRAME_EVENT*) event); break; case TsmfChannel_Redraw: - xf_process_tsmf_redraw_event(xfi, (RDP_REDRAW_EVENT*) event); + xf_process_tsmf_redraw_event(xfc, (RDP_REDRAW_EVENT*) event); break; } @@ -392,15 +392,15 @@ void xf_process_tsmf_event(xfInfo* xfi, wMessage* event) #else /* WITH_XV */ -void xf_tsmf_init(xfInfo* xfi, long xv_port) +void xf_tsmf_init(xfContext* xfc, long xv_port) { } -void xf_tsmf_uninit(xfInfo* xfi) +void xf_tsmf_uninit(xfContext* xfc) { } -void xf_process_tsmf_event(xfInfo* xfi, wMessage* event) +void xf_process_tsmf_event(xfContext* xfc, wMessage* event) { } diff --git a/client/X11/xf_tsmf.h b/client/X11/xf_tsmf.h index 65d7838d8..a8cf8cdae 100644 --- a/client/X11/xf_tsmf.h +++ b/client/X11/xf_tsmf.h @@ -23,8 +23,8 @@ #include "xf_interface.h" #include "xfreerdp.h" -void xf_tsmf_init(xfInfo* xfi, long xv_port); -void xf_tsmf_uninit(xfInfo* xfi); -void xf_process_tsmf_event(xfInfo* xfi, wMessage* event); +void xf_tsmf_init(xfContext* xfc, long xv_port); +void xf_tsmf_uninit(xfContext* xfc); +void xf_process_tsmf_event(xfContext* xfc, wMessage* event); #endif /* __XF_TSMF_H */ diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 780125455..a24ac7190 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -108,7 +108,7 @@ typedef struct _PropMotifWmHints PropMotifWmHints; /** * Post an event from the client to the X server */ -void xf_SendClientEvent(xfInfo* xfi, xfWindow* window, Atom atom, unsigned int numArgs, ...) +void xf_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned int numArgs, ...) { XEvent xevent; unsigned int i; @@ -119,7 +119,7 @@ void xf_SendClientEvent(xfInfo* xfi, xfWindow* window, Atom atom, unsigned int n xevent.xclient.type = ClientMessage; xevent.xclient.serial = 0; xevent.xclient.send_event = False; - xevent.xclient.display = xfi->display; + xevent.xclient.display = xfc->display; xevent.xclient.window = window->handle; xevent.xclient.message_type = atom; xevent.xclient.format = 32; @@ -131,23 +131,23 @@ void xf_SendClientEvent(xfInfo* xfi, xfWindow* window, Atom atom, unsigned int n DEBUG_X11("Send ClientMessage Event: wnd=0x%04X", (unsigned int) xevent.xclient.window); - XSendEvent(xfi->display, RootWindowOfScreen(xfi->screen), False, + XSendEvent(xfc->display, RootWindowOfScreen(xfc->screen), False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); - XSync(xfi->display, False); + XSync(xfc->display, False); va_end(argp); } -void xf_SetWindowFullscreen(xfInfo* xfi, xfWindow* window, BOOL fullscreen) +void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) { if (fullscreen) { - rdpSettings* settings = xfi->instance->settings; + rdpSettings* settings = xfc->instance->settings; - xf_SetWindowDecorations(xfi, window, FALSE); + xf_SetWindowDecorations(xfc, window, FALSE); - XMoveResizeWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY, window->width, window->height); - XMapRaised(xfi->display, window->handle); + XMoveResizeWindow(xfc->display, window->handle, settings->DesktopPosX, settings->DesktopPosY, window->width, window->height); + XMapRaised(xfc->display, window->handle); window->fullscreen = TRUE; } @@ -155,7 +155,7 @@ void xf_SetWindowFullscreen(xfInfo* xfi, xfWindow* window, BOOL fullscreen) /* http://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html */ -BOOL xf_GetWindowProperty(xfInfo* xfi, Window window, Atom property, int length, +BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property, int length, unsigned long* nitems, unsigned long* bytes, BYTE** prop) { int status; @@ -165,7 +165,7 @@ BOOL xf_GetWindowProperty(xfInfo* xfi, Window window, Atom property, int length, if (property == None) return FALSE; - status = XGetWindowProperty(xfi->display, window, + status = XGetWindowProperty(xfc->display, window, property, 0, length, FALSE, AnyPropertyType, &actual_type, &actual_format, nitems, bytes, prop); @@ -181,26 +181,26 @@ BOOL xf_GetWindowProperty(xfInfo* xfi, Window window, Atom property, int length, return TRUE; } -BOOL xf_GetCurrentDesktop(xfInfo* xfi) +BOOL xf_GetCurrentDesktop(xfContext* xfc) { BOOL status; unsigned long nitems; unsigned long bytes; unsigned char* prop; - status = xf_GetWindowProperty(xfi, DefaultRootWindow(xfi->display), - xfi->_NET_CURRENT_DESKTOP, 1, &nitems, &bytes, &prop); + status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display), + xfc->_NET_CURRENT_DESKTOP, 1, &nitems, &bytes, &prop); if (!status) return FALSE; - xfi->current_desktop = (int) *prop; + xfc->current_desktop = (int) *prop; free(prop); return TRUE; } -BOOL xf_GetWorkArea(xfInfo* xfi) +BOOL xf_GetWorkArea(xfContext* xfc) { long* plong; BOOL status; @@ -208,18 +208,18 @@ BOOL xf_GetWorkArea(xfInfo* xfi) unsigned long bytes; unsigned char* prop; - status = xf_GetCurrentDesktop(xfi); + status = xf_GetCurrentDesktop(xfc); if (status != TRUE) return FALSE; - status = xf_GetWindowProperty(xfi, DefaultRootWindow(xfi->display), - xfi->_NET_WORKAREA, 32 * 4, &nitems, &bytes, &prop); + status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display), + xfc->_NET_WORKAREA, 32 * 4, &nitems, &bytes, &prop); if (status != TRUE) return FALSE; - if ((xfi->current_desktop * 4 + 3) >= nitems) + if ((xfc->current_desktop * 4 + 3) >= nitems) { free(prop); return FALSE; @@ -227,16 +227,16 @@ BOOL xf_GetWorkArea(xfInfo* xfi) plong = (long*) prop; - xfi->workArea.x = plong[xfi->current_desktop * 4 + 0]; - xfi->workArea.y = plong[xfi->current_desktop * 4 + 1]; - xfi->workArea.width = plong[xfi->current_desktop * 4 + 2]; - xfi->workArea.height = plong[xfi->current_desktop * 4 + 3]; + xfc->workArea.x = plong[xfc->current_desktop * 4 + 0]; + xfc->workArea.y = plong[xfc->current_desktop * 4 + 1]; + xfc->workArea.width = plong[xfc->current_desktop * 4 + 2]; + xfc->workArea.height = plong[xfc->current_desktop * 4 + 3]; free(prop); return TRUE; } -void xf_SetWindowDecorations(xfInfo* xfi, xfWindow* window, BOOL show) +void xf_SetWindowDecorations(xfContext* xfc, xfWindow* window, BOOL show) { PropMotifWmHints hints; @@ -246,22 +246,22 @@ void xf_SetWindowDecorations(xfInfo* xfi, xfWindow* window, BOOL show) hints.inputMode = 0; hints.status = 0; - XChangeProperty(xfi->display, window->handle, xfi->_MOTIF_WM_HINTS, xfi->_MOTIF_WM_HINTS, 32, + XChangeProperty(xfc->display, window->handle, xfc->_MOTIF_WM_HINTS, xfc->_MOTIF_WM_HINTS, 32, PropModeReplace, (BYTE*) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS); } -void xf_SetWindowUnlisted(xfInfo* xfi, xfWindow* window) +void xf_SetWindowUnlisted(xfContext* xfc, xfWindow* window) { Atom window_state[2]; - window_state[0] = xfi->_NET_WM_STATE_SKIP_PAGER; - window_state[1] = xfi->_NET_WM_STATE_SKIP_TASKBAR; + window_state[0] = xfc->_NET_WM_STATE_SKIP_PAGER; + window_state[1] = xfc->_NET_WM_STATE_SKIP_TASKBAR; - XChangeProperty(xfi->display, window->handle, xfi->_NET_WM_STATE, + XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (BYTE*) &window_state, 2); } -void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, UINT32 style, UINT32 ex_style) +void xf_SetWindowStyle(xfContext* xfc, xfWindow* window, UINT32 style, UINT32 ex_style) { Atom window_type; @@ -278,11 +278,11 @@ void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, UINT32 style, UINT32 ex_st */ XSetWindowAttributes attrs; attrs.override_redirect = True; - XChangeWindowAttributes(xfi->display, window->handle, CWOverrideRedirect, &attrs); + XChangeWindowAttributes(xfc->display, window->handle, CWOverrideRedirect, &attrs); window->is_transient = TRUE; - xf_SetWindowUnlisted(xfi, window); - window_type = xfi->_NET_WM_WINDOW_TYPE_POPUP; + xf_SetWindowUnlisted(xfc, window); + window_type = xfc->_NET_WM_WINDOW_TYPE_POPUP; } /* * TOPMOST window that is not a toolwindow is treated like a regular window(ie. task manager). @@ -290,44 +290,44 @@ void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, UINT32 style, UINT32 ex_st */ else if (ex_style & WS_EX_TOPMOST) { - window_type = xfi->_NET_WM_WINDOW_TYPE_NORMAL; + window_type = xfc->_NET_WM_WINDOW_TYPE_NORMAL; } else if (style & WS_POPUP) { /* this includes dialogs, popups, etc, that need to be full-fledged windows */ window->is_transient = TRUE; - window_type = xfi->_NET_WM_WINDOW_TYPE_DIALOG; - xf_SetWindowUnlisted(xfi, window); + window_type = xfc->_NET_WM_WINDOW_TYPE_DIALOG; + xf_SetWindowUnlisted(xfc, window); } else { - window_type = xfi->_NET_WM_WINDOW_TYPE_NORMAL; + window_type = xfc->_NET_WM_WINDOW_TYPE_NORMAL; } - XChangeProperty(xfi->display, window->handle, xfi->_NET_WM_WINDOW_TYPE, + XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (BYTE*) &window_type, 1); } -void xf_SetWindowText(xfInfo *xfi, xfWindow* window, char *name) +void xf_SetWindowText(xfContext* xfc, xfWindow* window, char *name) { - XStoreName(xfi->display, window->handle, name); + XStoreName(xfc->display, window->handle, name); } -static void xf_SetWindowPID(xfInfo* xfi, xfWindow* window, pid_t pid) +static void xf_SetWindowPID(xfContext* xfc, xfWindow* window, pid_t pid) { Atom am_wm_pid; if (!pid) pid = getpid(); - am_wm_pid = XInternAtom(xfi->display, "_NET_WM_PID", False); + am_wm_pid = XInternAtom(xfc->display, "_NET_WM_PID", False); - XChangeProperty(xfi->display, window->handle, am_wm_pid, XA_CARDINAL, + XChangeProperty(xfc->display, window->handle, am_wm_pid, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); } -xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, BOOL decorations) +xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int height, BOOL decorations) { xfWindow* window; XEvent xevent; @@ -335,7 +335,7 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, window = (xfWindow*) malloc(sizeof(xfWindow)); ZeroMemory(window, sizeof(xfWindow)); - settings = xfi->instance->settings; + settings = xfc->instance->settings; if (window) { @@ -351,10 +351,10 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, window->is_mapped = FALSE; window->is_transient = FALSE; - window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen), - xfi->workArea.x, xfi->workArea.y, xfi->workArea.width, xfi->workArea.height, 0, xfi->depth, InputOutput, xfi->visual, + window->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), + xfc->workArea.x, xfc->workArea.y, xfc->workArea.width, xfc->workArea.height, 0, xfc->depth, InputOutput, xfc->visual, CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | - CWBorderPixel | CWWinGravity | CWBitGravity, &xfi->attribs); + CWBorderPixel | CWWinGravity | CWBitGravity, &xfc->attribs); shmid = shmget(SHARED_MEM_KEY, sizeof(int), IPC_CREAT | 0666); @@ -382,38 +382,38 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, { class_hints->res_name = "xfreerdp"; - if (xfi->instance->settings->WmClass) - class_hints->res_class = xfi->instance->settings->WmClass; + if (xfc->instance->settings->WmClass) + class_hints->res_class = xfc->instance->settings->WmClass; else class_hints->res_class = "xfreerdp"; - XSetClassHint(xfi->display, window->handle, class_hints); + XSetClassHint(xfc->display, window->handle, class_hints); XFree(class_hints); } - xf_ResizeDesktopWindow(xfi, window, width, height); - xf_SetWindowDecorations(xfi, window, decorations); - xf_SetWindowPID(xfi, window, 0); + xf_ResizeDesktopWindow(xfc, window, width, height); + xf_SetWindowDecorations(xfc, window, decorations); + xf_SetWindowPID(xfc, window, 0); input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | VisibilityChangeMask | FocusChangeMask | StructureNotifyMask | PointerMotionMask | ExposureMask | PropertyChangeMask; - if (xfi->grab_keyboard) + if (xfc->grab_keyboard) input_mask |= EnterWindowMask | LeaveWindowMask; - XChangeProperty(xfi->display, window->handle, xfi->_NET_WM_ICON, XA_CARDINAL, 32, + XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (BYTE*) xf_icon_prop, ARRAYSIZE(xf_icon_prop)); - if (xfi->settings->ParentWindowId) - XReparentWindow(xfi->display, window->handle, (Window) xfi->settings->ParentWindowId, 0, 0); + if (xfc->settings->ParentWindowId) + XReparentWindow(xfc->display, window->handle, (Window) xfc->settings->ParentWindowId, 0, 0); - XSelectInput(xfi->display, window->handle, input_mask); - XClearWindow(xfi->display, window->handle); - XMapWindow(xfi->display, window->handle); + XSelectInput(xfc->display, window->handle, input_mask); + XClearWindow(xfc->display, window->handle); + XMapWindow(xfc->display, window->handle); - xf_input_init(xfi, window->handle); + xf_input_init(xfc, window->handle); /* * NOTE: This must be done here to handle reparenting the window, @@ -421,7 +421,7 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, */ do { - XMaskEvent(xfi->display, VisibilityChangeMask, &xevent); + XMaskEvent(xfc->display, VisibilityChangeMask, &xevent); } while (xevent.type != VisibilityNotify); @@ -431,22 +431,22 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, * This extra call after the window is mapped will position the login window correctly */ - if (xfi->instance->settings->RemoteApplicationMode) + if (xfc->instance->settings->RemoteApplicationMode) { - XMoveWindow(xfi->display, window->handle, 0, 0); + XMoveWindow(xfc->display, window->handle, 0, 0); } else if (settings->DesktopPosX || settings->DesktopPosY) { - XMoveWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY); + XMoveWindow(xfc->display, window->handle, settings->DesktopPosX, settings->DesktopPosY); } } - xf_SetWindowText(xfi, window, name); + xf_SetWindowText(xfc, window, name); return window; } -void xf_ResizeDesktopWindow(xfInfo* xfi, xfWindow* window, int width, int height) +void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int height) { XSizeHints* size_hints; @@ -455,21 +455,21 @@ void xf_ResizeDesktopWindow(xfInfo* xfi, xfWindow* window, int width, int height if (size_hints) { size_hints->flags = PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = xfi->width; - size_hints->min_height = size_hints->max_height = xfi->height; - XSetWMNormalHints(xfi->display, window->handle, size_hints); - XResizeWindow(xfi->display, window->handle, xfi->width, xfi->height); + size_hints->min_width = size_hints->max_width = xfc->width; + size_hints->min_height = size_hints->max_height = xfc->height; + XSetWMNormalHints(xfc->display, window->handle, size_hints); + XResizeWindow(xfc->display, window->handle, xfc->width, xfc->height); XFree(size_hints); } } -void xf_FixWindowCoordinates(xfInfo* xfi, int* x, int* y, int* width, int* height) +void xf_FixWindowCoordinates(xfContext* xfc, int* x, int* y, int* width, int* height) { int vscreen_width; int vscreen_height; - vscreen_width = xfi->vscreen.area.right - xfi->vscreen.area.left + 1; - vscreen_height = xfi->vscreen.area.bottom - xfi->vscreen.area.top + 1; + vscreen_width = xfc->vscreen.area.right - xfc->vscreen.area.left + 1; + vscreen_height = xfc->vscreen.area.bottom - xfc->vscreen.area.top + 1; if (*width < 1) { @@ -479,15 +479,15 @@ void xf_FixWindowCoordinates(xfInfo* xfi, int* x, int* y, int* width, int* heigh { *height = 1; } - if (*x < xfi->vscreen.area.left) + if (*x < xfc->vscreen.area.left) { *width += *x; - *x = xfi->vscreen.area.left; + *x = xfc->vscreen.area.left; } - if (*y < xfi->vscreen.area.top) + if (*y < xfc->vscreen.area.top) { *height += *y; - *y = xfi->vscreen.area.top; + *y = xfc->vscreen.area.top; } if (*width > vscreen_width) { @@ -501,7 +501,7 @@ void xf_FixWindowCoordinates(xfInfo* xfi, int* x, int* y, int* width, int* heigh char rail_window_class[] = "RAIL:00000000"; -xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, int height, UINT32 id) +xfWindow* xf_CreateWindow(xfContext* xfc, rdpWindow* wnd, int x, int y, int width, int height, UINT32 id) { XGCValues gcv; int input_mask; @@ -512,7 +512,7 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, window = (xfWindow*) malloc(sizeof(xfWindow)); ZeroMemory(window, sizeof(xfWindow)); - xf_FixWindowCoordinates(xfi, &x, &y, &width, &height); + xf_FixWindowCoordinates(xfc, &x, &y, &width, &height); window->left = x; window->top = y; @@ -536,17 +536,17 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, window->rail_state = 0; window->rail_ignore_configure = FALSE; - window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen), - x, y, window->width, window->height, 0, xfi->depth, InputOutput, xfi->visual, + window->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), + x, y, window->width, window->height, 0, xfc->depth, InputOutput, xfc->visual, CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | - CWBorderPixel | CWWinGravity | CWBitGravity, &xfi->attribs); + CWBorderPixel | CWWinGravity | CWBitGravity, &xfc->attribs); DEBUG_X11_LMS("Create window=0x%X rc={l=%d t=%d r=%d b=%d} w=%d h=%d rdp=0x%X", (UINT32) window->handle, window->left, window->top, window->right, window->bottom, window->width, window->height, wnd->windowId); ZeroMemory(&gcv, sizeof(gcv)); - window->gc = XCreateGC(xfi->display, window->handle, GCGraphicsExposures, &gcv); + window->gc = XCreateGC(xfc->display, window->handle, GCGraphicsExposures, &gcv); class_hints = XAllocClassHint(); @@ -554,9 +554,9 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, { char* class = NULL; - if (xfi->instance->settings->WmClass != NULL) + if (xfc->instance->settings->WmClass != NULL) { - class_hints->res_class = xfi->instance->settings->WmClass; + class_hints->res_class = xfc->instance->settings->WmClass; } else { @@ -566,7 +566,7 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, } class_hints->res_name = "RAIL"; - XSetClassHint(xfi->display, window->handle, class_hints); + XSetClassHint(xfc->display, window->handle, class_hints); XFree(class_hints); if (class) @@ -577,10 +577,10 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, InputModeHint = XAllocWMHints(); InputModeHint->flags = (1L << 0); InputModeHint->input = True; - XSetWMHints(xfi->display, window->handle, InputModeHint); + XSetWMHints(xfc->display, window->handle, InputModeHint); XFree(InputModeHint); - XSetWMProtocols(xfi->display, window->handle, &(xfi->WM_DELETE_WINDOW), 1); + XSetWMProtocols(xfc->display, window->handle, &(xfc->WM_DELETE_WINDOW), 1); input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | @@ -591,23 +591,23 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, SubstructureRedirectMask | FocusChangeMask | PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask; - XSelectInput(xfi->display, window->handle, input_mask); + XSelectInput(xfc->display, window->handle, input_mask); - xf_SetWindowDecorations(xfi, window, window->decorations); - xf_SetWindowStyle(xfi, window, wnd->style, wnd->extendedStyle); - xf_SetWindowPID(xfi, window, 0); - xf_ShowWindow(xfi, window, WINDOW_SHOW); + xf_SetWindowDecorations(xfc, window, window->decorations); + xf_SetWindowStyle(xfc, window, wnd->style, wnd->extendedStyle); + xf_SetWindowPID(xfc, window, 0); + xf_ShowWindow(xfc, window, WINDOW_SHOW); - XClearWindow(xfi->display, window->handle); - XMapWindow(xfi->display, window->handle); + XClearWindow(xfc->display, window->handle); + XMapWindow(xfc->display, window->handle); /* Move doesn't seem to work until window is mapped. */ - xf_MoveWindow(xfi, window, x, y, width, height); + xf_MoveWindow(xfc, window, x, y, width, height); return window; } -void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window, +void xf_SetWindowMinMaxInfo(xfContext* xfc, xfWindow* window, int maxWidth, int maxHeight, int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight) { @@ -628,12 +628,12 @@ void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window, /* to speedup window drawing we need to select optimal value for sizing step. */ size_hints->width_inc = size_hints->height_inc = 1; - XSetWMNormalHints(xfi->display, window->handle, size_hints); + XSetWMNormalHints(xfc->display, window->handle, size_hints); XFree(size_hints); } } -void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, int direction, int x, int y) +void xf_StartLocalMoveSize(xfContext* xfc, xfWindow* window, int direction, int x, int y) { if (window->local_move.state != LMS_NOT_ACTIVE) return; @@ -655,10 +655,10 @@ void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, int direction, int x, window->local_move.state = LMS_STARTING; window->local_move.direction = direction; - XUngrabPointer(xfi->display, CurrentTime); + XUngrabPointer(xfc->display, CurrentTime); - xf_SendClientEvent(xfi, window, - xfi->_NET_WM_MOVERESIZE, /* request X window manager to initiate a local move */ + xf_SendClientEvent(xfc, window, + xfc->_NET_WM_MOVERESIZE, /* request X window manager to initiate a local move */ 5, /* 5 arguments to follow */ x, /* x relative to root window */ y, /* y relative to root window */ @@ -667,7 +667,7 @@ void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, int direction, int x, 1); /* 1 == application request per extended ICCM */ } -void xf_EndLocalMoveSize(xfInfo *xfi, xfWindow *window) +void xf_EndLocalMoveSize(xfContext* xfc, xfWindow *window) { DEBUG_X11_LMS("state=%d window=0x%X rc={l=%d t=%d r=%d b=%d} w=%d h=%d " @@ -689,8 +689,8 @@ void xf_EndLocalMoveSize(xfInfo *xfi, xfWindow *window) * RDP server for local moves. We must cancel the X window manager move. * Per ICCM, the X client can ask to cancel an active move. */ - xf_SendClientEvent(xfi, window, - xfi->_NET_WM_MOVERESIZE, /* request X window manager to abort a local move */ + xf_SendClientEvent(xfc, window, + xfc->_NET_WM_MOVERESIZE, /* request X window manager to abort a local move */ 5, /* 5 arguments to follow */ window->local_move.root_x, /* x relative to root window */ window->local_move.root_y, /* y relative to root window */ @@ -702,7 +702,7 @@ void xf_EndLocalMoveSize(xfInfo *xfi, xfWindow *window) window->local_move.state = LMS_NOT_ACTIVE; } -void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height) +void xf_MoveWindow(xfContext* xfc, xfWindow* window, int x, int y, int width, int height) { BOOL resize = FALSE; @@ -734,30 +734,30 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h window->height = height; if (resize) - XMoveResizeWindow(xfi->display, window->handle, x, y, width, height); + XMoveResizeWindow(xfc->display, window->handle, x, y, width, height); else - XMoveWindow(xfi->display, window->handle, x, y); + XMoveWindow(xfc->display, window->handle, x, y); - xf_UpdateWindowArea(xfi, window, 0, 0, width, height); + xf_UpdateWindowArea(xfc, window, 0, 0, width, height); } -void xf_ShowWindow(xfInfo* xfi, xfWindow* window, BYTE state) +void xf_ShowWindow(xfContext* xfc, xfWindow* window, BYTE state) { switch (state) { case WINDOW_HIDE: - XWithdrawWindow(xfi->display, window->handle, xfi->screen_number); + XWithdrawWindow(xfc->display, window->handle, xfc->screen_number); break; case WINDOW_SHOW_MINIMIZED: - XIconifyWindow(xfi->display, window->handle, xfi->screen_number); + XIconifyWindow(xfc->display, window->handle, xfc->screen_number); break; case WINDOW_SHOW_MAXIMIZED: /* Set the window as maximized */ - xf_SendClientEvent(xfi, window, xfi->_NET_WM_STATE, 4, 1, - XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_VERT", False), - XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False), 0); + xf_SendClientEvent(xfc, window, xfc->_NET_WM_STATE, 4, 1, + XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False), + XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False), 0); /* * This is a workaround for the case where the window is maximized locally before the rail server is told to maximize @@ -767,14 +767,14 @@ void xf_ShowWindow(xfInfo* xfi, xfWindow* window, BYTE state) */ if (window->rail_state == WINDOW_SHOW_MAXIMIZED) - xf_UpdateWindowArea(xfi, window, 0, 0, window->window->windowWidth, window->window->windowHeight); + xf_UpdateWindowArea(xfc, window, 0, 0, window->window->windowWidth, window->window->windowHeight); break; case WINDOW_SHOW: /* Ensure the window is not maximized */ - xf_SendClientEvent(xfi, window, xfi->_NET_WM_STATE, 4, 0, - XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_VERT", False), - XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False), 0); + xf_SendClientEvent(xfc, window, xfc->_NET_WM_STATE, 4, 0, + XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False), + XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False), 0); /* * Ignore configure requests until both the Maximized properties have been processed @@ -787,7 +787,7 @@ void xf_ShowWindow(xfInfo* xfi, xfWindow* window, BYTE state) window->rail_ignore_configure = TRUE; if (window->is_transient) - xf_SetWindowUnlisted(xfi, window); + xf_SetWindowUnlisted(xfc, window); break; } @@ -795,10 +795,10 @@ void xf_ShowWindow(xfInfo* xfi, xfWindow* window, BYTE state) /* Save the current rail state of this window */ window->rail_state = state; - XFlush(xfi->display); + XFlush(xfc->display); } -void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon) +void xf_SetWindowIcon(xfContext* xfc, xfWindow* window, rdpIcon* icon) { int x, y; int pixels; @@ -827,13 +827,13 @@ void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon) } } - XChangeProperty(xfi->display, window->handle, xfi->_NET_WM_ICON, XA_CARDINAL, 32, + XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (BYTE*) propdata, propsize); - XFlush(xfi->display); + XFlush(xfc->display); } -void xf_SetWindowRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* rects, int nrects) +void xf_SetWindowRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects) { int i; XRectangle* xrects; @@ -857,13 +857,13 @@ void xf_SetWindowRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* rects, int n * * Marc: enabling it works, and is required for round corners. */ - XShapeCombineRectangles(xfi->display, window->handle, ShapeBounding, 0, 0, xrects, nrects, ShapeSet, 0); + XShapeCombineRectangles(xfc->display, window->handle, ShapeBounding, 0, 0, xrects, nrects, ShapeSet, 0); #endif free(xrects); } -void xf_SetWindowVisibilityRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* rects, int nrects) +void xf_SetWindowVisibilityRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects) { int i; XRectangle* xrects; @@ -887,13 +887,13 @@ void xf_SetWindowVisibilityRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* re * * Marc: enabling it works, and is required for round corners. */ - XShapeCombineRectangles(xfi->display, window->handle, ShapeBounding, 0, 0, xrects, nrects, ShapeSet, 0); + XShapeCombineRectangles(xfc->display, window->handle, ShapeBounding, 0, 0, xrects, nrects, ShapeSet, 0); #endif free(xrects); } -void xf_UpdateWindowArea(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height) +void xf_UpdateWindowArea(xfContext* xfc, xfWindow* window, int x, int y, int width, int height) { int ax, ay; rdpWindow* wnd; @@ -901,7 +901,7 @@ void xf_UpdateWindowArea(xfInfo* xfi, xfWindow* window, int x, int y, int width, /* RemoteApp mode uses visibleOffset instead of windowOffset */ - if (!xfi->remote_app) + if (!xfc->remote_app) { ax = x + wnd->windowOffsetX; ay = y + wnd->windowOffsetY; @@ -924,23 +924,23 @@ void xf_UpdateWindowArea(xfInfo* xfi, xfWindow* window, int x, int y, int width, height = (wnd->visibleOffsetY + wnd->windowHeight - 1) - ay; } - WaitForSingleObject(xfi->mutex, INFINITE); + WaitForSingleObject(xfc->mutex, INFINITE); - if (xfi->settings->SoftwareGdi) + if (xfc->settings->SoftwareGdi) { - XPutImage(xfi->display, xfi->primary, window->gc, xfi->image, + XPutImage(xfc->display, xfc->primary, window->gc, xfc->image, ax, ay, ax, ay, width, height); } - XCopyArea(xfi->display, xfi->primary, window->handle, window->gc, + XCopyArea(xfc->display, xfc->primary, window->handle, window->gc, ax, ay, width, height, x, y); - XFlush(xfi->display); + XFlush(xfc->display); - ReleaseMutex(xfi->mutex); + ReleaseMutex(xfc->mutex); } -BOOL xf_IsWindowBorder(xfInfo* xfi, xfWindow* xfw, int x, int y) +BOOL xf_IsWindowBorder(xfContext* xfc, xfWindow* xfw, int x, int y) { rdpWindow* wnd; BOOL clientArea = FALSE; @@ -959,41 +959,38 @@ BOOL xf_IsWindowBorder(xfInfo* xfi, xfWindow* xfw, int x, int y) return (windowArea && !(clientArea)); } -void xf_DestroyWindow(xfInfo* xfi, xfWindow* window) +void xf_DestroyWindow(xfContext* xfc, xfWindow* window) { if (window == NULL) return; - if (xfi->window == window) - xfi->window = NULL; + if (xfc->window == window) + xfc->window = NULL; if (window->gc) - XFreeGC(xfi->display, window->gc); + XFreeGC(xfc->display, window->gc); if (window->handle) { - XUnmapWindow(xfi->display, window->handle); - XDestroyWindow(xfi->display, window->handle); + XUnmapWindow(xfc->display, window->handle); + XDestroyWindow(xfc->display, window->handle); } free(window); } -rdpWindow* xf_rdpWindowFromWindow(xfInfo* xfi, Window wnd) +rdpWindow* xf_rdpWindowFromWindow(xfContext* xfc, Window wnd) { rdpRail* rail; - if (xfi != NULL) + if (xfc) { - if (wnd != 0) + if (wnd) { - if (xfi->_context != NULL) - { - rail = xfi->_context->rail; + rail = ((rdpContext*) xfc)->rail; - if (rail != NULL) - return window_list_get_by_extra_id(rail->list, (void*) (long) wnd); - } + if (rail) + return window_list_get_by_extra_id(rail->list, (void*) (long) wnd); } } diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h index 96d08be50..c501b8224 100644 --- a/client/X11/xf_window.h +++ b/client/X11/xf_window.h @@ -82,39 +82,39 @@ struct xf_window BOOL rail_ignore_configure; }; -void xf_ewmhints_init(xfInfo* xfi); +void xf_ewmhints_init(xfContext* xfc); -BOOL xf_GetCurrentDesktop(xfInfo* xfi); -BOOL xf_GetWorkArea(xfInfo* xfi); +BOOL xf_GetCurrentDesktop(xfContext* xfc); +BOOL xf_GetWorkArea(xfContext* xfc); -void xf_SetWindowFullscreen(xfInfo* xfi, xfWindow* window, BOOL fullscreen); -void xf_SetWindowDecorations(xfInfo* xfi, xfWindow* window, BOOL show); -void xf_SetWindowUnlisted(xfInfo* xfi, xfWindow* window); +void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen); +void xf_SetWindowDecorations(xfContext* xfc, xfWindow* window, BOOL show); +void xf_SetWindowUnlisted(xfContext* xfc, xfWindow* window); -xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, BOOL decorations); -void xf_ResizeDesktopWindow(xfInfo* xfi, xfWindow* window, int width, int height); +xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int height, BOOL decorations); +void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int height); -xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, int height, UINT32 id); -void xf_SetWindowText(xfInfo *xfi, xfWindow* window, char *name); -void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height); -void xf_ShowWindow(xfInfo* xfi, xfWindow* window, BYTE state); -void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon); -void xf_SetWindowRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* rects, int nrects); -void xf_SetWindowVisibilityRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* rects, int nrects); -void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, UINT32 style, UINT32 ex_style); -void xf_UpdateWindowArea(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height); -BOOL xf_IsWindowBorder(xfInfo* xfi, xfWindow* xfw, int x, int y); -void xf_DestroyWindow(xfInfo* xfi, xfWindow* window); -rdpWindow* xf_rdpWindowFromWindow(xfInfo* xfi, Window wnd); +xfWindow* xf_CreateWindow(xfContext* xfc, rdpWindow* wnd, int x, int y, int width, int height, UINT32 id); +void xf_SetWindowText(xfContext* xfc, xfWindow* window, char *name); +void xf_MoveWindow(xfContext* xfc, xfWindow* window, int x, int y, int width, int height); +void xf_ShowWindow(xfContext* xfc, xfWindow* window, BYTE state); +void xf_SetWindowIcon(xfContext* xfc, xfWindow* window, rdpIcon* icon); +void xf_SetWindowRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects); +void xf_SetWindowVisibilityRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects); +void xf_SetWindowStyle(xfContext* xfc, xfWindow* window, UINT32 style, UINT32 ex_style); +void xf_UpdateWindowArea(xfContext* xfc, xfWindow* window, int x, int y, int width, int height); +BOOL xf_IsWindowBorder(xfContext* xfc, xfWindow* xfw, int x, int y); +void xf_DestroyWindow(xfContext* xfc, xfWindow* window); +rdpWindow* xf_rdpWindowFromWindow(xfContext* xfc, Window wnd); -BOOL xf_GetWindowProperty(xfInfo* xfi, Window window, Atom property, int length, +BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property, int length, unsigned long* nitems, unsigned long* bytes, BYTE** prop); -void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window, int maxWidth, int maxHeight, +void xf_SetWindowMinMaxInfo(xfContext* xfc, xfWindow* window, int maxWidth, int maxHeight, int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight); -void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, int direction, int x, int y); -void xf_EndLocalMoveSize(xfInfo *xfi, xfWindow *window); -void xf_SendClientEvent(xfInfo *xfi, xfWindow* window, Atom atom, unsigned int numArgs, ...); +void xf_StartLocalMoveSize(xfContext* xfc, xfWindow* window, int direction, int x, int y); +void xf_EndLocalMoveSize(xfContext* xfc, xfWindow *window); +void xf_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned int numArgs, ...); #endif /* __XF_WINDOW_H */ diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 19417d0d6..e9bf35144 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -54,18 +54,11 @@ struct xf_glyph }; typedef struct xf_glyph xfGlyph; -typedef struct xf_context xfContext; - struct xf_context { - rdpContext _p; - - xfInfo* xfi; + rdpContext context; freerdp* instance; - xfContext* context; - rdpContext* _context; - rdpClient* client; rdpSettings* settings; @@ -165,8 +158,8 @@ struct xf_context RdpeiClientContext* rdpei; }; -void xf_create_window(xfInfo* xfi); -void xf_toggle_fullscreen(xfInfo* xfi); +void xf_create_window(xfContext* xfc); +void xf_toggle_fullscreen(xfContext* xfc); BOOL xf_post_connect(freerdp* instance); enum XF_EXIT_CODE @@ -210,10 +203,10 @@ enum XF_EXIT_CODE XF_EXIT_UNKNOWN = 255, }; -void xf_lock_x11(xfInfo* xfi, BOOL display); -void xf_unlock_x11(xfInfo* xfi, BOOL display); +void xf_lock_x11(xfContext* xfc, BOOL display); +void xf_unlock_x11(xfContext* xfc, BOOL display); -void xf_draw_screen_scaled(xfInfo* xfi); +void xf_draw_screen_scaled(xfContext* xfc); DWORD xf_exit_code_from_disconnect_reason(DWORD reason);