broadway: No more screen

This gets rid of the GdkBroadwayScreen object and all
remnants of GdkScreen in the broadway backend.
This commit is contained in:
Matthias Clasen 2017-11-01 14:46:26 -04:00
parent e41936c19c
commit bee74e8243
11 changed files with 50 additions and 251 deletions

View File

@ -26,8 +26,6 @@
#include "gdkdisplay.h"
#include "gdkeventsource.h"
#include "gdkscreen.h"
#include "gdkscreen-broadway.h"
#include "gdkmonitor-broadway.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
@ -73,6 +71,38 @@ gdk_event_init (GdkDisplay *display)
broadway_display->event_source = _gdk_broadway_event_source_new (display);
}
void
_gdk_broadway_display_size_changed (GdkDisplay *display,
BroadwayInputScreenResizeNotify *msg)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
GdkMonitor *monitor;
GdkRectangle size;
GList *toplevels, *l;
monitor = broadway_display->monitor;
gdk_monitor_get_geometry (monitor, &size);
if (msg->width == size.width && msg->height == size.height)
return;
gdk_monitor_set_size (monitor, msg->width, msg->height);
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
toplevels = gdk_display_get_toplevel_windows (display);
for (l = toplevels; l != NULL; l = l->next)
{
GdkWindow *toplevel = l->data;
GdkWindowImplBroadway *toplevel_impl = GDK_WINDOW_IMPL_BROADWAY (toplevel->impl);
if (toplevel_impl->maximized)
gdk_window_move_resize (toplevel, 0, 0, msg->width, msg->height);
}
g_list_free (toplevels);
}
GdkDisplay *
_gdk_broadway_display_open (const gchar *display_name)
{
@ -83,17 +113,7 @@ _gdk_broadway_display_open (const gchar *display_name)
display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
broadway_display = GDK_BROADWAY_DISPLAY (display);
/* initialize the display's screens */
broadway_display->screens = g_new (GdkScreen *, 1);
broadway_display->screens[0] = _gdk_broadway_screen_new (display, 0);
/* We need to initialize events after we have the screen
* structures in places
*/
_gdk_broadway_screen_events_init (broadway_display->screens[0]);
/*set the default screen */
broadway_display->default_screen = broadway_display->screens[0];
_gdk_broadway_display_init_root_window (broadway_display);
display->device_manager = _gdk_broadway_device_manager_new (display);
@ -125,14 +145,6 @@ gdk_broadway_display_get_name (GdkDisplay *display)
return (gchar *) "Broadway";
}
static GdkScreen *
gdk_broadway_display_get_default_screen (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return GDK_BROADWAY_DISPLAY (display)->default_screen;
}
static void
gdk_broadway_display_beep (GdkDisplay *display)
{
@ -178,7 +190,8 @@ gdk_broadway_display_dispose (GObject *object)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
_gdk_screen_close (broadway_display->screens[0]);
if (broadway_display->root_window)
_gdk_window_destroy (broadway_display->root_window, TRUE);
if (broadway_display->event_source)
{
@ -201,10 +214,7 @@ gdk_broadway_display_finalize (GObject *object)
_gdk_broadway_cursor_display_finalize (GDK_DISPLAY(broadway_display));
/* Free all GdkScreens */
g_object_unref (broadway_display->screens[0]);
g_free (broadway_display->screens);
g_object_unref (broadway_display->root_window);
g_object_unref (broadway_display->monitor);
G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
@ -321,7 +331,7 @@ gdk_broadway_display_get_root_window (GdkDisplay *display)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
return GDK_BROADWAY_SCREEN (broadway_display->default_screen)->root_window;
return broadway_display->root_window;
}
static void
@ -336,7 +346,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->window_type = GDK_TYPE_BROADWAY_WINDOW;
display_class->get_name = gdk_broadway_display_get_name;
display_class->get_default_screen = gdk_broadway_display_get_default_screen;
display_class->beep = gdk_broadway_display_beep;
display_class->sync = gdk_broadway_display_sync;
display_class->flush = gdk_broadway_display_flush;
@ -375,4 +384,3 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->get_setting = gdk_broadway_display_get_setting;
display_class->get_root_window = gdk_broadway_display_get_root_window;
}

View File

@ -37,8 +37,6 @@ G_BEGIN_DECLS
struct _GdkBroadwayDisplay
{
GdkDisplay parent_instance;
GdkScreen *default_screen;
GdkScreen **screens;
GHashTable *id_ht;
GList *toplevels;
@ -56,6 +54,7 @@ struct _GdkBroadwayDisplay
gpointer move_resize_data;
GdkMonitor *monitor;
GdkWindow *root_window;
};
struct _GdkBroadwayDisplayClass

