Ignore:
Timestamp:
04/30/19 14:49:39 (6 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

ACARS CEF works on Windows (re #347)

Location:
src/mlx/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/cef.py

    r944 r945  
    1414import tempfile
    1515import traceback
     16import ctypes
    1617import urllib.request, urllib.error, urllib.parse
    1718from lxml import etree
     
    322323    """Start a browser instance in the given container with the given URL."""
    323324    if os.name=="nt":
    324         window = container.get_window()
    325         if window is None:
    326             print("mlx.gui.cef.startInContainer: no window found!")
    327             windowID = None
    328         else:
    329             windowID = window.handle
     325        gdk.threads_enter()
     326        ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
     327        ctypes.pythonapi.PyCapsule_GetPointer.argtypes = \
     328            [ctypes.py_object]
     329        gpointer = ctypes.pythonapi.PyCapsule_GetPointer(
     330            container.get_property("window").__gpointer__, None)
     331        libgdk = ctypes.CDLL("libgdk-3-0.dll")
     332        windowID = libgdk.gdk_win32_window_get_handle(gpointer)
     333        container.windowID = windowID
     334        gdk.threads_leave()
    330335    else:
    331336        container.set_visual(container.get_screen().lookup_visual(0x21))
     
    427432
    428433def _handleSizeAllocate(widget, sizeAlloc):
    429     """Handle the size-allocate event."""
    430     window = widget.get_window()
     434    """Handle the size-allocate event on Windows."""
    431435    if widget is not None:
    432         cefpython.WindowUtils.OnSize(window.handle, 0, 0, 0)
     436        cefpython.WindowUtils.OnSize(widget.windowID, 0, 0, 0)
  • src/mlx/gui/gui.py

    r931 r945  
    199199
    200200        window.show_all()
    201         if os.name=="nt":
    202             window.get_window().focus()
    203201
    204202        self._wizard.grabDefault()
     
    767765        Here we reset the focus to the main window as CEF might have acquired
    768766        it earlier."""
    769         self._mainWindow.get_window().focus()
     767        self._mainWindow.get_window().focus(0)
    770768
    771769    def raiseCallback(self):
Note: See TracChangeset for help on using the changeset viewer.