css: Add -gtk-dpi CSS property hack
This property is necessary to ensure widgets automatically update after
the text scale factor is changed desktop-wide.
And if I'm already doing a property like this, I can make it
overridable. So now you can override the dpi per-widget with CSS like
GtkSwitch {
-gtk-dpi: 48;
}
if you want to debug things.
Long-term, we want to get rid of this property and insist on dpi being
96 everywhere and people can change the font size to get larger fonts.
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssstringvalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
@ -49,6 +50,18 @@ gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case GTK_CSS_PROPERTY_DPI:
|
||||
settings = _gtk_style_provider_private_get_settings (provider);
|
||||
if (settings)
|
||||
{
|
||||
GdkScreen *screen = _gtk_settings_get_screen (settings);
|
||||
double resolution = gdk_screen_get_resolution (screen);
|
||||
|
||||
if (resolution > 0.0)
|
||||
return _gtk_css_number_value_new (resolution, GTK_CSS_NUMBER);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_CSS_PROPERTY_FONT_FAMILY:
|
||||
settings = _gtk_style_provider_private_get_settings (provider);
|
||||
if (settings)
|
||||
|
||||
Reference in New Issue
Block a user