@@ -627,6 +627,75 @@ meta_compositor_unmanage (MetaCompositor *compositor)
627627 META_COMPOSITOR_GET_CLASS (compositor )-> unmanage (compositor );
628628}
629629
630+ static void
631+ ensure_tooltip_visible (MetaWindow * window )
632+ {
633+ const MetaLogicalMonitor * monitor ;
634+ MetaRectangle work_area , win_rect ;
635+ gint new_x , new_y ;
636+
637+ /* Why this is here:
638+ * As of gtk 3.24, tooltips for GtkStatusIcons began displaying their tool tip
639+ * off the screen in certain situations.
640+ *
641+ * See: https://github.com/GNOME/gtk/commit/14d22cb3233e
642+ *
643+ * If the status icon is too small relative to its panel (which has been assigned
644+ * as a strut to muffin), tooltip positioning fails both tests in gdkwindowimpl.c
645+ * (maybe_flip_position()) skipping repositioning of the tooltip inside the workarea.
646+ * This only occurs on bottom panels, and only begins happening when the status icon
647+ * becomes 10px or more smaller than the panel it's *centered* on.
648+ *
649+ * Since the calculations are based upon the monitor's workarea and the status icon
650+ * plug window's size, there's no way to compensate for or fool gtk into displaying it
651+ * correctly. So here, we do our own check and adjustment if a part of the tooltip
652+ * window falls outside the current monitor's work area. This is also useful since
653+ * muffin knows *exactly* the work area for each monitor, whereas gtk only has
654+ * _NET_WORKAREA to go by, which only keeps track of (primary monitor * n_workspaces),
655+ * so an odd monitor layout would trip this up anyhow.
656+ *
657+ * This may cause regressions - see: https://github.com/linuxmint/muffin/commit/050038690,
658+ * but without being able to reproduce the issue mentioned there, we'll just have to address
659+ * it if it appears again as a result of this change. */
660+
661+ monitor = window -> monitor ;
662+
663+ if (!monitor )
664+ return ;
665+
666+ meta_workspace_get_work_area_for_monitor (meta_workspace_manager_get_active_workspace (window -> display -> workspace_manager ),
667+ monitor -> number ,
668+ & work_area );
669+
670+ meta_window_get_buffer_rect (window , & win_rect );
671+
672+ new_x = win_rect .x ;
673+ new_y = win_rect .y ;
674+
675+ if (win_rect .y < work_area .y )
676+ {
677+ new_y = work_area .y ;
678+ }
679+ else if (win_rect .y + win_rect .height > work_area .y + work_area .height )
680+ {
681+ new_y = (work_area .y + work_area .height - win_rect .height );
682+ }
683+
684+ if (win_rect .x < work_area .x )
685+ {
686+ new_x = work_area .x ;
687+ }
688+ else if (win_rect .x + win_rect .width > work_area .x + work_area .width )
689+ {
690+ new_x = (work_area .x + work_area .width - win_rect .width );
691+ }
692+
693+ if (new_x != win_rect .x || new_y != win_rect .y )
694+ {
695+ meta_window_move_frame (window , FALSE, new_x , new_y );
696+ }
697+ }
698+
630699void
631700meta_compositor_add_window (MetaCompositor * compositor ,
632701 MetaWindow * window )
@@ -659,7 +728,15 @@ meta_compositor_add_window (MetaCompositor *compositor,
659728 NULL );
660729
661730 if (window -> layer == META_LAYER_OVERRIDE_REDIRECT )
662- window_group = priv -> top_window_group ;
731+ {
732+ if (window -> type == META_WINDOW_TOOLTIP )
733+ {
734+ ensure_tooltip_visible (window );
735+ }
736+
737+ window_group = priv -> top_window_group ;
738+ }
739+
663740 else if (window -> type == META_WINDOW_DESKTOP )
664741 window_group = priv -> bottom_window_group ;
665742 else
0 commit comments