mirror of
https://gitlab.gnome.org/GNOME/libmks.git
synced 2024-12-22 13:45:21 +00:00
parent
6a024f0e5d
commit
69dfaddb9d
@ -19,12 +19,13 @@
|
|||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "mks-screen-attributes.h"
|
#include "mks-screen-attributes.h"
|
||||||
#include "mks-screen-resizer-private.h"
|
#include "mks-screen-resizer-private.h"
|
||||||
#include "mks-util-private.h"
|
#include "mks-util-private.h"
|
||||||
|
|
||||||
static void
|
static void mks_screen_resizer_reconfigure (MksScreenResizer *self,
|
||||||
mks_screen_resizer_reconfigure (MksScreenResizer *self,
|
|
||||||
MksScreenAttributes *attributes);
|
MksScreenAttributes *attributes);
|
||||||
|
|
||||||
struct _MksScreenResizer
|
struct _MksScreenResizer
|
||||||
@ -36,7 +37,8 @@ struct _MksScreenResizer
|
|||||||
/* Remember our last operation */
|
/* Remember our last operation */
|
||||||
MksScreenAttributes *next_op;
|
MksScreenAttributes *next_op;
|
||||||
MksScreenAttributes *previous_op;
|
MksScreenAttributes *previous_op;
|
||||||
gboolean in_progress;
|
|
||||||
|
guint in_progress : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -62,6 +64,7 @@ mks_screen_resizer_get_property (GObject *object,
|
|||||||
case PROP_SCREEN:
|
case PROP_SCREEN:
|
||||||
g_value_set_object (value, self->screen);
|
g_value_set_object (value, self->screen);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -102,6 +105,7 @@ static void
|
|||||||
mks_screen_resizer_class_init (MksScreenResizerClass *klass)
|
mks_screen_resizer_class_init (MksScreenResizerClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->dispose = mks_screen_resizer_dispose;
|
object_class->dispose = mks_screen_resizer_dispose;
|
||||||
object_class->get_property = mks_screen_resizer_get_property;
|
object_class->get_property = mks_screen_resizer_get_property;
|
||||||
object_class->set_property = mks_screen_resizer_set_property;
|
object_class->set_property = mks_screen_resizer_set_property;
|
||||||
@ -120,9 +124,9 @@ on_screen_configure_cb (GObject *object,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MksScreen *screen = (MksScreen *)object;
|
MksScreen *screen = (MksScreen *)object;
|
||||||
|
g_autoptr(MksScreenAttributes) attributes = NULL;
|
||||||
g_autoptr(MksScreenResizer) self = user_data;
|
g_autoptr(MksScreenResizer) self = user_data;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(MksScreenAttributes) attributes = NULL;
|
|
||||||
|
|
||||||
MKS_ENTRY;
|
MKS_ENTRY;
|
||||||
|
|
||||||
@ -135,12 +139,10 @@ on_screen_configure_cb (GObject *object,
|
|||||||
|
|
||||||
self->in_progress = FALSE;
|
self->in_progress = FALSE;
|
||||||
attributes = g_steal_pointer (&self->next_op);
|
attributes = g_steal_pointer (&self->next_op);
|
||||||
if (attributes != NULL &&
|
|
||||||
!mks_screen_attributes_equal (attributes, self->previous_op))
|
if (!mks_screen_attributes_equal (attributes, self->previous_op))
|
||||||
{
|
mks_screen_resizer_reconfigure (self, g_steal_pointer (&attributes));
|
||||||
mks_screen_resizer_reconfigure (self,
|
|
||||||
g_steal_pointer (&attributes));
|
|
||||||
}
|
|
||||||
MKS_EXIT;
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,13 +154,7 @@ on_screen_configure_cb (GObject *object,
|
|||||||
MksScreenResizer *
|
MksScreenResizer *
|
||||||
mks_screen_resizer_new (void)
|
mks_screen_resizer_new (void)
|
||||||
{
|
{
|
||||||
MksScreenResizer *self;
|
return g_object_new (MKS_TYPE_SCREEN_RESIZER, NULL);
|
||||||
|
|
||||||
self = g_object_new (MKS_TYPE_SCREEN_RESIZER, NULL);
|
|
||||||
self->next_op = NULL;
|
|
||||||
self->previous_op = NULL;
|
|
||||||
self->in_progress = FALSE;
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,13 +174,15 @@ void
|
|||||||
mks_screen_resizer_set_screen (MksScreenResizer *self,
|
mks_screen_resizer_set_screen (MksScreenResizer *self,
|
||||||
MksScreen *screen)
|
MksScreen *screen)
|
||||||
{
|
{
|
||||||
|
MKS_ENTRY;
|
||||||
|
|
||||||
g_return_if_fail (MKS_IS_SCREEN_RESIZER (self));
|
g_return_if_fail (MKS_IS_SCREEN_RESIZER (self));
|
||||||
g_return_if_fail (!screen || MKS_IS_SCREEN (screen));
|
g_return_if_fail (!screen || MKS_IS_SCREEN (screen));
|
||||||
|
|
||||||
if (g_set_object (&self->screen, screen))
|
if (g_set_object (&self->screen, screen))
|
||||||
{
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SCREEN]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SCREEN]);
|
||||||
}
|
|
||||||
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,18 +198,23 @@ void
|
|||||||
mks_screen_resizer_queue_resize (MksScreenResizer *self,
|
mks_screen_resizer_queue_resize (MksScreenResizer *self,
|
||||||
MksScreenAttributes *attributes)
|
MksScreenAttributes *attributes)
|
||||||
{
|
{
|
||||||
|
MKS_ENTRY;
|
||||||
|
|
||||||
g_return_if_fail (MKS_IS_SCREEN_RESIZER (self));
|
g_return_if_fail (MKS_IS_SCREEN_RESIZER (self));
|
||||||
|
|
||||||
if (mks_screen_attributes_equal (attributes, self->previous_op))
|
if (mks_screen_attributes_equal (attributes, self->previous_op))
|
||||||
return;
|
MKS_EXIT;
|
||||||
|
|
||||||
if (self->in_progress)
|
if (self->in_progress)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&self->next_op, mks_screen_attributes_free);
|
g_clear_pointer (&self->next_op, mks_screen_attributes_free);
|
||||||
self->next_op = g_steal_pointer (&attributes);
|
self->next_op = g_steal_pointer (&attributes);
|
||||||
return;
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
mks_screen_resizer_reconfigure (self, attributes);
|
mks_screen_resizer_reconfigure (self, attributes);
|
||||||
|
|
||||||
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,14 +228,20 @@ static void
|
|||||||
mks_screen_resizer_reconfigure (MksScreenResizer *self,
|
mks_screen_resizer_reconfigure (MksScreenResizer *self,
|
||||||
MksScreenAttributes *attributes)
|
MksScreenAttributes *attributes)
|
||||||
{
|
{
|
||||||
|
MKS_ENTRY;
|
||||||
|
|
||||||
g_assert (MKS_IS_SCREEN_RESIZER (self));
|
g_assert (MKS_IS_SCREEN_RESIZER (self));
|
||||||
|
|
||||||
self->in_progress = TRUE;
|
self->in_progress = TRUE;
|
||||||
|
|
||||||
|
g_clear_pointer (&self->previous_op, mks_screen_attributes_free);
|
||||||
|
self->previous_op = mks_screen_attributes_copy (attributes);
|
||||||
|
|
||||||
mks_screen_configure (self->screen,
|
mks_screen_configure (self->screen,
|
||||||
g_steal_pointer (&attributes),
|
g_steal_pointer (&attributes),
|
||||||
NULL,
|
NULL,
|
||||||
on_screen_configure_cb,
|
on_screen_configure_cb,
|
||||||
g_object_ref (self));
|
g_object_ref (self));
|
||||||
g_clear_pointer (&self->previous_op, mks_screen_attributes_free);
|
|
||||||
self->previous_op = g_steal_pointer (&attributes);
|
MKS_EXIT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user