/* * Kangaroo Punch MultiPlayer Game Server Mark II * Copyright (C) 2020-2021 Scott Duensing * * 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 . * */ #include "desktop.h" #include "window.h" static void desktopDel(WidgetT **widget); static void desktopPaint(WidgetT *desktop, RectT pos); static void desktopDel(WidgetT **widget) { DesktopT *d = (DesktopT *)*widget; vbeSurfaceDestroy(&d->base.surface); free(d); d = NULL; } WidgetT *desktopInit(WidgetT *desktop) { DesktopT *d = (DesktopT *)desktop; d->base.magic = MAGIC_DESKTOP; d->base.delMethod = desktopDel; d->base.paintMethod = desktopPaint; GUI_SET_FLAG(desktop, WIDGET_FLAG_OWNS_SURFACE); d->base.surface = vbeSurfaceCreate(d->base.pos.w, d->base.pos.h); if (!d->base.surface) { free(d); return NULL; } return desktop; } DesktopT *desktopNew(void) { DesktopT *desktop = (DesktopT *)malloc(sizeof(DesktopT)); WidgetT *widget = NULL; if (!desktop) return NULL; widget = widgetInit(W(desktop), MAGIC_DESKTOP, 0, 0, vbeDisplayWidthGet(), vbeDisplayHeightGet(), 0, 0, 0, 0); if (!widget) { free(desktop); return NULL; } desktop = (DesktopT *)desktopInit((WidgetT *)desktop); return desktop; } static void desktopPaint(WidgetT *desktop, RectT pos) { (void)pos; if (GUI_GET_FLAG(desktop, WIDGET_FLAG_DIRTY)) { vbeSurfaceClear(_guiColor[COLOR_DESKTOP]); GUI_CLEAR_FLAG(desktop, WIDGET_FLAG_DIRTY); } }