Author: dmeyer
Date: Fri Mar 10 13:22:32 2006
New Revision: 1259

Added:
   trunk/display/src/x11.py
Modified:
   trunk/display/setup.py
   trunk/display/src/__init__.py
   trunk/display/src/dfb.c
   trunk/display/src/dfb.py
   trunk/display/src/display.c
   trunk/display/src/display.h
   trunk/display/src/evas.c
   trunk/display/src/evas.h
   trunk/display/src/fb.c
   trunk/display/src/fb.py
   trunk/display/src/imlib2.c
   trunk/display/src/imlib2.h
   trunk/display/src/sdl.c
   trunk/display/src/sdl.h
   trunk/display/src/sdl.py
   trunk/display/src/x11display.c
   trunk/display/src/x11display.h
   trunk/display/src/x11window.c
   trunk/display/src/x11window.h

Log:
some cleanups, code movemenets

Modified: trunk/display/setup.py
==============================================================================
--- trunk/display/setup.py      (original)
+++ trunk/display/setup.py      Fri Mar 10 13:22:32 2006
@@ -5,7 +5,7 @@
 # $Id$
 #
 # -----------------------------------------------------------------------------
-# kaa-display - X11/SDL Display module
+# kaa-display - Display module
 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -37,89 +37,43 @@
 
 try:
     # kaa base imports
-    from kaa.base.distribution import Extension, Configfile, setup
+    from kaa.base.distribution import Extension, Configfile, setup, \
+         check_library, get_library
 except ImportError:
     print 'kaa.base not installed'
     sys.exit(1)
 
-# a list of all modules
-modules = []
-
-# the framebuffer so module
-fb = Extension('kaa.display._FBmodule', [ 'src/fb.c'] )
-
-if fb.check_library('imlib2', '1.1.1'):
-    print "+ FB support enabled"
-    modules.append(fb)
-else:
-    print "- FB support disabled"
-    fb = None
-
-# the DirectFB so module
-dfb = Extension('kaa.display._DFBmodule', [ 'src/dfb.c'] )
-
-if dfb.check_library('directfb', '0.9.20'):
-    print "+ DFB support enabled"
-    modules.append(dfb)
-else:
-    print "- DFB support disabled"
-    dfb = None
-
 # config file
 config = Configfile('src/config.h')
 
-# the display so module
-x11 = Extension('kaa.display._Displaymodule',
-                [ 'src/display.c', 'src/sdl.c', 'src/x11display.c',
-                  'src/x11window.c', 'src/imlib2.c', 'src/evas.c' ],
-                libraries = ['png', 'rt'])
-
-# check if X11 is actually present
-if not x11.check_cc(['<X11/Xlib.h>'], ''):
-    print "System without X11 detected! Disabling all X11 dependencies..."
-    x11 = None
-else:
-    modules.append(x11)
-    config.define('HAVE_X11')
+check_library('X11', ['<X11/Xlib.h>'], '')
+check_library('imlib2', '1.1.1')
+check_library('evas', '0.9.9.010')
+check_library('directfb', '0.9.20')
 
-    if x11.check_library('imlib2', '1.1.1'):
-        config.define('USE_IMLIB2')
-        if 'X11' in x11.libraries:
-            config.define('USE_IMLIB2_DISPLAY')
-            print "+ Imlib2 support enabled"
-        else:
-            print '- Imlib2 compiled without X11, not building imlib2 display'
-    else:
-        print "- Imlib2 support disabled."
+print 'checking for pygame', '...',
+sys.__stdout__.flush()
 
-    try:
-        # test for pygame support
-        try:
-            import pygame
-        except ImportError, e:
-            print 'pygame module not found'
-            raise e
-        inc = re.sub("/(lib|lib64)/", "/include/",
-                     pygame.__path__[0]).replace("site-packages/", "")
-        if not os.path.isdir(inc):
-            print 'pygame header file not found. Install pygame-devel.'
-            raise ImportError
-        if not x11.check_library('sdl', '1.2.5'):
-            print 'SDL not found'
-            raise ImportError
-        x11.include_dirs.append(inc)
-        config.define('USE_PYGAME\n')
-        print "+ pygame support enabled"
-    except ImportError:
-        print '- pygame support disabled'
-
-
-# Test for evas and supported engines
-evas_engines = ""
-for display in modules:
-    if not display.check_library('evas', '0.9.9.010'):
-        break
-else:
+try:
+    import pygame
+    print 'ok'
+    print 'checking for pygame header files', '...',
+    inc = re.sub("/(lib|lib64)/", "/include/",
+                 pygame.__path__[0]).replace("site-packages/", "")
+    if not os.path.isdir(inc):
+        raise ImportError
+
+    print 'ok'
+    check_library('sdl', '1.2.5')
+    has_pygame = True
+    
+except ImportError, e:
+    print 'not installed'
+    has_pygame = False
+
+
+evas_engines = []
+if get_library('evas'):
     indent = re.compile("^", re.M)
     out = "/tmp/a.out.%s" % os.getpid()
     cmd = "cc -x c - `evas-config --libs --cflags` -o %s" % out
@@ -144,32 +98,88 @@
         if os.waitpid(p.pid, 0)[1] != 0:
             output = indent.sub("\t", output)
             print "! Failed to run evas test program:\n", output