View File

@ -30,7 +30,6 @@
#include "gdkproperty.h"
#include "gdkprivate-broadway.h"
#include "gdkinternals.h"
#include "gdkscreen-broadway.h"
#include "gdkdisplay-broadway.h"
#include <string.h>

View File

@ -95,7 +95,6 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
GdkDisplay *display;
GdkBroadwayDisplay *display_broadway;
GdkBroadwayDeviceManager *device_manager;
GdkScreen *screen;
GdkWindow *window;
GdkEvent *event = NULL;
GList *node;
@ -350,13 +349,11 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
break;
case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
screen = gdk_display_get_default_screen (display);
window = gdk_display_get_root_window (display);
window->width = message->screen_resize_notify.width;
window->height = message->screen_resize_notify.height;
_gdk_window_update_size (window);
_gdk_broadway_screen_size_changed (screen, &message->screen_resize_notify);
_gdk_broadway_display_size_changed (display, &message->screen_resize_notify);
break;
case BROADWAY_EVENT_FOCUS:

View File

@ -21,7 +21,6 @@
#include <gio/gio.h>
#include "gdkmonitor-broadway.h"
#include "gdkscreen-broadway.h"
G_DEFINE_TYPE (GdkBroadwayMonitor, gdk_broadway_monitor, GDK_TYPE_MONITOR)

View File

@ -88,13 +88,12 @@ void _gdk_keymap_add_virtual_modifiers_compat (GdkKeymap *keymap,
gboolean _gdk_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode);
void _gdk_broadway_screen_events_init (GdkScreen *screen);
void _gdk_broadway_screen_size_changed (GdkScreen *screen,
BroadwayInputScreenResizeNotify *msg);
void _gdk_broadway_display_size_changed (GdkDisplay *display,
BroadwayInputScreenResizeNotify *msg);
void _gdk_broadway_events_got_input (BroadwayInputMsg *message);
void _gdk_broadway_screen_init_root_window (GdkScreen *screen);
void _gdk_broadway_display_init_root_window (GdkDisplay *display);
void _gdk_broadway_display_init_dnd (GdkDisplay *display);
GdkDisplay * _gdk_broadway_display_open (const gchar *display_name);
void _gdk_broadway_display_queue_events (GdkDisplay *display);

View File

@ -30,7 +30,7 @@
#include "gdkprivate.h"
#include "gdkinternals.h"
#include "gdkdisplay-broadway.h"
#include "gdkscreen-broadway.h"
#include "gdkprivate-broadway.h"
#include "gdkselection.h"
#include <string.h>

View File

