Hand-apply patches (rail improvements) from Authentic8 branch: 6e15b4a 2c99e69 3f30429 aad2aaa 4f8481e 5117ac2 f3dcf1a
This commit is contained in:
parent
3221caff62
commit
3ae1b415a1
@ -525,19 +525,6 @@ process_message_channel_data(struct stream *s)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
process_message_channel_rail_title_request(struct stream* s)
|
||||
{
|
||||
int window_id;
|
||||
LOG(10, ("process_message_channel_rail_title_request:"));
|
||||
|
||||
in_uint32_le(s, window_id);
|
||||
rail_request_title(window_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
@ -595,9 +582,6 @@ process_message(void)
|
||||
case 7: /* channel data response */
|
||||
rv = process_message_channel_data_response(s);
|
||||
break;
|
||||
case 9:
|
||||
rv = process_message_channel_rail_title_request(s);
|
||||
break;
|
||||
default:
|
||||
LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ",
|
||||
"unknown msg %d", id));
|
||||
|
@ -43,6 +43,7 @@ extern Atom g_wm_delete_window_atom; /* in xcommon.c */
|
||||
extern Atom g_wm_protocols_atom; /* in xcommon.c */
|
||||
extern Atom g_utf8_string; /* in xcommon.c */
|
||||
extern Atom g_net_wm_name; /* in xcommon.c */
|
||||
extern Atom g_wm_state; /* in xcommon.c */
|
||||
|
||||
int g_rail_up = 0;
|
||||
|
||||
@ -103,6 +104,24 @@ static int g_rail_running = 1;
|
||||
/* Perform the default action of the window's system menu. */
|
||||
#define SC_DEFAULT 0xF160
|
||||
|
||||
/* for tooltips */
|
||||
#define RAIL_STYLE_TOOLTIP (0x80000000)
|
||||
#define RAIL_EXT_STYLE_TOOLTIP (0x00000080 | 0x00000008)
|
||||
|
||||
/* for normal desktop windows */
|
||||
#define RAIL_STYLE_NORMAL (0x00C00000 | 0x00080000 | 0x00040000 | 0x00010000 | 0x00020000)
|
||||
#define RAIL_EXT_STYLE_NORMAL (0x00040000)
|
||||
|
||||
/* for dialogs */
|
||||
#define RAIL_STYLE_DIALOG (0x80000000)
|
||||
#define RAIL_EXT_STYLE_DIALOG (0x00040000)
|
||||
|
||||
static int APP_CC rail_win_get_state(Window win);
|
||||
static int APP_CC rail_create_window(Window window_id, Window parent_id);
|
||||
static int APP_CC rail_win_set_state(Window win, unsigned long state);
|
||||
static int APP_CC rail_show_window(Window window_id, int show_state);
|
||||
static int APP_CC rail_win_send_text(Window win);
|
||||
|
||||
/******************************************************************************/
|
||||
static int APP_CC
|
||||
is_window_valid_child_of_root(unsigned int window_id)
|
||||
@ -260,7 +279,6 @@ read_uni(struct stream *s, int num_chars)
|
||||
static int APP_CC
|
||||
rail_process_exec(struct stream *s, int size)
|
||||
{
|
||||
int pid;
|
||||
int flags;
|
||||
int ExeOrFileLength;
|
||||
int WorkingDirLength;
|
||||
@ -307,6 +325,10 @@ rail_close_window(int window_id)
|
||||
XEvent ce;
|
||||
|
||||
LOG(0, ("chansrv::rail_close_window:"));
|
||||
|
||||
/* don't receive UnmapNotify for closing window */
|
||||
XSelectInput(g_display, window_id, PropertyChangeMask);
|
||||
|
||||
g_memset(&ce, 0, sizeof(ce));
|
||||
ce.xclient.type = ClientMessage;
|
||||
ce.xclient.message_type = g_wm_protocols_atom;
|
||||
@ -341,14 +363,48 @@ rail_process_activate(struct stream *s, int size)
|
||||
XWindowAttributes window_attributes;
|
||||
XGetWindowAttributes(g_display, window_id, &window_attributes);
|
||||
|
||||
LOG(10, (" window attributes: override_redirect %d",
|
||||
window_attributes.override_redirect));
|
||||
if (window_attributes.override_redirect) {
|
||||
LOG(10, (" dismiss popup window 0x%8.8x", window_id));
|
||||
rail_close_window(window_id);
|
||||
XUnmapWindow(g_display, window_id);
|
||||
//rail_win_set_state(window_id, 0x3);
|
||||
//rail_show_window(window_id, 0x0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_restore_windows(void)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int nchild;
|
||||
Window r;
|
||||
Window p;
|
||||
Window* children;
|
||||
|
||||
XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild);
|
||||
for (i = 0; i < nchild; i++)
|
||||
{
|
||||
XWindowAttributes window_attributes;
|
||||
XGetWindowAttributes(g_display, children[i], &window_attributes);
|
||||
if (!window_attributes.override_redirect)
|
||||
{
|
||||
if (window_attributes.map_state == IsViewable)
|
||||
{
|
||||
rail_win_set_state(children[i], 0x0); /* WithdrawnState */
|
||||
rail_create_window(children[i], g_root_window);
|
||||
rail_win_set_state(children[i], 0x1); /* NormalState */
|
||||
rail_win_send_text(children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
XFree(children);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_system_param(struct stream *s, int size)
|
||||
@ -358,9 +414,137 @@ rail_process_system_param(struct stream *s, int size)
|
||||
LOG(10, ("chansrv::rail_process_system_param:"));
|
||||
in_uint32_le(s, system_param);
|
||||
LOG(10, (" system_param 0x%8.8x", system_param));
|
||||
/*
|
||||
* Ask client to re-create the existing rail windows. This is supposed
|
||||
* to be done after handshake and client is initialised properly, we
|
||||
* consider client is ready when it sends "SET_WORKAREA" sysparam.
|
||||
*/
|
||||
if (system_param == 0x0000002F) /*SPI_SET_WORK_AREA*/
|
||||
{
|
||||
LOG(10, (" restore rail windows"));
|
||||
rail_restore_windows();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_get_property(Display* display, Window target, Atom type, Atom property,
|
||||
unsigned char** data, unsigned long* count)
|
||||
{
|
||||
Atom atom_return;
|
||||
int size;
|
||||
unsigned long nitems, bytes_left;
|
||||
char* prop_name;
|
||||
|
||||
int ret = XGetWindowProperty(display, target, property,
|
||||
0l, 1l, False,
|
||||
type, &atom_return, &size,
|
||||
&nitems, &bytes_left, data);
|
||||
if ((ret != Success || nitems < 1) && atom_return == None)
|
||||
{
|
||||
prop_name = XGetAtomName(g_display, property);
|
||||
LOG(10, (" rail_get_property %s: failed", prop_name));
|
||||
XFree(prop_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bytes_left != 0)
|
||||
{
|
||||
XFree(*data);
|
||||
unsigned long remain = ((size / 8) * nitems) + bytes_left;
|
||||
ret = XGetWindowProperty(g_display, target,
|
||||
property, 0l, remain, False,
|
||||
atom_return, &atom_return, &size,
|
||||
&nitems, &bytes_left, data);
|
||||
if (ret != Success)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
*count = nitems;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_win_get_state(Window win)
|
||||
{
|
||||
unsigned long nitems = 0;
|
||||
int rv = -1;
|
||||
char* data = 0;
|
||||
|
||||
rail_get_property(g_display, win, g_wm_state, g_wm_state,
|
||||
(unsigned char **)&data,
|
||||
&nitems);
|
||||
|
||||
if (data || nitems > 0)
|
||||
{
|
||||
rv = *(unsigned long *)data;
|
||||
XFree(data);
|
||||
LOG(10, (" rail_win_get_state: %d", rv));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_win_set_state(Window win, unsigned long state)
|
||||
{
|
||||
int old_state;
|
||||
unsigned long data[2] = { state, None };
|
||||
|
||||
LOG(10, (" rail_win_set_state: %d", state));
|
||||
/* check whether WM_STATE exists */
|
||||
old_state = rail_win_get_state(win);
|
||||
if (old_state == -1)
|
||||
{
|
||||
/* create WM_STATE property */
|
||||
XChangeProperty(g_display, win, g_wm_state, g_wm_state, 32, PropModeAppend,
|
||||
(unsigned char *)data, 2);
|
||||
LOG(10, (" rail_win_set_state: create WM_STATE property"));
|
||||
}
|
||||
else
|
||||
{
|
||||
XChangeProperty(g_display, win, g_wm_state, g_wm_state, 32, PropModeReplace,
|
||||
(unsigned char *)data, 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_win_get_text(Window win, char **data)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
unsigned long nitems = 0;
|
||||
|
||||
ret = rail_get_property(g_display, win, g_utf8_string, g_net_wm_name,
|
||||
(unsigned char **)data, &nitems);
|
||||
if (ret != 0)
|
||||
{
|
||||
/* _NET_WM_NAME isn't set, use WM_NAME (XFetchName) instead */
|
||||
XFetchName(g_display, win, data);
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
char *ptr = *data;
|
||||
for (; ptr != NULL; i++)
|
||||
{
|
||||
if (ptr[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int APP_CC
|
||||
rail_minmax_window(int window_id, int max)
|
||||
@ -371,8 +555,13 @@ rail_minmax_window(int window_id, int max)
|
||||
|
||||
} else {
|
||||
XUnmapWindow(g_display, window_id);
|
||||
LOG(10, (" XUnmapWindow"));
|
||||
/* change window state to IconicState (3) */
|
||||
rail_win_set_state(window_id, 0x3);
|
||||
/*
|
||||
* TODO dismiss popups opened so far
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -380,8 +569,12 @@ static int APP_CC
|
||||
rail_restore_window(int window_id)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_restore_window 0x%8.8x:", window_id));
|
||||
LOG(10, (" XMapWindow"));
|
||||
XMapWindow(g_display, window_id);
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id));
|
||||
XRaiseWindow(g_display, window_id);
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id));
|
||||
XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -651,73 +844,27 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length,
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
rail_get_property(Display *display, Window target, Atom type, Atom property,
|
||||
unsigned char** data, unsigned long* count) {
|
||||
Atom atom_return;
|
||||
int size;
|
||||
unsigned long nitems, bytes_left;
|
||||
|
||||
int ret = XGetWindowProperty(display, target, property,
|
||||
0l, 1l, False,
|
||||
type, &atom_return, &size,
|
||||
&nitems, &bytes_left, data);
|
||||
if (ret != Success || nitems < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bytes_left != 0)
|
||||
{
|
||||
XFree(*data);
|
||||
unsigned long remain = ((size / 8) * nitems) + bytes_left;
|
||||
ret = XGetWindowProperty(g_display, target,
|
||||
property, 0l, remain, False,
|
||||
type, &atom_return, &size,
|
||||
&nitems, &bytes_left, data);
|
||||
if (ret != Success)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
*count = nitems;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
const int APP_CC
|
||||
rail_send_win_text(Display *disp, Window win) {
|
||||
unsigned char *data = 0;
|
||||
unsigned long nitems = 0;
|
||||
/* returns 0, event handled, 1 unhandled */
|
||||
static int APP_CC
|
||||
rail_win_send_text(Window win) {
|
||||
char* data = 0;
|
||||
struct stream* s;
|
||||
int len = 0;
|
||||
int flags;
|
||||
|
||||
rail_get_property(disp, win, g_utf8_string, g_net_wm_name,
|
||||
&data, &nitems);
|
||||
if (nitems == 0)
|
||||
{
|
||||
/* _NET_WM_NAME isn't set, use WM_NAME (XFetchName) instead */
|
||||
XFetchName(disp, win, (char **)&data);
|
||||
}
|
||||
len = rail_win_get_text(win, &data);
|
||||
|
||||
if (data)
|
||||
{
|
||||
int i = 0;
|
||||
for (;;i++)
|
||||
{
|
||||
if (data[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOG(10, ("rail_send_win_text: 0x%8.8x text 0x%x size %d", win, data, i));
|
||||
if (data && len > 0) {
|
||||
LOG(10, ("chansrv::rail_win_send_text: 0x%8.8x text %s length %d",
|
||||
win, data, len));
|
||||
make_stream(s);
|
||||
init_stream(s, 1024);
|
||||
|
||||
out_uint32_le(s, 2); /* update title info */
|
||||
flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_FIELD_TITLE;
|
||||
out_uint32_le(s, 8); /* update title info */
|
||||
out_uint32_le(s, win); /* window id */
|
||||
out_uint32_le(s, i); /* title size */
|
||||
out_uint8a(s, data, i); /* title */
|
||||
out_uint32_le(s, flags); /* flags */
|
||||
out_uint32_le(s, len); /* title size */
|
||||
out_uint8a(s, data, len); /* title */
|
||||
s_mark_end(s);
|
||||
send_rail_drawing_orders(s->data, (int)(s->end - s->data));
|
||||
free_stream(s);
|
||||
@ -727,10 +874,173 @@ rail_send_win_text(Display *disp, Window win) {
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
rail_request_title(int window_id)
|
||||
static int APP_CC
|
||||
rail_destroy_window(Window window_id)
|
||||
{
|
||||
return rail_send_win_text(g_display, (Window)window_id);
|
||||
LOG(10, ("chansrv::rail_destroy_window 0x%8.8x", window_id));
|
||||
make_stream(s);
|
||||
init_stream(s, 1024);
|
||||
|
||||
out_uint32_le(s, 4); /* destroy_window */
|
||||
out_uint32_le(s, window_id);
|
||||
s_mark_end(s);
|
||||
send_rail_drawing_orders(s->data, (int)(s->end - s->data));
|
||||
free_stream(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_show_window(Window window_id, int show_state)
|
||||
{
|
||||
int flags;
|
||||
struct stream* s;
|
||||
|
||||
LOG(10, ("chansrv::rail_show_window 0x%8.8x 0x%x", window_id, show_state));
|
||||
make_stream(s);
|
||||
init_stream(s, 1024);
|
||||
|
||||
flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_FIELD_SHOW;
|
||||
out_uint32_le(s, 6); /* show_window */
|
||||
out_uint32_le(s, window_id); /* window_id */
|
||||
out_uint32_le(s, flags); /* flags */
|
||||
out_uint32_le(s, show_state); /* show_state */
|
||||
s_mark_end(s);
|
||||
send_rail_drawing_orders(s->data, (int)(s->end - s->data));
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_create_window(Window window_id, Window parent_id)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
tui32 width;
|
||||
tui32 height;
|
||||
tui32 border;
|
||||
Window root;
|
||||
tui32 depth;
|
||||
char* title_bytes = 0;
|
||||
int title_size = 0;
|
||||
XWindowAttributes attributes;
|
||||
int style;
|
||||
int ext_style;
|
||||
int num_window_rects = 1;
|
||||
int num_visibility_rects = 1;
|
||||
int i = 0;
|
||||
|
||||
int flags;
|
||||
int state;
|
||||
struct stream* s;
|
||||
|
||||
LOG(10, ("chansrv::rail_create_window 0x%8.8x", window_id));
|
||||
|
||||
XGetGeometry(g_display, window_id, &root, &x, &y, &width, &height,
|
||||
&border, &depth);
|
||||
XGetWindowAttributes(g_display, window_id, &attributes);
|
||||
|
||||
LOG(10, (" x %d y %d width %d height %d border_width %d", x, y, width,
|
||||
height, border));
|
||||
|
||||
state = rail_win_get_state(window_id);
|
||||
if ((state == 0) || (state == -1))
|
||||
{
|
||||
LOG(10, (" create new window"));
|
||||
flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_STATE_NEW;
|
||||
list_add_item(g_window_list, window_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(10, (" update existing window"));
|
||||
flags = WINDOW_ORDER_TYPE_WINDOW;
|
||||
}
|
||||
|
||||
title_size = rail_win_get_text(window_id, &title_bytes);
|
||||
|
||||
if (attributes.override_redirect)
|
||||
{
|
||||
style = RAIL_STYLE_TOOLTIP;
|
||||
ext_style = RAIL_EXT_STYLE_TOOLTIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
style = RAIL_STYLE_NORMAL;
|
||||
ext_style = RAIL_EXT_STYLE_NORMAL;
|
||||
}
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 1024);
|
||||
|
||||
out_uint32_le(s, 2); /* create_window */
|
||||
out_uint32_le(s, window_id); /* window_id */
|
||||
out_uint32_le(s, parent_id); /* owner_window_id */
|
||||
flags |= WINDOW_ORDER_FIELD_OWNER;
|
||||
out_uint32_le(s, style); /* style */
|
||||
out_uint32_le(s, ext_style); /* extended_style */
|
||||
flags |= WINDOW_ORDER_FIELD_STYLE;
|
||||
out_uint32_le(s, 0x05); /* show_state */
|
||||
flags |= WINDOW_ORDER_FIELD_SHOW;
|
||||
if (title_size > 0)
|
||||
{
|
||||
out_uint16_le(s, title_size); /* title_size */
|
||||
out_uint8a(s, title_bytes, title_size); /* title */
|
||||
}
|
||||
else
|
||||
{
|
||||
out_uint16_le(s, 5); /* title_size */
|
||||
out_uint8a(s, "title", 5); /* title */
|
||||
}
|
||||
LOG(10, (" set title info %d", title_size));
|
||||
flags |= WINDOW_ORDER_FIELD_TITLE;
|
||||
out_uint32_le(s, 0); /* client_offset_x */
|
||||
out_uint32_le(s, 0); /* client_offset_y */
|
||||
flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET;
|
||||
out_uint32_le(s, width); /* client_area_width */
|
||||
out_uint32_le(s, height); /* client_area_height */
|
||||
flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE;
|
||||
out_uint32_le(s, 0); /* rp_content */
|
||||
out_uint32_le(s, g_root_window); /* root_parent_handle */
|
||||
flags |= WINDOW_ORDER_FIELD_ROOT_PARENT;
|
||||
out_uint32_le(s, x); /* window_offset_x */
|
||||
out_uint32_le(s, y); /* window_offset_y */
|
||||
flags |= WINDOW_ORDER_FIELD_WND_OFFSET;
|
||||
out_uint32_le(s, 0); /* window_client_delta_x */
|
||||
out_uint32_le(s, 0); /* window_client_delta_y */
|
||||
flags |= WINDOW_ORDER_FIELD_WND_CLIENT_DELTA;
|
||||
out_uint32_le(s, width); /* window_width */
|
||||
out_uint32_le(s, height); /* window_height */
|
||||
flags |= WINDOW_ORDER_FIELD_WND_SIZE;
|
||||
out_uint16_le(s, num_window_rects); /* num_window_rects */
|
||||
for (i = 0; i < num_window_rects; i++)
|
||||
{
|
||||
out_uint16_le(s, 0); /* left */
|
||||
out_uint16_le(s, 0); /* top */
|
||||
out_uint16_le(s, width); /* right */
|
||||
out_uint16_le(s, height); /* bottom */
|
||||
}
|
||||
flags |= WINDOW_ORDER_FIELD_WND_RECTS;
|
||||
out_uint32_le(s, x); /* visible_offset_x */
|
||||
out_uint32_le(s, y); /* visible_offset_y */
|
||||
flags |= WINDOW_ORDER_FIELD_VIS_OFFSET;
|
||||
out_uint16_le(s, num_visibility_rects); /* num_visibility_rects */
|
||||
for (i = 0; i < num_visibility_rects; i++)
|
||||
{
|
||||
out_uint16_le(s, 0); /* left */
|
||||
out_uint16_le(s, 0); /* top */
|
||||
out_uint16_le(s, width); /* right */
|
||||
out_uint16_le(s, height); /* bottom */
|
||||
}
|
||||
flags |= WINDOW_ORDER_FIELD_VISIBILITY;
|
||||
out_uint32_le(s, flags); /*flags*/
|
||||
|
||||
s_mark_end(s);
|
||||
send_rail_drawing_orders(s->data, (int)(s->end - s->data));
|
||||
free_stream(s);
|
||||
XFree(title_bytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -741,12 +1051,6 @@ rail_xevent(void *xevent)
|
||||
XEvent *lxevent;
|
||||
XWindowChanges xwc;
|
||||
int rv;
|
||||
int nchildren_return = 0;
|
||||
Window root_return;
|
||||
Window parent_return;
|
||||
Window *children_return;
|
||||
Window wreturn;
|
||||
int revert_to;
|
||||
XWindowAttributes wnd_attributes;
|
||||
char* prop_name;
|
||||
|
||||
@ -764,14 +1068,20 @@ rail_xevent(void *xevent)
|
||||
{
|
||||
case PropertyNotify:
|
||||
prop_name = XGetAtomName(g_display, lxevent->xproperty.atom);
|
||||
LOG(10, (" got PropertyNotify window_id 0x%8.8x %s",
|
||||
lxevent->xproperty.window, prop_name));
|
||||
if (strcmp(prop_name, "WM_NAME") == 0 ||
|
||||
strcmp(prop_name, "_NEW_WM_NAME") == 0)
|
||||
LOG(10, (" got PropertyNotify window_id 0x%8.8x %s state new %d",
|
||||
lxevent->xproperty.window, prop_name,
|
||||
lxevent->xproperty.state == PropertyNewValue));
|
||||
if (g_strcmp(prop_name, "WM_NAME") == 0 ||
|
||||
g_strcmp(prop_name, "_NET_WM_NAME") == 0)
|
||||
{
|
||||
rail_send_win_text(g_display, lxevent->xproperty.window);
|
||||
rv = 0;
|
||||
XGetWindowAttributes(g_display, lxevent->xproperty.window, &wnd_attributes);
|
||||
if (wnd_attributes.map_state == IsViewable)
|
||||
{
|
||||
rail_win_send_text(lxevent->xproperty.window);
|
||||
rv = 0;
|
||||
}
|
||||
}
|
||||
XFree(prop_name);
|
||||
break;
|
||||
case ConfigureRequest:
|
||||
LOG(10, (" got ConfigureRequest window_id 0x%8.8x", lxevent->xconfigurerequest.window));
|
||||
@ -791,24 +1101,67 @@ rail_xevent(void *xevent)
|
||||
break;
|
||||
|
||||
case CreateNotify:
|
||||
LOG(10, (" got CreateNotify"));
|
||||
LOG(10, (" got CreateNotify 0x%8.8x", lxevent->xcreatewindow.window));
|
||||
XSelectInput(g_display, lxevent->xcreatewindow.window,
|
||||
PropertyChangeMask | StructureNotifyMask);
|
||||
rail_win_set_state(lxevent->xcreatewindow.window, 0x0); /* WithdrawnState */
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
LOG(10, (" got DestroyNotify 0x%8.8x", lxevent->xdestroywindow.window));
|
||||
/*
|
||||
* FIXME The destroy msg may be sent from a non-rail window. Ideally,
|
||||
* this will be handled by client, but we better have to maintain
|
||||
* a list of managed rail windows here.
|
||||
*/
|
||||
rail_destroy_window(lxevent->xdestroywindow.window);
|
||||
v = 0;
|
||||
break;
|
||||
|
||||
case MapRequest:
|
||||
LOG(10, (" got MapRequest"));
|
||||
LOG(10, (" got MapRequest 0x%8.8x", lxevent->xmaprequest.window));
|
||||
XMapWindow(g_display, lxevent->xmaprequest.window);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
LOG(10, (" got MapNotify"));
|
||||
LOG(10, (" got MapNotify 0x%8.8x", lxevent->xmap.event));
|
||||
if (lxevent->xmap.window != lxevent->xmap.event)
|
||||
{
|
||||
XGetWindowAttributes(g_display, lxevent->xmap.window, &wnd_attributes);
|
||||
if (wnd_attributes.map_state == IsViewable)
|
||||
{
|
||||
rail_create_window(lxevent->xmap.window, lxevent->xmap.event);
|
||||
rail_win_set_state(lxevent->xmap.window, 0x1); /* NormalState */
|
||||
if (!wnd_attributes.override_redirect)
|
||||
{
|
||||
rail_win_send_text(lxevent->xmap.window);
|
||||
}
|
||||
rv = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case UnmapNotify:
|
||||
LOG(10, (" got UnmapNotify"));
|
||||
LOG(10, (" got UnmapNotify 0x%8.8x", lxevent->xunmap.event));
|
||||
if (lxevent->xunmap.window == lxevent->xunmap.event &&
|
||||
is_window_valid_child_of_root(lxevent->xunmap.window))
|
||||
{
|
||||
int state = rail_win_get_state(lxevent->xunmap.window);
|
||||
LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window));
|
||||
if (state != -1 && state != 0x3)
|
||||
{
|
||||
LOG(10, (" trying to dismiss popup"));
|
||||
XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes);
|
||||
if (wnd_attributes.override_redirect)
|
||||
{
|
||||
rail_show_window(lxevent->xunmap.window, 0x0);
|
||||
rail_win_set_state(lxevent->xunmap.window, 0x3);
|
||||
rv = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef _RAIL_H_
|
||||
#define _RAIL_H_
|
||||
|
||||
#include "../../common/rail.h"
|
||||
#include "arch.h"
|
||||
#include "parse.h"
|
||||
|
||||
|
@ -42,6 +42,7 @@ Atom g_wm_delete_window_atom = 0;
|
||||
Atom g_wm_protocols_atom = 0;
|
||||
Atom g_utf8_string = 0;
|
||||
Atom g_net_wm_name = 0;
|
||||
Atom g_wm_state = 0;
|
||||
|
||||
/*****************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
@ -119,8 +120,9 @@ xcommon_init(void)
|
||||
|
||||
g_wm_delete_window_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", 0);
|
||||
g_wm_protocols_atom = XInternAtom(g_display, "WM_PROTOCOLS", 0);
|
||||
g_utf8_string = XInternAtom(g_display, "UTF8_STRIING", 0);
|
||||
g_utf8_string = XInternAtom(g_display, "UTF8_STRING", 0);
|
||||
g_net_wm_name = XInternAtom(g_display, "_NET_WM_NAME", 0);
|
||||
g_wm_state = XInternAtom(g_display, "WM_STATE", 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -824,8 +824,10 @@ rdpDestroyWindow(WindowPtr pWindow)
|
||||
|
||||
if (g_use_rail)
|
||||
{
|
||||
#ifdef XRDP_WM_RDPUP
|
||||
LLOGLN(10, (" rdpup_delete_window"));
|
||||
rdpup_delete_window(pWindow, priv);
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -887,7 +889,9 @@ rdpRealizeWindow(WindowPtr pWindow)
|
||||
pWindow->drawable.x, pWindow->drawable.y,
|
||||
pWindow->drawable.width, pWindow->drawable.height));
|
||||
priv->status = 1;
|
||||
#ifdef XRDP_WM_RDPUP
|
||||
rdpup_create_window(pWindow, priv);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -917,6 +921,7 @@ rdpUnrealizeWindow(WindowPtr pWindow)
|
||||
LLOGLN(10, ("rdpUnrealizeWindow:"));
|
||||
priv->status = 0;
|
||||
if (pWindow->overrideRedirect) {
|
||||
#ifdef XRDP_WM_RDPUP
|
||||
/*
|
||||
* Popups are unmapped by X server, so probably
|
||||
* they will be mapped again. Thereby we should
|
||||
@ -925,6 +930,7 @@ rdpUnrealizeWindow(WindowPtr pWindow)
|
||||
*/
|
||||
LLOGLN(10, (" rdpup_show_window"));
|
||||
rdpup_show_window(pWindow, priv, 0x0); /* 0x0 - do not show the window */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +760,9 @@ rdpup_process_msg(struct stream *s)
|
||||
if (g_rdpScreen.client_info.rail_support_level > 0)
|
||||
{
|
||||
g_use_rail = 1;
|
||||
#ifdef XRDP_WM_RDPUP
|
||||
rdpup_send_rail();
|
||||
#endif
|
||||
}
|
||||
if (g_rdpScreen.client_info.offscreen_cache_entries == 2000)
|
||||
{
|
||||
|
200
xrdp/xrdp_mm.c
200
xrdp/xrdp_mm.c
@ -676,28 +676,157 @@ xrdp_mm_trans_process_channel_data(struct xrdp_mm *self, struct trans *trans)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
/* returns error
|
||||
process rail create window order */
|
||||
static int APP_CC
|
||||
xrdp_mm_trans_send_channel_rail_title_request(struct xrdp_mm* self,
|
||||
int window_id)
|
||||
xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s)
|
||||
{
|
||||
struct stream* s;
|
||||
int flags;
|
||||
int window_id;
|
||||
int title_bytes;
|
||||
int index;
|
||||
int bytes;
|
||||
int rv;
|
||||
struct rail_window_state_order rwso;
|
||||
|
||||
s = trans_get_out_s(self->chan_trans, 8192);
|
||||
g_writeln("xrdp_mm_trans_send_channel_rail_title_request: 0x%8.8x",
|
||||
window_id);
|
||||
g_memset(&rwso, 0, sizeof(rwso));
|
||||
in_uint32_le(s, window_id);
|
||||
|
||||
if (s == 0)
|
||||
g_writeln("xrdp_mm_process_rail_create_window: 0x%8.8x", window_id);
|
||||
|
||||
in_uint32_le(s, rwso.owner_window_id);
|
||||
in_uint32_le(s, rwso.style);
|
||||
in_uint32_le(s, rwso.extended_style);
|
||||
in_uint32_le(s, rwso.show_state);
|
||||
in_uint16_le(s, title_bytes);
|
||||
if (title_bytes > 0)
|
||||
{
|
||||
return 1;
|
||||
rwso.title_info = g_malloc(title_bytes + 1, 0);
|
||||
in_uint8a(s, rwso.title_info, title_bytes);
|
||||
rwso.title_info[title_bytes] = 0;
|
||||
}
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8 + 4); /* size */
|
||||
out_uint32_le(s, 9); /* msg id */
|
||||
out_uint32_le(s, 8 + 4); /* size */
|
||||
out_uint32_le(s, window_id);
|
||||
s_mark_end(s);
|
||||
return trans_force_write(self->chan_trans);
|
||||
in_uint32_le(s, rwso.client_offset_x);
|
||||
in_uint32_le(s, rwso.client_offset_y);
|
||||
in_uint32_le(s, rwso.client_area_width);
|
||||
in_uint32_le(s, rwso.client_area_height);
|
||||
in_uint32_le(s, rwso.rp_content);
|
||||
in_uint32_le(s, rwso.root_parent_handle);
|
||||
in_uint32_le(s, rwso.window_offset_x);
|
||||
in_uint32_le(s, rwso.window_offset_y);
|
||||
in_uint32_le(s, rwso.window_client_delta_x);
|
||||
in_uint32_le(s, rwso.window_client_delta_y);
|
||||
in_uint32_le(s, rwso.window_width);
|
||||
in_uint32_le(s, rwso.window_height);
|
||||
in_uint16_le(s, rwso.num_window_rects);
|
||||
if (rwso.num_window_rects > 0)
|
||||
{
|
||||
bytes = sizeof(struct rail_window_rect) * rwso.num_window_rects;
|
||||
rwso.window_rects = (struct rail_window_rect*)g_malloc(bytes, 0);
|
||||
for (index = 0; index < rwso.num_window_rects; index++)
|
||||
{
|
||||
in_uint16_le(s, rwso.window_rects[index].left);
|
||||
in_uint16_le(s, rwso.window_rects[index].top);
|
||||
in_uint16_le(s, rwso.window_rects[index].right);
|
||||
in_uint16_le(s, rwso.window_rects[index].bottom);
|
||||
}
|
||||
}
|
||||
in_uint32_le(s, rwso.visible_offset_x);
|
||||
in_uint32_le(s, rwso.visible_offset_y);
|
||||
in_uint16_le(s, rwso.num_visibility_rects);
|
||||
if (rwso.num_visibility_rects > 0)
|
||||
{
|
||||
bytes = sizeof(struct rail_window_rect) * rwso.num_visibility_rects;
|
||||
rwso.visibility_rects = (struct rail_window_rect*)g_malloc(bytes, 0);
|
||||
for (index = 0; index < rwso.num_visibility_rects; index++)
|
||||
{
|
||||
in_uint16_le(s, rwso.visibility_rects[index].left);
|
||||
in_uint16_le(s, rwso.visibility_rects[index].top);
|
||||
in_uint16_le(s, rwso.visibility_rects[index].right);
|
||||
in_uint16_le(s, rwso.visibility_rects[index].bottom);
|
||||
}
|
||||
}
|
||||
in_uint32_le(s, flags);
|
||||
rv = libxrdp_orders_init(self->wm->session);
|
||||
rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags);
|
||||
rv = libxrdp_orders_send(self->wm->session);
|
||||
g_free(rwso.title_info);
|
||||
g_free(rwso.window_rects);
|
||||
g_free(rwso.visibility_rects);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error
|
||||
process rail destroy window order */
|
||||
static int APP_CC
|
||||
xrdp_mm_process_rail_destroy_window(struct xrdp_mm* self, struct stream* s)
|
||||
{
|
||||
int window_id;
|
||||
int rv;
|
||||
|
||||
in_uint32_le(s, window_id);
|
||||
g_writeln("xrdp_mm_process_rail_destroy_window 0x%8.8x", window_id);
|
||||
rv = libxrdp_orders_init(self->wm->session);
|
||||
rv = libxrdp_window_delete(self->wm->session, window_id);
|
||||
rv = libxrdp_orders_send(self->wm->session);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error
|
||||
process rail update window (show state) order */
|
||||
static int APP_CC
|
||||
xrdp_mm_process_rail_show_window(struct xrdp_mm* self, struct stream* s)
|
||||
{
|
||||
int window_id;
|
||||
int rv;
|
||||
int flags;
|
||||
struct rail_window_state_order rwso;
|
||||
|
||||
g_memset(&rwso, 0, sizeof(rwso));
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint32_le(s, flags);
|
||||
in_uint32_le(s, rwso.show_state);
|
||||
g_writeln("xrdp_mm_process_rail_show_window 0x%8.8x %x", window_id,
|
||||
rwso.show_state);
|
||||
rv = libxrdp_orders_init(self->wm->session);
|
||||
rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags);
|
||||
rv = libxrdp_orders_send(self->wm->session);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error
|
||||
process rail update window (title) order */
|
||||
static int APP_CC
|
||||
xrdp_mm_process_rail_update_window_text(struct xrdp_mm* self, struct stream* s)
|
||||
{
|
||||
int size;
|
||||
int flags;
|
||||
int rv = 0;
|
||||
int window_id;
|
||||
struct rail_window_state_order rwso;
|
||||
|
||||
g_writeln("xrdp_mm_process_rail_update_window_text:");
|
||||
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint32_le(s, flags);
|
||||
g_writeln(" update window title info: 0x%8.8x", window_id);
|
||||
|
||||
g_memset(&rwso, 0, sizeof(rwso));
|
||||
in_uint32_le(s, size); /* title size */
|
||||
rwso.title_info = g_malloc(size + 1, 0);
|
||||
in_uint8a(s, rwso.title_info, size);
|
||||
rwso.title_info[size] = 0;
|
||||
g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags);
|
||||
rv = libxrdp_orders_init(self->wm->session);
|
||||
rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags);
|
||||
rv = libxrdp_orders_send(self->wm->session);
|
||||
g_writeln(" set window title %s %d", rwso.title_info, rv);
|
||||
|
||||
g_free(rwso.title_info);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -707,15 +836,10 @@ static int APP_CC
|
||||
xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans)
|
||||
{
|
||||
struct stream* s;
|
||||
int size;
|
||||
int order_type;
|
||||
int window_id;
|
||||
int flags;
|
||||
int rv = 0;
|
||||
struct rail_window_state_order rwso;
|
||||
|
||||
g_writeln("xrdp_mm_process_rail_drawing_orders:");
|
||||
|
||||
s = trans_get_in_s(trans);
|
||||
if (s == 0)
|
||||
{
|
||||
@ -725,27 +849,23 @@ xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans)
|
||||
|
||||
switch(order_type)
|
||||
{
|
||||
case 2: /* update title info */
|
||||
in_uint32_le(s, window_id);
|
||||
g_writeln(" update window title info: 0x%8.8x", window_id);
|
||||
|
||||
g_memset(&rwso, 0, sizeof(rwso));
|
||||
in_uint32_le(s, size); /* title size */
|
||||
rwso.title_info = g_malloc(size + 1, 0);
|
||||
in_uint8a(s, rwso.title_info, size);
|
||||
rwso.title_info[size] = 0;
|
||||
flags = WINDOW_ORDER_FIELD_TITLE;
|
||||
rv = libxrdp_orders_init(self->wm->session);
|
||||
rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags);
|
||||
rv = libxrdp_orders_send(self->wm->session);
|
||||
g_writeln(" set window title %s %d", rwso.title_info, rv);
|
||||
g_free(rwso.title_info);
|
||||
case 2: /* create_window */
|
||||
xrdp_mm_process_rail_create_window(self, s);
|
||||
break;
|
||||
case 4: /* destroy_window */
|
||||
xrdp_mm_process_rail_destroy_window(self, s);
|
||||
break;
|
||||
case 6: /* show_window */
|
||||
rv = xrdp_mm_process_rail_show_window(self, s);
|
||||
break;
|
||||
case 8: /* update title info */
|
||||
rv = xrdp_mm_process_rail_update_window_text(self, s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -2627,12 +2747,6 @@ server_window_new_update(struct xrdp_mod *mod, int window_id,
|
||||
struct xrdp_wm *wm;
|
||||
|
||||
wm = (struct xrdp_wm *)(mod->wm);
|
||||
if ((flags & WINDOW_ORDER_STATE_NEW) &&
|
||||
!(window_state->style & 0x80000000))
|
||||
{
|
||||
/* requesting title info / icon info */
|
||||
xrdp_mm_trans_send_channel_rail_title_request(wm->mm, window_id);
|
||||
}
|
||||
return libxrdp_window_new_update(wm->session, window_id,
|
||||
window_state, flags);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user