]> git.alsa-project.org Git - alsa.git/commitdiff
hda-analyzer: Fix popup in graph
authorJacek Kosek <Jacek Kosek>
Wed, 12 Jan 2022 14:58:21 +0000 (15:58 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 6 Apr 2023 06:57:39 +0000 (08:57 +0200)
From: Jacek Kosek
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
hda-analyzer/hda_graph.py

index 5c616912089569c5413722154a6ee855145d82d3..631872162e5d90ae99e79a1ed49e339fce8c145c 100755 (executable)
@@ -657,7 +657,7 @@ class CodecGraphLayout(Gtk.Layout):
 
     if self.popup_win:
       self.popup_win.destroy()
-    self.popup_win = Gtk.Window(Gtk.WindowType.POPUP)
+    self.popup_win = Gtk.Window.new(Gtk.WindowType.POPUP)
     label = Gtk.Label()
     label.modify_font(get_fixed_font())
     label.set_text(self.popup)
@@ -666,18 +666,14 @@ class CodecGraphLayout(Gtk.Layout):
     self.popup_win.show_all()
     popup_width, popup_height = self.popup_win.get_size()
 
-    #rootwin = self.get_screen().get_root_window()
-    #x, y, mods = rootwin.get_pointer()
+    pos_x = event.x_root + 10
+    if pos_x + popup_width > screen_width:
+      pos_x = pos_x - popup_width - 20
+    pos_y = event.y_root + 10
+    if pos_y + popup_height > screen_height:
+      pos_y = pos_y - popup_height - 20
 
-    pos_x = screen_width - popup_width
-    if pos_x < 0:
-      pos_x = 0
-    pos_y = screen_height - popup_height
-    if pos_y < 0:
-      pox_y = 0
-
-    self.popup_win.move(int(pos_x), int(pos_y))
-    #self.popup_win.show_all()
+    self.popup_win.move(pos_x, pos_y)
 
   def mouse_move(self, widget, event):
     oldpopup = self.popup
@@ -909,19 +905,19 @@ class CodecGraph(Gtk.Window):
     statusbar = Gtk.Statusbar()
     self.layout = CodecGraphLayout(None, None, codec, self.get_title(), statusbar)
     table.attach(self.layout, 0, 1, 0, 1, Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND,
-                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND, 0, 0)
+                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND)
     vScrollbar = Gtk.VScrollbar(None)
     table.attach(vScrollbar, 1, 2, 0, 1, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK,
-                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0)
+                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK)
     hScrollbar = Gtk.HScrollbar(None)
     table.attach(hScrollbar, 0, 1, 1, 2, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK,
-                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0)        
+                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK)      
     vAdjust = self.layout.get_vadjustment()
     vScrollbar.set_adjustment(vAdjust)
     hAdjust = self.layout.get_hadjustment()
     hScrollbar.set_adjustment(hAdjust)
     table.attach(statusbar, 0, 2, 2, 3, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK,
-                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0)
+                 Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK)
     self.show_all()
     GRAPH_WINDOWS[codec] = self
     TRACKER.add(self)