|
|
| version 1.4, 2007/01/12 19:09:58 | version 1.8, 2007/01/24 14:09:32 |
|---|---|
| Line 25 | Line 25 |
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ | */ |
| #ifdef HAVE_CONFIG_H | |
| #include "config.h" | |
| #endif | |
| #include <string.h> | #include <string.h> |
| #include "gtk2/xnp2.h" | #include "gtk2/xnp2.h" |
| #include <gdk/gdkx.h> | #include <gdk/gdkx.h> |
| #ifdef HAVE_XF86VIDMODE | |
| #include <X11/extensions/xf86vmode.h> | |
| #endif | |
| extern int verbose; | extern int verbose; |
| void | void |
| Line 90 gdk_window_get_pixmap_format(GdkWindow * | Line 90 gdk_window_get_pixmap_format(GdkWindow * |
| } | } |
| #ifdef HAVE_XF86VIDMODE | #ifdef HAVE_XF86VIDMODE |
| #include <X11/extensions/xf86vmode.h> | |
| static XF86VidModeModeInfo **modes = NULL; | static XF86VidModeModeInfo **modes = NULL; |
| static int modeidx = -1; | static int modeidx = -1; |
| static XF86VidModeModeInfo *saved_modes; | static XF86VidModeModeInfo *saved_modes; |
| static XF86VidModeModeInfo orig_mode; | static XF86VidModeModeInfo orig_mode; |
| static Display *fs_xdisplay; | |
| static int fs_xscreen; | |
| static int view_x, view_y; | static int view_x, view_y; |
| static gint orig_x, orig_y; | static gint orig_x, orig_y; |
| Line 117 gtk_window_init_fullscreen(GtkWidget *wi | Line 121 gtk_window_init_fullscreen(GtkWidget *wi |
| GtkWindow *window; | GtkWindow *window; |
| GdkWindow *w; | GdkWindow *w; |
| Display *xdisplay; | Display *xdisplay; |
| XF86VidModeModeInfo mode; | |
| int xscreen; | int xscreen; |
| XF86VidModeModeInfo mode; | |
| int event_base, error_base; | int event_base, error_base; |
| int major_ver, minor_ver; | int major_ver, minor_ver; |
| int nmodes; | int nmodes; |
| Line 174 gtk_window_init_fullscreen(GtkWidget *wi | Line 178 gtk_window_init_fullscreen(GtkWidget *wi |
| modes[i]->hdisplay, modes[i]->vdisplay); | modes[i]->hdisplay, modes[i]->vdisplay); |
| } | } |
| rv = XF86VidModeValidateModeLine(xdisplay, xscreen, modes[i]); | if ((modes[i]->hdisplay == 640) |
| if (rv) { | && (modes[i]->vdisplay == 480)) { |
| if ((modes[i]->hdisplay == 640) | rv = XF86VidModeGetModeInfo(xdisplay, xscreen, |
| && (modes[i]->vdisplay == 480)) { | &orig_mode); |
| rv = XF86VidModeGetModeInfo(xdisplay, xscreen, | if (rv) { |
| &orig_mode); | if (verbose) { |
| if (rv) { | printf("found\n"); |
| if (verbose) { | |
| printf("found\n"); | |
| } | |
| modeidx = i; | |
| ret = TRUE; | |
| break; | |
| } | } |
| modeidx = i; | |
| ret = TRUE; | |
| break; | |
| } | } |
| } | } |
| } | } |
| XFree(modes); | |
| if (ret) { | |
| fs_xdisplay = xdisplay; | |
| fs_xscreen = xscreen; | |
| } else { | |
| XFree(modes); | |
| modes = NULL; | |
| } | |
| out: | out: |
| XUnlockDisplay(xdisplay); | XUnlockDisplay(xdisplay); |
| Line 205 gtk_window_fullscreen_mode(GtkWidget *wi | Line 213 gtk_window_fullscreen_mode(GtkWidget *wi |
| { | { |
| #ifdef HAVE_XF86VIDMODE | #ifdef HAVE_XF86VIDMODE |
| GtkWindow *window; | GtkWindow *window; |
| GdkWindow *w; | |
| Display *xdisplay; | |
| int xscreen; | |
| g_return_if_fail(widget != NULL); | g_return_if_fail(widget != NULL); |
| g_return_if_fail(widget->window != NULL); | |
| if (modeidx < 0) | if (modes == NULL || modeidx < 0) |
| return; | return; |
| window = GTK_WINDOW(widget); | window = GTK_WINDOW(widget); |
| w = widget->window; | g_return_if_fail(window != NULL); |
| xdisplay = GDK_WINDOW_XDISPLAY(w); | |
| xscreen = XDefaultScreen(xdisplay); | |
| XLockDisplay(xdisplay); | XLockDisplay(fs_xdisplay); |
| XF86VidModeLockModeSwitch(xdisplay, xscreen, True); | XF86VidModeLockModeSwitch(fs_xdisplay, fs_xscreen, True); |
| XF86VidModeGetViewPort(xdisplay, xscreen, &view_x, &view_y); | XF86VidModeGetViewPort(fs_xdisplay, fs_xscreen, &view_x, &view_y); |
| gdk_window_get_origin(w, &orig_x, &orig_y); | gdk_window_get_origin(widget->window, &orig_x, &orig_y); |
| gtk_window_move(window, 0, 0); | gtk_window_move(window, 0, 0); |
| XF86VidModeSwitchToMode(xdisplay, xscreen, modes[modeidx]); | XF86VidModeSwitchToMode(fs_xdisplay, fs_xscreen, modes[modeidx]); |
| XUnlockDisplay(xdisplay); | XUnlockDisplay(fs_xdisplay); |
| #endif /* HAVE_XF86VIDMODE */ | #endif /* HAVE_XF86VIDMODE */ |
| } | } |
| Line 236 gtk_window_restore_mode(GtkWidget *widge | Line 240 gtk_window_restore_mode(GtkWidget *widge |
| { | { |
| #ifdef HAVE_XF86VIDMODE | #ifdef HAVE_XF86VIDMODE |
| GtkWindow *window; | GtkWindow *window; |
| GdkWindow *w; | |
| Display *xdisplay; | |
| int xscreen; | |
| XF86VidModeModeInfo mode; | XF86VidModeModeInfo mode; |
| int rv; | int rv; |
| Line 248 gtk_window_restore_mode(GtkWidget *widge | Line 249 gtk_window_restore_mode(GtkWidget *widge |
| return; | return; |
| window = GTK_WINDOW(widget); | window = GTK_WINDOW(widget); |
| w = widget->window; | |
| xdisplay = GDK_WINDOW_XDISPLAY(w); | |
| xscreen = XDefaultScreen(xdisplay); | |
| XLockDisplay(xdisplay); | XLockDisplay(fs_xdisplay); |
| rv = XF86VidModeGetModeInfo(xdisplay, xscreen, &mode); | rv = XF86VidModeGetModeInfo(fs_xdisplay, fs_xscreen, &mode); |
| if (rv) { | if (rv) { |
| if ((orig_mode.hdisplay != mode.hdisplay) | if ((orig_mode.hdisplay != mode.hdisplay) |
| || (orig_mode.vdisplay != mode.vdisplay)) { | || (orig_mode.vdisplay != mode.vdisplay)) { |
| XF86VidModeSwitchToMode(xdisplay, xscreen, &orig_mode); | XF86VidModeSwitchToMode(fs_xdisplay, fs_xscreen, |
| XF86VidModeLockModeSwitch(xdisplay, xscreen, False); | &orig_mode); |
| XF86VidModeLockModeSwitch(fs_xdisplay, fs_xscreen, | |
| False); | |
| } | } |
| if ((view_x != 0) || (view_y != 0)) { | if ((view_x != 0) || (view_y != 0)) { |
| XF86VidModeSetViewPort(xdisplay,xscreen,view_x,view_y); | XF86VidModeSetViewPort(fs_xdisplay, fs_xscreen, |
| view_x, view_y); | |
| } | } |
| } | } |
| gtk_window_move(window, orig_x, orig_y); | if (window != NULL) { |
| gtk_window_move(window, orig_x, orig_y); | |
| } | |
| XUnlockDisplay(xdisplay); | XUnlockDisplay(fs_xdisplay); |
| #endif /* HAVE_XF86VIDMODE */ | #endif /* HAVE_XF86VIDMODE */ |
| } | } |