Constrain tooltips to monitors
Use st_tooltip_set_constrain_func() to set a function that constrains tooltips to be on the same monitor as the original tip area. https://bugzilla.gnome.org/show_bug.cgi?id=645547
This commit is contained in:
parent
d19cdc206b
commit
80eb37ef60
41
src/main.c
41
src/main.c
@ -108,6 +108,45 @@ shell_dbus_init (void)
|
|||||||
g_object_unref (bus);
|
g_object_unref (bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
constrain_tooltip (StTooltip *tooltip,
|
||||||
|
const ClutterGeometry *geometry,
|
||||||
|
ClutterGeometry *adjusted_geometry,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
const ClutterGeometry *tip_area = st_tooltip_get_tip_area (tooltip);
|
||||||
|
ShellGlobal *global = shell_global_get ();
|
||||||
|
MetaScreen *screen = shell_global_get_screen (global);
|
||||||
|
int n_monitors = meta_screen_get_n_monitors (screen);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
*adjusted_geometry = *geometry;
|
||||||
|
|
||||||
|
/* A point that determines what screen we'll constrain to */
|
||||||
|
int x = tip_area->x + tip_area->width / 2;
|
||||||
|
int y = tip_area->y + tip_area->height / 2;
|
||||||
|
|
||||||
|
for (i = 0; i < n_monitors; i++)
|
||||||
|
{
|
||||||
|
MetaRectangle rect;
|
||||||
|
meta_screen_get_monitor_geometry (screen, i, &rect);
|
||||||
|
if (x >= rect.x && x < rect.x + rect.width &&
|
||||||
|
y >= rect.y && y < rect.y + rect.height)
|
||||||
|
{
|
||||||
|
if (adjusted_geometry->x + adjusted_geometry->width > rect.x + rect.width)
|
||||||
|
adjusted_geometry->x = rect.x + rect.width - adjusted_geometry->width;
|
||||||
|
if (adjusted_geometry->x < rect.x)
|
||||||
|
adjusted_geometry->x = rect.x;
|
||||||
|
|
||||||
|
if (adjusted_geometry->y + adjusted_geometry->height > rect.y + rect.height)
|
||||||
|
adjusted_geometry->y = rect.y + rect.height - adjusted_geometry->height;
|
||||||
|
if (adjusted_geometry->y < rect.y)
|
||||||
|
adjusted_geometry->y = rect.y;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_font_options (GtkSettings *settings)
|
update_font_options (GtkSettings *settings)
|
||||||
@ -139,6 +178,8 @@ update_font_options (GtkSettings *settings)
|
|||||||
else
|
else
|
||||||
st_theme_context_set_default_resolution (context);
|
st_theme_context_set_default_resolution (context);
|
||||||
|
|
||||||
|
st_tooltip_set_constrain_func (stage, constrain_tooltip, NULL, NULL);
|
||||||
|
|
||||||
/* Clutter (as of 0.9) passes comprehensively wrong font options
|
/* Clutter (as of 0.9) passes comprehensively wrong font options
|
||||||
* override whatever set_font_flags() did above.
|
* override whatever set_font_flags() did above.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user