Remove all support for single user mode.

This commit is contained in:
Gregory Nutt 2017-10-14 10:13:34 -06:00
parent 64898d7a48
commit f4298e0aa8
8 changed files with 13 additions and 217 deletions

29
Kconfig
View File

@ -8,7 +8,7 @@ menu "NxWidgets/NxWM"
config NXWIDGETS
bool "Enable NxWidgets"
default n
depends on NX && HAVE_CXX
depends on NX && HAVE_CXX && NX_MULTIUSER
---help---
Enable support for NxWidgets
@ -36,23 +36,6 @@ config NXWIDGETS_EXTERNINIT
---help---
Define to support external display initialization.
config NXWIDGETS_DEVNO
int "LCD Device Number"
default 0
depends on (NXWIDGETS_EXTERNINIT || NX_LCDDRIVER) && !NX_MULTIUSER
---help---
LCD device number (in case there are more than one LCDs connected).
Default: 0
config NXWIDGETS_VPLANE
int "Plane Number"
default 0
depends on !NX_LCDDRIVER && !NXWIDGETS_EXTERNINIT && !NX_MULTIUSER
---help---
Only a single video plane is supported. Default: 0
if NX_MULTIUSER
config NXWIDGET_SERVERINIT
bool "Start server"
default y
@ -70,15 +53,13 @@ config NXWIDGETS_CLIENTPRIO
default 100
---help---
The thread that calls CNxServer::connect() will be re-prioritized to
this priority. This applies only if NX is configured in multi-user
mode (NX_MULTIUSER=y). Default: 100
this priority. Default: 100
config NXWIDGETS_LISTENERPRIO
int "NX Listener Priority"
default 100
---help---
Priority of the NX event listener thread. This applies only if NX
is configured in multi-user mode (NX_MULTIUSER=y). Default: 100
Priority of the NX event listener thread. Default: 100
config NXWIDGETS_LISTENERSTACK
int "NX Listener Stack Size"
@ -86,8 +67,6 @@ config NXWIDGETS_LISTENERSTACK
---help---
NX listener thread stack size (in multi-user mode). Default 2048
endif # NX_MULTIUSER
config NXWIDGET_EVENTWAIT
bool "Event Waiting"
default n
@ -294,7 +273,7 @@ endif # NxWidgets
config NXWM
bool "Enable NxWM"
default n
depends on NXWIDGETS && NX_MULTIUSER
depends on NXWIDGETS
---help---
Enable support for the NuttX Tiny Window Manager (NxWM)

View File

@ -207,9 +207,7 @@ namespace NXWidgets
* @param arg2 - User provided argument (see nx_block or nxtk_block)
*/
#ifdef CONFIG_NX_MULTIUSER
static void windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2);
#endif
public:

View File

