libmks/lib/mks-screen-attributes.c
Christian Hergert 9bb71b8ea8 lib: add MksScreenAttributes and mks_screen_configure()
MksScreenAttributes is an opaque type with setters so that we can
potentially extend it in the future without ABI issues.

Furthermore, this adds a configure API for both sync and async to
MksScreen.

Currently, I get NOT_SUPPORTED back from Qemu, but I think that's because
I'm not even past the bootloader/EFI stage for tests.
2023-02-09 15:39:03 -08:00

116 lines
2.9 KiB
C

/*
* mks-screen-attributes.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "mks-screen-attributes-private.h"
G_DEFINE_BOXED_TYPE (MksScreenAttributes,
mks_screen_attributes,
mks_screen_attributes_copy,
mks_screen_attributes_free)
/**
* mks_screen_attributes_new:
*
* Creates a new #MksScreenAttributes.
*
* Returns: (transfer full): A newly created #MksScreenAttributes
*/
MksScreenAttributes *
mks_screen_attributes_new (void)
{
return g_new0 (MksScreenAttributes, 1);
}
/**
* mks_screen_attributes_copy:
* @self: (nullable): a #MksScreenAttributes
*
* Makes a deep copy of a #MksScreenAttributes.
*
* Returns: (transfer full): A newly created #MksScreenAttributes with the same
* contents as @self. If @self is %NULL, %NULL is returned.
*/
MksScreenAttributes *
mks_screen_attributes_copy (MksScreenAttributes *self)
{
if (self == NULL)
return NULL;
return g_memdup2 (self, sizeof *self);
}
/**
* mks_screen_attributes_free:
* @self: a #MksScreenAttributes
*
* Frees a #MksScreenAttributes allocated using mks_screen_attributes_new()
* or mks_screen_attributes_copy().
*/
void
mks_screen_attributes_free (MksScreenAttributes *self)
{
g_free (self);
}
void
mks_screen_attributes_set_width_mm (MksScreenAttributes *self,
guint16 width_mm)
{
self->width_mm = width_mm;
}
void
mks_screen_attributes_set_height_mm (MksScreenAttributes *self,
guint16 height_mm)
{
self->height_mm = height_mm;
}
void
mks_screen_attributes_set_x_offset (MksScreenAttributes *self,
int x_offset)
{
self->x_offset = x_offset;
}
void
mks_screen_attributes_set_y_offset (MksScreenAttributes *self,
int y_offset)
{
self->y_offset = y_offset;
}
void
mks_screen_attributes_set_width (MksScreenAttributes *self,
guint width)
{
self->width = width;
}
void
mks_screen_attributes_set_height (MksScreenAttributes *self,
guint height)
{
self->height = height;
}