@ -1,137 +0,0 @@
/*
* gdkscreen-broadway.c
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkscreen-broadway.h"
#include "gdkscreen.h"
#include "gdkdisplay.h"
#include "gdkdisplay-broadway.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
static void gdk_broadway_screen_dispose (GObject *object);
static void gdk_broadway_screen_finalize (GObject *object);
G_DEFINE_TYPE (GdkBroadwayScreen, gdk_broadway_screen, GDK_TYPE_SCREEN)
static void
gdk_broadway_screen_init (GdkBroadwayScreen *screen)
{
}
static GdkDisplay *
gdk_broadway_screen_get_display (GdkScreen *screen)
{
return GDK_BROADWAY_SCREEN (screen)->display;
}
void
_gdk_broadway_screen_size_changed (GdkScreen *screen,
BroadwayInputScreenResizeNotify *msg)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
GdkMonitor *monitor;
GdkRectangle size;
GList *toplevels, *l;
monitor = GDK_BROADWAY_DISPLAY (broadway_screen->display)->monitor;
gdk_monitor_get_geometry (monitor, &size);
if (msg->width == size.width &&
msg->height == size.height)
return;
gdk_monitor_set_size (monitor, msg->width, msg->height);
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
toplevels = gdk_display_get_toplevel_windows (broadway_screen->display);
for (l = toplevels; l != NULL; l = l->next)
{
GdkWindow *toplevel = l->data;
GdkWindowImplBroadway *toplevel_impl = GDK_WINDOW_IMPL_BROADWAY (toplevel->impl);
if (toplevel_impl->maximized)
gdk_window_move_resize (toplevel, 0, 0, msg->width, msg->height);
}
g_list_free (toplevels);
}
static void
gdk_broadway_screen_dispose (GObject *object)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (object);
if (broadway_screen->root_window)
_gdk_window_destroy (broadway_screen->root_window, TRUE);
G_OBJECT_CLASS (gdk_broadway_screen_parent_class)->dispose (object);
}
static void
gdk_broadway_screen_finalize (GObject *object)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (object);
if (broadway_screen->root_window)
g_object_unref (broadway_screen->root_window);
G_OBJECT_CLASS (gdk_broadway_screen_parent_class)->finalize (object);
}
GdkScreen *
_gdk_broadway_screen_new (GdkDisplay *display,
gint screen_number)
{
GdkScreen *screen;
GdkBroadwayScreen *broadway_screen;
screen = g_object_new (GDK_TYPE_BROADWAY_SCREEN, NULL);
broadway_screen = GDK_BROADWAY_SCREEN (screen);
broadway_screen->display = display;
_gdk_broadway_screen_init_root_window (screen);
return screen;
}
void
_gdk_broadway_screen_events_init (GdkScreen *screen)
{
}
static void
gdk_broadway_screen_class_init (GdkBroadwayScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
object_class->dispose = gdk_broadway_screen_dispose;
object_class->finalize = gdk_broadway_screen_finalize;
screen_class->get_display = gdk_broadway_screen_get_display;
}

View File

@ -1,63 +0,0 @@
/*
* gdkscreen-broadway.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_BROADWAY_SCREEN_H__
#define __GDK_BROADWAY_SCREEN_H__
#include <gdk/gdkscreenprivate.h>
#include "gdkprivate-broadway.h"
G_BEGIN_DECLS
typedef struct _GdkBroadwayScreen GdkBroadwayScreen;
typedef struct _GdkBroadwayScreenClass GdkBroadwayScreenClass;
#define GDK_TYPE_BROADWAY_SCREEN (gdk_broadway_screen_get_type ())
#define GDK_BROADWAY_SCREEN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreen))
#define GDK_BROADWAY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreenClass))
#define GDK_IS_BROADWAY_SCREEN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_SCREEN))
#define GDK_IS_BROADWAY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_SCREEN))
#define GDK_BROADWAY_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreenClass))
typedef struct _GdkBroadwayMonitor GdkBroadwayMonitor;
struct _GdkBroadwayScreen
{
GdkScreen parent_instance;
GdkDisplay *display;
GdkWindow *root_window;
};
struct _GdkBroadwayScreenClass
{
GdkScreenClass parent_class;
void (* window_manager_changed) (GdkBroadwayScreen *screen);
};
GType gdk_broadway_screen_get_type (void);
GdkScreen * _gdk_broadway_screen_new (GdkDisplay *display,
gint screen_number);
G_END_DECLS
#endif /* __GDK_BROADWAY_SCREEN_H__ */

View File

@ -26,7 +26,6 @@
#include "config.h"
#include "gdkwindow-broadway.h"
#include "gdkscreen-broadway.h"
#include "gdkbroadwaydisplay.h"
#include "gdkdisplay.h"
@ -196,19 +195,19 @@ gdk_window_impl_broadway_finalize (GObject *object)
}
void
_gdk_broadway_screen_init_root_window (GdkScreen * screen)
_gdk_broadway_display_init_root_window (GdkDisplay *display)
{
GdkWindow *window;
GdkWindowImplBroadway *impl;
GdkBroadwayScreen *broadway_screen;
GdkBroadwayDisplay *broadway_display;
broadway_screen = GDK_BROADWAY_SCREEN (screen);
broadway_display = GDK_BROADWAY_DISPLAY (display);
g_assert (broadway_screen->root_window == NULL);
g_assert (broadway_display->root_window == NULL);
broadway_screen->root_window = g_object_new (GDK_TYPE_BROADWAY_WINDOW, NULL);
broadway_display->root_window = g_object_new (GDK_TYPE_BROADWAY_WINDOW, NULL);
window = broadway_screen->root_window;
window = broadway_display->root_window;
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_BROADWAY, NULL);
window->impl_window = window;
@ -227,7 +226,7 @@ _gdk_broadway_screen_init_root_window (GdkScreen * screen)
window->height = 768;
window->viewable = TRUE;
_gdk_window_update_size (broadway_screen->root_window);
_gdk_window_update_size (broadway_display->root_window);
}
static void

View File

@ -14,7 +14,6 @@ gdk_broadway_sources = files([
'gdkkeys-broadway.c',
'gdkmonitor-broadway.c',
'gdkproperty-broadway.c',
'gdkscreen-broadway.c',
'gdkselection-broadway.c',
'gdkwindow-broadway.c',
])