[Gambas-user] [Gambas Bug Tracker] Bug #1082: Desktop.Windows[0].FullScreen Fails with Error Void key

bugtracker at ...3416... bugtracker at ...3416...
Fri Feb 17 18:08:54 CET 2017


http://gambaswiki.org/bugtracker/edit?object=BUG.1082&from=L21haW4-

Tony MOREHEN reported a new bug.

Summary
-------

Desktop.Windows[0].FullScreen Fails with Error Void key

Type             : Bug
Priority         : Medium
Gambas version   : 3.9.90 (TRUNK)
Product          : Unknown


Description
-----------

Desktop.Windows[0].FullScreen=true fails with error Void key

Cause:

Fullscreen is a property in DesktopWindows.class

in Desktop.Windows.class, the function FullScreen_Write calls:

SetState("_NET_WM_STATE_FULLSCREEN")

This means that the X11 SendClientMessage function is called with State2 defaulting to an empty string.

Private Sub SetState(State As String, Optional State2 As String)
  
  X11.SendClientMessageToRootWindow(Atom["_NET_WM_STATE"], [1, Atom[State], Atom[State2], 2], $iId)
  
End

In Atom.class, this causes a void key failure at $cAtom[sAtom] = iAtom

' Gambas class file

Static Private $cAtom As New Collection

Static Public Sub _get(sAtom As String) As Integer
  
  Dim iAtom As Integer
  
  Try iAtom = $cAtom[sAtom]
  If Error Then
    iAtom = X11.InternAtom(sAtom, True)
    $cAtom[sAtom] = iAtom
  Endif
  Return iAtom
  
End

Solution 1:

The X11 documentation for the _NET_WM_STATE message says that if there is no State2, Atom(State2) should be set to zero.  SetState could be written as:

Private Sub SetState(State As String, Optional State2 As String)
  
  if IsMissing(State2) then
    X11.SendClientMessageToRootWindow(Atom["_NET_WM_STATE"], [1, Atom[State], 0, 2], $iId)
  Else
    X11.SendClientMessageToRootWindow(Atom["_NET_WM_STATE"], [1, Atom[State], Atom[State2], 2], $iId)
  Endif
End

or:

Private Sub SetState(State As String, Optional State2 As String)
  
  if State2 = "" then
    X11.SendClientMessageToRootWindow(Atom["_NET_WM_STATE"], [1, Atom[State], 0, 2], $iId)
  Else
    X11.SendClientMessageToRootWindow(Atom["_NET_WM_STATE"], [1, Atom[State], Atom[State2], 2], $iId)
  Endif
End

Solution 2:

A more general solution is to have Atom check for a empty Atom name string and return 0 when found.


' Gambas class file

Static Private $cAtom As New Collection

Static Public Sub _get(sAtom As String) As Integer
  
  Dim iAtom As Integer
  
if sAtom = "" then return 0
  Try iAtom = $cAtom[sAtom]
  If Error Then
    iAtom = X11.InternAtom(sAtom, True)
    $cAtom[sAtom] = iAtom
  Endif
  Return iAtom
  
End

This is the approach I am currently using but, of course, I cannot know the implication of the change to Atom for all uses, just the ones in my program.


System information
------------------

[System]
Gambas=3.9.90 r8018
OperatingSystem=Linux
Kernel=4.8.15-1-MANJARO
Architecture=x86_64
Distribution=Manjaro Linux
Desktop=XFCE
Theme=Gtk
Language=en_CA.utf8
Memory=3947M

[Libraries]
Cairo=libcairo.so.2.11400.8
Curl=libcurl.so.4.4.0
DBus=libdbus-1.so.3.14.9
GStreamer=libgstreamer-0.10.so.0.30.0
GStreamer=libgstreamer-1.0.so.0.1002.0
GTK+2=libgtk-x11-2.0.so.0.2400.31
GTK+3=libgtk-3.so.0.2200.5
OpenGL=libGL.so.1.2.0
Poppler=libpoppler.so.66.0.0
QT4=libQtCore.so.4.8.7
QT5=libQt5Core.so.5.7.1
SDL=libSDL-1.2.so.0.11.4
SQLite=libsqlite3.so.0.8.6

[Environment]
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=xfce
DISPLAY=:0.0
GB_GUI=gb.qt4
GDMSESSION=xfce
GLADE_CATALOG_PATH=:
GLADE_MODULE_PATH=:
GLADE_PIXMAP_PATH=:
GTK2_RC_FILES=<home>/.gtkrc-2.0
GTK_MODULES=canberra-gtk-module
HOME=<home>
LANG=en_CA.utf8
LC_ADDRESS=en_CA.UTF-8
LC_IDENTIFICATION=en_CA.UTF-8
LC_MEASUREMENT=en_CA.UTF-8
LC_MONETARY=en_CA.UTF-8
LC_NAME=en_CA.UTF-8
LC_NUMERIC=en_CA.UTF-8
LC_PAPER=en_CA.UTF-8
LC_TELEPHONE=en_CA.UTF-8
LC_TIME=en_CA.UTF-8
LOGNAME=<user>
MAIL=/var/spool/mail/<user>
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
PWD=<home>
QT_QPA_PLATFORMTHEME=qt5ct
SAL_USE_VCLPLUGIN=gtk
SESSION_MANAGER=local/<hostname>:@/tmp/.ICE-unix/9931,unix/<hostname>:/tmp/.ICE-unix/9931
SHELL=/bin/bash
SHLVL=2
SSH_AGENT_PID=9936
SSH_AUTH_SOCK=/tmp/ssh-bUdChQqs4Zo0/agent.9935
TZ=:/etc/localtime
USER=<user>
XAUTHORITY=<home>/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg
XDG_CURRENT_DESKTOP=XFCE
XDG_DATA_DIRS=/usr/local/share:/usr/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/<user>
XDG_MENU_PREFIX=xfce-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_DESKTOP=xfce
XDG_SESSION_ID=c4
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
XDG_SESSION_TYPE=x11
XDG_VTNR=7
_=/usr/bin/gambas3






More information about the User mailing list