Constants and Function definitions for a simple window manager.
/*
* $QNXLicenseC:
* Copyright 2012, QNX Software Systems Limited. All Rights Reserved.
*
* This software is QNX Confidential Information subject to
* confidentiality restrictions. DISCLOSURE OF THIS SOFTWARE
* IS PROHIBITED UNLESS AUTHORIZED BY QNX SOFTWARE SYSTEMS IN
* WRITING.
*
* You must obtain a written license from and pay applicable license
* fees to QNX Software Systems Limited before you may reproduce, modify
* or distribute this software, or any work that includes all or part
* of this software. For more information visit
* http://licensing.qnx.com or email licensing@qnx.com.
*
* This file may contain contributions from others. Please review
* this entire file for other proprietary rights or license notices,
* as well as the QNX Development Suite License Guide at
* http://licensing.qnx.com/license-guide/ for other information.
* $
*/
#ifndef STRUCT_H_
#define STRUCT_H_
#include <errno.h>
#include <ctype.h> /* Header file for isdigit */
#include <stdio.h> /* Header file for fprintf */
#include <stdlib.h> /* Header file for EXIT_FAILURE, EXIT_SUCCESS, atoi */
#include <string.h> /* Header file for strncmp */
#include <sys/keycodes.h> /* Header file for KEYCODE_ESCAPE */
#include <time.h> /* Header file for clock_gettime, timespec2nsec */
#include <screen/screen.h> /* Header file for all screen API calls */
#include <pthread.h>
#include <fcntl.h>
#include <sys/pps.h>
#include <sys/slog.h>
#include <sys/slogcodes.h>
#define WINMGR_SLOG_CODE _SLOG_SETCODE(_SLOGC_TEST,104)
#define SLOG_WARNING(...) slogf(WINMGR_SLOG_CODE,_SLOG_WARNING, __VA_ARGS__)
#define SLOG_ERROR(...) slogf(WINMGR_SLOG_CODE,_SLOG_ERROR, __VA_ARGS__)
#define SLOG_NOTICE(...) slogf(WINMGR_SLOG_CODE,_SLOG_NOTICE, __VA_ARGS__)
#define KILO(n) ((n)*1024)
#define MEG(n) ((n)*1024*1024)
#define MAX_REQSIZE KILO(32)
#define MAX_RESSIZE KILO(1)
#define MAX_ATTRS KILO(1)
// launcher commands
#define CMD_START "start"
#define CMD_DEBUG "debug"
#define CMD_STOP "stop"
#define CMD_FREEZE "freeze"
#define CMD_THAW "thaw"
#define CMD_LOWMEM "lowmem"
#define CMD_STOPPED "stopped"
#define CMD_ACTIVE "active"
#define CMD_QUERY "query"
#define CMD_HIDE "hide"
enum {
WINMGR_UPDATE = (1 << 0),
WINMGR_TERMINATE = (1 << 1),
};
typedef enum {
PPS_EVENT_OBJECT_UNKNOWN = 0x00,
PPS_EVENT_OBJECT_CHANGED = 0x01,
PPS_EVENT_OBJECT_CREATED = 0x02,
PPS_EVENT_OBJECT_DELETED = 0x04,
PPS_EVENT_ALL = 0x7,
PPS_FLAG_CREDENTIALS = 1 << 15
} pps_event_type;
typedef struct {
char *id;
char *pid;
char *data;
} app_t;
typedef struct
{
char *name;
char *encoding;
char *value;
} pps_attr_t;
typedef struct {
int state;
int pps_fd;
app_t car_app;
app_t weather_app;
int verbose;
int background;
// pps related
int numattrs;
char *objname;
pps_event_type ptype;
pps_attr_t attrs[MAX_ATTRS];
int pps_tid;
// screen related
screen_context_t screen_ctx; /* connection to screen windowing system */
screen_window_t screen_win; /* native handle for our window */
screen_event_t screen_ev; /* handle used to pop events from our queue */
int screen_tid;
} window_manager_t;
// pps.c
extern void* pps_thread(void* arg);
int pps_write(int pps_fd, const char *msgbuf, int msgsize);
int pps_is_open(int pps_fd);
char * pps_lookup(window_manager_t *winmgr, char *name);
pps_attr_t* pps_lookup_attr(window_manager_t *winmgr, char *name);
// launcher.c
int launcher_pps(window_manager_t *winmgr);
void launcher_send(window_manager_t *winmgr,
char *cmd,
char *data,
char *id);
// core.c
void core_app_started(window_manager_t *winmgr,
char *id,
char *data,
int error,
char *errstr);
void core_app_stopped(window_manager_t *winmgr, char *data);
void core_lowmem(window_manager_t *winmgr, char *data);
// screen.c
int screen_init(window_manager_t *winmgr, int argc, char **argv);
void *screen_thread(void *arg);
#endif /* STRUCT_H_ */