-
-        for line in output.splitlines():
-            engine = line.strip()
-            if engine == "software_x11" and x11:
-                config.define("ENABLE_ENGINE_SOFTWARE_X11")
-                evas_engines += " software_x11"
-            elif engine == "gl_x11" and x11:
-                config.define("ENABLE_ENGINE_GL_X11")
-                evas_engines += " gl_x11"
-            elif engine == 'fb' and fb:
-                config.define("ENABLE_ENGINE_FB")
-                evas_engines += " fb"
-            elif engine == 'directfb' and dfb:
-                config.define("ENABLE_ENGINE_DFB")
-                evas_engines += " dfb"
+        else:
+            config.define("USE_EVAS")
+            for line in output.splitlines():
+                engine = line.strip()
+                config.define("ENABLE_ENGINE_%s" % engine.upper())
+                evas_engines.append(engine)
         os.unlink(out)
 
-if evas_engines == "":
-    print "- evas support disabled"
+
+if get_library('X11'):
+    
+    # the display so module
+    x11 = Extension('kaa.display._X11module',
+                    [ 'src/display.c', 'src/x11display.c', 'src/x11window.c',
+                      'src/imlib2.c', 'src/evas.c' ],
+                    libraries = ['png', 'rt'])
+    
+    config.define('HAVE_X11')
+    features = []
+    if get_library('imlib2') and 'X11' in get_library('imlib2').libraries:
+        config.define('USE_IMLIB2')
+        x11.add_library('imlib2')
+        features.append('imlib2')
+    if 'software_x11' in evas_engines:
+        features.append('evas')
+        x11.add_library('evas')
+    if 'gl_x11' in evas_engines:
+        features.append('evasGL')
+        x11.add_library('evas')
+    if not features:
+        features = [ 'yes' ]
+    else:
+        print "+ X11 (%s)" % ', '.join(features)
+    x11.build()
+else:
+    print '- X11'
+
+
+if get_library('imlib2'):
+
+    # the framebuffer so module
+    fb = Extension('kaa.display._FBmodule', [ 'src/fb.c'] )
+    fb.add_library('imlib2')
+    if 'fb' in evas_engines:
+        fb.add_library('evas')
+        print "+ Framebuffer (imlib2, evas)"
+    else:
+        print "+ Framebuffer (imlib2)"
+    fb.build()
+else:
+    print "- Framebuffer"
+
+
+if get_library('directfb'):
+
+    # the dfb so module
+    dfb = Extension('kaa.display._DFBmodule', [ 'src/dfb.c'] )
+    dfb.add_library('directfb')
+    if 'directfb' in evas_engines:
+        print "+ DirectFB (evas)"
+        dfb.add_library('evas')
+    else:
+        print "+ DirectFB"
+    dfb.build()
+else:
+    print "- DirectFB"
+
+
+if has_pygame and get_library('sdl') and get_library('imlib2'):
+
+    # pygame module
+    sdl = Extension('kaa.display._SDLmodule', ['src/sdl.c'])
+    sdl.add_library('imlib2')
+    sdl.add_library('sdl')
+    sdl.build()
+    print "+ SDL (imlib2)"
 else:
-    print "+ evas support enabled for engines:" + evas_engines
-    config.define("USE_EVAS")
+    print "- SDL"
+    
 
 setup(module  = 'display',
       version = '0.1',
-      ext_modules = modules
 )
 
 config.unlink()

Modified: trunk/display/src/__init__.py
==============================================================================
--- trunk/display/src/__init__.py       (original)
+++ trunk/display/src/__init__.py       Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
 # $Id$
 #
 # -----------------------------------------------------------------------------
-# kaa-display - X11/SDL Display module
+# kaa-display - Generic Display Module
 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # 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
@@ -29,404 +29,34 @@
 #
 # -----------------------------------------------------------------------------
 
-# python imports
-import weakref
-import time
-import threading
-import select
-import os
+displays = []
 
-# the display module
-import _Display
+# import X11 support
+try:
+    from x11 import X11Display, X11Window, EvasX11Window
+    displays.append('x11')
+except ImportError, e:
+    pass
 
 # import Framebuffer support
 try:
     from fb import Framebuffer, EvasFramebuffer, PAL_768x576, PAL_800x600, \
          NTSC_640x480, NTSC_768x576, NTSC_800x600
-except ImportError:
+    displays.append('framebuffer')
+except ImportError, e:
     pass
 
 # import DirectFB support
 try:
     from dfb import EvasDirectFB
-except ImportError:
+    displays.append('directfb')
+except ImportError, e:
     pass
 
