1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* vi:set sw=2 sts=2 ts=2 et ai tw=100: */
/*-
* Copyright (c) 2017 Viktor Odintsev <zakhams@gmail.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 2 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, write to the Free Software
* Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include <string.h>
#include <gdk/gdkx.h>
#include "xfwm-common.h"
void
xfwm_widget_reparent (GtkWidget *widget,
GtkWidget *new_parent)
{
GtkWidget *old_parent;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_IS_CONTAINER (new_parent));
old_parent = gtk_widget_get_parent (widget);
g_return_if_fail (old_parent != NULL);
if (old_parent != new_parent)
{
g_object_ref (widget);
gtk_container_remove (GTK_CONTAINER (old_parent), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (widget);
}
}
void
xfwm_get_screen_dimensions (gint *width, gint *height)
{
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle geometry;
display = gdk_display_get_default ();
monitor = gdk_display_get_primary_monitor (display);
gdk_monitor_get_geometry (monitor, &geometry);
if (width != NULL)
*width = geometry.width;
if (height != NULL)
*height = geometry.height;
#else
if (width != NULL)
*width = gdk_screen_width ();
if (height != NULL)
*height = gdk_screen_height ();
#endif
}
void
xfwm_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *geometry)
{
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay *display;
GdkMonitor *monitor;
display = gdk_screen_get_display (screen);
monitor = gdk_display_get_monitor (display, monitor_num);
gdk_monitor_get_geometry (monitor, geometry);
#else
gdk_screen_get_monitor_geometry (screen, monitor_num, geometry);
#endif
}
void
xfwm_get_primary_monitor_geometry (GdkScreen *screen,
GdkRectangle *geometry)
{
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay *display;
GdkMonitor *monitor;
display = gdk_screen_get_display (screen);
monitor = gdk_display_get_primary_monitor (display);
gdk_monitor_get_geometry (monitor, geometry);
#else
gdk_screen_get_monitor_geometry (screen,
gdk_screen_get_primary_monitor (screen),
geometry);
#endif
}
gint
xfwm_get_n_monitors (GdkScreen *screen)
{
#if GTK_CHECK_VERSION(3, 22, 0)
return gdk_display_get_n_monitors (gdk_screen_get_display (screen));
#else
return gdk_screen_get_n_monitors (screen);
#endif
}
|