CtrlCore: Ctrl::GetEventLevel

This commit is contained in:
Mirek Fidler 2021-12-05 10:03:47 +01:00
parent fc6946e016
commit 198e8114a6
8 changed files with 25 additions and 6 deletions

View file

@ -29,6 +29,7 @@ bool (*&DisplayErrorFn())(const Value& v)
}
int64 Ctrl::eventid;
int Ctrl::EventLevel;
Ctrl *Ctrl::LoopCtrl;
int Ctrl::LoopLevel;

View file

@ -534,6 +534,7 @@ private:
static bool globalbackpaint;
static bool globalbackbuffer;
static bool painting;
static int EventLevel;
static int LoopLevel;
static Ctrl *LoopCtrl;
static int64 EventLoopNo;
@ -729,6 +730,11 @@ private:
static void InstallPanicBox();
bool IsDHCtrl() const;
struct EventLevelDo {
EventLevelDo() { EventLevel++; };
~EventLevelDo() { EventLevel--; };
};
private:
void DoRemove();
@ -1214,9 +1220,11 @@ public:
static bool IsWaitingEvent();
static bool ProcessEvent(bool *quit = NULL);
static bool ProcessEvents(bool *quit = NULL);
static int GetEventLevel() { return EventLevel; }
bool IsPopUp() const { return popup; }
static void EventLoop(Ctrl *loopctrl = NULL);
static int GetLoopLevel() { return LoopLevel; }
static Ctrl *GetLoopCtrl() { return LoopCtrl; }

View file

@ -38,6 +38,7 @@ void Ctrl::RefreshAccessKeysDo(bool vis)
bool Ctrl::DispatchKey(dword keycode, int count)
{
GuiLock __;
EventLevelDo ___;
if(GUI_AltAccessKeys()) {
bool alt = GetAlt();
Ctrl *c = GetActiveCtrl();

View file

@ -524,6 +524,7 @@ bool sDblTime(int time)
Image Ctrl::DispatchMouse(int e, Point p, int zd) {
GuiLock __;
EventLevelDo ___;
if(e == MOUSEWHEEL && !zd) // ignore non-scroll wheel events
return Null;
if(e == MOUSEMOVE && repeatTopCtrl == this) {

View file

@ -2423,6 +2423,16 @@ intercepted (Win32 specific).&]
were processed, false that queue was empty.&]
[s3;%- &]
[s4;%- &]
[s5;:Upp`:`:Ctrl`:`:GetEventLevel`(`):%- [@(0.0.255) static] [@(0.0.255) int]_[* GetEventLe
vel]()&]
[s2; Returns the level of input event. This is basically a reentrancy
level of ProcessEvent(s) routine `- it starts zero but increments
each time the input event is generated by ProcessEvent(s). This
information can be useful for background threads or in timer
events (where this is zero when application is in the `"base`"
state).&]
[s3;%- &]
[s4;%- &]
[s5;:Ctrl`:`:IsPopUp`(`)const:%- [@(0.0.255) bool]_[* IsPopUp]()_[@(0.0.255) const]&]
[s7;i1120;a17; [*/ Return value]-|True if Ctrl is pop`-up window.&]
[s3; &]

View file

@ -69,7 +69,7 @@ void GLDrawText(const GLContext2D& dd, Pointf pos, double angle, const wchar *te
if(angle)
u = Polar(-angle);
if(n < 0)
n = wstrlen(text);
n = strlen__(text);
for(int i = 0; i < n; i++) {
GLTexture m = GetGlyphGLTextureCached(-angle, text[i], font, ink);
Point h = m.GetHotSpot();

View file

@ -645,10 +645,8 @@ void Ide::Periodic()
SetIcon();
if(debugger && debugger->IsFinished() && !IdeIsDebugLock())
IdeEndDebug();
if(file_scanned) {
if(EditFileAssistSync2())
file_scanned = false;
}
if(file_scanned && Ctrl::GetEventLevel() == 0 && EditFileAssistSync2())
file_scanned = false;
}
const Workspace& Ide::IdeWorkspace() const

View file

@ -686,7 +686,7 @@ void Ide::TriggerAssistSync()
String s = ~editor;
String fn = editfile;
file_scan++;
if(!CoWork::TrySchedule([=] {
if(Ctrl::GetEventLevel() == 0 && !CoWork::TrySchedule([=] {
StringStream ss(s);
file_scanned = TryCodeBaseScanFile(ss, editfile);
file_scan--;