-# kaa notifier for the socket callback
-import kaa.notifier
-from kaa.notifier import Signal
-
-# default X11 display
-_default_x11_display = None
-
-_keysym_names = {
-    338: "up",
-    340: "down",
-    337: "left",
-    339: "right",
-
-    446: "F1",
-    447: "F2",
-    448: "F3",
-    449: "F4",
-    450: "F5",
-    451: "F6",
-    452: "F7",
-    453: "F8",
-    454: "F9",
-    455: "F10",
-    456: "F11",
-    457: "F21",
-
-    355: "ins",
-    511: "del",
-    336: "home",
-    343: "end",
-    283: "esc",
-    269: "enter",
-    264: "backspace",
-    32: "space",
-
-    489: "left-alt",
-    490: "right-alt",
-    483: "left-ctrl",
-    484: "right-ctrl",
-    481: "left-shift",
-    482: "right-shift",
-    359: "menu",
-    275: "pause",
-
-    # keypad
-    427: "kp_plus",
-    429: "kp_minus"
-}
- 
-class X11Display(object):
-
-    XEVENT_MOTION_NOTIFY = 6
-    XEVENT_EXPOSE = 12
-    XEVENT_BUTTON_PRESS = 4
-    XEVENT_KEY_PRESS = 2
-    XEVENT_FOCUS_IN = 9
-    XEVENT_FOCUS_OUT = 10
-    XEVENT_EXPOSE = 12
-    XEVENT_UNMAP_NOTIFY = 18
-    XEVENT_MAP_NOTIFY = 19
-    XEVENT_CONFIGURE_NOTIFY = 22
-    
-    #XEVENT_WINDOW_EVENTS = (6, 12, 4, 2, 22, 18, 19)
-
-    def __init__(self, dispname = ""):
-        self._display = _Display.X11Display(dispname)
-        self._windows = {}
-
-        dispatcher = kaa.notifier.WeakSocketDispatcher(self.handle_events)
-        dispatcher.register(self.socket)
-        # Also connect to the idle signal. It is a bad hack, but when
-        # drawing is done, the socket is read and we will miss keypress
-        # events when doing drawings.
-        kaa.notifier.signals['idle'].connect_weak(self.handle_events)
-
-    def handle_events(self):
-        window_events = {}
-        for event, data in self._display.handle_events():
-            wid = 0
-            if event in X11Display.XEVENT_WINDOW_EVENTS:
-                wid = data["window"]
-            if wid:
-                if wid not in window_events:
-                    window_events[wid] = []
-                if event == X11Display.XEVENT_CONFIGURE_NOTIFY:
-                    # Remove any existing configure events in the list (only
-                    # the last one applies)
-                    window_events[wid] = [ x for x in window_events[wid] if 
x[0] != 
-                                           X11Display.XEVENT_CONFIGURE_NOTIFY ]
-                window_events[wid].append((event, data))
-
-        for wid, events in window_events.items():
-            assert(wid in self._windows)
-            window = self._windows[wid]()
-            if not window:
-                # Window no longer exists.
-                del self._windows[wid]
-            else:
-                window.handle_events(events)
-
-        # call the socket again
-        return True
-    
-
-    def __getattr__(self, attr):
-        if attr in ("socket,"):
-            return getattr(self._display, attr)
-
-        return getattr(super(X11Display, self), attr)
-
-    def sync(self):
-        return self._display.sync()
-
-    def lock(self):
-        return self._display.lock()
-
-    def unlock(self):
-        return self._display.unlock()
-
-    def get_size(self, screen = -1):
-        return self._display.get_size(screen)
-
-    def get_string(self):
-        return self._display.get_string()
-
-    def glx_supported(self):
-        return self._display.glx_supported()
-
-
-
-X11Display.XEVENT_WINDOW_EVENTS_LIST = filter(lambda x: x.find("XEVENT_") != 
-1, dir(X11Display))
-X11Display.XEVENT_WINDOW_EVENTS = map(lambda x: getattr(X11Display, x), 
X11Display.XEVENT_WINDOW_EVENTS_LIST)
-
-def _get_display(display):
-    if not display:
-        global _default_x11_display
-        if not _default_x11_display:
-            _default_x11_display = X11Display()
-        display = _default_x11_display
-
-    assert(type(display) == X11Display)
-    return display
-
-
-
-class X11Window(object):
-    def __init__(self, display = None, window = None, **kwargs):
-        display = _get_display(display)
-        if window:
-            self._window = window
-        else:
-            assert("size" in kwargs)
-            if "title" in kwargs:
-                assert(type(kwargs["title"]) == str)
-            if "parent" in kwargs:
-                assert(isinstance(kwargs["parent"], X11Window))
-                kwargs["parent"] = kwargs["parent"]._window
-
-            self._window = _Display.X11Window(display._display, 
kwargs["size"], **kwargs)
-
-        self._display = display
-        display._windows[self._window.ptr] = weakref.ref(self)
-        self._cursor_hide_timeout = -1
-        self._cursor_hide_timer = 
kaa.notifier.WeakOneShotTimer(self._cursor_hide_cb)
-        self._cursor_visible = True
-        self._fs_size_save = None
-        self._last_configured_size = 0, 0
-
-        self.signals = {
-            "key_press_event": Signal(),
-            "focus_in_event": Signal(),
-            "focus_out_event": Signal(),
-            "expose_event": Signal(),
-            "map_event": Signal(),
-            "unmap_event": Signal(),
-            "resize_event": Signal(),
-            "configure_event": Signal(),
-        }
-        
-    def get_display(self):
-        return self._display
-
-    def raise_window(self):
-        self._window.raise_window()
-        self._display.handle_events()
-
-    def lower_window(self):
-        self._window.lower_window()
-        self._display.handle_events()
-
-    def show(self, raised = False):
-        self._window.show(raised)
-        self._display.handle_events()
-
-    def hide(self):
-        self._window.hide()
-        self._display.handle_events()
-
-    def set_visible(self, visible = True):
-        if visible:
-            self.show()
-        else:
-            self.hide()
-
-    def get_visible(self):
-        return self._window.get_visible()
-
-    def render_imlib2_image(self, i, dst_pos = (0, 0), src_pos = (0, 0),
-                            size = (-1, -1), dither = True, blend = False):
-        return _Display.render_imlib2_image(self._window, i._image, dst_pos, \
-                                            src_pos, size, dither, blend)
-
-    def handle_events(self, events):
-        expose_regions = []
-        for event, data in events:
-            if event == X11Display.XEVENT_MOTION_NOTIFY:
-                # Mouse moved, so show cursor.
-                if self._cursor_hide_timeout != 0 and not self._cursor_visible:
-                    self.set_cursor_visible(True)
-
-                self._cursor_hide_timer.start(self._cursor_hide_timeout)
-
-            elif event == X11Display.XEVENT_KEY_PRESS:
-                key = data["key"]
-                if key in _keysym_names:
-                    key = _keysym_names[key]
-                elif key < 255:
-                    key = chr(key)
-                self.signals["key_press_event"].emit(key)
-
-            elif event == X11Display.XEVENT_EXPOSE:
-                # Queue expose regions so we only need to emit one signal.
-                expose_regions.append((data["pos"], data["size"]))
-
-            elif event == X11Display.XEVENT_MAP_NOTIFY:
-                self.signals["map_event"].emit()
-
-            elif event == X11Display.XEVENT_UNMAP_NOTIFY:
-                self.signals["unmap_event"].emit()
-
-            elif event == X11Display.XEVENT_CONFIGURE_NOTIFY:
-                cur_size = self.get_size()
-                last_size = self._last_configured_size
-                if last_size != cur_size and last_size != (-1, -1):
-                    # Set this now to prevent reentry.
-                    self._last_configured_size = -1, -1
-                    self.signals["resize_event"].emit(last_size, cur_size)
-                    # Callback could change size again, so save our actual
-                    # size to prevent being called again.
-                    self._last_configured_size = self.get_size()
-                self.signals["configure_event"].emit(data["pos"], data["size"])
-            elif event == X11Display.XEVENT_FOCUS_IN:
-                self.signals["focus_in_event"].emit()
-            elif event == X11Display.XEVENT_FOCUS_OUT:
-                self.signals["focus_out_event"].emit()
-                
-
-        if len(expose_regions) > 0:
-            self.signals["expose_event"].emit(expose_regions)
-                
-
-    def move(self, pos, force = False):
-        return self.set_geometry(pos, (-1, -1))
-
-    def resize(self, size, force = False):
-        return self.set_geometry((-1, -1), size, force)
-
-    def set_geometry(self, pos, size, force = False):
-        if self.get_fullscreen() and not force:
-            self._fs_size_save = size
-            return False
-
-        self._window.set_geometry(pos, size)
-        self._display.handle_events()
-        return True
-
-    def get_geometry(self):
-        return self._window.get_geometry()
-
-    def get_size(self):
-        return self.get_geometry()[1]
-
-    def get_pos(self):
-        return self.get_geometry()[0]
-
-    def set_cursor_visible(self, visible):
-        self._window.set_cursor_visible(visible)
-        self._cursor_visible = visible
-        self._display.handle_events()
-
-    def _cursor_hide_cb(self):
-        self.set_cursor_visible(False)
-
-    def set_cursor_hide_timeout(self, timeout):
-        self._cursor_hide_timeout = timeout
-        self._cursor_hide_timer.start(self._cursor_hide_timeout)
-
-    def set_fullscreen(self, fs = True):
-        if not fs:
-            if self._fs_size_save:
-                self.resize(self._fs_size_save, force = True)
-                self._window.set_fullscreen(False)
-                self._fs_size_save = None
-                return True
-
-            return False
-
-        if self._fs_size_save:
-            return False
-
-        self._fs_size_save = self.get_size()
-        display_size = self.get_display().get_size()
-        self._window.set_fullscreen(True)
-        self.resize(display_size, force = True)
-
-    def get_fullscreen(self):
-        return self._fs_size_save != None
-     
-    def get_id(self):
-        return self._window.ptr
-
-    def focus(self):
-        return self._window.focus()
-
-
-class EvasX11Window(X11Window):
-    def __init__(self, gl = False, display = None, size = (640, 480), 
-                 title = "Evas", **kwargs):
-        import kaa.evas
-
-        if not gl:
-            f = _Display.new_evas_software_x11
-        else:
-            f = _Display.new_evas_gl_x11
-
-        if "parent" in kwargs:
-            assert(isinstance(kwargs["parent"], X11Window))
-            kwargs["parent"] = kwargs["parent"]._window
-
-        assert(type(size) == tuple)
-        display = _get_display(display)
-        self._evas = kaa.evas.Evas()
-        window = f(self._evas._evas, display._display, size = size,
-                   title = title, **kwargs)
-        self._evas.output_size_set(size)
-        self._evas.viewport_set((0, 0), size)
-
-        # Ensures the display remains alive until after Evas gets deallocated
-        # during garbage collection.  
-        self._evas._dependencies.append(display._display)
-        self._evas._dependencies.append(window)
-        if "parent" in kwargs:
-            self._evas._dependencies.append(kwargs["parent"])
-        super(EvasX11Window, self).__init__(display, window)
-
-
-    def handle_events(self, events):
-        needs_render = False
-        for event, data in events:
-            if event == X11Display.XEVENT_EXPOSE:
-                self._evas.damage_rectangle_add((data["pos"], data["size"]))
-                needs_render = True
-            #elif event == X11Display.XEVENT_CONFIGURE_NOTIFY:
-            #    if data["size"] != self._evas.output_size_get():
-            #        # This doesn't act right for gl.
-            #        self._evas.output_size_set(data["size"])
-            #        #self._evas.viewport_set((0, 0), data["size"])
-            #        needs_render = True
-
-        super(EvasX11Window, self).handle_events(events)
-
-        if needs_render:
-            self._evas.render()
-            self._display.handle_events()
-
+# import SDL support
+try:
+    from sdl import PygameDisplay
+    displays.append('sdl')
+except ImportError, e:
+    pass
 
