[nemiver] Hide var tooltip appropriatly (Closes: #545596)
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver] Hide var tooltip appropriatly (Closes: #545596)
- Date: Tue, 2 Jun 2009 10:18:04 -0400 (EDT)
commit 6a5d14a2c20d7968f2628dacf3ae8b933db59d4c
Author: Dodji Seketeli <dodji redhat com>
Date: Tue Jun 2 15:52:03 2009 +0200
Hide var tooltip appropriatly (Closes: #545596)
* src/uicommon/nmv-popup-tip.cc:
(PopupTip::Priv::Priv): Hide the popup tip window whenever
mouse or keyboard focus leaves said window.
(PopupTip::Priv::on_leave_notify_event,
PopupTip::Priv::on_signal_focus_out_event): New methods.
(PopupTip::PopupTip): Gently ask window managers to treat the
popup tip as a popup menu.
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::show_underline_tip_at_position,
DBGPerspective::get_popup_tip): Make sure
the var inspector is created before accessing it.
(DBGPerspective::restart_mouse_immobile_timer,
DBGPerspective::stop_mouse_immobile_timer): This the wrong level
to try to hide the popup tip.
(DBGPerspective::get_popup_var_inspector): New method.
(DBGPerspective::hide_popup_tip): Removed this.
---
src/persp/dbgperspective/nmv-dbg-perspective.cc | 56 ++++++++---------------
src/uicommon/nmv-popup-tip.cc | 38 +++++++++++++++
2 files changed, 58 insertions(+), 36 deletions(-)
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 4ada7b9..465ad58 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -453,12 +453,12 @@ private:
#ifdef WITH_VAROBJS
void show_underline_tip_at_position (int a_x, int a_y,
IDebugger::VariableSafePtr a_var);
+ VarInspector2& get_popup_var_inspector ();
#endif // WITH_VAROBJS
void restart_mouse_immobile_timer ();
void stop_mouse_immobile_timer ();
PopupTip& get_popup_tip ();
- void hide_popup_tip ();
FindTextDialog& get_find_text_dialog ();
public:
@@ -1770,10 +1770,6 @@ DBGPerspective::on_button_pressed_in_source_view_signal
LOG_FUNCTION_SCOPE_NORMAL_DD;
NEMIVER_TRY
- if (get_popup_tip ().is_visible ()) {
- hide_popup_tip ();
- }
-
if (a_event->type != GDK_BUTTON_PRESS) {
return false;
}
@@ -4167,7 +4163,7 @@ DBGPerspective::try_to_request_show_variable_value_at_position (int a_x,
int abs_x=0, abs_y=0;
gdk_window->get_origin (abs_x, abs_y);
abs_x += a_x;
- abs_y += a_y /*+ start_rect.get_height () / 2*/;
+ abs_y += a_y + start_rect.get_height () / 2;
m_priv->in_show_var_value_at_pos_transaction = true;
m_priv->var_popup_tip_x = abs_x;
m_priv->var_popup_tip_y = abs_y;
@@ -4202,10 +4198,25 @@ DBGPerspective::show_underline_tip_at_position
const IDebugger::VariableSafePtr a_var)
{
LOG_FUNCTION_SCOPE_NORMAL_DD
- m_priv->popup_var_inspector->set_variable (a_var,
- true /* expand variable */);
+ get_popup_var_inspector ().set_variable (a_var,
+ true /* expand variable */);
get_popup_tip ().show_at_position (a_x, a_y);
}
+
+VarInspector2&
+DBGPerspective::get_popup_var_inspector ()
+{
+ LOG_FUNCTION_SCOPE_NORMAL_DD
+
+ if (!m_priv->popup_var_inspector)
+ m_priv->popup_var_inspector.reset
+ (new VarInspector2 (debugger (),
+ *const_cast<DBGPerspective*> (this)));
+
+ THROW_IF_FAIL (m_priv->popup_var_inspector);
+ return *m_priv->popup_var_inspector;
+}
+
#endif // WITH_VAROBJS
void
@@ -4222,7 +4233,6 @@ DBGPerspective::restart_mouse_immobile_timer ()
(sigc::mem_fun
(*this, &DBGPerspective::on_mouse_immobile_timer_signal),
1);
- hide_popup_tip ();
}
void
@@ -4231,7 +4241,6 @@ DBGPerspective::stop_mouse_immobile_timer ()
LOG_FUNCTION_SCOPE_NORMAL_D (DBG_PERSPECTIVE_MOUSE_MOTION_DOMAIN);
THROW_IF_FAIL (m_priv);
m_priv->timeout_source_connection.disconnect ();
- hide_popup_tip ();
}
PopupTip&
@@ -4242,38 +4251,13 @@ DBGPerspective::get_popup_tip ()
if (!m_priv->popup_tip) {
m_priv->popup_tip.reset (new PopupTip);
#ifdef WITH_VAROBJS
- m_priv->popup_var_inspector.reset
- (new VarInspector2 (debugger (), *this));
- m_priv->popup_tip->add_child (m_priv->popup_var_inspector->widget ());
+ m_priv->popup_tip->add_child (get_popup_var_inspector ().widget ());
#endif
}
THROW_IF_FAIL (m_priv->popup_tip);
return *m_priv->popup_tip;
}
-/// If the pointer is outside of the popup window,
-/// of the variable popup tip, then hide it.
-void
-DBGPerspective::hide_popup_tip ()
-{
- if (get_popup_tip ().get_window ()) {
- int x = 0, y = 0;
- GdkModifierType state = (GdkModifierType) 0;
- gdk_window_get_pointer (get_popup_tip ().get_window ()->gobj (),
- &x, &y, &state);
- Gdk::Rectangle alloc = get_popup_tip ().get_allocation ();
- if (x < 0
- || y < 0
- || x > alloc.get_width ()
- || y > alloc.get_height ()) {
- LOG_DD ("(x,y): (" << (int)x << "," << (int)y << "), "
- << "(w,h): ("
- << alloc.get_width () << "," << alloc.get_height () << ")");
- get_popup_tip ().hide ();
- }
- }
-}
-
FindTextDialog&
DBGPerspective::get_find_text_dialog ()
{
diff --git a/src/uicommon/nmv-popup-tip.cc b/src/uicommon/nmv-popup-tip.cc
index f602bc9..5791583 100644
--- a/src/uicommon/nmv-popup-tip.cc
+++ b/src/uicommon/nmv-popup-tip.cc
@@ -71,6 +71,13 @@ public:
(sigc::mem_fun (*this,
&Priv::on_expose_event_signal));
+ window.add_events (Gdk::LEAVE_NOTIFY_MASK
+ | Gdk::FOCUS_CHANGE_MASK);
+ window.signal_leave_notify_event ().connect
+ (sigc::mem_fun (*this, &Priv::on_leave_notify_event));
+ window.signal_focus_out_event ().connect
+ (sigc::mem_fun (*this, &Priv::on_signal_focus_out_event));
+
window.ensure_style ();
}
@@ -103,12 +110,43 @@ public:
NEMIVER_CATCH
return false;
}
+
+ bool
+ on_leave_notify_event (GdkEventCrossing *a_event)
+ {
+ NEMIVER_TRY
+
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ if (a_event
+ && a_event->type == GDK_LEAVE_NOTIFY
+ && a_event->detail != GDK_NOTIFY_INFERIOR)
+ window.hide ();
+
+ NEMIVER_CATCH
+
+ return false;
+ }
+
+ bool
+ on_signal_focus_out_event (GdkEventFocus *)
+ {
+ NEMIVER_TRY
+
+ window.hide ();
+
+ NEMIVER_CATCH
+
+ return false;
+ }
+
};//end PopupTip
PopupTip::PopupTip (const UString &a_text) :
Gtk::Window (Gtk::WINDOW_POPUP)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
+ set_type_hint (Gdk::WINDOW_TYPE_HINT_POPUP_MENU );
m_priv.reset (new PopupTip::Priv (*this));
if (!a_text.empty ())
text (a_text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]