Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » [Linux] Upp application can block all mouse events
[Linux] Upp application can block all mouse events [message #43161] Wed, 21 May 2014 14:08 Go to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Hi,

When Upp GUI application is not responding to events, it blocks mouse events sent to other GUI programs (gnome menu or unity dash can not be open with mouse click)

Here is sample code:
CursorTest.lay:

LAYOUT(CursorTestLayout, 200, 100)
	ITEM(Button, button, SetLabel(t_("Test")).HCenterPosZ(84, 2).VCenterPosZ(32, -2))
END_LAYOUT

CursorTest.cpp:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <CursorTest/CursorTest.lay>
#include <CtrlCore/lay.h>

class CursorTest : public WithCursorTestLayout<TopWindow> {
	void Test() 	{	Sleep(10000);}

public:
	typedef CursorTest CLASSNAME;
	CursorTest()	
	{
		CtrlLayout(*this, "Cursor Test");
		button.WhenAction = THISBACK(Test);
	};
};

GUI_APP_MAIN
{
	CursorTest().Run();
}


I made test in Ubuntu 12.04 and Debian 6 (both GTK and X11 backends). In both systems mouse events were blocked.

Does anyone know why all other applications can not receive mouse events?

[Updated on: Wed, 21 May 2014 14:23]

Report message to a moderator

Re: [Linux] Upp application can block all mouse events [message #46739 is a reply to message #43161] Thu, 21 July 2016 19:31 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
Confirms that gui "hangs" for sleep period.
You are using WhenAction for Callback on the button
Everything works fine if you use WhenPush

Example:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

struct SleepTest : public TopWindow
{
	typedef SleepTest CLASSNAME;
	
	Button button;

	void Test()
	{
	Sleep(10000); //calls Util.cpp - Sleep()
	}

	SleepTest()
	{
		Title("Sleep Test").CenterScreen().Sizeable();
		SetRect(0,0,200,200);
		
		Add(button.SetLabel(t_("Test")).HCenterPosZ(84, 2).VCenterPosZ(32, -2));
		//button.WhenAction = THISBACK(Test); --- hogs the gui for sleep-time - Alt-D in debug still works
		button.WhenPush = THISBACK(Test); //this is fine
	};
	
	virtual ~SleepTest(){}
};

GUI_APP_MAIN
{
	SleepTest().Run();
}


I don't know what WhenAction does internally to hog the gui so - mirek?
I guess some kind of thread-lockup with X that leave X waiting?
Re: [Linux] Upp application can block all mouse events [message #46740 is a reply to message #46739] Thu, 21 July 2016 22:53 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
slashupp wrote on Thu, 21 July 2016 19:31

I guess some kind of thread-lockup with X that leave X waiting?


No, it is not a bug, the lock is made on purpose (I don't remember exact X11 function name, maybe XGrabPointer).
The question is: is it really necessary?
Re: [Linux] Upp application can block all mouse events [message #46741 is a reply to message #46740] Fri, 22 July 2016 07:22 Go to previous message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
This is an inherent problem of X11.

Thing is, GUI logic requires mouse grab here and there (e.g. if DropList is dropped). If application freezes while holding the grab, then whole X11 becomes unresponsive.

In Windows, which has equivalent to grab, situation is is solved by additional API logic (see Remarks):

https://msdn.microsoft.com/en-us/library/windows/desktop/ms6 46262(v=vs.85).aspx

Unfortunately, nothing like that ever happened in X11.
Previous Topic: ColumnList clipping problem
Next Topic: Question about Drag and Drop
Goto Forum:
  


Current Time: Sun Jun 23 01:05:42 CEST 2024

Total time taken to generate the page: 0.06248 seconds