@ -82,12 +82,10 @@ namespace NXWidgets
private:
FAR NX_DRIVERTYPE *m_hDevice; /**< LCD/Framebuffer device handle */
NXHANDLE m_hNxServer; /**< NX server handle */
#ifdef CONFIG_NX_MULTIUSER
volatile bool m_running; /**< True: The listener thread is running */
volatile bool m_connected; /**< True: Connected to the server */
volatile bool m_stop; /**< True: Waiting for the listener thread to stop */
sem_t m_connsem; /**< Wait for server connection */
#endif
static uint8_t m_nServers; /**< The number of NX server instances */
/**
@ -95,9 +93,7 @@ namespace NXWidgets
* dispatches events from the NX server.
*/
#ifdef CONFIG_NX_MULTIUSER
static FAR void *listener(FAR void *arg);
#endif
public:
@ -147,11 +143,7 @@ namespace NXWidgets
inline bool connected(void)
{
#ifdef CONFIG_NX_MULTIUSER
return m_connected;
#else
return true;
#endif
}
/**

View File

@ -215,10 +215,8 @@ namespace NXWidgets
struct nxgl_size_s m_size; /**< Size of the window */
struct nxgl_point_s m_pos; /**< Position in display space */
struct nxgl_rect_s m_bounds; /**< Size of the display */
#ifdef CONFIG_NX_MULTIUSER
sem_t m_geoSem; /**< Posted when geometry is valid */
sem_t m_boundsSem; /**< Posted when bounds are valid */
#endif
CWindowEventHandlerList m_eventHandlers; /**< List of event handlers. */
/**
@ -312,11 +310,7 @@ namespace NXWidgets
* Take the geometry semaphore (handling signal interruptions)
*/
#ifdef CONFIG_NX_MULTIUSER
void takeGeoSem(void);
#else
inline void takeGeoSem(void) {}
#endif
/**
* Give the geometry semaphore
@ -324,9 +318,7 @@ namespace NXWidgets
inline void giveGeoSem(void)
{
#ifdef CONFIG_NX_MULTIUSER
sem_post(&m_geoSem);
#endif
}
/**
@ -343,11 +335,7 @@ namespace NXWidgets
* Take the bounds semaphore (handling signal interruptions)
*/
#ifdef CONFIG_NX_MULTIUSER
void takeBoundsSem(void);
#else
inline void takeBoundsSem(void) {}
#endif
/**
* Give the bounds semaphore
@ -355,9 +343,7 @@ namespace NXWidgets
inline void giveBoundsSem(void)
{
#ifdef CONFIG_NX_MULTIUSER
sem_post(&m_boundsSem);
#endif
}
/**
@ -660,12 +646,10 @@ namespace NXWidgets
* @param arg - User provided argument (see nx_block or nxtk_block)
*/
#ifdef CONFIG_NX_MULTIUSER
inline void windowBlocked(FAR void *arg)
{
m_eventHandlers.raiseBlockedEvent(arg);
}
#endif
/**
* This event means that cursor control data is available for the window.

View File

@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/nxconfig.hxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -63,22 +63,16 @@
*
* NX Server/Device Configuration
*
* CONFIG_NXWIDGETS_DEVNO - LCD device number (in case there are more than
* one LCDs connected (single user mode only). Default: 0
* CONFIG_NXWIDGETS_VPLANE - Only a single video plane is supported. Default: 0
* CONFIG_NXSTART_SERVERPRIO - Priority of the NX server. This applies
* only if NX is configured in multi-user mode (CONFIG_NX_MULTIUSER=y).
* CONFIG_NXSTART_SERVERPRIO - Priority of the NX server.
* Default: (SCHED_PRIORITY_DEFAULT+10). NOTE: Of the three priority
* definitions here, CONFIG_NXSTART_SERVERPRIO should have the highest
* priority to avoid data overrun race conditions. Such errors would most
* likely appear as duplicated rows of data on the display.
* CONFIG_NXWIDGETS_CLIENTPRIO - The thread that calls CNxServer::connect()
* will be re-prioritized to this priority. This applies only if NX is
* configured in multi-user mode (CONFIG_NX_MULTIUSER=y). Default:
* will be re-prioritized to this priority. Default:
* SCHED_PRIORITY_DEFAULT
* CONFIG_NXWIDGETS_LISTENERPRIO - Priority of the NX event listener thread.
* This applies only if NX is configured in multi-user mode
* (CONFIG_NX_MULTIUSER=y). Default: SCHED_PRIORITY_DEFAULT
* Default: SCHED_PRIORITY_DEFAULT
* CONFIG_NXWIDGETS_EXTERNINIT - Define to support external display
* initialization.
* CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
@ -191,22 +185,6 @@
#endif
/* NX Server/Device Configuration *******************************************/
/**
* LCD device number (in case there are more than one LCDs connected)
*/
#ifndef CONFIG_NXWIDGETS_DEVNO
# define CONFIG_NXWIDGETS_DEVNO 0
#endif
/**
* Only a single video plane is supported
*/
#ifndef CONFIG_NXWIDGETS_VPLANE
# define CONFIG_NXWIDGETS_VPLANE 0
#endif
/**
* Priority of the NX server (in multi-user mode)
*/

View File

@ -246,7 +246,6 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
* @param arg2 - User provided argument (see nx_block or nxtk_block)
*/
#ifdef CONFIG_NX_MULTIUSER
void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2)
{
ginfo("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2);
@ -259,5 +258,4 @@ void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2)
This->m_widgetControl->windowBlocked(arg2);
}
#endif

View File

