mirror of https://github.com/neutrinolabs/xrdp
chansrv: rail, open X later, release window manager on rail disconnect
This commit is contained in:
parent
0e6210fb13
commit
05bb56b676
|
@ -704,11 +704,6 @@ main(int argc, char** argv)
|
|||
LOGM((LOG_LEVEL_ERROR, "main: error, display is zero"));
|
||||
return 1;
|
||||
}
|
||||
if (xcommon_init() != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "main: error, xcommon_init failed"));
|
||||
return 1;
|
||||
}
|
||||
LOGM((LOG_LEVEL_INFO, "main: using DISPLAY %d", g_display_num));
|
||||
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
|
||||
g_term_event = g_create_wait_obj(text);
|
||||
|
|
|
@ -112,6 +112,7 @@ clipboard_init(void)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
xcommon_init();
|
||||
clipboard_deinit();
|
||||
rv = 0;
|
||||
if (rv == 0)
|
||||
|
|
|
@ -41,7 +41,6 @@ int g_rail_up = 0;
|
|||
|
||||
/* for rail_is_another_wm_running */
|
||||
static int g_rail_running = 1;
|
||||
static int g_rail_managed = 0;
|
||||
|
||||
/* Indicates a Client Execute PDU from client to server. */
|
||||
#define TS_RAIL_ORDER_EXEC 0x0001
|
||||
|
@ -170,8 +169,8 @@ rail_is_another_wm_running(void)
|
|||
EnterWindowMask | LeaveWindowMask);
|
||||
XSync(g_display, 0);
|
||||
XSetErrorHandler((XErrorHandler)old);
|
||||
g_rail_managed = g_rail_running;
|
||||
if (!g_rail_managed)
|
||||
g_rail_up = g_rail_running;
|
||||
if (!g_rail_up)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -183,6 +182,7 @@ int APP_CC
|
|||
rail_init(void)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_init:"));
|
||||
xcommon_init();
|
||||
if (rail_is_another_wm_running())
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "rail_init: another window manager "
|
||||
|
@ -197,6 +197,12 @@ rail_init(void)
|
|||
int APP_CC
|
||||
rail_deinit(void)
|
||||
{
|
||||
if (g_rail_up)
|
||||
{
|
||||
/* no longer window manager */
|
||||
XSelectInput(g_display, g_root_window, 0);
|
||||
g_rail_up = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -251,7 +257,7 @@ rail_close_window(int window_id)
|
|||
{
|
||||
XEvent ce;
|
||||
|
||||
LOG(10, ("chansrv::rail_close_window:"));
|
||||
LOG(0, ("chansrv::rail_close_window:"));
|
||||
g_memset(&ce, 0, sizeof(ce));
|
||||
ce.xclient.type = ClientMessage;
|
||||
ce.xclient.message_type = g_wm_protocols_atom;
|
||||
|
|
|
@ -47,9 +47,9 @@ xcommon_error_handler(Display* dis, XErrorEvent* xer)
|
|||
char text[256];
|
||||
|
||||
XGetErrorText(dis, xer->error_code, text, 255);
|
||||
log_message(LOG_LEVEL_ERROR, "X error [%s](%d) opcodes %d/%d\n "
|
||||
"resource 0x%lx", text, xer->error_code,
|
||||
xer->request_code, xer->minor_code, xer->resourceid);
|
||||
LOGM((LOG_LEVEL_ERROR, "X error [%s](%d) opcodes %d/%d "
|
||||
"resource 0x%lx", text, xer->error_code,
|
||||
xer->request_code, xer->minor_code, xer->resourceid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,16 +81,18 @@ xcommon_init(void)
|
|||
{
|
||||
if (g_display != 0)
|
||||
{
|
||||
g_writeln("xcommon_init: xcommon_init already called");
|
||||
LOG(10, ("xcommon_init: xcommon_init already called"));
|
||||
return 0;
|
||||
}
|
||||
g_display = XOpenDisplay(0);
|
||||
if (g_display == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed");
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(0, ("xcommon_init: connected to display ok"));
|
||||
|
||||
/* setting the error handlers can cause problem when shutting down
|
||||
chansrv on some xlibs */
|
||||
XSetErrorHandler(xcommon_error_handler);
|
||||
|
@ -99,7 +101,7 @@ xcommon_init(void)
|
|||
g_x_socket = XConnectionNumber(g_display);
|
||||
if (g_x_socket == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed");
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -126,7 +128,7 @@ xcommon_get_wait_objs(tbus* objs, int* count, int* timeout)
|
|||
|
||||
if (((!g_clip_up) && (!g_rail_up)) || (objs == 0) || (count == 0))
|
||||
{
|
||||
g_writeln("xcommon_get_wait_objs: nothing to do");
|
||||
LOG(10, ("xcommon_get_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
lcount = *count;
|
||||
|
@ -147,7 +149,7 @@ xcommon_check_wait_objs(void)
|
|||
|
||||
if ((!g_clip_up) && (!g_rail_up))
|
||||
{
|
||||
g_writeln("xcommon_check_wait_objs: nothing to do");
|
||||
LOG(10, ("xcommon_check_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
if (g_is_wait_obj_set(g_x_wait_obj))
|
||||
|
@ -155,7 +157,7 @@ xcommon_check_wait_objs(void)
|
|||
if (XPending(g_display) < 1)
|
||||
{
|
||||
/* something is wrong, should not get here */
|
||||
log_message(LOG_LEVEL_ERROR, "xcommon_check_wait_objs: sck closed");
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: sck closed"));
|
||||
return 0;
|
||||
}
|
||||
if (g_waiting_for_data_response)
|
||||
|
@ -164,8 +166,8 @@ xcommon_check_wait_objs(void)
|
|||
g_waiting_for_data_response_time;
|
||||
if (time_diff > 1000)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, "
|
||||
"waiting for data response too long");
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, "
|
||||
"waiting for data response too long"));
|
||||
}
|
||||
}
|
||||
while (XPending(g_display) > 0)
|
||||
|
@ -177,7 +179,7 @@ xcommon_check_wait_objs(void)
|
|||
rail_rv = rail_xevent(&xevent);
|
||||
if ((clip_rv == 1) && (rail_rv == 1))
|
||||
{
|
||||
LOG(0, ("xcommon_check_wait_objs unknown xevent type %d", xevent.type));
|
||||
LOG(10, ("xcommon_check_wait_objs unknown xevent type %d", xevent.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue