U++ framework
Do not panic. Ask here before giving up.

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 Go to next message
fudadmin is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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 #30923 is a reply to message #30902] Fri, 28 January 2011 12:42 Go to previous messageGo to next message
mirek is currently offline  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.



Actually, on top of everything else is OK. This is the only way X11 can do...
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30924 is a reply to message #30923] Fri, 28 January 2011 13:29 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
mirek wrote on Fri, 28 January 2011 11:42

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.



Actually, on top of everything else is OK. This is the only way X11 can do...



index.php?t=getfile&id=3063&private=0

but this is not ok?
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 Go to previous messageGo to next message
fudadmin is currently offline  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 #30954 is a reply to message #30927] Sat, 29 January 2011 20:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
fudadmin wrote on Fri, 28 January 2011 08:03

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?



Well looks like X11 on macosx is not really 100% compliant. No wonder, X11 is absolute mess.

Well, I guess there might be sideeffect - I would use

#ifndef PLATFORM_OSX11

there.

Mirek
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30956 is a reply to message #30954] Sat, 29 January 2011 21:15 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
mirek wrote on Sat, 29 January 2011 19:39

fudadmin wrote on Fri, 28 January 2011 08:03

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?



Well looks like X11 on macosx is not really 100% compliant. No wonder, X11 is absolute mess.

Well, I guess there might be sideeffect - I would use

#ifndef PLATFORM_OSX11

there.

Mirek


But have you read this?
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30959 is a reply to message #30956] Sun, 30 January 2011 09:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Would

if(active) wnd->SetWndForeground();

work for you?
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30984 is a reply to message #30959] Mon, 31 January 2011 13:04 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
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();

Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30986 is a reply to message #30984] Mon, 31 January 2011 14:12 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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

[Updated on: Mon, 31 January 2011 14:12]

Report message to a moderator

Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30987 is a reply to message #30984] Mon, 31 January 2011 14:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 31 January 2011 07: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();




Ops, should have been 'activate' (param of the function).

BTW, FYI, this call to SetWndForeground is quite essential, as we simply expect that setting focus activates the window (puts it to foreground).

Mirek

Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30988 is a reply to message #30986] Mon, 31 January 2011 14:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
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 Smile

Mirek
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30989 is a reply to message #30988] Mon, 31 January 2011 14:51 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Mon, 31 January 2011 14:13

dolik.rce wrote on Mon, 31 January 2011 08:12

if(activate) wnd->SetWndForeground();
At least that is what I did and it helped.

Honza


Did it? It's a great news then Smile

Mirek

Well, it did fix the annoying behavior of theide stealing the focus to other programs Smile Not sure about OSX...

I still don't understand why is it necessary to SetWndForeground when setting focus. I would expect window manager to take care of that in case of user causes the focus change (e.g. by clicking in the window). In case of setting the focus from code, it should IMHO be up to programmer to decide if the window should get activated. And the programmer should use it very rarely, as it is quite annoying Smile

Honza

PS: And it didn't solve Radeks problems in the other thread...

[Updated on: Mon, 31 January 2011 14:53]

Report message to a moderator

Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30990 is a reply to message #30988] Mon, 31 January 2011 15:01 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
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 Smile

Mirek


Honza's proposed solution was based on a wrong believe Smile. 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
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30991 is a reply to message #30990] Mon, 31 January 2011 15:09 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
This works as well :
	if(activate) _this->SetWndForeground();

Maybe such was the intention?
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 Go to previous messageGo to next message
mirek is currently offline  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 Smile

Mirek


Honza's proposed solution was based on a wrong believe Smile. 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 #30994 is a reply to message #30992] Mon, 31 January 2011 15:18 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Oups, I made a mistake by copy/pasting from some other post Embarassed I actually just added the if(activate) to the already existing line. So to clear it up:
Quote:

if(activate) topwindow->SetWndForeground(); //works for me


Sorry for confusion,
Honza
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30995 is a reply to message #30992] Mon, 31 January 2011 15:25 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
mirek wrote on Mon, 31 January 2011 14:09

[or maybe

if(activate)
    topctrl->SetWndForeground();


If you have time to check in osx11 and/or linux, it would be very helpful.



This works on osx11! I don't have linux. Honza could check, please.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30998 is a reply to message #30995] Mon, 31 January 2011 16:03 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

fudadmin wrote on Mon, 31 January 2011 15:25

mirek wrote on Mon, 31 January 2011 14:09

[or maybe

if(activate)
    topctrl->SetWndForeground();


If you have time to check in osx11 and/or linux, it would be very helpful.



This works on osx11! I don't have linux. Honza could check, please.

Appears to work fine on Linux too.
Honza
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #30999 is a reply to message #30998] Mon, 31 January 2011 16:15 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Sorry, just noticed that this way is better:
	if(activate) {
		if(!this->IsPopUp())
			topwindow->SetWndForeground();
		else
			focusCtrl->SetWndForeground();		
	}

the previous
if(activate)
    topctrl->SetWndForeground();

causes flickering of the window frame, shadows and titlebar.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31001 is a reply to message #30999] Mon, 31 January 2011 17:17 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
fudadmin wrote on Mon, 31 January 2011 15:15

Sorry, just noticed that this way is better:
	if(activate) {
		if(!this->IsPopUp())
			topwindow->SetWndForeground();
		else
			focusCtrl->SetWndForeground();		
	}

the previous
if(activate)
    topctrl->SetWndForeground();

causes flickering of the window frame, shadows and titlebar.

Sorry once again. I rushed. The above causes menu disappear when trying to select. I will try to investigate deeper - I need to understand more of the logic here. At least now I can work faster because I have ultimate++ theide quite useable in osx11.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31002 is a reply to message #31001] Mon, 31 January 2011 17:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 31 January 2011 11:17

fudadmin wrote on Mon, 31 January 2011 15:15

Sorry, just noticed that this way is better:
	if(activate) {
		if(!this->IsPopUp())
			topwindow->SetWndForeground();
		else
			focusCtrl->SetWndForeground();		
	}

the previous
if(activate)
    topctrl->SetWndForeground();

causes flickering of the window frame, shadows and titlebar.

Sorry once again. I rushed. The above causes menu disappear when trying to select. I will try to investigate deeper - I need to understand more of the logic here. At least now I can work faster because I have ultimate++ theide quite useable in osx11.


So, should I put

if(activate)
    topctrl->SetWndForeground();


into trunk for now? Is flickering the only problem now?
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31003 is a reply to message #31002] Mon, 31 January 2011 17:39 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
mirek wrote on Mon, 31 January 2011 16:28

fudadmin wrote on Mon, 31 January 2011 11:17

fudadmin wrote on Mon, 31 January 2011 15:15

Sorry, just noticed that this way is better:
	if(activate) {
		if(!this->IsPopUp())
			topwindow->SetWndForeground();
		else
			focusCtrl->SetWndForeground();		
	}

the previous
if(activate)
    topctrl->SetWndForeground();

causes flickering of the window frame, shadows and titlebar.

Sorry once again. I rushed. The above causes menu disappear when trying to select. I will try to investigate deeper - I need to understand more of the logic here. At least now I can work faster because I have ultimate++ theide quite useable in osx11.


So, should I put

if(activate)
    topctrl->SetWndForeground();


into trunk for now? Is flickering the only problem now?


Could go into trunk for now. I'll try to find out what causes that flickering. I haven't noticed anything else bad.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31006 is a reply to message #31003] Mon, 31 January 2011 19:34 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
if(activate && !topctrl->IsPopUp())
		topwindow->SetWndForeground();

no more flickering and menus works well! Smile

Bet I feel (tried a bit...) that now it is possible to optimize (do not use redundant focus change in some cases in the code below that line:
		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 #31027 is a reply to message #31006] Tue, 01 February 2011 19:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 31 January 2011 13:34

if(activate && !topctrl->IsPopUp())
		topwindow->SetWndForeground();

no more flickering and menus works well! Smile




Does this variant work in linux too?

Mirek
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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! Smile




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 #31049 is a reply to message #31033] Wed, 02 February 2011 13:49 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I've just discovered that this
	if(activate && !topctrl->IsPopUp())

		topwindow->SetWndForeground();

doesn't solve all popups. E.g in theide left botton file list popup are still opening under the main window... Sad . I guess because theide immediately activates file contents in the editor window, so the editor steals the focus? I'll try to investigate deeper.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #31054 is a reply to message #31049] Wed, 02 February 2011 17:42 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
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.
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 #32118 is a reply to message #31072] Mon, 25 April 2011 19:41 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

After compiling theide on OpenBSD, I noticed that it also suffers from this problem and that no fix was commited so far...

Using
if(activate) topctrl->SetWndForeground();
in SetFocus0() as described above by fudadmin seems to fix it correctly. Could this fix be commited (at least with #ifdef PLATFORM_BSD) ?

Honza

Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32204 is a reply to message #32118] Sat, 30 April 2011 19:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
I have to admit I am little bit lost about what code change required... Smile

Could you provide complete SetFocus0 please?

Mirek
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Sat, 30 April 2011 19:07

I have to admit I am little bit lost about what code change required... Smile

Could you provide complete SetFocus0 please?

Mirek


I understand, I had trouble finding the fix in this thread as well Smile
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 #32219 is a reply to message #32206] Sun, 01 May 2011 19:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Applied...
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32257 is a reply to message #32219] Wed, 04 May 2011 11:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
mirek wrote on Sun, 01 May 2011 13:42

Applied...


Unfortunately, this patch causes flashing of window titlebar in Win32 when working with menu.

For now, I have used #ifdef PLATFORM_POSIX, but I hope there is some better solution...

Anyway, it needs to be

#ifdef PLATFORM_POSIX
	if(activate) // Dolik/fudadmin 2011-5-1
		topctrl->SetWndForeground();
#else
	topwindow->SetWndForeground();  // cxl 2007-4-27
#endif


I guess the problem is different handling of popups in Win32 vs X11.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32258 is a reply to message #32257] Wed, 04 May 2011 12:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
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?

[Updated on: Wed, 04 May 2011 12:13]

Report message to a moderator

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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32260 is a reply to message #32259] Wed, 04 May 2011 13:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
dolik.rce wrote on Wed, 04 May 2011 06: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++.



I guess that would be another kind of error anyway.
Re: [BUG?] X11 (at least OSX) Menus displayed under TopWindow, owner=RootWindow [message #32265 is a reply to message #30902] Wed, 04 May 2011 21:11 Go to previous message
xzsa is currently offline  xzsa
Messages: 5
Registered: February 2011
Promising Member
Since last updete (3401 - Arch Linux x86-64) I can also report flashing of window titlebar when working with menus.

[Updated on: Wed, 04 May 2011 21:12]

Report message to a moderator

Previous Topic: Restoring TrayIcon control
Next Topic: TrayIcon test V2
Goto Forum:
  


Current Time: Sun Apr 26 03:56:47 GMT+2 2026

Total time taken to generate the page: 0.01530 seconds