Add window size constraint option in gsettings.
This commit is contained in:
		@ -46,6 +46,16 @@
 | 
				
			|||||||
      <summary>Switch to fullscreen mode when startup</summary>
 | 
					      <summary>Switch to fullscreen mode when startup</summary>
 | 
				
			||||||
      <description>If true, switch to fullscreen mode when startup.</description>
 | 
					      <description>If true, switch to fullscreen mode when startup.</description>
 | 
				
			||||||
    </key>
 | 
					    </key>
 | 
				
			||||||
 | 
					    <key name="size-constraint-landscape" type="(dd)">
 | 
				
			||||||
 | 
					      <default>(1.0, 0.3)</default>
 | 
				
			||||||
 | 
					      <summary>Constraint of the maximum window size on landscape screen</summary>
 | 
				
			||||||
 | 
					      <description>Constraint of maximum window size on landscape screen</description>
 | 
				
			||||||
 | 
					    </key>
 | 
				
			||||||
 | 
					    <key name="size-constraint-portrait" type="(dd)">
 | 
				
			||||||
 | 
					      <default>(1.0, 0.5)</default>
 | 
				
			||||||
 | 
					      <summary>Constraint of the maximum window size on portrait screen</summary>
 | 
				
			||||||
 | 
					      <description>Constraint of maximum window size on portrait screen</description>
 | 
				
			||||||
 | 
					    </key>
 | 
				
			||||||
    <key name="theme" type="s">
 | 
					    <key name="theme" type="s">
 | 
				
			||||||
      <default>'default'</default>
 | 
					      <default>'default'</default>
 | 
				
			||||||
      <summary>Theme</summary>
 | 
					      <summary>Theme</summary>
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,8 @@
 | 
				
			|||||||
enum {
 | 
					enum {
 | 
				
			||||||
    PROP_0,
 | 
					    PROP_0,
 | 
				
			||||||
    PROP_UI_TOOLKIT,
 | 
					    PROP_UI_TOOLKIT,
 | 
				
			||||||
 | 
					    PROP_SIZE_CONSTRAINT_LANDSCAPE,
 | 
				
			||||||
 | 
					    PROP_SIZE_CONSTRAINT_PORTRAIT,
 | 
				
