[med-svn] [aghermann] 12/23: correctly anchor menu for Alt+N on SF montage

andrei zavada hmmr-guest at moszumanska.debian.org
Wed Jan 4 22:59:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to tag 1.1.2
in repository aghermann.

commit 6abff5488cc76c52240deec63b8a394553004a9e
Author: Andrei Zavada <hmmr at frdg>
Date:   Tue Jan 3 05:49:55 2017 +0200

    correctly anchor menu for Alt+N on SF montage
---
 upstream/src/aghermann/ui/sf/mainmenu_cb.cc | 34 ++++++++++++++++-------------
 upstream/src/aghermann/ui/sf/sf.cc          |  6 +++--
 upstream/src/aghermann/ui/ui.cc             | 21 ++++++++++++++++++
 upstream/src/aghermann/ui/ui.hh             |  6 ++---
 4 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/upstream/src/aghermann/ui/sf/mainmenu_cb.cc b/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
index c196d0d..73e2c04 100644
--- a/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
+++ b/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
@@ -260,23 +260,21 @@ iSFMontageCloseAndNext_activate_cb(
 
 namespace {
 
-#define EVENT_X 30
-
+const double EVENT_X = 40;
 size_t position_for_channel = -1;
+
 void channel_menu_position(
         GtkMenu*,
         gint *x,
         gint *y,
-        gboolean*, //push_in,
         const gpointer userdata)
 {
         auto& SF = *(SScoringFacility*)userdata;
-        int mwx, mwy, rwx, rwy;
-        gtk_window_get_position( SF.wSF, &mwx, &mwy);
+        int rwx, rwy;
         gdk_window_get_position( gtk_widget_get_window( (GtkWidget*)SF.daSFMontage), &rwx, &rwy);
         if ( position_for_channel < SF.channels.size() ) {
-                *x = mwx + rwx + EVENT_X;
-                *y = mwy + rwx + SF[position_for_channel].zeroy-20;
+                *x = rwx + EVENT_X;
+                *y = rwy + SF[position_for_channel].zeroy-20;
         } else
                 *x = *y = 0;
 }
@@ -284,7 +282,7 @@ void channel_menu_position(
 }
 
 gboolean
-wSF_key_press_event_cb( GtkWidget*, const GdkEventKey *event, const gpointer userdata)
+wSF_key_press_event_cb( GtkWidget* window, const GdkEventKey *event, const gpointer userdata)
 {
         auto& SF = *(SScoringFacility*)userdata;
 
@@ -293,13 +291,19 @@ wSF_key_press_event_cb( GtkWidget*, const GdkEventKey *event, const gpointer use
                 return FALSE;
 
 #define KEKE(N) \
-        position_for_channel = N-1;                                        \
-        if ( position_for_channel < SF.channels.size() ) {                \
-                SF.using_channel = &SF[position_for_channel];                \
-                SF.using_channel->update_channel_menu_items( EVENT_X);        \
-                gtk_menu_popup( SF.iiSFPage, NULL, NULL, channel_menu_position, userdata, 3, event->time); \
-        } else                                                                \
-                gdk_beep();                                                \
+        position_for_channel = N-1;                                     \
+        if ( position_for_channel < SF.channels.size() ) {              \
+                SF.using_channel = &SF[position_for_channel];           \
+                SF.using_channel->update_channel_menu_items( EVENT_X);  \
+                GdkRectangle rect;                                      \
+                channel_menu_position( SF.iiSFPage, &rect.x, &rect.y, userdata); \
+                rect.width = rect.height = 1;                           \
+                gtk_menu_popup_at_rect( SF.iiSFPage, gtk_widget_get_window(window), &rect, \
+                                        GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL); \
+                gtk_label_set_text( SF.lSFOverChannel, SF.using_channel->name()); \
+                gtk_widget_queue_draw( window);                         \
+        } else                                                          \
+                gdk_beep();                                             \
         return TRUE;
 
         switch ( event->keyval ) {
diff --git a/upstream/src/aghermann/ui/sf/sf.cc b/upstream/src/aghermann/ui/sf/sf.cc
index 87083a6..170eca1 100644
--- a/upstream/src/aghermann/ui/sf/sf.cc
+++ b/upstream/src/aghermann/ui/sf/sf.cc
@@ -279,14 +279,16 @@ SScoringFacility (agh::CSubject& J,
                         "You can hide some using appropriate channel context menus.", channels.size() - n_hidden);
 
         {
+                GdkRectangle rect;
+                get_monitor_geometry( gtk_widget_get_window((GtkWidget*)wSF), &rect);
                 int bar_height;
                 gtk_widget_get_size_request( (GtkWidget*)cSFControlBar, NULL, &bar_height);
                 int optimal_win_height = min(
                         (int)(HypnogramHeight + bar_height + da_ht + 100),
-                        (int)(gdk_screen_get_height( gdk_screen_get_default()) * .95));
+                        (int)(rect.height * .95));
                 gtk_window_set_default_size(
                         wSF,
-                        gdk_screen_get_width( gdk_screen_get_default()) * .90,
+                        rect.width * .90,
                         optimal_win_height);
         }
 
diff --git a/upstream/src/aghermann/ui/ui.cc b/upstream/src/aghermann/ui/ui.cc
index 3489e92..b52148e 100644
--- a/upstream/src/aghermann/ui/ui.cc
+++ b/upstream/src/aghermann/ui/ui.cc
@@ -19,6 +19,27 @@ using namespace std;
 using namespace agh::ui;
 
 
+void
+agh::ui::
+get_monitor_geometry( GdkWindow    *window,
+                      GdkRectangle *geometry)
+{
+        GdkDisplay *display = gdk_display_get_default();
+        GdkMonitor *monitor = gdk_display_get_monitor_at_window( display, window);
+
+        gdk_monitor_get_geometry( monitor, geometry);
+}
+
+
+void
+agh::ui::
+set_window_size_as_screen_fraction( GtkWindow* window, double fx, double fy)
+{
+        GdkRectangle rect;
+        get_monitor_geometry( gtk_widget_get_window((GtkWidget*)window), &rect);
+        gtk_window_set_default_size( window, rect.width * fx, rect.height * fy);
+}
+
 
 // cairo
 
diff --git a/upstream/src/aghermann/ui/ui.hh b/upstream/src/aghermann/ui/ui.hh
index 6da80ca..779ba1a 100644
--- a/upstream/src/aghermann/ui/ui.hh
+++ b/upstream/src/aghermann/ui/ui.hh
@@ -33,7 +33,6 @@ namespace agh {
 namespace ui {
 
 
-
 inline void
 gtk_flush()
 {
@@ -41,11 +40,12 @@ gtk_flush()
                 gtk_main_iteration();
 }
 
+void get_monitor_geometry( GdkWindow*, GdkRectangle*);
+void set_window_size_as_screen_fraction( GtkWindow*, double fx, double fy);
+
 void gtk_combo_box_set_model_properly( GtkComboBox*, GtkListStore*);
 void gtk_cell_layout_set_renderer( GtkComboBox*);
 
-
-
 enum class TDrawSignalDirection { forward, backward };
 enum class TDrawSignalPathOption { yes, no };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list