2008-11-28 15:42:52 +01:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libnx/nxmu/nx_openwindow.c
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2011-07-24 22:49:01 +02:00
|
|
|
#include <nuttx/nx/nx.h>
|
2013-12-27 21:30:13 +01:00
|
|
|
#include <nuttx/nx/nxbe.h>
|
|
|
|
#include <nuttx/nx/nxmu.h>
|
2012-05-14 01:40:23 +02:00
|
|
|
|
2013-12-28 15:40:03 +01:00
|
|
|
#include "nxcontext.h"
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nx_openwindow
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Create a new window.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* handle - The handle returned by nx_connect
|
2019-05-07 16:49:16 +02:00
|
|
|
* flags - Optional flags. These include:
|
|
|
|
* NXBE_WINDOW_RAMBACKED: Creates a RAM backed window. This
|
|
|
|
* option is only valid if CONFIG_NX_RAMBACKED is enabled.
|
|
|
|
* NXBE_WINDOW_HIDDEN: The window is create in the HIDDEN state
|
|
|
|
* and can be made visible later with nx_setvisibility().
|
2013-12-29 15:19:02 +01:00
|
|
|
* cb - Callbacks used to process window events
|
2008-12-01 14:26:23 +01:00
|
|
|
* arg - User provided value that will be returned with NX callbacks.
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2008-11-28 15:42:52 +01:00
|
|
|
* Success: A non-NULL handle used with subsequent NX accesses
|
|
|
|
* Failure: NULL is returned and errno is set appropriately
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-03-13 19:34:13 +01:00
|
|
|
NXWINDOW nx_openwindow(NXHANDLE handle, uint8_t flags,
|
|
|
|
FAR const struct nx_callback_s *cb, FAR void *arg)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
|
|
|
FAR struct nxbe_window_s *wnd;
|
|
|
|
int ret;
|
|
|
|
|
2016-06-11 22:14:08 +02:00
|
|
|
#ifdef CONFIG_DEBUG_FEATURES
|
2019-03-18 16:44:38 +01:00
|
|
|
if (handle == NULL || cb == NULL || (flags & ~NX_WINDOW_USER) != 0)
|
2008-11-29 00:04:54 +01:00
|
|
|
{
|
2013-12-27 21:30:13 +01:00
|
|
|
set_errno(EINVAL);
|
2008-11-29 00:04:54 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-28 15:42:52 +01:00
|
|
|
/* Pre-allocate the window structure */
|
|
|
|
|
2021-02-23 20:23:56 +01:00
|
|
|
wnd = (FAR struct nxbe_window_s *)
|
|
|
|
lib_uzalloc(sizeof(struct nxbe_window_s));
|
2008-11-28 15:42:52 +01:00
|
|
|
if (!wnd)
|
|
|
|
{
|
2013-12-27 21:30:13 +01:00
|
|
|
set_errno(ENOMEM);
|
2008-11-28 15:42:52 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-28 18:33:21 +01:00
|
|
|
/* Then let nx_constructwindow do the rest */
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2019-03-13 19:34:13 +01:00
|
|
|
ret = nx_constructwindow(handle, (NXWINDOW)wnd, flags, cb, arg);
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2008-12-01 14:26:23 +01:00
|
|
|
/* An error occurred, the window has been freed */
|
|
|
|
|
2008-11-28 15:42:52 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the uninitialized window reference. Since the server
|
|
|
|
* serializes all operations, we can be assured that the window will
|
|
|
|
* be initialized before the first operation on the window.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return (NXWINDOW)wnd;
|
|
|
|
}
|