-    def get_evas(self):
-        return self._evas

Modified: trunk/display/src/dfb.c
==============================================================================
--- trunk/display/src/dfb.c     (original)
+++ trunk/display/src/dfb.c     Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id: fb.c 1041 2005-12-27 19:06:37Z dmeyer $
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Dirk Meyer <[EMAIL PROTECTED]>
  * Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/dfb.py
==============================================================================
--- trunk/display/src/dfb.py    (original)
+++ trunk/display/src/dfb.py    Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
 # $Id: fb.py 1041 2005-12-27 19:06:37Z dmeyer $
 #
 # -----------------------------------------------------------------------------
-# kaa-display - X11/SDL Display module
+# kaa-display - Generic Display Module
 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # 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

Modified: trunk/display/src/display.c
==============================================================================
--- trunk/display/src/display.c (original)
+++ trunk/display/src/display.c Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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
@@ -37,10 +37,8 @@
 #include "x11window.h"
 #include "imlib2.h"
 #include "evas.h"
-#include "sdl.h"
 
 PyMethodDef display_methods[] = {
-    { "image_to_surface", (PyCFunction) image_to_surface, METH_VARARGS },
     { "render_imlib2_image", (PyCFunction) render_imlib2_image, METH_VARARGS },
 #ifdef USE_EVAS
     { "new_evas_software_x11", (PyCFunction) new_evas_software_x11, 
METH_VARARGS | METH_KEYWORDS },
@@ -67,13 +65,13 @@
     return ptrs;
 }
 
