*CtrlCore X11: Fixed the position of window when opening it

git-svn-id: svn://ultimatepp.org/upp/trunk@2992 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-01-11 22:59:02 +00:00
parent 66b4da328e
commit 6ff25863e0
4 changed files with 22 additions and 27 deletions

View file

@ -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();

View file

@ -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]));

View file

@ -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;

View file

@ -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,