chansrv: rail, open X later, release window manager on rail disconnect

master
Jay Sorg 12 years ago
parent 0e6210fb13
commit 05bb56b676

@ -704,11 +704,6 @@ main(int argc, char** argv)
LOGM((LOG_LEVEL_ERROR, "main: error, display is zero")); LOGM((LOG_LEVEL_ERROR, "main: error, display is zero"));
return 1; 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)); LOGM((LOG_LEVEL_INFO, "main: using DISPLAY %d", g_display_num));
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
g_term_event = g_create_wait_obj(text); g_term_event = g_create_wait_obj(text);

@ -112,6 +112,7 @@ clipboard_init(void)
{ {
return 0; return 0;
} }
xcommon_init();
clipboard_deinit(); clipboard_deinit();
rv = 0; rv = 0;
if (rv == 0) if (rv == 0)

@ -41,7 +41,6 @@ int g_rail_up = 0;
/* for rail_is_another_wm_running */ /* for rail_is_another_wm_running */
static int g_rail_running = 1; static int g_rail_running = 1;
static int g_rail_managed = 0;
/* Indicates a Client Execute PDU from client to server. */ /* Indicates a Client Execute PDU from client to server. */
#define TS_RAIL_ORDER_EXEC 0x0001 #define TS_RAIL_ORDER_EXEC 0x0001
@ -170,8 +169,8 @@ rail_is_another_wm_running(void)
EnterWindowMask | LeaveWindowMask); EnterWindowMask | LeaveWindowMask);
XSync(g_display, 0); XSync(g_display, 0);
XSetErrorHandler((XErrorHandler)old); XSetErrorHandler((XErrorHandler)old);
g_rail_managed = g_rail_running; g_rail_up = g_rail_running;
if (!g_rail_managed) if (!g_rail_up)
{ {
return 1; return 1;
} }
@ -183,6 +182,7 @@ int APP_CC
rail_init(void) rail_init(void)
{ {
LOG(10, ("chansrv::rail_init:")); LOG(10, ("chansrv::rail_init:"));
xcommon_init();
if (rail_is_another_wm_running()) if (rail_is_another_wm_running())
{ {
log_message(LOG_LEVEL_ERROR, "rail_init: another window manager " log_message(LOG_LEVEL_ERROR, "rail_init: another window manager "
@ -197,6 +197,12 @@ rail_init(void)
int APP_CC int APP_CC
rail_deinit(void) rail_deinit(void)
{ {
if (g_rail_up)
{
/* no longer window manager */
XSelectInput(g_display, g_root_window, 0);
g_rail_up = 0;
}
return 0; return 0;
} }
@ -251,7 +257,7 @@ rail_close_window(int window_id)
{ {
XEvent ce; XEvent ce;
LOG(10, ("chansrv::rail_close_window:")); LOG(0, ("chansrv::rail_close_window:"));
g_memset(&ce, 0, sizeof(ce)); g_memset(&ce, 0, sizeof(ce));
ce.xclient.type = ClientMessage; ce.xclient.type = ClientMessage;
ce.xclient.message_type = g_wm_protocols_atom; ce.xclient.message_type = g_wm_protocols_atom;

@ -47,9 +47,9 @@ xcommon_error_handler(Display* dis, XErrorEvent* xer)
char text[256]; char text[256];
XGetErrorText(dis, xer->error_code, text, 255); XGetErrorText(dis, xer->error_code, text, 255);
log_message(LOG_LEVEL_ERROR, "X error [%s](%d) opcodes %d/%d\n " LOGM((LOG_LEVEL_ERROR, "X error [%s](%d) opcodes %d/%d "
"resource 0x%lx", text, xer->error_code, "resource 0x%lx", text, xer->error_code,
xer->request_code, xer->minor_code, xer->resourceid); xer->request_code, xer->minor_code, xer->resourceid));
return 0; return 0;
} }
@ -81,16 +81,18 @@ xcommon_init(void)
{ {
if (g_display != 0) if (g_display != 0)
{ {
g_writeln("xcommon_init: xcommon_init already called"); LOG(10, ("xcommon_init: xcommon_init already called"));
return 0; return 0;
} }
g_display = XOpenDisplay(0); g_display = XOpenDisplay(0);
if (g_display == 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; return 1;
} }
LOG(0, ("xcommon_init: connected to display ok"));
/* setting the error handlers can cause problem when shutting down /* setting the error handlers can cause problem when shutting down
chansrv on some xlibs */ chansrv on some xlibs */
XSetErrorHandler(xcommon_error_handler); XSetErrorHandler(xcommon_error_handler);
@ -99,7 +101,7 @@ xcommon_init(void)
g_x_socket = XConnectionNumber(g_display); g_x_socket = XConnectionNumber(g_display);
if (g_x_socket == 0) if (g_x_socket == 0)
{ {
log_message(LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"); LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
return 1; 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)) 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; return 0;
} }
lcount = *count; lcount = *count;
@ -147,7 +149,7 @@ xcommon_check_wait_objs(void)
if ((!g_clip_up) && (!g_rail_up)) 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; return 0;
} }
if (g_is_wait_obj_set(g_x_wait_obj)) if (g_is_wait_obj_set(g_x_wait_obj))
@ -155,7 +157,7 @@ xcommon_check_wait_objs(void)
if (XPending(g_display) < 1) if (XPending(g_display) < 1)
{ {
/* something is wrong, should not get here */ /* 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; return 0;
} }
if (g_waiting_for_data_response) if (g_waiting_for_data_response)
@ -164,8 +166,8 @@ xcommon_check_wait_objs(void)
g_waiting_for_data_response_time; g_waiting_for_data_response_time;
if (time_diff > 1000) if (time_diff > 1000)
{ {
log_message(LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, " LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, "
"waiting for data response too long"); "waiting for data response too long"));
} }
} }
while (XPending(g_display) > 0) while (XPending(g_display) > 0)
@ -177,7 +179,7 @@ xcommon_check_wait_objs(void)
rail_rv = rail_xevent(&xevent); rail_rv = rail_xevent(&xevent);
if ((clip_rv == 1) && (rail_rv == 1)) 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…
Cancel
Save