diff --git a/uppsrc/CtrlCore/TopWinX11.cpp b/uppsrc/CtrlCore/TopWinX11.cpp index f7684dab5..1bcb4651c 100644 --- a/uppsrc/CtrlCore/TopWinX11.cpp +++ b/uppsrc/CtrlCore/TopWinX11.cpp @@ -173,7 +173,7 @@ void TopWindow::SyncCaption0() void TopWindow::CenterRect(Ctrl *owner) { - GuiLock __; + GuiLock __; SetupRect(); if(owner && center == 1 || center == 2) { Size sz = GetRect().Size(); @@ -213,6 +213,7 @@ void TopWindow::Open(Ctrl *owner) UsrLogT(3, "OPEN " + Desc(this)); LLOG("OPEN " << Name() << " owner: " << UPP::Name(owner)); IgnoreMouseUp(); + bool weplace = owner && center == 1 || center == 2 || !GetRect().IsEmpty(); if(fullscreen) SetRect(0, 0, Xwidth, Xheight); else @@ -221,8 +222,10 @@ void TopWindow::Open(Ctrl *owner) Create(owner, false, false); xminsize.cx = xmaxsize.cx = Null; title2.Clear(); - LLOG("SyncCaption"); - SyncCaption(); + if(!weplace) { + LLOG("SyncCaption"); + SyncCaption0(); + } LLOG("SyncSizeHints"); size_hints->flags = 0; SyncSizeHints(); @@ -261,6 +264,14 @@ void TopWindow::Open(Ctrl *owner) LLOG("SetWndFocus"); SetWndFocus(); for(int i = 0; i < 50; i++) { + // X11 tries to move our window, so ignore the first set of ConfigureNotify + // and move the window into position after FocusIn - but not if we want WM to + // place the window + if(weplace) + while(XCheckTypedWindowEvent(Xdisplay, top->window, ConfigureNotify, &e)) { + if(e.xconfigure.window != top->window) + ProcessEvent(&e); + } if(XCheckTypedWindowEvent(Xdisplay, top->window, FocusIn, &e)) { ProcessEvent(&e); if(e.xfocus.window == top->window) @@ -269,6 +280,11 @@ void TopWindow::Open(Ctrl *owner) Sleep(10); } } + if(weplace) { + WndSetPos0(GetRect()); + LLOG("SyncCaption"); + SyncCaption0(); + } LLOG(">Open NextRequest " << NextRequest(Xdisplay)); LLOG(">OPENED " << Name()); PlaceFocus(); diff --git a/uppsrc/CtrlCore/TopWindow.cpp b/uppsrc/CtrlCore/TopWindow.cpp index 52d248a44..6017732d7 100644 --- a/uppsrc/CtrlCore/TopWindow.cpp +++ b/uppsrc/CtrlCore/TopWindow.cpp @@ -314,6 +314,7 @@ int TopWindow::Run(bool appmodal) #endif EventLoop(this); #ifdef _DEBUG +DLOG("b " << GetRect()); LLOG("Finished EventLoop in " << UPP::Name(this)); for(int e = 0; e < disabled.GetCount(); e++) LLOG("EnableCtrls[" << e << "] = " << UPP::Name(disabled[e])); diff --git a/uppsrc/CtrlCore/X11App.cpp b/uppsrc/CtrlCore/X11App.cpp index aab5fc72b..249ae626a 100644 --- a/uppsrc/CtrlCore/X11App.cpp +++ b/uppsrc/CtrlCore/X11App.cpp @@ -447,7 +447,7 @@ void Ctrl::ExitX11() Rect Ctrl::GetDefaultWindowRect() { GuiLock __; - static int pos = 0; + static int pos = min(Xwidth / 10, 50); pos += 10; int cx = Xwidth * 2 / 3; int cy = Xheight * 2 / 3; diff --git a/uppsrc/CtrlCore/X11Wnd.cpp b/uppsrc/CtrlCore/X11Wnd.cpp index 670826437..8d02f5879 100644 --- a/uppsrc/CtrlCore/X11Wnd.cpp +++ b/uppsrc/CtrlCore/X11Wnd.cpp @@ -12,7 +12,7 @@ NAMESPACE_UPP bool Ctrl::LogMessages -// = true + = true ; #endif @@ -493,28 +493,6 @@ void Ctrl::Create0(Ctrl *owner, bool redirect, bool savebits) cw.xic = NULL; if(xim) { -/* char **missing_list; - int missing_count; - char *def_string; - - static XFontSet dummy_fs = XCreateFontSet(Xdisplay, "-*-*-*-*-*-*-*-*-*-*-*-*-*-", - &missing_list, &missing_count, &def_string); - DDUMP((void *)dummy_fs); - - XPoint spot; - spot.x = 1; - spot.y = 1; - XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, XNFontSet, dummy_fs, NULL); - - DDUMP((void *)preedit_attr); - - cw.xic = XCreateIC(xim, - XNInputStyle, XIMPreeditPosition|XIMStatusNothing, - XNPreeditAttributes, preedit_attr, - XNClientWindow, w, - NULL); - XFree(preedit_attr); - DDUMP((void *)cw.xic);*/ cw.xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing|XIMStatusNothing, XNClientWindow, w,