xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2466: gtkglarea.patch

File gtkglarea.patch, 4.3 KB (added by Antoine Martin, 18 months ago)

try to use Gtk.GLArea

  • xpra/client/gl/gtk3/gtkgl_client_window.py

     
     1# This file is part of Xpra.
     2# Copyright (C) 2017 Antoine Martin <antoine@xpra.org>
     3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
     4# later version. See the file COPYING for details.
     5
     6from gi.repository import Gtk, Gdk, GObject               #@UnresolvedImport @UnusedImport
     7
     8from xpra.os_util import DummyContextManager
     9from xpra.client.gl.gtk3.gl_client_window import GLClientWindowBase, log
     10from xpra.client.gl.gl_window_backing_base import GLWindowBackingBase
     11
     12
     13def check_support(force_enable=False):
     14    return {"safe" : True}
     15
     16
     17class GLDrawingArea(GLWindowBackingBase):
     18
     19    def init_gl_config(self, window_alpha):
     20        pass
     21
     22    def init_backing(self):
     23        da = Gtk.GLArea()
     24        #da.connect('configure_event', self.on_configure_event)
     25        #da.connect('draw', self.on_draw)                   
     26        #double-buffering is enabled by default anyway, so this is redundant:
     27        #da.set_double_buffered(True)
     28        da.set_size_request(*self.size)
     29        da.set_events(da.get_events() | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.EXPOSURE_MASK)
     30        da.connect("render", self._render)
     31        def realized(*args):
     32            log.warn("realize%s", args)
     33            with self.gl_context():
     34                self.gl_init()
     35        da.connect("realize", realized)
     36        da.realize()
     37        self._backing = da
     38
     39    def _render(self, area, context):
     40        log.warn("_render(%s, %s)", area, context)
     41        context.make_current()
     42        self.gl_init()
     43        super().do_present_fbo()
     44        return True
     45
     46    def is_double_buffered(self):
     47        return True
     48
     49    def do_gl_show(self, rect_count):
     50        #with self.gl_context() as c:
     51        #    c.swap()
     52        if self.is_double_buffered():
     53            # Show the backbuffer on screen
     54            log("%s.do_gl_show(%s) swapping buffers now", rect_count, self)
     55            #self.window_context.swap_buffers()
     56        else:
     57            #glFlush was enough
     58            pass
     59
     60    def gl_context(self):
     61        #import traceback
     62        #traceback.print_stack()
     63        d = DummyContextManager()
     64        d.context = self._backing.get_context()
     65        d.context.make_current()
     66        return d
     67
     68
     69class GLClientWindow(GLClientWindowBase):
     70    __gsignals__ = GLClientWindowBase.__common_gsignals__
     71
     72    def get_backing_class(self):
     73        return GLDrawingArea
     74
     75    def drawing_area_draw(self, widget, context):
     76        pass
     77
     78    def queue_draw_area(self, x, y, w, h):
     79        pass
     80
     81GObject.type_register(GLClientWindow)
  • xpra/client/gl/window_backend.py

     
    1414def get_gl_client_window_module(force_enable=False):
    1515    log("get_gl_client_window_module()")
    1616    try:
    17         from xpra.client.gl.gtk3 import nativegl_client_window
     17        from xpra.client.gl.gtk3 import gtkgl_client_window
    1818    except ImportError as e:
    1919        log("cannot import opengl window module", exc_info=True)
    2020        log.warn("Warning: cannot import native OpenGL module")
    2121        log.warn(" %s", e)
    2222        return {}, None
    23     opengl_props = nativegl_client_window.check_support(force_enable)
     23    opengl_props = gtkgl_client_window.check_support(force_enable)
    2424    log("check_support(%s)=%s", force_enable, opengl_props)
    2525    if opengl_props:
    26         return opengl_props, nativegl_client_window
     26        return opengl_props, gtkgl_client_window
    2727    return {}, None
    2828
    2929def noop(*_args):
     
    128128            from gi.repository import Gtk, GLib
    129129            def window_close_event(*_args):
    130130                Gtk.main_quit()
     131            def start_draw():
     132                GLib.timeout_add(REPAINT_DELAY, draw)
     133            window.when_realized("start-draw", start_draw)
    131134            noclient.window_close_event = window_close_event
    132             GLib.timeout_add(REPAINT_DELAY, draw)
    133135            Gtk.main()
    134136        else:
    135137            draw()