-void init_Display()
+void init_X11()
 {
     PyObject *m, *display_c_api;
     void **imlib2_api_ptrs, **evas_api_ptrs;
     static void *display_api_ptrs[3];
 
-    m = Py_InitModule("_Display", display_methods);
+    m = Py_InitModule("_X11", display_methods);
 
     if (PyType_Ready(&X11Display_PyObject_Type) < 0)
         return;

Modified: trunk/display/src/display.h
==============================================================================
--- trunk/display/src/display.h (original)
+++ trunk/display/src/display.h Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Dirk Meyer <[EMAIL PROTECTED]>
  * Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/evas.c
==============================================================================
--- trunk/display/src/evas.c    (original)
+++ trunk/display/src/evas.c    Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/evas.h
==============================================================================
--- trunk/display/src/evas.h    (original)
+++ trunk/display/src/evas.h    Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/fb.c
==============================================================================
--- trunk/display/src/fb.c      (original)
+++ trunk/display/src/fb.c      Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Dirk Meyer <[EMAIL PROTECTED]>
  * Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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
@@ -311,16 +311,12 @@
     void **imlib2_api_ptrs, **evas_api_ptrs;
     (void) Py_InitModule("_FBmodule", fb_methods);
   
-#ifdef USE_IMLIB2
     // Import kaa-imlib2's C api
     imlib2_api_ptrs = get_module_api("kaa.imlib2._Imlib2");
     if (imlib2_api_ptrs == NULL)
         return;
     imlib_image_from_pyobject = imlib2_api_ptrs[0];
     Image_PyObject_Type = imlib2_api_ptrs[1];
-#else
-    Image_PyObject_Type = NULL;
-#endif
 
 #ifdef USE_EVAS
     // Import kaa-evas's C api

Modified: trunk/display/src/fb.py
==============================================================================
--- trunk/display/src/fb.py     (original)
+++ trunk/display/src/fb.py     Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
 # $Id$
 #
 # -----------------------------------------------------------------------------
-# kaa-display - X11/SDL Display module
+# kaa-display - Generic Display Module
 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # 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

Modified: trunk/display/src/imlib2.c
==============================================================================
--- trunk/display/src/imlib2.c  (original)
+++ trunk/display/src/imlib2.c  Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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
@@ -36,12 +36,11 @@
 PyTypeObject *Image_PyObject_Type;
 
 #ifdef USE_IMLIB2
+
 #include "imlib2.h"
 Imlib_Image *(*imlib_image_from_pyobject)(PyObject *pyimg);
-#endif
-
-#ifdef USE_IMLIB2_DISPLAY
 
+#include <X11/Xlib.h>
 #include "x11window.h"
 #include "x11display.h"
 

Modified: trunk/display/src/imlib2.h
==============================================================================
--- trunk/display/src/imlib2.h  (original)
+++ trunk/display/src/imlib2.h  Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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
@@ -37,17 +37,14 @@
 #include "display.h"
 
 #ifdef USE_IMLIB2
-#ifndef USE_IMLIB2_DISPLAY
-    #define X_DISPLAY_MISSING
-#else
-    #include <X11/Xlib.h>
-#endif
 
+#include <X11/Xlib.h>
 #include <Imlib2.h>
 extern Imlib_Image *(*imlib_image_from_pyobject)(PyObject *pyimg);
 
 #endif
-#endif
 
 PyObject *render_imlib2_image(PyObject *self, PyObject *args);
 
+#endif
+

Modified: trunk/display/src/sdl.c
==============================================================================
--- trunk/display/src/sdl.c     (original)
+++ trunk/display/src/sdl.c     Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Dirk Meyer <[EMAIL PROTECTED]>
  * Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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
@@ -33,7 +33,6 @@
 #include "config.h"
 #include <Python.h>
 
-#if defined(USE_PYGAME) && defined(USE_IMLIB2)
 #include "imlib2.h"
 #include <pygame.h>
 
@@ -65,12 +64,40 @@
     Py_INCREF(Py_None);
     return Py_None;
 }
-#else
 
