diff --git a/uppsrc/CtrlCore/GtkCapture.cpp b/uppsrc/CtrlCore/GtkCapture.cpp index 828c980e5..277331459 100644 --- a/uppsrc/CtrlCore/GtkCapture.cpp +++ b/uppsrc/CtrlCore/GtkCapture.cpp @@ -21,7 +21,7 @@ void Ctrl::StartGrabPopup() { if(activePopup.GetCount() && !grabpopup) { Ctrl *w = activePopup[0]; - if(w) { + if(w && w->IsOpen()) { ReleaseWndCapture0(); if(gdk_pointer_grab(w->gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), @@ -36,6 +36,8 @@ bool Ctrl::SetWndCapture() GuiLock __; ASSERT(IsMainThread()); LLOG("SetWndCapture " << Name()); + if(!IsOpen()) + return false; StopGrabPopup(); ReleaseWndCapture(); if(gdk_pointer_grab(gdk(), FALSE, @@ -69,12 +71,12 @@ bool Ctrl::ReleaseWndCapture() bool Ctrl::HasWndCapture() const { GuiLock __; - return this == grabwindow && gdk_pointer_is_grabbed(); + return this == grabwindow && grabwindow->IsOpen() && gdk_pointer_is_grabbed(); } void Ctrl::CaptureSync() { - if(grabwindow && !gdk_pointer_is_grabbed()) { + if(grabwindow && grabwindow->IsOpen() && !gdk_pointer_is_grabbed()) { if(gdk_pointer_grab(grabwindow->gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), NULL, NULL, CurrentTime) != GDK_GRAB_SUCCESS) { diff --git a/uppsrc/CtrlCore/GtkCtrl.cpp b/uppsrc/CtrlCore/GtkCtrl.cpp index fc50760d6..495e66614 100644 --- a/uppsrc/CtrlCore/GtkCtrl.cpp +++ b/uppsrc/CtrlCore/GtkCtrl.cpp @@ -59,7 +59,7 @@ bool GuiPlatformHasSizeGrip() void GuiPlatformGripResize(TopWindow *q) { - if(q->top) { + if(q->IsOpen()) { Point p = GetMousePos(); gtk_window_begin_resize_drag(q->gtk(), GDK_WINDOW_EDGE_SOUTH_EAST, 1, p.x, p.y, Ctrl::CurrentTime); diff --git a/uppsrc/CtrlCore/GtkCtrl.h b/uppsrc/CtrlCore/GtkCtrl.h index 18fb03127..ffb8753aa 100644 --- a/uppsrc/CtrlCore/GtkCtrl.h +++ b/uppsrc/CtrlCore/GtkCtrl.h @@ -4,11 +4,16 @@ static gboolean GtkProc(GtkWidget *widget, GdkEvent *event, gpointer user_data); static void IMCommit(GtkIMContext *context, gchar *str, gpointer user_data); - static void DoMouseEvent(int state, Point pos); static int DoButtonEvent(GdkEvent *event, bool press); - static void AddEvent(gpointer user_data, int type, const Value& value); + static void AddEvent(gpointer user_data, int type, const Value& value, GdkEvent *event); static void FetchEvents(bool may_block); +/* +_DBG_ + static void AddEvent(gpointer user_data, int type, const Value& value); + static void DoMouseEvent(int state, Point pos); +*/ + bool DispatchMouseIn(int act, int zd); void GtkMouseEvent(int action, int act, int zd); void GtkButtonEvent(int action); diff --git a/uppsrc/CtrlCore/GtkEvent.cpp b/uppsrc/CtrlCore/GtkEvent.cpp index f06f8657b..66c0c735b 100644 --- a/uppsrc/CtrlCore/GtkEvent.cpp +++ b/uppsrc/CtrlCore/GtkEvent.cpp @@ -125,16 +125,13 @@ gboolean Ctrl::GtkEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data) if(((GdkEventFocus *)event)->in) gtk_im_context_focus_in(p->top->im_context); else - gtk_im_context_focus_in(p->top->im_context); - AddEvent(user_data, EVENT_NONE, value); + gtk_im_context_focus_out(p->top->im_context); + AddEvent(user_data, EVENT_NONE, value, event); } return false; case GDK_LEAVE_NOTIFY: - case GDK_MOTION_NOTIFY: { - GdkEventMotion *e = (GdkEventMotion *)event; - DoMouseEvent(e->state, Point((int)e->x_root, (int)e->y_root)); + case GDK_MOTION_NOTIFY: break; - } case GDK_BUTTON_PRESS: value = DoButtonEvent(event, true); if(IsNull(value)) @@ -153,7 +150,6 @@ gboolean Ctrl::GtkEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data) case GDK_SCROLL: { GdkEventScroll *e = (GdkEventScroll *)event; value = findarg(e->direction, GDK_SCROLL_UP, GDK_SCROLL_LEFT) < 0 ? -120 : 120; - DoMouseEvent(e->state, Point((int)e->x_root, (int)e->y_root)); break; } case GDK_KEY_PRESS: @@ -177,14 +173,10 @@ gboolean Ctrl::GtkEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data) default: return false; } - AddEvent(user_data, event->type, value); + AddEvent(user_data, event->type, value, event); return retval; } -void Ctrl::DoMouseEvent(int state, Point pos) -{ -} - int Ctrl::DoButtonEvent(GdkEvent *event, bool press) { GdkEventButton *e = (GdkEventButton *)event; @@ -196,7 +188,6 @@ int Ctrl::DoButtonEvent(GdkEvent *event, bool press) state |= m; else state &= ~m; - DoMouseEvent(state, Point((int)e->x_root, (int)e->y_root)); return e->button; } return Null; @@ -218,7 +209,7 @@ void Ctrl::Event::Free() void Ctrl::Event::Set(const Event& e) { *(Event0 *)this = e; - event = gdk_event_copy(e.event); + event = e.event ? gdk_event_copy(e.event) : NULL; } Ctrl::Event::~Event() @@ -239,12 +230,11 @@ void Ctrl::Event::operator=(const Event& e) Set(e); } -void Ctrl::AddEvent(gpointer user_data, int type, const Value& value) +void Ctrl::AddEvent(gpointer user_data, int type, const Value& value, GdkEvent *event) { if(Events.GetCount() > 50000) return; Event& e = Events.AddTail(); - e.time = gtk_get_current_event_time(); e.windowid = (uint32)(uintptr_t)user_data; e.type = type; e.value = value; @@ -254,13 +244,21 @@ void Ctrl::AddEvent(gpointer user_data, int type, const Value& value) e.mousepos = Point(x, y); e.state = mod; e.count = 1; - e.event = gtk_get_current_event(); + e.event = NULL; + if(event) { + e.time = gdk_event_get_time(event); + e.event = gdk_event_copy(event); + } + else { + e.time = gtk_get_current_event_time(); + e.event = gtk_get_current_event(); + } } void Ctrl::IMCommit(GtkIMContext *context, gchar *str, gpointer user_data) { GuiLock __; - AddEvent(user_data, EVENT_TEXT, FromUtf8(str)); + AddEvent(user_data, EVENT_TEXT, FromUtf8(str), NULL); } void Ctrl::FetchEvents(bool may_block) @@ -345,7 +343,7 @@ void Ctrl::Proc() ProcStop tm; tm.ev = ev; #endif - if(!top) + if(!IsOpen()) return; Ptr _this = this; bool pressed = false; @@ -501,6 +499,8 @@ bool Ctrl::ProcessEvent0(bool *quit, bool fetch) break; } Event& e = Events.Head(); + DDUMP(e.type); + DDUMP(e.windowid); CurrentTime = e.time; CurrentMousePos = e.mousepos; CurrentState = e.state; diff --git a/uppsrc/CtrlCore/GtkWnd.cpp b/uppsrc/CtrlCore/GtkWnd.cpp index 1e5661b92..4c0d7af6c 100644 --- a/uppsrc/CtrlCore/GtkWnd.cpp +++ b/uppsrc/CtrlCore/GtkWnd.cpp @@ -100,7 +100,7 @@ void Ctrl::SetMouseCursor(const Image& image) if(pb) c = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pb, p.x, p.y); } - if(c) { + if(c && topctrl->IsOpen()) { gdk_window_set_cursor(topctrl->gdk(), c); gdk_cursor_unref(c); gdk_flush(); // Make it visible immediately @@ -111,7 +111,7 @@ void Ctrl::SetMouseCursor(const Image& image) Ctrl *Ctrl::GetOwner() { GuiLock __; - return top ? top->owner : NULL; + return IsOpen() ? top->owner : NULL; } Ctrl *Ctrl::GetActiveCtrl() @@ -187,7 +187,7 @@ void Ctrl::SyncCaret() { Rect Ctrl::GetWndScreenRect() const { GuiLock __; - if(top) { + if(IsOpen()) { gint x, y; gdk_window_get_position(gdk(), &x, &y); #if GTK_CHECK_VERSION(2, 24, 0) @@ -206,7 +206,7 @@ void Ctrl::WndShow(bool b) { GuiLock __; LLOG("WndShow " << Name() << ", " << b); - if(top) { + if(IsOpen()) { if(b) gtk_widget_show_now(top->window); else @@ -317,7 +317,7 @@ int Ctrl::GetKbdSpeed() void Ctrl::SetWndForeground() { GuiLock __; - if(top) + if(IsOpen()) gtk_window_present(gtk()); } @@ -325,19 +325,19 @@ bool Ctrl::IsWndForeground() const { GuiLock __; LLOG("IsWndForeground"); - return top && gtk_window_is_active(gtk()); + return IsOpen() && gtk_window_is_active(gtk()); } bool Ctrl::HasWndFocus() const { GuiLock __; - return top && gtk_window_is_active(gtk()); + return IsOpen() && gtk_window_is_active(gtk()); } void Ctrl::FocusSync() { GuiLock __; - if(focusCtrlWnd && gtk_window_is_active(focusCtrlWnd->gtk())) + if(focusCtrlWnd && focusCtrlWnd->IsOpen() && gtk_window_is_active(focusCtrlWnd->gtk())) return; Ptr focus = NULL; static Ptr ctrl; @@ -409,11 +409,11 @@ void Ctrl::WndSetPos(const Rect& rect) { LLOG("WndSetPos0 " << rect); GuiLock __; - if(!top) + if(!IsOpen()) return; Ptr this_ = this; SweepConfigure(false); // Remove any previous GDK_CONFIGURE for this window - if(!this_) + if(!this_ || !IsOpen()) return; // gtk_window_move(gtk(), rect.left, rect.top); // gtk_window_resize(gtk(), rect.GetWidth(), rect.GetHeight()); @@ -430,7 +430,7 @@ void Ctrl::WndSetPos(const Rect& rect) void Ctrl::WndEnable(bool b) { GuiLock __; - if(top) { + if(IsOpen()) { gtk_widget_set_sensitive(top->window, b); StateH(ENABLE); } diff --git a/uppsrc/TextDiffCtrl/TextCtrl.cpp b/uppsrc/TextDiffCtrl/TextCtrl.cpp index 2ceeb96c5..54b2f51ab 100644 --- a/uppsrc/TextDiffCtrl/TextCtrl.cpp +++ b/uppsrc/TextDiffCtrl/TextCtrl.cpp @@ -43,8 +43,7 @@ void TextCompareCtrl::LeftUp(Point pt, dword keyflags) void TextCompareCtrl::MouseMove(Point pt, dword keyflags) { - if(HasCapture()) - { + if(HasCapture()) { LeftDown(pt, keyflags); } } diff --git a/uppsrc/ide/Debuggers/Debuggers.h b/uppsrc/ide/Debuggers/Debuggers.h index 83c6f5682..6baf30c0e 100644 --- a/uppsrc/ide/Debuggers/Debuggers.h +++ b/uppsrc/ide/Debuggers/Debuggers.h @@ -20,6 +20,8 @@ bool TTYQuit(); String GdbCommand(bool console); +int CharFilterReSlash(int c); + class DbgDisas : public Ctrl { public: virtual void Paint(Draw& w); diff --git a/uppsrc/ide/Debuggers/Gdb.cpp b/uppsrc/ide/Debuggers/Gdb.cpp index 8612d941c..c339d8dc4 100644 --- a/uppsrc/ide/Debuggers/Gdb.cpp +++ b/uppsrc/ide/Debuggers/Gdb.cpp @@ -54,7 +54,7 @@ void Gdb::CopyDisas() disas.WriteClipboard(); } -static int CharFilterReSlash(int c) +int CharFilterReSlash(int c) { return c == '\\' ? '/' : c; } diff --git a/uppsrc/ide/Debuggers/Gdb_MI2.cpp b/uppsrc/ide/Debuggers/Gdb_MI2.cpp index 984aa4d5d..e22a57d4a 100644 --- a/uppsrc/ide/Debuggers/Gdb_MI2.cpp +++ b/uppsrc/ide/Debuggers/Gdb_MI2.cpp @@ -56,11 +56,6 @@ void Gdb_MI2::DebugBar(Bar& bar) bar.Add(b, "Copy dissassembly", THISBACK(CopyDisas)); } -static int CharFilterReSlash(int c) -{ - return c == '\\' ? '/' : c; -} - bool Gdb_MI2::SetBreakpoint(const String& filename, int line, const String& bp) { String file = Filter(host->GetHostPath(NormalizePath(filename)), CharFilterReSlash);