mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
Split GDK initialization from MetaUI
Get rid of the deprecated gdk_display_get_default_screen () https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
parent
89727aa747
commit
d4c4d6e64d
@ -404,8 +404,7 @@ gboolean meta_display_show_resize_popup (MetaDisplay *display,
|
|||||||
int display_w,
|
int display_w,
|
||||||
int display_h);
|
int display_h);
|
||||||
|
|
||||||
void meta_restart_init (void);
|
void meta_set_is_restart (gboolean whether);
|
||||||
void meta_restart_finish (void);
|
|
||||||
|
|
||||||
void meta_display_cancel_touch (MetaDisplay *display);
|
void meta_display_cancel_touch (MetaDisplay *display);
|
||||||
|
|
||||||
|
@ -46,32 +46,17 @@
|
|||||||
void
|
void
|
||||||
meta_error_trap_push (MetaX11Display *x11_display)
|
meta_error_trap_push (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
GdkDisplay *gdk_display;
|
gdk_x11_display_error_trap_push (x11_display->gdk_display);
|
||||||
|
|
||||||
gdk_display = gdk_x11_lookup_xdisplay (x11_display->xdisplay);
|
|
||||||
g_assert (gdk_display != NULL);
|
|
||||||
|
|
||||||
gdk_x11_display_error_trap_push (gdk_display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_error_trap_pop (MetaX11Display *x11_display)
|
meta_error_trap_pop (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
GdkDisplay *gdk_display;
|
gdk_x11_display_error_trap_pop_ignored (x11_display->gdk_display);
|
||||||
|
|
||||||
gdk_display = gdk_x11_lookup_xdisplay (x11_display->xdisplay);
|
|
||||||
g_assert (gdk_display != NULL);
|
|
||||||
|
|
||||||
gdk_x11_display_error_trap_pop_ignored (gdk_display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_error_trap_pop_with_return (MetaX11Display *x11_display)
|
meta_error_trap_pop_with_return (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
GdkDisplay *gdk_display;
|
return gdk_x11_display_error_trap_pop (x11_display->gdk_display);
|
||||||
|
|
||||||
gdk_display = gdk_x11_lookup_xdisplay (x11_display->xdisplay);
|
|
||||||
g_assert (gdk_display != NULL);
|
|
||||||
|
|
||||||
return gdk_x11_display_error_trap_pop (gdk_display);
|
|
||||||
}
|
}
|
||||||
|
@ -599,10 +599,6 @@ meta_init (void)
|
|||||||
meta_fatal ("Can't specify both SM save file and SM client id\n");
|
meta_fatal ("Can't specify both SM save file and SM client id\n");
|
||||||
|
|
||||||
meta_main_loop = g_main_loop_new (NULL, FALSE);
|
meta_main_loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
meta_ui_init ();
|
|
||||||
|
|
||||||
meta_restart_init ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,15 +50,9 @@ static gboolean restart_message_shown = FALSE;
|
|||||||
static gboolean is_restart = FALSE;
|
static gboolean is_restart = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_restart_init (void)
|
meta_set_is_restart (gboolean whether)
|
||||||
{
|
{
|
||||||
Display *xdisplay = meta_ui_get_display ();
|
is_restart = whether;
|
||||||
Atom atom_restart_helper = XInternAtom (xdisplay, "_MUTTER_RESTART_HELPER", False);
|
|
||||||
Window restart_helper_window = None;
|
|
||||||
|
|
||||||
restart_helper_window = XGetSelectionOwner (xdisplay, atom_restart_helper);
|
|
||||||
if (restart_helper_window)
|
|
||||||
is_restart = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -187,18 +181,6 @@ meta_restart (const char *message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
meta_restart_finish (void)
|
|
||||||
{
|
|
||||||
if (is_restart)
|
|
||||||
{
|
|
||||||
MetaDisplay *display = meta_get_display ();
|
|
||||||
Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
|
|
||||||
Atom atom_restart_helper = XInternAtom (xdisplay, "_MUTTER_RESTART_HELPER", False);
|
|
||||||
XSetSelectionOwner (xdisplay, atom_restart_helper, None, META_CURRENT_TIME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_is_restart:
|
* meta_is_restart:
|
||||||
*
|
*
|
||||||
|
59
src/ui/ui.c
59
src/ui/ui.c
@ -26,6 +26,7 @@
|
|||||||
#include <meta/util.h>
|
#include <meta/util.h>
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "theme-private.h"
|
#include "theme-private.h"
|
||||||
|
#include "x11/meta-x11-display-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -44,52 +45,18 @@ struct _MetaUI
|
|||||||
guint32 button_click_time;
|
guint32 button_click_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
MetaUI *
|
||||||
meta_ui_init (void)
|
meta_ui_new (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
const char *gdk_gl_env = NULL;
|
|
||||||
gdk_set_allowed_backends ("x11");
|
|
||||||
|
|
||||||
gdk_gl_env = g_getenv ("GDK_GL");
|
|
||||||
g_setenv("GDK_GL", "disable", TRUE);
|
|
||||||
|
|
||||||
if (!gtk_init_check (NULL, NULL))
|
|
||||||
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
|
||||||
|
|
||||||
if (gdk_gl_env)
|
|
||||||
g_setenv("GDK_GL", gdk_gl_env, TRUE);
|
|
||||||
else
|
|
||||||
unsetenv("GDK_GL");
|
|
||||||
|
|
||||||
/* We need to be able to fully trust that the window and monitor sizes
|
|
||||||
that Gdk reports corresponds to the X ones, so we disable the automatic
|
|
||||||
scale handling */
|
|
||||||
gdk_x11_display_set_window_scale (gdk_display_get_default (), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Display*
|
|
||||||
meta_ui_get_display (void)
|
|
||||||
{
|
|
||||||
return GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
meta_ui_get_screen_number (void)
|
|
||||||
{
|
|
||||||
return gdk_screen_get_number (gdk_screen_get_default ());
|
|
||||||
}
|
|
||||||
|
|
||||||
MetaUI*
|
|
||||||
meta_ui_new (Display *xdisplay)
|
|
||||||
{
|
|
||||||
GdkDisplay *gdisplay;
|
|
||||||
MetaUI *ui;
|
MetaUI *ui;
|
||||||
|
|
||||||
ui = g_new0 (MetaUI, 1);
|
if (!gtk_init_check (NULL, NULL))
|
||||||
ui->xdisplay = xdisplay;
|
meta_fatal ("Unable to initialize GTK");
|
||||||
|
|
||||||
gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
|
g_assert (x11_display->gdk_display == gdk_display_get_default ());
|
||||||
g_assert (gdisplay == gdk_display_get_default ());
|
|
||||||
|
ui = g_new0 (MetaUI, 1);
|
||||||
|
ui->xdisplay = x11_display->xdisplay;
|
||||||
|
|
||||||
ui->frames = meta_frames_new ();
|
ui->frames = meta_frames_new ();
|
||||||
/* GTK+ needs the frame-sync protocol to work in order to properly
|
/* GTK+ needs the frame-sync protocol to work in order to properly
|
||||||
@ -100,7 +67,7 @@ meta_ui_new (Display *xdisplay)
|
|||||||
*/
|
*/
|
||||||
gtk_widget_show (GTK_WIDGET (ui->frames));
|
gtk_widget_show (GTK_WIDGET (ui->frames));
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
|
g_object_set_data (G_OBJECT (x11_display->gdk_display), "meta-ui", ui);
|
||||||
|
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
@ -108,12 +75,12 @@ meta_ui_new (Display *xdisplay)
|
|||||||
void
|
void
|
||||||
meta_ui_free (MetaUI *ui)
|
meta_ui_free (MetaUI *ui)
|
||||||
{
|
{
|
||||||
GdkDisplay *gdisplay;
|
GdkDisplay *gdk_display;
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
||||||
|
|
||||||
gdisplay = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
gdk_display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", NULL);
|
g_object_set_data (G_OBJECT (gdk_display), "meta-ui", NULL);
|
||||||
|
|
||||||
g_free (ui);
|
g_free (ui);
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,7 @@ typedef struct _MetaUIFrame MetaUIFrame;
|
|||||||
|
|
||||||
typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
|
typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
|
||||||
|
|
||||||
void meta_ui_init (void);
|
MetaUI *meta_ui_new (MetaX11Display *x11_display);
|
||||||
|
|
||||||
Display* meta_ui_get_display (void);
|
|
||||||
|
|
||||||
gint meta_ui_get_screen_number (void);
|
|
||||||
|
|
||||||
MetaUI* meta_ui_new (Display *xdisplay);
|
|
||||||
void meta_ui_free (MetaUI *ui);
|
void meta_ui_free (MetaUI *ui);
|
||||||
|
|
||||||
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||||
|
@ -47,6 +47,7 @@ struct _MetaX11Display
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
|
GdkDisplay *gdk_display;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
char *screen_name;
|
char *screen_name;
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "core/display-private.h"
|
#include "core/display-private.h"
|
||||||
#include "x11/meta-x11-display-private.h"
|
#include "x11/meta-x11-display-private.h"
|
||||||
|
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -189,7 +191,8 @@ meta_x11_display_dispose (GObject *object)
|
|||||||
XSelectInput (x11_display->xdisplay, x11_display->xroot, 0);
|
XSelectInput (x11_display->xdisplay, x11_display->xroot, 0);
|
||||||
if (meta_error_trap_pop_with_return (x11_display) != Success)
|
if (meta_error_trap_pop_with_return (x11_display) != Success)
|
||||||
meta_warning ("Could not release screen %d on display \"%s\"\n",
|
meta_warning ("Could not release screen %d on display \"%s\"\n",
|
||||||
meta_ui_get_screen_number (), x11_display->name);
|
DefaultScreen (x11_display->xdisplay),
|
||||||
|
x11_display->name);
|
||||||
|
|
||||||
x11_display->xroot = None;
|
x11_display->xroot = None;
|
||||||
}
|
}
|
||||||
@ -202,6 +205,12 @@ meta_x11_display_dispose (GObject *object)
|
|||||||
x11_display->xdisplay = NULL;
|
x11_display->xdisplay = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x11_display->gdk_display)
|
||||||
|
{
|
||||||
|
gdk_display_close (x11_display->gdk_display);
|
||||||
|
x11_display->gdk_display = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_free (x11_display->name);
|
g_free (x11_display->name);
|
||||||
x11_display->name = NULL;
|
x11_display->name = NULL;
|
||||||
|
|
||||||
@ -979,6 +988,46 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
MetaWorkspace *current_workspace;
|
MetaWorkspace *current_workspace;
|
||||||
uint32_t current_workspace_index = 0;
|
uint32_t current_workspace_index = 0;
|
||||||
|
Atom atom_restart_helper;
|
||||||
|
Window restart_helper_window = None;
|
||||||
|
GdkDisplay *gdk_display;
|
||||||
|
const char *gdk_gl_env = NULL;
|
||||||
|
const char *xdisplay_name;
|
||||||
|
|
||||||
|
xdisplay_name = g_getenv ("DISPLAY");
|
||||||
|
if (!xdisplay_name)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Unable to open display, DISPLAY not set");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_set_allowed_backends ("x11");
|
||||||
|
|
||||||
|
gdk_gl_env = g_getenv ("GDK_GL");
|
||||||
|
g_setenv("GDK_GL", "disable", TRUE);
|
||||||
|
|
||||||
|
gdk_display = gdk_display_open (xdisplay_name);
|
||||||
|
|
||||||
|
if (!gdk_display)
|
||||||
|
{
|
||||||
|
meta_warning (_("Failed to initialize GDK\n"));
|
||||||
|
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Failed to initialize GDK");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gdk_gl_env)
|
||||||
|
g_setenv("GDK_GL", gdk_gl_env, TRUE);
|
||||||
|
else
|
||||||
|
unsetenv("GDK_GL");
|
||||||
|
|
||||||
|
/* We need to be able to fully trust that the window and monitor sizes
|
||||||
|
that Gdk reports corresponds to the X ones, so we disable the automatic
|
||||||
|
scale handling */
|
||||||
|
gdk_x11_display_set_window_scale (gdk_display, 1);
|
||||||
|
|
||||||
/* A list of all atom names, so that we can intern them in one go. */
|
/* A list of all atom names, so that we can intern them in one go. */
|
||||||
const char *atom_names[] = {
|
const char *atom_names[] = {
|
||||||
@ -990,7 +1039,7 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
|
|
||||||
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
||||||
|
|
||||||
xdisplay = meta_ui_get_display ();
|
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
|
||||||
|
|
||||||
if (xdisplay == NULL)
|
if (xdisplay == NULL)
|
||||||
{
|
{
|
||||||
@ -1000,6 +1049,8 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Failed to open X11 display");
|
"Failed to open X11 display");
|
||||||
|
|
||||||
|
gdk_display_close (gdk_display);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,7 +1064,10 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
|
|
||||||
replace_current_wm = meta_get_replace_current_wm ();
|
replace_current_wm = meta_get_replace_current_wm ();
|
||||||
|
|
||||||
number = meta_ui_get_screen_number ();
|
/* According to _gdk_x11_display_open (), this will be returned
|
||||||
|
* by gdk_display_get_default_screen ()
|
||||||
|
*/
|
||||||
|
number = DefaultScreen (xdisplay);
|
||||||
|
|
||||||
xroot = RootWindow (xdisplay, number);
|
xroot = RootWindow (xdisplay, number);
|
||||||
|
|
||||||
@ -1031,12 +1085,20 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
XFlush (xdisplay);
|
XFlush (xdisplay);
|
||||||
XCloseDisplay (xdisplay);
|
XCloseDisplay (xdisplay);
|
||||||
|
|
||||||
|
gdk_display_close (gdk_display);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xscreen = ScreenOfDisplay (xdisplay, number);
|
xscreen = ScreenOfDisplay (xdisplay, number);
|
||||||
|
|
||||||
|
atom_restart_helper = XInternAtom (xdisplay, "_MUTTER_RESTART_HELPER", False);
|
||||||
|
restart_helper_window = XGetSelectionOwner (xdisplay, atom_restart_helper);
|
||||||
|
if (restart_helper_window)
|
||||||
|
meta_set_is_restart (TRUE);
|
||||||
|
|
||||||
x11_display = g_object_new (META_TYPE_X11_DISPLAY, NULL);
|
x11_display = g_object_new (META_TYPE_X11_DISPLAY, NULL);
|
||||||
|
x11_display->gdk_display = gdk_display;
|
||||||
x11_display->display = display;
|
x11_display->display = display;
|
||||||
|
|
||||||
/* here we use XDisplayName which is what the user
|
/* here we use XDisplayName which is what the user
|
||||||
@ -1144,7 +1206,8 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
|
|
||||||
/* Now that we've gotten taken a reference count on the COW, we
|
/* Now that we've gotten taken a reference count on the COW, we
|
||||||
* can close the helper that is holding on to it */
|
* can close the helper that is holding on to it */
|
||||||
meta_restart_finish ();
|
if (meta_is_restart ())
|
||||||
|
XSetSelectionOwner (xdisplay, atom_restart_helper, None, META_CURRENT_TIME);
|
||||||
|
|
||||||
/* Handle creating a no_focus_window for this screen */
|
/* Handle creating a no_focus_window for this screen */
|
||||||
x11_display->no_focus_window =
|
x11_display->no_focus_window =
|
||||||
@ -1166,7 +1229,7 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
|
|
||||||
set_desktop_geometry_hint (x11_display);
|
set_desktop_geometry_hint (x11_display);
|
||||||
|
|
||||||
x11_display->ui = meta_ui_new (xdisplay);
|
x11_display->ui = meta_ui_new (x11_display);
|
||||||
|
|
||||||
x11_display->keys_grabbed = FALSE;
|
x11_display->keys_grabbed = FALSE;
|
||||||
meta_x11_display_grab_keys (x11_display);
|
meta_x11_display_grab_keys (x11_display);
|
||||||
@ -1255,7 +1318,7 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
int
|
int
|
||||||
meta_x11_display_get_screen_number (MetaX11Display *x11_display)
|
meta_x11_display_get_screen_number (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
return meta_ui_get_screen_number ();
|
return DefaultScreen (x11_display->xdisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1588,7 +1651,7 @@ meta_x11_display_set_cm_selection (MetaX11Display *x11_display)
|
|||||||
|
|
||||||
timestamp = meta_x11_display_get_current_time_roundtrip (x11_display);
|
timestamp = meta_x11_display_get_current_time_roundtrip (x11_display);
|
||||||
g_snprintf (selection, sizeof (selection), "_NET_WM_CM_S%d",
|
g_snprintf (selection, sizeof (selection), "_NET_WM_CM_S%d",
|
||||||
meta_ui_get_screen_number ());
|
DefaultScreen (x11_display->xdisplay));
|
||||||
a = XInternAtom (x11_display->xdisplay, selection, False);
|
a = XInternAtom (x11_display->xdisplay, selection, False);
|
||||||
|
|
||||||
x11_display->wm_cm_selection_window = take_manager_selection (x11_display, x11_display->xroot, a, timestamp, TRUE);
|
x11_display->wm_cm_selection_window = take_manager_selection (x11_display, x11_display->xroot, a, timestamp, TRUE);
|
||||||
|
Loading…
Reference in New Issue
Block a user