-PyObject *image_to_surface(PyObject *self, PyObject *args)
+
+PyMethodDef sdl_methods[] = {
+    { "image_to_surface", (PyCFunction) image_to_surface, METH_VARARGS },
+    { NULL }
+};
+
+
+void **get_module_api(char *module)
 {
-    PyErr_Format(PyExc_SystemError, "kaa-display compiled without pygame "
-                                    "and/or imlib2");
-    return NULL;
+    PyObject *m, *c_api;
+    void **ptrs;
+
+    m = PyImport_ImportModule(module);
+    if (m == NULL)
+       return NULL;
+    c_api = PyObject_GetAttrString(m, "_C_API");
+    if (c_api == NULL || !PyCObject_Check(c_api))
+        return NULL;
+    ptrs = (void **)PyCObject_AsVoidPtr(c_api);
+    Py_DECREF(c_api);
+    return ptrs;
+}
+
+void init_SDL()
+{
+    void **imlib2_api_ptrs;
+
+    Py_InitModule("_SDL", display_methods);
+
+    // Import kaa-imlib2's C api
+    imlib2_api_ptrs = get_module_api("kaa.imlib2._Imlib2");
+    if (imlib2_api_ptrs == NULL)
+        return;
+    imlib_image_from_pyobject = imlib2_api_ptrs[0];
+    Image_PyObject_Type = imlib2_api_ptrs[1];
 }
-#endif

Modified: trunk/display/src/sdl.h
==============================================================================
--- trunk/display/src/sdl.h     (original)
+++ trunk/display/src/sdl.h     Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Dirk Meyer <[EMAIL PROTECTED]>
  * Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/sdl.py
==============================================================================
--- trunk/display/src/sdl.py    (original)
+++ trunk/display/src/sdl.py    Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
 # $Id$
 #
 # -----------------------------------------------------------------------------
-# kaa-display - X11/SDL Display module
+# kaa-display - Generic Display Module
 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # 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
@@ -36,7 +36,7 @@
 import kaa.notifier
 
 # the display module
-import _Display
+import _X11
 
 class PygameDisplay(object):
     def __init__(self, size):