@ -48,15 +48,12 @@
#include <unistd.h>
#include <cstdlib>
#include <cerrno>
#include <sched.h>
#include <pthread.h>
#include <debug.h>
#include <nuttx/board.h>
#ifdef CONFIG_NX_MULTIUSER
# include <sched.h>
# include <pthread.h>
#endif
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
@ -87,10 +84,8 @@ CNxServer::CNxServer(void)
m_hDevice = (FAR NX_DRIVERTYPE *)NULL; // LCD/Framebuffer device handle
m_hNxServer = (NXHANDLE)NULL; // NX server handle
#ifdef CONFIG_NX_MULTIUSER
m_connected = false; // True: Connected to the server
sem_init(&m_connsem, 0, 0); // Wait for server connection
#endif
// Increment the global count of NX servers. Normally there is only one
// but we don't want to preclude the case where there might be multiple
@ -125,110 +120,9 @@ CNxServer::~CNxServer(void)
}
/**
* Connect to the NX Server -- Single user version
* Connect to the NX Server
*/
#ifndef CONFIG_NX_MULTIUSER
bool CNxServer::connect(void)
{
#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
// Use external graphics driver initialization
printf("nxtext_initialize: Initializing external graphics device\n");
devinfo.devno = CONFIG_NXWIDGETS_DEVNO;
devinfo.dev = NULL;
ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
if (ret < 0)
{
gerr("ERROR: boardctl failed, devno=%d: %d\n", CONFIG_NXWIDGETS_DEVNO, errno);
return false;
}
m_hDevice = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
// Initialize the LCD device
ret = board_lcd_initialize();
if (ret < 0)
{
gerr("ERROR: board_lcd_initialize failed: %d\n", -ret);
return false;
}
// Get the device instance
m_hDevice = board_lcd_getdev(CONFIG_NXWIDGETS_DEVNO);
if (!m_hDevice)
{
gerr("ERROR: board_lcd_getdev failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
return false;
}
// Turn the LCD on at 75% power
(void)m_hDevice->setpower(m_hDevice, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else // CONFIG_NX_LCDDRIVER
int ret;
// Initialize the frame buffer device
// REVISIT: display == 0 is assumed
ret = up_fbinitialize(0);
if (ret < 0)
{
gerr("ERROR: up_fbinitialize failed: %d\n", -ret);
return false;
}
m_hDevice = up_fbgetvplane(0, CONFIG_NXWIDGETS_VPLANE);
if (!m_hDevice)
{
gerr("ERROR: CNxServer::connect: up_fbgetvplane failed, vplane=%d\n",
CONFIG_NXWIDGETS_VPLANE);
return false;
}
#endif // CONFIG_NX_LCDDRIVER
// Then open NX
m_hNxServer = nx_open(m_hDevice);
if (!m_hNxServer)
{
gerr("ERROR: CNxServer::connect: nx_open failed: %d\n", errno);
return false;
}
#ifdef CONFIG_VNCSERVER
// Setup the VNC server to support keyboard/mouse inputs
ret = vnc_default_fbinitialize(0, m_hNxServer);
if (ret < 0)
{
gerr("ERROR: CNxServer::connect: vnc_default_fbinitialize failed: %d\n", ret);
disconnect();
return false;
}
#endif
return true;
}
#endif // CONFIG_NX_MULTIUSER
/**
* Connect to the NX Server -- Multi user version
*/
#ifdef CONFIG_NX_MULTIUSER
bool CNxServer::connect(void)
{
struct sched_param param;
@ -329,30 +223,11 @@ bool CNxServer::connect(void)
return true;
}
#endif // CONFIG_NX_MULTIUSER
/**
* Disconnect to the NX Server -- Single user version
* Disconnect from the NX Server
*/
#ifndef CONFIG_NX_MULTIUSER
void CNxServer::disconnect(void)
{
// Close the server
if (m_hNxServer)
{
nx_close(m_hNxServer);
m_hNxServer = NULL;
}
}
#endif // CONFIG_NX_MULTIUSER
/**
* Disconnect to the NX Server -- Single user version
*/
#ifdef CONFIG_NX_MULTIUSER
void CNxServer::disconnect(void)
{
// Is the listener running?
@ -379,14 +254,12 @@ void CNxServer::disconnect(void)
m_hNxServer = NULL;
}
}
#endif // CONFIG_NX_MULTIUSER
/**
* This is the entry point of a thread that listeners for and dispatches
* events from the NX server.
*/
#ifdef CONFIG_NX_MULTIUSER
FAR void *CNxServer::listener(FAR void *arg)
{
// The argument must be the CNxServer instance
@ -436,4 +309,4 @@ FAR void *CNxServer::listener(FAR void *arg)
sem_post(&This->m_connsem);
return NULL;
}
#endif // CONFIG_NX_MULTIUSER

View File

@ -118,10 +118,8 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
m_waiting = false;
sem_init(&m_waitSem, 0, 0);
#endif
#ifdef CONFIG_NX_MULTIUSER
sem_init(&m_boundsSem, 0, 0);
sem_init(&m_geoSem, 0, 0);
#endif
// Do we need to fetch the default style?
@ -908,7 +906,6 @@ bool CWidgetControl::pollCursorControlEvents(void)
* Take the geometry semaphore (handling signal interruptions)
*/
#ifdef CONFIG_NX_MULTIUSER
void CWidgetControl::takeGeoSem(void)
{
// Take the geometry semaphore. Retry is an error occurs (only if
@ -921,13 +918,11 @@ void CWidgetControl::takeGeoSem(void)
}
while (ret < 0 && errno == EINTR);
}
#endif
/**
* Take the bounds semaphore (handling signal interruptions)
*/
#ifdef CONFIG_NX_MULTIUSER
void CWidgetControl::takeBoundsSem(void)
{
// Take the bounds semaphore. Retry is an error occurs (only if
@ -940,7 +935,6 @@ void CWidgetControl::takeBoundsSem(void)
}
while (ret < 0 && errno == EINTR);
}
#endif
/**
* Clear all mouse events