			||||||
    PROP_LAST
 | 
					    PROP_LAST
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -59,6 +61,8 @@ struct _ServerContextService {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    GSettings *settings;
 | 
					    GSettings *settings;
 | 
				
			||||||
    UIToolkitType ui_toolkit;
 | 
					    UIToolkitType ui_toolkit;
 | 
				
			||||||
 | 
					    gdouble size_constraint_landscape[2];
 | 
				
			||||||
 | 
					    gdouble size_constraint_portrait[2];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct _ServerContextServiceClass {
 | 
					struct _ServerContextServiceClass {
 | 
				
			||||||
@ -238,7 +242,16 @@ set_geometry (ServerContextService *context)
 | 
				
			|||||||
                                          context);
 | 
					                                          context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (eekboard_context_service_get_fullscreen (EEKBOARD_CONTEXT_SERVICE(context))) {
 | 
					    if (eekboard_context_service_get_fullscreen (EEKBOARD_CONTEXT_SERVICE(context))) {
 | 
				
			||||||
        gint width = rect.width, height = rect.height / 2;
 | 
					        gint width = rect.width;
 | 
				
			||||||
 | 
					        gint height = rect.height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (width > height) {
 | 
				
			||||||
 | 
					            width *= context->size_constraint_landscape[0];
 | 
				
			||||||
 | 
					            height *= context->size_constraint_landscape[1];
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            width *= context->size_constraint_portrait[0];
 | 
				
			||||||
 | 
					            height *= context->size_constraint_portrait[1];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (width * bounds.height > height * bounds.width)
 | 
					        if (width * bounds.height > height * bounds.width)
 | 
				
			||||||
            width = (height / bounds.height) * bounds.width;
 | 
					            width = (height / bounds.height) * bounds.width;
 | 
				
			||||||
@ -402,6 +415,7 @@ server_context_service_set_property (GObject      *object,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
 | 
					    ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
 | 
				
			||||||
    const gchar *ui_toolkit;
 | 
					    const gchar *ui_toolkit;
 | 
				
			||||||
 | 
					    GVariant *variant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (prop_id) {
 | 
					    switch (prop_id) {
 | 
				
			||||||
    case PROP_UI_TOOLKIT:
 | 
					    case PROP_UI_TOOLKIT:
 | 
				
			||||||
@ -415,6 +429,19 @@ server_context_service_set_property (GObject      *object,
 | 
				
			|||||||
        else
 | 
					        else
 | 
				
			||||||
            g_warning ("unknown UI toolkit %s", ui_toolkit);
 | 
					            g_warning ("unknown UI toolkit %s", ui_toolkit);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					    case PROP_SIZE_CONSTRAINT_LANDSCAPE:
 | 
				
			||||||
 | 
					        variant = g_value_get_variant (value);
 | 
				
			||||||
 | 
					        g_variant_get (variant, "(dd)",
 | 
				
			||||||
 | 
					                       &context->size_constraint_landscape[0],
 | 
				
			||||||
 | 
					                       &context->size_constraint_landscape[1]);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case PROP_SIZE_CONSTRAINT_PORTRAIT:
 | 
				
			||||||
 | 
					        variant = g_value_get_variant (value);
 | 
				
			||||||
 | 
					        g_variant_get (variant, "(dd)",
 | 
				
			||||||
 | 
					                       &context->size_constraint_portrait[0],
 | 
				
			||||||
 | 
					                       &context->size_constraint_portrait[1]);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
        g_object_set_property (object,
 | 
					        g_object_set_property (object,
 | 
				
			||||||
                               g_param_spec_get_name (pspec),
 | 
					                               g_param_spec_get_name (pspec),
 | 
				
			||||||
@ -459,6 +486,26 @@ server_context_service_class_init (ServerContextServiceClass *klass)
 | 
				
			|||||||
    g_object_class_install_property (gobject_class,
 | 
					    g_object_class_install_property (gobject_class,
 | 
				
			||||||
                                     PROP_UI_TOOLKIT,
 | 
					                                     PROP_UI_TOOLKIT,
 | 
				
			||||||
                                     pspec);
 | 
					                                     pspec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pspec = g_param_spec_variant ("size-constraint-landscape",
 | 
				
			||||||
 | 
					                                  "Size constraint landscape",
 | 
				
			||||||
 | 
					                                  "Size constraint landscape",
 | 
				
			||||||
 | 
					                                  G_VARIANT_TYPE("(dd)"),
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  G_PARAM_WRITABLE);
 | 
				
			||||||
 | 
					    g_object_class_install_property (gobject_class,
 | 
				
			||||||
 | 
					                                     PROP_SIZE_CONSTRAINT_LANDSCAPE,
 | 
				
			||||||
 | 
					                                     pspec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pspec = g_param_spec_variant ("size-constraint-portrait",
 | 
				
			||||||
 | 
					                                  "Size constraint portrait",
 | 
				
			||||||
 | 
					                                  "Size constraint portrait",
 | 
				
			||||||
 | 
					                                  G_VARIANT_TYPE("(dd)"),
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  G_PARAM_WRITABLE);
 | 
				
			||||||
 | 
					    g_object_class_install_property (gobject_class,
 | 
				
			||||||
 | 
					                                     PROP_SIZE_CONSTRAINT_PORTRAIT,
 | 
				
			||||||
 | 
					                                     pspec);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
@ -484,6 +531,20 @@ server_context_service_init (ServerContextService *context)
 | 
				
			|||||||
    g_settings_bind (context->settings, "ui-toolkit",
 | 
					    g_settings_bind (context->settings, "ui-toolkit",
 | 
				
			||||||
                     context, "ui-toolkit",
 | 
					                     context, "ui-toolkit",
 | 
				
			||||||
                     G_SETTINGS_BIND_GET);
 | 
					                     G_SETTINGS_BIND_GET);
 | 
				
			||||||
 | 
					    g_settings_bind_with_mapping (context->settings, "size-constraint-landscape",
 | 
				
			||||||
 | 
					                                  context, "size-constraint-landscape",
 | 
				
			||||||
 | 
					                                  G_SETTINGS_BIND_GET,
 | 
				
			||||||
 | 
					                                  (GSettingsBindGetMapping *)g_value_set_variant,
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  NULL);
 | 
				
			||||||
 | 
					    g_settings_bind_with_mapping (context->settings, "size-constraint-portrait",
 | 
				
			||||||
 | 
					                                  context, "size-constraint-portrait",
 | 
				
			||||||
 | 
					                                  G_SETTINGS_BIND_GET,
 | 
				
			||||||
 | 
					                                  (GSettingsBindGetMapping *)g_value_set_variant,
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  NULL,
 | 
				
			||||||
 | 
					                                  NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ServerContextService *
 | 
					ServerContextService *
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user