[totem] backend: Use GDK provided work area code
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] backend: Use GDK provided work area code
- Date: Fri, 6 Jan 2012 12:39:52 +0000 (UTC)
commit 73cff153771914ec3dc783c68f00ecfad6f085b4
Author: Bastien Nocera <hadess hadess net>
Date: Fri Jan 6 12:39:25 2012 +0000
backend: Use GDK provided work area code
configure.in | 2 +-
src/backend/video-utils.c | 164 ++------------------------------------------
2 files changed, 9 insertions(+), 157 deletions(-)
---
diff --git a/configure.in b/configure.in
index d224062..bff5777 100644
--- a/configure.in
+++ b/configure.in
@@ -43,7 +43,7 @@ AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
# Requirements
GLIB_REQS=2.27.92
GIO_REQS=2.27.92
-GTK_REQS=2.99.3
+GTK_REQS=3.3.6
TOTEM_PLPARSER_REQS=2.32.4
GNOMEICON_REQS=2.15.90
DBUS_REQS=0.82
diff --git a/src/backend/video-utils.c b/src/backend/video-utils.c
index 893ba9b..fe0093d 100644
--- a/src/backend/video-utils.c
+++ b/src/backend/video-utils.c
@@ -38,14 +38,6 @@
#include <string.h>
#include <stdio.h>
-#ifdef GDK_WINDOWING_X11
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <gdk/gdkx.h>
-#endif /* GDK_WINDOWING_X11 */
-
void
totem_gdk_window_set_invisible_cursor (GdkWindow *window)
{
@@ -101,152 +93,23 @@ totem_time_to_string (gint64 msecs)
}
static gboolean
-totem_ratio_fits_screen_generic (GtkWidget *video_widget,
- int new_w, int new_h,
- gfloat ratio)
-{
- GdkRectangle fullscreen_rect;
- GdkScreen *screen;
- GdkWindow *window;
-
- window = gtk_widget_get_window (video_widget);
- g_return_val_if_fail (window != NULL, FALSE);
-
- screen = gtk_widget_get_screen (video_widget);
- gdk_screen_get_monitor_geometry (screen,
- gdk_screen_get_monitor_at_window (screen, window),
- &fullscreen_rect);
-
- if (new_w > (fullscreen_rect.width - 128) ||
- new_h > (fullscreen_rect.height - 128)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-#ifdef GDK_WINDOWING_X11
-static int
-get_current_desktop (GdkScreen *screen)
-{
- Display *display;
- Window win;
- Atom current_desktop, type;
- int format;
- unsigned long n_items, bytes_after;
- unsigned char *data_return = NULL;
- int workspace = 0;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
- win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen));
-
- current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True);
-
- XGetWindowProperty (display,
- win,
- current_desktop,
- 0, G_MAXLONG,
- False, XA_CARDINAL,
- &type, &format, &n_items, &bytes_after,
- &data_return);
-
- if (type == XA_CARDINAL && format == 32 && n_items > 0)
- workspace = (int) data_return[0];
- if (data_return)
- XFree (data_return);
-
- return workspace;
-}
-
-static gboolean
-get_work_area (GdkScreen *screen,
- GdkRectangle *rect)
-{
- Atom workarea;
- Atom type;
- Window win;
- int format;
- gulong num;
- gulong leftovers;
- gulong max_len = 4 * 32;
- guchar *ret_workarea;
- long *workareas;
- int result;
- int disp_screen;
- int desktop;
- Display *display;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
- workarea = XInternAtom (display, "_NET_WORKAREA", True);
-
- disp_screen = GDK_SCREEN_XNUMBER (screen);
-
- /* Defaults in case of error */
- rect->x = 0;
- rect->y = 0;
- rect->width = gdk_screen_get_width (screen);
- rect->height = gdk_screen_get_height (screen);
-
- if (workarea == None)
- return FALSE;
-
- win = XRootWindow (display, disp_screen);
- result = XGetWindowProperty (display,
- win,
- workarea,
- 0,
- max_len,
- False,
- AnyPropertyType,
- &type,
- &format,
- &num,
- &leftovers,
- &ret_workarea);
-
- if (result != Success
- || type == None
- || format == 0
- || leftovers
- || num % 4) {
- return FALSE;
- }
-
- desktop = get_current_desktop (screen);
-
- workareas = (long *) ret_workarea;
- rect->x = workareas[desktop * 4];
- rect->y = workareas[desktop * 4 + 1];
- rect->width = workareas[desktop * 4 + 2];
- rect->height = workareas[desktop * 4 + 3];
-
- XFree (ret_workarea);
-
- return TRUE;
-}
-
-static gboolean
-totem_ratio_fits_screen_x11 (GtkWidget *video_widget,
- int new_w, int new_h,
- gfloat ratio)
+totem_ratio_fits_screen_helper (GtkWidget *video_widget,
+ int new_w, int new_h,
+ gfloat ratio)
{
GdkScreen *screen;
GdkRectangle work_rect, mon_rect;
GdkWindow *window;
+ int monitor;
window = gtk_widget_get_window (video_widget);
g_return_val_if_fail (window != NULL, FALSE);
screen = gtk_widget_get_screen (video_widget);
+ window = gtk_widget_get_window (video_widget);
+ monitor = gdk_screen_get_monitor_at_window (screen, window);
- /* Get the work area */
- if (get_work_area (screen, &work_rect) == FALSE) {
- return totem_ratio_fits_screen_generic (video_widget,
- new_w,
- new_h,
- ratio);
- }
-
+ gdk_screen_get_monitor_workarea (screen, monitor, &work_rect);
gdk_screen_get_monitor_geometry (screen,
gdk_screen_get_monitor_at_window (screen, window),
&mon_rect);
@@ -257,7 +120,6 @@ totem_ratio_fits_screen_x11 (GtkWidget *video_widget,
return TRUE;
}
-#endif /* GDK_WINDOWING_X11 */
static void
get_window_size (GtkWidget *widget,
@@ -278,7 +140,6 @@ totem_ratio_fits_screen (GtkWidget *video_widget,
int video_width, int video_height,
gfloat ratio)
{
- GdkDisplay *display;
int new_w, new_h;
GtkWidget *window;
@@ -299,17 +160,8 @@ totem_ratio_fits_screen (GtkWidget *video_widget,
new_w += win_w - gdk_window_get_width (video_win);
new_h += win_h - gdk_window_get_height (video_win);
- } else {
- return totem_ratio_fits_screen_generic (video_widget, new_w, new_h, ratio);
}
-#ifdef GDK_WINDOWING_X11
- display = gtk_widget_get_display (video_widget);
-
- if (GDK_IS_X11_DISPLAY (display)) {
- return totem_ratio_fits_screen_x11 (video_widget, new_w, new_h, ratio);
- }
-#endif
- return totem_ratio_fits_screen_generic (video_widget, new_w, new_h, ratio);
+ return totem_ratio_fits_screen_helper (video_widget, new_w, new_h, ratio);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]