@@ -77,7 +77,7 @@
         """
         if self._surface:
             # we need to use our tmp surface
-            _Display.image_to_surface(image, self._surface)
+            _X11.image_to_surface(image, self._surface)
             if areas == None:
                 # copy everything
                 self._screen.blit(self._surface, (0,0))
@@ -87,7 +87,7 @@
                     self._screen.blit(self._surface, pos, pos + size)
         else:
             # copy everything
-            _Display.image_to_surface(image, self._screen)
+            _X11.image_to_surface(image, self._screen)
 
         # update the screen
         if areas:

Added: trunk/display/src/x11.py
==============================================================================
--- (empty file)
+++ trunk/display/src/x11.py    Fri Mar 10 13:22:32 2006
@@ -0,0 +1,415 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# x11.py - X11 Display classes
+# -----------------------------------------------------------------------------
+# $Id: __init__.py 1081 2005-12-29 20:43:29Z tack $
+#
+# -----------------------------------------------------------------------------
+# kaa-display - Generic Display Module
+# Copyright (C) 2005-2006 Dirk Meyer, Jason Tackaberry
+#
+# First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
+# Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# 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 MER-
+# CHANTABILITY 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.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# python imports
+import weakref
+
+# kaa notifier for the socket callback
+import kaa.notifier
+from kaa.notifier import Signal
+
+# the display module
+import _X11
+
+# default X11 display
+_default_x11_display = None
+
+_keysym_names = {
+    338: "up",
+    340: "down",
+    337: "left",
+    339: "right",
+
+    446: "F1",
+    447: "F2",
+    448: "F3",
+    449: "F4",
+    450: "F5",
+    451: "F6",
+    452: "F7",
+    453: "F8",
+    454: "F9",
+    455: "F10",
+    456: "F11",
+    457: "F21",
+
+    355: "ins",
+    511: "del",
+    336: "home",
+    343: "end",
+    283: "esc",
+    269: "enter",
+    264: "backspace",
+    32: "space",
+
+    489: "left-alt",
+    490: "right-alt",
+    483: "left-ctrl",
+    484: "right-ctrl",
+    481: "left-shift",
+    482: "right-shift",
+    359: "menu",
+    275: "pause",
+
+    # keypad
+    427: "kp_plus",
+    429: "kp_minus"
+}
+ 
+class X11Display(object):
+
+    XEVENT_MOTION_NOTIFY = 6
+    XEVENT_EXPOSE = 12
+    XEVENT_BUTTON_PRESS = 4
+    XEVENT_KEY_PRESS = 2
+    XEVENT_FOCUS_IN = 9
+    XEVENT_FOCUS_OUT = 10
+    XEVENT_EXPOSE = 12
+    XEVENT_UNMAP_NOTIFY = 18
+    XEVENT_MAP_NOTIFY = 19
+    XEVENT_CONFIGURE_NOTIFY = 22
+    
+    #XEVENT_WINDOW_EVENTS = (6, 12, 4, 2, 22, 18, 19)
+
+    def __init__(self, dispname = ""):
+        self._display = _X11.X11Display(dispname)
+        self._windows = {}
+
+        dispatcher = kaa.notifier.WeakSocketDispatcher(self.handle_events)
+        dispatcher.register(self.socket)
+        # Also connect to the idle signal. It is a bad hack, but when
+        # drawing is done, the socket is read and we will miss keypress
+        # events when doing drawings.
+        kaa.notifier.signals['idle'].connect_weak(self.handle_events)
+
+    def handle_events(self):
+        window_events = {}
+        for event, data in self._display.handle_events():
+            wid = 0
+            if event in X11Display.XEVENT_WINDOW_EVENTS:
+                wid = data["window"]
+            if wid:
+                if wid not in window_events:
+                    window_events[wid] = []
+                if event == X11Display.XEVENT_CONFIGURE_NOTIFY:
+                    # Remove any existing configure events in the list (only
+                    # the last one applies)
+                    window_events[wid] = [ x for x in window_events[wid] if 
x[0] != 
+                                           X11Display.XEVENT_CONFIGURE_NOTIFY ]
+                window_events[wid].append((event, data))
+
+        for wid, events in window_events.items():
+            assert(wid in self._windows)
+            window = self._windows[wid]()
+            if not window:
+                # Window no longer exists.
+                del self._windows[wid]
+            else:
+                window.handle_events(events)
+
+        # call the socket again
+        return True
+    
+
+    def __getattr__(self, attr):
+        if attr in ("socket,"):
+            return getattr(self._display, attr)
+
+        return getattr(super(X11Display, self), attr)
+
+    def sync(self):
+        return self._display.sync()
+
+    def lock(self):
+        return self._display.lock()
+
+    def unlock(self):
+        return self._display.unlock()
+
+    def get_size(self, screen = -1):
+        return self._display.get_size(screen)
+
+    def get_string(self):
+        return self._display.get_string()
+
+    def glx_supported(self):
+        return self._display.glx_supported()
+
+
+
+X11Display.XEVENT_WINDOW_EVENTS_LIST = filter(lambda x: x.find("XEVENT_") != 
-1, dir(X11Display))
+X11Display.XEVENT_WINDOW_EVENTS = map(lambda x: getattr(X11Display, x), 
X11Display.XEVENT_WINDOW_EVENTS_LIST)
+
+def _get_display(display):
+    if not display:
+        global _default_x11_display
+        if not _default_x11_display:
+            _default_x11_display = X11Display()
+        display = _default_x11_display
+
+    assert(type(display) == X11Display)
+    return display
+
+
+
+class X11Window(object):
+    def __init__(self, display = None, window = None, **kwargs):
+        display = _get_display(display)
+        if window:
+            self._window = window
+        else:
+            assert("size" in kwargs)
+            if "title" in kwargs:
+                assert(type(kwargs["title"]) == str)
+            if "parent" in kwargs:
+                assert(isinstance(kwargs["parent"], X11Window))
+                kwargs["parent"] = kwargs["parent"]._window
+
+            self._window = _X11.X11Window(display._display, kwargs["size"], 
**kwargs)
+
+        self._display = display
+        display._windows[self._window.ptr] = weakref.ref(self)
+        self._cursor_hide_timeout = -1
+        self._cursor_hide_timer = 
kaa.notifier.WeakOneShotTimer(self._cursor_hide_cb)
+        self._cursor_visible = True
+        self._fs_size_save = None
+        self._last_configured_size = 0, 0
+
+        self.signals = {
+            "key_press_event": Signal(),
+            "focus_in_event": Signal(),
+            "focus_out_event": Signal(),
+            "expose_event": Signal(),
+            "map_event": Signal(),
+            "unmap_event": Signal(),
+            "resize_event": Signal(),
+            "configure_event": Signal(),
+        }
+        
+    def get_display(self):
+        return self._display
+
+    def raise_window(self):
+        self._window.raise_window()
+        self._display.handle_events()
+
+    def lower_window(self):
+        self._window.lower_window()
+        self._display.handle_events()
+
+    def show(self, raised = False):
+        self._window.show(raised)
+        self._display.handle_events()
+
+    def hide(self):
+        self._window.hide()
+        self._display.handle_events()
+
+    def set_visible(self, visible = True):
+        if visible:
+            self.show()
+        else:
+            self.hide()
+
+    def get_visible(self):
+        return self._window.get_visible()
+
+    def render_imlib2_image(self, i, dst_pos = (0, 0), src_pos = (0, 0),
+                            size = (-1, -1), dither = True, blend = False):
+        return _X11.render_imlib2_image(self._window, i._image, dst_pos, \
+                                            src_pos, size, dither, blend)
+
+    def handle_events(self, events):
+        expose_regions = []
+        for event, data in events:
+            if event == X11Display.XEVENT_MOTION_NOTIFY:
+                # Mouse moved, so show cursor.
+                if self._cursor_hide_timeout != 0 and not self._cursor_visible:
+                    self.set_cursor_visible(True)
+
+                self._cursor_hide_timer.start(self._cursor_hide_timeout)
+
+            elif event == X11Display.XEVENT_KEY_PRESS:
+                key = data["key"]
+                if key in _keysym_names:
+                    key = _keysym_names[key]
+                elif key < 255:
+                    key = chr(key)
+                self.signals["key_press_event"].emit(key)
+
+            elif event == X11Display.XEVENT_EXPOSE:
+                # Queue expose regions so we only need to emit one signal.
+                expose_regions.append((data["pos"], data["size"]))
+
+            elif event == X11Display.XEVENT_MAP_NOTIFY:
+                self.signals["map_event"].emit()
+
+            elif event == X11Display.XEVENT_UNMAP_NOTIFY:
+                self.signals["unmap_event"].emit()
+
+            elif event == X11Display.XEVENT_CONFIGURE_NOTIFY:
+                cur_size = self.get_size()
+                last_size = self._last_configured_size
+                if last_size != cur_size and last_size != (-1, -1):
+                    # Set this now to prevent reentry.
+                    self._last_configured_size = -1, -1
+                    self.signals["resize_event"].emit(last_size, cur_size)
+                    # Callback could change size again, so save our actual
+                    # size to prevent being called again.
+                    self._last_configured_size = self.get_size()
+                self.signals["configure_event"].emit(data["pos"], data["size"])
+            elif event == X11Display.XEVENT_FOCUS_IN:
+                self.signals["focus_in_event"].emit()
+            elif event == X11Display.XEVENT_FOCUS_OUT:
+                self.signals["focus_out_event"].emit()
+                
+
+        if len(expose_regions) > 0:
+            self.signals["expose_event"].emit(expose_regions)
+                
+
+    def move(self, pos, force = False):
+        return self.set_geometry(pos, (-1, -1))
+
+    def resize(self, size, force = False):
+        return self.set_geometry((-1, -1), size, force)
+
+    def set_geometry(self, pos, size, force = False):
+        if self.get_fullscreen() and not force:
+            self._fs_size_save = size
+            return False
+
+        self._window.set_geometry(pos, size)
+        self._display.handle_events()
+        return True
+
+    def get_geometry(self):
+        return self._window.get_geometry()
+
+    def get_size(self):
+        return self.get_geometry()[1]
+
+    def get_pos(self):
+        return self.get_geometry()[0]
+
+    def set_cursor_visible(self, visible):
+        self._window.set_cursor_visible(visible)
+        self._cursor_visible = visible
+        self._display.handle_events()
+
+    def _cursor_hide_cb(self):
+        self.set_cursor_visible(False)
+
+    def set_cursor_hide_timeout(self, timeout):
+        self._cursor_hide_timeout = timeout
+        self._cursor_hide_timer.start(self._cursor_hide_timeout)
+
+    def set_fullscreen(self, fs = True):
+        if not fs:
+            if self._fs_size_save:
+                self.resize(self._fs_size_save, force = True)
+                self._window.set_fullscreen(False)
+                self._fs_size_save = None
+                return True
+
+            return False
+
+        if self._fs_size_save:
+            return False
+
+        self._fs_size_save = self.get_size()
+        display_size = self.get_display().get_size()
+        self._window.set_fullscreen(True)
+        self.resize(display_size, force = True)
+
+    def get_fullscreen(self):
+        return self._fs_size_save != None
+     
+    def get_id(self):
+        return self._window.ptr
+
+    def focus(self):
+        return self._window.focus()
+
+
+class EvasX11Window(X11Window):
+    def __init__(self, gl = False, display = None, size = (640, 480), 
+                 title = "Evas", **kwargs):
+        import kaa.evas
+
+        if not gl:
+            f = _X11.new_evas_software_x11
+        else:
+            f = _X11.new_evas_gl_x11
+
+        if "parent" in kwargs:
+            assert(isinstance(kwargs["parent"], X11Window))
+            kwargs["parent"] = kwargs["parent"]._window
+
+        assert(type(size) == tuple)
+        display = _get_display(display)
+        self._evas = kaa.evas.Evas()
+        window = f(self._evas._evas, display._display, size = size,
+                   title = title, **kwargs)
+        self._evas.output_size_set(size)
+        self._evas.viewport_set((0, 0), size)
+
+        # Ensures the display remains alive until after Evas gets deallocated
+        # during garbage collection.  
+        self._evas._dependencies.append(display._display)
+        self._evas._dependencies.append(window)
+        if "parent" in kwargs:
+            self._evas._dependencies.append(kwargs["parent"])
+        super(EvasX11Window, self).__init__(display, window)
+
+
+    def handle_events(self, events):
+        needs_render = False
+        for event, data in events:
+            if event == X11Display.XEVENT_EXPOSE:
+                self._evas.damage_rectangle_add((data["pos"], data["size"]))
+                needs_render = True
+            #elif event == X11Display.XEVENT_CONFIGURE_NOTIFY:
+            #    if data["size"] != self._evas.output_size_get():
+            #        # This doesn't act right for gl.
+            #        self._evas.output_size_set(data["size"])
+            #        #self._evas.viewport_set((0, 0), data["size"])
+            #        needs_render = True
+
+        super(EvasX11Window, self).handle_events(events)
+
+        if needs_render:
+            self._evas.render()
+            self._display.handle_events()
+
+
+    def get_evas(self):
+        return self._evas

Modified: trunk/display/src/x11display.c
==============================================================================
--- trunk/display/src/x11display.c      (original)
+++ trunk/display/src/x11display.c      Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/x11display.h
==============================================================================
--- trunk/display/src/x11display.h      (original)
+++ trunk/display/src/x11display.h      Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/x11window.c
==============================================================================
--- trunk/display/src/x11window.c       (original)
+++ trunk/display/src/x11window.c       Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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

Modified: trunk/display/src/x11window.h
==============================================================================
--- trunk/display/src/x11window.h       (original)
+++ trunk/display/src/x11window.h       Fri Mar 10 13:22:32 2006
@@ -5,13 +5,13 @@
  * $Id$
  *
  * ----------------------------------------------------------------------------
- * kaa-display - X11/SDL Display module
+ * kaa-display - Generic Display Module
  * Copyright (C) 2005 Dirk Meyer, Jason Tackaberry
  *
  * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
  * Maintainer:    Jason Tackaberry <[EMAIL PROTECTED]>
  *
- * Please see the file doc/CREDITS for a complete list of authors.
+ * Please see the file AUTHORS for a complete list of authors.
  *
  * 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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to