Search
lxdream.org :: lxdream/src/drivers/video_gtk.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gtk.c
changeset 658:f5926310bfbe
prev653:3202ff01d48e
next659:6b1dff1575b3
author nkeynes
date Wed Apr 16 12:43:52 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Start removing X11isms from gtkui into drivers
Overhaul the configure rules for figuring out the video driver
file annotate diff log raw
1.1 --- a/src/drivers/video_gtk.c Fri Mar 28 12:32:25 2008 +0000
1.2 +++ b/src/drivers/video_gtk.c Wed Apr 16 12:43:52 2008 +0000
1.3 @@ -17,17 +17,87 @@
1.4 * GNU General Public License for more details.
1.5 */
1.6
1.7 -#include <gdk/gdkx.h>
1.8 #include <gdk/gdkkeysyms.h>
1.9 #include <stdint.h>
1.10 -#include "dream.h"
1.11 +#include "lxdream.h"
1.12 #include "display.h"
1.13 #include "dckeysyms.h"
1.14 -#include "drivers/video_glx.h"
1.15 #include "drivers/video_gl.h"
1.16 #include "pvr2/pvr2.h"
1.17 #include "gtkui/gtkui.h"
1.18
1.19 +#ifdef HAVE_GTK_X11
1.20 +
1.21 +#include <gdk/gdkx.h>
1.22 +#include "drivers/video_glx.h"
1.23 +
1.24 +/************* X11-specificness **********/
1.25 +
1.26 +guint gdk_keycode_to_modifier( GdkDisplay *display, guint keycode )
1.27 +{
1.28 + int i;
1.29 + int result = 0;
1.30 + Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1.31 + XModifierKeymap *keymap = XGetModifierMapping( xdisplay );
1.32 + for( i=0; i<8*keymap->max_keypermod; i++ ) {
1.33 + if( keymap->modifiermap[i] == keycode ) {
1.34 + result = 1 << (i/keymap->max_keypermod);
1.35 + break;
1.36 + }
1.37 + }
1.38 + XFreeModifiermap(keymap);
1.39 + return result;
1.40 +}
1.41 +
1.42 +#if !(GTK_CHECK_VERSION(2,8,0))
1.43 +/* gdk_display_warp_pointer was added in GTK 2.8. If we're using an earlier
1.44 + * version, include the code here. (Can't just set the dependency on 2.8 as
1.45 + * it still hasn't been included in fink yet...) Original copyright statement
1.46 + * below.
1.47 + */
1.48 +
1.49 +/* GDK - The GIMP Drawing Kit
1.50 + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
1.51 + *
1.52 + * This library is free software; you can redistribute it and/or
1.53 + * modify it under the terms of the GNU Lesser General Public
1.54 + * License as published by the Free Software Foundation; either
1.55 + * version 2 of the License, or (at your option) any later version.
1.56 + *
1.57 + * This library is distributed in the hope that it will be useful,
1.58 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.59 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.60 + * Lesser General Public License for more details.
1.61 + *
1.62 + * You should have received a copy of the GNU Lesser General Public
1.63 + * License along with this library; if not, write to the
1.64 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.65 + * Boston, MA 02111-1307, USA.
1.66 + */
1.67 +
1.68 +/*
1.69 + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
1.70 + * file for a list of people on the GTK+ Team. See the ChangeLog
1.71 + * files for a list of changes. These files are distributed with
1.72 + * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
1.73 + */
1.74 +void gdk_display_warp_pointer (GdkDisplay *display,
1.75 + GdkScreen *screen,
1.76 + gint x,
1.77 + gint y)
1.78 +{
1.79 + Display *xdisplay;
1.80 + Window dest;
1.81 +
1.82 + xdisplay = GDK_DISPLAY_XDISPLAY (display);
1.83 + dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));
1.84 +
1.85 + XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y);
1.86 +}
1.87 +
1.88 +#endif
1.89 +
1.90 +#endif
1.91 GtkWidget *gtk_video_win = NULL;
1.92 int video_width = 640;
1.93 int video_height = 480;
1.94 @@ -165,16 +235,18 @@
1.95 G_CALLBACK(video_gtk_resize_callback), NULL );
1.96 video_width = gtk_video_win->allocation.width;
1.97 video_height = gtk_video_win->allocation.height;
1.98 +#ifdef HAVE_OSMESA
1.99 + video_gdk_init_driver( &display_gtk_driver );
1.100 +#else
1.101 +#ifdef HAVE_GLX
1.102 Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(gtk_video_win)));
1.103 Window window = GDK_WINDOW_XWINDOW( GTK_WIDGET(gtk_video_win)->window );
1.104 -#ifdef HAVE_LIBOSMESA
1.105 - video_gdk_init_driver( &display_gtk_driver );
1.106 -#else
1.107 if( ! video_glx_init_context( display, window ) ||
1.108 ! video_glx_init_driver( &display_gtk_driver ) ) {
1.109 return FALSE;
1.110 }
1.111 #endif
1.112 +#endif
1.113
1.114 #ifdef HAVE_LINUX_JOYSTICK
1.115 linux_joystick_init();
1.116 @@ -195,19 +267,21 @@
1.117 gdk_colormap_free_colors( cmap, &color, 1 );
1.118 }
1.119
1.120 +#ifdef HAVE_GTK_X11
1.121 XVisualInfo *video_gtk_get_visual()
1.122 {
1.123 -#ifdef HAVE_LIBOSMESA
1.124 +#ifdef HAVE_OSMESA
1.125 return NULL;
1.126 #else
1.127 return video_glx_get_visual();
1.128 #endif
1.129 }
1.130 +#endif
1.131
1.132 void video_gtk_shutdown()
1.133 {
1.134 if( gtk_video_win != NULL ) {
1.135 -#ifdef HAVE_LIBOSMESA
1.136 +#ifdef HAVE_OSMESA
1.137 video_gdk_shutdown();
1.138 #else
1.139 video_glx_shutdown();
.