forked from AuroraMiddleware/gtk
remove virtualization and made it cross platform. fix #79961 fixed
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com> * gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window): remove virtualization and made it cross platform. fix #79961 * gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama): fixed initialization bugs. * gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry): * tests/testxinerama.c: * gtk/gtkwindow.c (gtk_window_compute_configure_request): * gtk/gtkmenu.c (gtk_menu_position): take a GdkRectangle argument instead of returning a GdkRectangle * and propagated the changes. fix #79974
This commit is contained in:
parent
ec72bb76d4
commit
2325caf979
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -1,3 +1,16 @@
|
||||
2002-05-01 Erwann Chenede - <erwann.chenede@sun.com>
|
||||
|
||||
* gdk/gdkscreen.[hc] (gdk_screen_x11_get_monitor_at_window):
|
||||
remove virtualization and made it cross platform. fix #79961
|
||||
* gdk/x11/gdkdisplay-x11.c (check_solaris_xinerama):
|
||||
fixed initialization bugs.
|
||||
* gdk/x11/gdkscreen-x11.[hc] (gdk_screen_get_monitor_geometry):
|
||||
* tests/testxinerama.c:
|
||||
* gtk/gtkwindow.c (gtk_window_compute_configure_request):
|
||||
* gtk/gtkmenu.c (gtk_menu_position):
|
||||
take a GdkRectangle argument instead of returning
|
||||
a GdkRectangle * and propagated the changes. fix #79974
|
||||
|
||||
2002-05-01 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c
|
||||
|
@ -275,24 +275,24 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
|
||||
* gdk_screen_get_monitor_geometry:
|
||||
* @screen : a #GdkScreen.
|
||||
* @monitor_num: the monitor number.
|
||||
* @dest : a #GdkRectangle to be filled with the monitor geometry
|
||||
*
|
||||
* Returns a #GdkRectangle representing the size and start
|
||||
* Retrieves the #GdkRectangle representing the size and start
|
||||
* coordinates of the individual monitor within the the entire virtual
|
||||
* screen.
|
||||
*
|
||||
* Note that the virtual screen coordinates can be retrieved via
|
||||
* gdk_screen_get_width() and gdk_screen_get_height().
|
||||
*
|
||||
* Returns: the size and start position of the monitor wrt to
|
||||
* the virtual screen.
|
||||
**/
|
||||
GdkRectangle *
|
||||
gdk_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
void
|
||||
gdk_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
|
||||
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_geometry (screen, monitor_num);
|
||||
GDK_SCREEN_GET_CLASS (screen)->get_monitor_geometry (screen, monitor_num, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,9 +328,29 @@ gdk_screen_get_monitor_at_point (GdkScreen *screen,
|
||||
**/
|
||||
gint
|
||||
gdk_screen_get_monitor_at_window (GdkScreen *screen,
|
||||
GdkNativeWindow anid)
|
||||
GdkWindow *window)
|
||||
{
|
||||
gint num_monitors, i, sum = 0, screen_num = 0;
|
||||
GdkRectangle win_rect;
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
|
||||
|
||||
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_at_window (screen, anid);
|
||||
gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width,
|
||||
&win_rect.height, NULL);
|
||||
gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
|
||||
num_monitors = gdk_screen_get_n_monitors (screen);
|
||||
|
||||
for (i=0;i<num_monitors;i++)
|
||||
{
|
||||
GdkRectangle tmp_monitor, intersect;
|
||||
|
||||
gdk_screen_get_monitor_geometry (screen, i, &tmp_monitor);
|
||||
gdk_rectangle_intersect (&win_rect, &tmp_monitor, &intersect);
|
||||
|
||||
if (intersect.width * intersect.height > sum)
|
||||
{
|
||||
sum = intersect.width * intersect.height;
|
||||
screen_num = i;
|
||||
}
|
||||
}
|
||||
return screen_num;
|
||||
}
|
||||
|
@ -47,30 +47,28 @@ struct _GdkScreenClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
GdkDisplay * (*get_display) (GdkScreen *screen);
|
||||
gint (*get_width) (GdkScreen *screen);
|
||||
gint (*get_height) (GdkScreen *screen);
|
||||
gint (*get_width_mm) (GdkScreen *screen);
|
||||
gint (*get_height_mm) (GdkScreen *screen);
|
||||
gint (*get_root_depth) (GdkScreen *screen);
|
||||
gint (*get_screen_num) (GdkScreen *screen);
|
||||
GdkWindow * (*get_root_window) (GdkScreen *screen);
|
||||
GdkColormap * (*get_default_colormap) (GdkScreen *screen);
|
||||
void (*set_default_colormap) (GdkScreen *screen,
|
||||
GdkColormap *colormap);
|
||||
GdkWindow * (*get_window_at_pointer) (GdkScreen *screen,
|
||||
gint *win_x,
|
||||
gint *win_y);
|
||||
gboolean (*use_virtual_screen) (GdkScreen *screen);
|
||||
gint (*get_n_monitors) (GdkScreen *screen);
|
||||
GdkRectangle *(*get_monitor_geometry) (GdkScreen *screen,
|
||||
gint monitor_num);
|
||||
|
||||
gint (*get_monitor_at_point) (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
gint (*get_monitor_at_window) (GdkScreen *screen,
|
||||
GdkNativeWindow anid);
|
||||
GdkDisplay * (*get_display) (GdkScreen *screen);
|
||||
gint (*get_width) (GdkScreen *screen);
|
||||
gint (*get_height) (GdkScreen *screen);
|
||||
gint (*get_width_mm) (GdkScreen *screen);
|
||||
gint (*get_height_mm) (GdkScreen *screen);
|
||||
gint (*get_root_depth) (GdkScreen *screen);
|
||||
gint (*get_screen_num) (GdkScreen *screen);
|
||||
GdkWindow * (*get_root_window) (GdkScreen *screen);
|
||||
GdkColormap * (*get_default_colormap) (GdkScreen *screen);
|
||||
void (*set_default_colormap) (GdkScreen *screen,
|
||||
GdkColormap *colormap);
|
||||
GdkWindow * (*get_window_at_pointer) (GdkScreen *screen,
|
||||
gint *win_x,
|
||||
gint *win_y);
|
||||
gboolean (*use_virtual_screen) (GdkScreen *screen);
|
||||
gint (*get_n_monitors) (GdkScreen *screen);
|
||||
void (*get_monitor_geometry) (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest);
|
||||
gint (*get_monitor_at_point) (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
};
|
||||
|
||||
GType gdk_screen_get_type (void);
|
||||
@ -98,15 +96,16 @@ GList * gdk_screen_list_visuals (GdkScreen *screen);
|
||||
GList * gdk_screen_get_toplevel_windows (GdkScreen *screen);
|
||||
|
||||
|
||||
gboolean gdk_screen_use_virtual_screen (GdkScreen *screen);
|
||||
gint gdk_screen_get_n_monitors (GdkScreen *screen);
|
||||
GdkRectangle *gdk_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
gint monitor_num);
|
||||
gint gdk_screen_get_monitor_at_point (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
gint gdk_screen_get_monitor_at_window (GdkScreen *screen,
|
||||
GdkNativeWindow anid);
|
||||
gboolean gdk_screen_use_virtual_screen (GdkScreen *screen);
|
||||
gint gdk_screen_get_n_monitors (GdkScreen *screen);
|
||||
void gdk_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest);
|
||||
gint gdk_screen_get_monitor_at_point (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
gint gdk_screen_get_monitor_at_window (GdkScreen *screen,
|
||||
GdkWindow *window);
|
||||
|
||||
void gdk_screen_broadcast_client_message (GdkScreen *screen,
|
||||
GdkEvent *event);
|
||||
|
@ -106,17 +106,22 @@ static gboolean
|
||||
check_solaris_xinerama (GdkScreen *screen)
|
||||
{
|
||||
#ifdef HAVE_SOLARIS_XINERAMA
|
||||
|
||||
if (XineramaGetState (GDK_SCREEN_XDISPLAY (screen),
|
||||
gdk_screen_get_number (screen)))
|
||||
{
|
||||
XRectangle monitors[MAXFRAMEBUFFERS];
|
||||
char hints[16];
|
||||
|
||||
gint result;
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
|
||||
result = XineramaGetInfo (GDK_SCREEN_XDISPLAY (screen),
|
||||
gdk_screen_get_number (screen),
|
||||
monitors, hints,
|
||||
&screen_x11->num_monitors);
|
||||
if (result != Success)
|
||||
/* Yes I know it should be Success but the current implementation
|
||||
returns the num of monitor*/
|
||||
if (result == 0)
|
||||
{
|
||||
/* FIXME: We need to trap errors, since XINERAMA isn't always XINERAMA.
|
||||
*/
|
||||
|
@ -47,13 +47,12 @@ static void gdk_screen_x11_finalize (GObject *object);
|
||||
|
||||
static gboolean gdk_screen_x11_use_virtual_screen (GdkScreen *screen);
|
||||
static gint gdk_screen_x11_get_n_monitors (GdkScreen *screen);
|
||||
static GdkRectangle *gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
gint num_monitor);
|
||||
static void gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
gint num_monitor,
|
||||
GdkRectangle *dest);
|
||||
static gint gdk_screen_x11_get_monitor_at_point (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
static gint gdk_screen_x11_get_monitor_at_window (GdkScreen *screen,
|
||||
GdkNativeWindow anid);
|
||||
|
||||
GType gdk_screen_x11_get_type ();
|
||||
static gpointer parent_class = NULL;
|
||||
@ -104,7 +103,6 @@ gdk_screen_x11_class_init (GdkScreenX11Class * klass)
|
||||
screen_class->get_n_monitors = gdk_screen_x11_get_n_monitors;
|
||||
screen_class->get_monitor_geometry = gdk_screen_x11_get_monitor_geometry;
|
||||
screen_class->get_monitor_at_point = gdk_screen_x11_get_monitor_at_point;
|
||||
screen_class->get_monitor_at_window = gdk_screen_x11_get_monitor_at_window;
|
||||
|
||||
G_OBJECT_CLASS (klass)->finalize = gdk_screen_x11_finalize;
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
@ -260,14 +258,15 @@ gdk_screen_x11_get_n_monitors (GdkScreen *screen)
|
||||
return GDK_SCREEN_X11 (screen)->num_monitors;
|
||||
}
|
||||
|
||||
static GdkRectangle *
|
||||
gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
gint num_monitor)
|
||||
static void
|
||||
gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
gint num_monitor,
|
||||
GdkRectangle *dest)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
g_return_val_if_fail (num_monitor < GDK_SCREEN_X11 (screen)->num_monitors, NULL);
|
||||
|
||||
return &GDK_SCREEN_X11 (screen)->monitors[num_monitor];
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
g_return_if_fail (num_monitor < GDK_SCREEN_X11 (screen)->num_monitors);
|
||||
|
||||
*dest = screen_x11->monitors[num_monitor];
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -295,48 +294,6 @@ gdk_screen_x11_get_monitor_at_point (GdkScreen *screen,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_screen_x11_get_monitor_at_window (GdkScreen *screen,
|
||||
GdkNativeWindow anid)
|
||||
{
|
||||
gint x, y, width, height, depth;
|
||||
gint left_monitor, right_monitor, diff_monitor;
|
||||
GdkRectangle *left_monitor_rect, *right_monitor_rect;
|
||||
|
||||
GdkWindow *window = gdk_window_lookup_for_display (GDK_SCREEN_DISPLAY (screen), anid);
|
||||
|
||||
gdk_window_get_geometry (window, &x, &y, &width, &height, &depth);
|
||||
gdk_window_get_position (window, &x, &y);
|
||||
|
||||
left_monitor = gdk_screen_x11_get_monitor_at_point (screen, x, y);
|
||||
right_monitor = gdk_screen_x11_get_monitor_at_point (screen, x + width,
|
||||
y + height);
|
||||
left_monitor_rect = gdk_screen_x11_get_monitor_geometry (screen,
|
||||
left_monitor);
|
||||
right_monitor_rect = gdk_screen_x11_get_monitor_geometry (screen,
|
||||
right_monitor);
|
||||
|
||||
diff_monitor = right_monitor - left_monitor;
|
||||
if (diff_monitor == 0)
|
||||
{
|
||||
return left_monitor;
|
||||
}
|
||||
if (diff_monitor == 1)
|
||||
{
|
||||
int dist_left, dist_right;
|
||||
|
||||
dist_left = left_monitor_rect->x + left_monitor_rect->width - x;
|
||||
dist_right = x + width - right_monitor_rect->x;
|
||||
|
||||
if (dist_left >= dist_right)
|
||||
return left_monitor;
|
||||
|
||||
return right_monitor;
|
||||
}
|
||||
/* Window window span on at least 3 monitors */
|
||||
return left_monitor + 1;
|
||||
}
|
||||
|
||||
Screen *
|
||||
gdk_x11_screen_get_xscreen (GdkScreen *screen)
|
||||
{
|
||||
|
@ -2333,7 +2333,7 @@ gtk_menu_position (GtkMenu *menu)
|
||||
gint menu_height;
|
||||
gboolean push_in;
|
||||
GdkScreen *screen;
|
||||
GdkRectangle *monitor;
|
||||
GdkRectangle monitor;
|
||||
gint monitor_num;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU (menu));
|
||||
@ -2345,7 +2345,7 @@ gtk_menu_position (GtkMenu *menu)
|
||||
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
|
||||
monitor = gdk_screen_get_monitor_geometry (screen, monitor_num);
|
||||
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
||||
|
||||
/* We need the requisition to figure out the right place to
|
||||
* popup the menu. In fact, we always need to ask here, since
|
||||
@ -2360,8 +2360,8 @@ gtk_menu_position (GtkMenu *menu)
|
||||
(* menu->position_func) (menu, &x, &y, &push_in, menu->position_func_data);
|
||||
else
|
||||
{
|
||||
x = CLAMP (x - 2, monitor->x, MAX (monitor->x, monitor->x + monitor->width - requisition.width));
|
||||
y = CLAMP (y - 2, monitor->y, MAX (monitor->y, monitor->y + monitor->height - requisition.height));
|
||||
x = CLAMP (x - 2, monitor.x, MAX (monitor.x, monitor.x + monitor.width - requisition.width));
|
||||
y = CLAMP (y - 2, monitor.y, MAX (monitor.y, monitor.y + monitor.height - requisition.height));
|
||||
}
|
||||
|
||||
scroll_offset = 0;
|
||||
@ -2370,30 +2370,30 @@ gtk_menu_position (GtkMenu *menu)
|
||||
{
|
||||
menu_height = GTK_WIDGET (menu)->requisition.height;
|
||||
|
||||
if (y + menu_height > monitor->y + monitor->height)
|
||||
if (y + menu_height > monitor.y + monitor.height)
|
||||
{
|
||||
scroll_offset -= y + menu_height - (monitor->y + monitor->height);
|
||||
y = (monitor->y + monitor->height) - menu_height;
|
||||
scroll_offset -= y + menu_height - (monitor.y + monitor.height);
|
||||
y = (monitor.y + monitor.height) - menu_height;
|
||||
}
|
||||
|
||||
if (y < monitor->y)
|
||||
if (y < monitor.y)
|
||||
{
|
||||
scroll_offset -= y;
|
||||
y = monitor->y;
|
||||
y = monitor.y;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: should this be done in the various position_funcs ? */
|
||||
x = CLAMP (x, monitor->x, MAX (monitor->x, monitor->x + monitor->width - requisition.width));
|
||||
x = CLAMP (x, monitor.x, MAX (monitor.x, monitor.x + monitor.width - requisition.width));
|
||||
|
||||
if (y + requisition.height > monitor->y + monitor->height)
|
||||
requisition.height = (monitor->y + monitor->height) - y;
|
||||
if (y + requisition.height > monitor.y + monitor.height)
|
||||
requisition.height = (monitor.y + monitor.height) - y;
|
||||
|
||||
if (y < monitor->y)
|
||||
if (y < monitor.y)
|
||||
{
|
||||
scroll_offset -= y;
|
||||
requisition.height -= -y;
|
||||
y = monitor->y;
|
||||
y = monitor.y;
|
||||
}
|
||||
|
||||
if (scroll_offset > 0)
|
||||
|
@ -4094,7 +4094,7 @@ gtk_window_compute_configure_request (GtkWindow *window,
|
||||
case GTK_WIN_POS_CENTER:
|
||||
{
|
||||
gint px, py, monitor_num;
|
||||
GdkRectangle *monitor;
|
||||
GdkRectangle monitor;
|
||||
|
||||
gdk_window_get_pointer (gdk_screen_get_root_window (window->screen),
|
||||
&px, &py, NULL);
|
||||
@ -4103,10 +4103,10 @@ gtk_window_compute_configure_request (GtkWindow *window,
|
||||
if (monitor_num == -1)
|
||||
monitor_num = 0;
|
||||
|
||||
monitor = gdk_screen_get_monitor_geometry (window->screen, monitor_num);
|
||||
gdk_screen_get_monitor_geometry (window->screen, monitor_num, &monitor);
|
||||
|
||||
x = (monitor->width - w) / 2 + monitor->x;
|
||||
y = (monitor->height - h) / 2 + monitor->y;
|
||||
x = (monitor.width - w) / 2 + monitor.x;
|
||||
y = (monitor.height - h) / 2 + monitor.y;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "x11/gdkx.h"
|
||||
|
||||
static gint num_monitors;
|
||||
|
||||
@ -11,18 +10,19 @@ request (GtkWidget *widget,
|
||||
{
|
||||
gchar *str;
|
||||
gint i = gdk_screen_get_monitor_at_window (gtk_widget_get_screen (widget),
|
||||
GDK_WINDOW_XWINDOW (widget->window));
|
||||
widget->window);
|
||||
|
||||
if (i < 0)
|
||||
str = g_strdup ("<big><span foreground='white' background='black'>Not on a monitor </span></big>");
|
||||
else
|
||||
{
|
||||
GdkRectangle *monitor = gdk_screen_get_monitor_geometry (gtk_widget_get_screen (widget), i);
|
||||
GdkRectangle monitor;
|
||||
gdk_screen_get_monitor_geometry (gtk_widget_get_screen (widget), i, &monitor);
|
||||
str = g_strdup_printf ("<big><span foreground='white' background='black'>"
|
||||
"Monitor %d of %d</span></big>\n"
|
||||
"<i>Width - Height </i>: (%d,%d)\n"
|
||||
"<i>Top left coordinate </i>: (%d,%d)",i+1, num_monitors,
|
||||
monitor->width, monitor->height, monitor->x, monitor->y);
|
||||
monitor.width, monitor.height, monitor.x, monitor.y);
|
||||
}
|
||||
|
||||
gtk_label_set_markup (GTK_LABEL (user_data), str);
|
||||
@ -42,25 +42,26 @@ main (int argc, char *argv[])
|
||||
|
||||
num_monitors = gdk_screen_get_n_monitors (screen);
|
||||
if (num_monitors == 1)
|
||||
g_warning ("The current display has only one monitor.");
|
||||
g_warning ("The current display does not support xinerama.");
|
||||
|
||||
for (i=0; i<num_monitors; i++)
|
||||
{
|
||||
GdkRectangle *monitor = gdk_screen_get_monitor_geometry (screen, i);
|
||||
GdkRectangle monitor;
|
||||
gchar *str;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gdk_screen_get_monitor_geometry (screen, i, &monitor);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
|
||||
gtk_window_move (GTK_WINDOW (window), (monitor->width - 200) / 2 + monitor->x,
|
||||
(monitor->height - 200) / 2 + monitor->y);
|
||||
gtk_window_move (GTK_WINDOW (window), (monitor.width - 200) / 2 + monitor.x,
|
||||
(monitor.height - 200) / 2 + monitor.y);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
str = g_strdup_printf ("<big><span foreground='white' background='black'>"
|
||||
"Monitor %d of %d</span></big>\n"
|
||||
"<i>Width - Height </i>: (%d,%d)\n"
|
||||
"<i>Top left coordinate </i>: (%d,%d)",i+1, num_monitors,
|
||||
monitor->width, monitor->height, monitor->x, monitor->y);
|
||||
monitor.width, monitor.height, monitor.x, monitor.y);
|
||||
gtk_label_set_markup (GTK_LABEL (label), str);
|
||||
g_free (str);
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
|
Loading…
Reference in New Issue
Block a user