Home » U++ Library support » TopWindow&PopUp, TrayIcon » [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow
| [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30902] |
Fri, 28 January 2011 06:41  |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
on OSX, as it has been mentioned in the forums, upp menus are shown.
I have found out that they are displayed under the application window and parent is desktop root window. Or popups are displayed miles away on top of other apps.
As a quick fix, I applied in X11Wnd.cpp
void Ctrl::Create0(Ctrl *owner, bool redirect, bool savebits)
{
...
Window dad;
if(IsPopUp())
{
dad = (owner->top)->window;
}
else
dad = RootWindow(Xdisplay, Xscreenno);
Window w = XCreateWindow(Xdisplay, dad,
r.left, r.top, r.Width(), r.Height(),
0, CopyFromParent, InputOutput, CopyFromParent,
CWBitGravity|CWSaveUnder|CWOverrideRedirect|
(IsCompositedGui() ? CWBackPixel : CWBackPixmap),
&swa);
if(!w) XError("XCreateWindow failed !");
...
also popup=true; before Create
the menus are displayed now but by the size of a window bar lower.
I guess that there is also a problem with focusCtrl.
Before I explore any deeper could someone tell:
Are menus supposed to have parent RootWindow(Xdisplay, Xscreenno); in upp?
and
void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz)
{
bool szcx = true;
bool szcy = true;
bool szx = false;
bool szy = false;
if(parentmenu) {
if(parentmenu->IsChild())
szcx = false;
else
szcy = false;
WhenHelp = parentmenu->WhenHelp;
}
Rect r = GetWorkArea(p);
Rect r = the whole screen?
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30922 is a reply to message #30902] |
Fri, 28 January 2011 12:37   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
| fudadmin wrote on Fri, 28 January 2011 00:41 | on OSX, as it has been mentioned in the forums, upp menus are shown.
I have found out that they are displayed under the application window and parent is desktop root window. Or popups are displayed miles away on top of other apps.
As a quick fix, I applied in X11Wnd.cpp
void Ctrl::Create0(Ctrl *owner, bool redirect, bool savebits)
{
...
Window dad;
if(IsPopUp())
{
dad = (owner->top)->window;
}
else
dad = RootWindow(Xdisplay, Xscreenno);
Window w = XCreateWindow(Xdisplay, dad,
r.left, r.top, r.Width(), r.Height(),
0, CopyFromParent, InputOutput, CopyFromParent,
CWBitGravity|CWSaveUnder|CWOverrideRedirect|
(IsCompositedGui() ? CWBackPixel : CWBackPixmap),
&swa);
if(!w) XError("XCreateWindow failed !");
...
also popup=true; before Create
the menus are displayed now but by the size of a window bar lower.
I guess that there is also a problem with focusCtrl.
Before I explore any deeper could someone tell:
Are menus supposed to have parent RootWindow(Xdisplay, Xscreenno); in upp?
|
Of course. Not possible to do this any other way. Parent clips content of its child, so if we want menus to extend "outside" its owner window, parent has to be RootWindow.
| Quote: |
void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz)
{
bool szcx = true;
bool szcy = true;
bool szx = false;
bool szy = false;
if(parentmenu) {
if(parentmenu->IsChild())
szcx = false;
else
szcy = false;
WhenHelp = parentmenu->WhenHelp;
}
Rect r = GetWorkArea(p);
Rect r = the whole screen?
|
In most cases, yes.
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30927 is a reply to message #30924] |
Fri, 28 January 2011 14:03   |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
I think I have the remedy.
in CtrlKbd.cpp,
if I comment the line
topwindow->SetWndForeground(); // cxl 2007-4-27
the menus are displayed properly. Any side effects from your point of view?
like this:
bool Ctrl::SetFocus0(bool activate)
{
GuiLock __;
if(IsUsrLog())
UsrLogT(6, String().Cat() << "SETFOCUS " << Desc(this));
LLOG("Ctrl::SetFocus " << Desc(this));
LLOG("focusCtrlWnd " << UPP::Name(focusCtrlWnd));
LLOG("Ctrl::SetFocus0 -> deferredSetFocus = NULL; was: " << UPP::Name(defferedSetFocus));
defferedSetFocus = NULL;
if(focusCtrl == this) return true;
if(!IsOpen() || !IsEnabled() || !IsVisible()) return false;
Ptr<Ctrl> pfocusCtrl = focusCtrl;
Ptr<Ctrl> topwindow = GetTopWindow();
Ptr<Ctrl> topctrl = GetTopCtrl();
Ptr<Ctrl> _this = this;
if(!topwindow) topwindow = topctrl;
LLOG("SetFocus -> SetWndFocus: topwindow = " << UPP::Name(topwindow) << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd));
if(!topwindow->HasWndFocus() && !topwindow->SetWndFocus()) return false;// cxl 31.1.2004
// topwindow->SetWndForeground(); // cxl 2007-4-27
LLOG("SetFocus -> focusCtrl = this: " << FormatIntHex(this) << ", _this = " << FormatIntHex(~_this) << ", " << UPP::Name(_this));
focusCtrl = _this;
focusCtrlWnd = topwindow;
DoKillFocus(pfocusCtrl, _this);
LLOG("SetFocus 2 - after DoKillFocus");
DoDeactivate(pfocusCtrl, _this);
DoSetFocus(pfocusCtrl, _this, activate);
if(topwindow)
lastActiveWnd = topwindow;
return true;
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30992 is a reply to message #30990] |
Mon, 31 January 2011 15:09   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
| fudadmin wrote on Mon, 31 January 2011 09:01 |
| mirek wrote on Mon, 31 January 2011 13:13 |
| dolik.rce wrote on Mon, 31 January 2011 08:12 |
| fudadmin wrote on Mon, 31 January 2011 13:04 |
| mirek wrote on Sun, 30 January 2011 08:51 | Would
if(active) wnd->SetWndForeground();
work for you?
|
error: active is not declared
blind try - this works:if(focusCtrl) focusCtrl->SetWndForeground();
|
I believe it should have been if(activate) wnd->SetWndForeground(); At least that is what I did and it helped.
Honza
|
Did it? It's a great news then 
Mirek
|
Honza's proposed solution was based on a wrong believe . Because - error: "wnd is not declared". What works is:
if(activate) {
// topwindow->SetWndForeground(); //this prevents menus in OSX11
focusCtrl->SetWndForeground();
}
if I understand correctly, if a menu pane is activated it should become focusCtrl and it should be put into foreground
|
Oh, I guess I have made a mistake with ids, sorry.
Should have been:
if(activate)
topwindow->SetWndForeground();
It cannot be focusCtrl, as focusCtrl is not required to be topctrl...
Anyway, now looking at it, perhaps the really correct solution is
topctrl->SetWndForeground();
or maybe
if(activate)
topctrl->SetWndForeground();
If you have time to check in osx11 and/or linux, it would be very helpful.
[Updated on: Mon, 31 January 2011 15:19] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31033 is a reply to message #31027] |
Tue, 01 February 2011 22:51   |
|
|
| mirek wrote on Tue, 01 February 2011 19:29 |
| fudadmin wrote on Mon, 31 January 2011 13:34 |
if(activate && !topctrl->IsPopUp())
topwindow->SetWndForeground();
no more flickering and menus works well! 
|
Does this variant work in linux too?
Mirek
|
It works in the sense of "compiles and runs". But with this solution theide still comes to foreground when linking is finished. I would prefer some solution that removes that behavior.
Honza
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31072 is a reply to message #31054] |
Thu, 03 February 2011 19:20   |
|
|
| fudadmin wrote on Wed, 02 February 2011 17:42 | ok, semi-blind fix. I do not know which cases or intentions should be covered with SetWndForeground.. It looks working well on osx11:
focusCtrl = _this;
focusCtrlWnd = topwindow;
DoKillFocus(pfocusCtrl, _this);
LLOG("SetFocus 2 - after DoKillFocus");
DoDeactivate(pfocusCtrl, _this);
if( !topctrl->IsPopUp() )
_this->SetWndForeground();
DoSetFocus(pfocusCtrl, _this, activate);
if(topwindow)
lastActiveWnd = topwindow;
return true;
I just thought that there's no good logic to put ->SetWndForeground before DoDeactivate.
also, I removed if(activate) because that prevented Assist popup getting focus and wheel was not working.
|
Sounds logical and works well for me on X11.
Honza
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32206 is a reply to message #32204] |
Sat, 30 April 2011 20:20   |
|
|
| mirek wrote on Sat, 30 April 2011 19:07 | I have to admit I am little bit lost about what code change required... 
Could you provide complete SetFocus0 please?
Mirek
|
I understand, I had trouble finding the fix in this thread as well 
bool Ctrl::SetFocus0(bool activate)
{
GuiLock __;
if(IsUsrLog())
UsrLogT(6, String().Cat() << "SETFOCUS " << Desc(this));
LLOG("Ctrl::SetFocus " << Desc(this));
LLOG("focusCtrlWnd " << UPP::Name(focusCtrlWnd));
LLOG("Ctrl::SetFocus0 -> deferredSetFocus = NULL; was: " << UPP::Name(defferedSetFocus));
defferedSetFocus = NULL;
if(focusCtrl == this) return true;
if(!IsOpen() || !IsEnabled() || !IsVisible()) return false;
Ptr<Ctrl> pfocusCtrl = focusCtrl;
Ptr<Ctrl> topwindow = GetTopWindow();
Ptr<Ctrl> topctrl = GetTopCtrl();
Ptr<Ctrl> _this = this;
if(!topwindow) topwindow = topctrl;
LLOG("SetFocus -> SetWndFocus: topwindow = " << UPP::Name(topwindow) << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd));
if(!topwindow->HasWndFocus() && !topwindow->SetWndFocus()) return false;// cxl 31.1.2004
if(activate) topctrl->SetWndForeground(); // <- this line changed
LLOG("SetFocus -> focusCtrl = this: " << FormatIntHex(this) << ", _this = " << FormatIntHex(~_this) << ", " << UPP::Name(_this));
focusCtrl = _this;
focusCtrlWnd = topwindow;
DoKillFocus(pfocusCtrl, _this);
LLOG("SetFocus 2");
DoDeactivate(pfocusCtrl, _this);
DoSetFocus(pfocusCtrl, _this, activate);
if(topwindow)
lastActiveWnd = topwindow;
return true;
}
Tested on OpenBSD+gcc4.2 and Linux+gcc4.6, seems to work fine on both...
Honza
|
|
|
|
|
|
|
|
|
|
| Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32259 is a reply to message #32258] |
Wed, 04 May 2011 12:50   |
|
|
| mirek wrote on Wed, 04 May 2011 12:00 | I believe the right solution is to change PopUp method, not SetFocus0...
Perhaps something around X11Wnd.cpp line 518...
Maybe adding _NET_WM_STATE_ABOVE too?
|
_NET_WM_STATE_ABOVE might be a solution for menus, but I'm not sure if it won't cause trouble with popups in general. It might lead to situations where popup stays hanging on screen. I am no X11 expert, but I remember such things happening in past with U++.
Honza
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 26 03:56:47 GMT+2 2026
Total time taken to generate the page: 0.01530 seconds
|