Add support for Xnest
This commit is contained in:
parent
ed303285a8
commit
5ec089b829
@ -1,16 +1,11 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
from Process import Process
|
from Process import Process
|
||||||
|
|
||||||
class XephyrProcess(Process):
|
def get_display_number():
|
||||||
def __init__(self):
|
|
||||||
self._display = self.get_display_number()
|
|
||||||
cmd = 'Xephyr :%d -ac -screen 640x480' % (self._display)
|
|
||||||
Process.__init__(self, cmd)
|
|
||||||
|
|
||||||
def get_display_number(self):
|
|
||||||
"""Find a free display number trying to connect to 6000+ ports"""
|
"""Find a free display number trying to connect to 6000+ ports"""
|
||||||
retries = 20
|
retries = 20
|
||||||
display_number = 1
|
display_number = 1
|
||||||
@ -30,16 +25,33 @@ class XephyrProcess(Process):
|
|||||||
|
|
||||||
if display_is_free:
|
if display_is_free:
|
||||||
return display_number
|
return display_number
|
||||||
|
else:
|
||||||
|
logging.error('Cannot find a free display.')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
return -1
|
class XephyrProcess(Process):
|
||||||
|
def __init__(self):
|
||||||
|
self._display = get_display_number()
|
||||||
|
cmd = 'Xephyr :%d -ac -screen 640x480' % (self._display)
|
||||||
|
Process.__init__(self, cmd)
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return 'Xephyr'
|
return 'Xephyr'
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self._display < 0:
|
Process.start(self)
|
||||||
logging.error('Cannot find a free display.')
|
os.environ['DISPLAY'] = ":%d" % (self._display)
|
||||||
else:
|
|
||||||
|
class XnestProcess(Process):
|
||||||
|
def __init__(self):
|
||||||
|
self._display = get_display_number()
|
||||||
|
cmd = 'Xnest :%d -geometry 640x480' % (self._display)
|
||||||
|
Process.__init__(self, cmd)
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return 'Xnest'
|
||||||
|
|
||||||
|
def start(self):
|
||||||
Process.start(self)
|
Process.start(self)
|
||||||
os.environ['DISPLAY'] = ":%d" % (self._display)
|
os.environ['DISPLAY'] = ":%d" % (self._display)
|
||||||
|
|
||||||
@ -50,5 +62,13 @@ class Emulator:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
try:
|
||||||
process = XephyrProcess()
|
process = XephyrProcess()
|
||||||
process.start()
|
process.start()
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
process = XnestProcess()
|
||||||
|
process.start()
|
||||||
|
except:
|
||||||
|
logging.error('Cannot run the emulator. You need to install Xephyr or Xnest.')
|
||||||
|
sys.exit(0)
|
||||||
|
@ -3,6 +3,7 @@ bin_SCRIPTS = sugar sugar-activity
|
|||||||
sugardir = $(pkgdatadir)/shell
|
sugardir = $(pkgdatadir)/shell
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
|
ActivitiesModel.py \
|
||||||
ActivityRegistry.py \
|
ActivityRegistry.py \
|
||||||
ConsoleLogger.py \
|
ConsoleLogger.py \
|
||||||
Emulator.py \
|
Emulator.py \
|
||||||
|
Loading…
Reference in New Issue
Block a user