summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManiraj Devadoss <Maniraj.Devadoss@in.bosch.com>2018-01-23 10:47:08 +0530
committerRajendraprasad K J <KarammelJayakumar.Rajendraprasad@in.bosch.com>2019-04-30 06:51:48 -0400
commit24a34b2b3241cb60567934e97d6319b38f2da38f (patch)
tree1c485ef1edbac15c4252c3171dfc4a4b0645713d
parent926787f53515ab1f58f25cb942439644f21b910c (diff)
downloadwayland-ivi-extension-24a34b2b3241cb60567934e97d6319b38f2da38f.tar.gz
simple-weston-client: enable debug-proto based on pkgconfig
Based on the libweston-2-protocols pkgconfig file availability, decide whether to have the debug-protocol support or not. Conflicts: ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c Changes to be committed: modified: ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt modified: ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c Cherry-picked the commit 3ad4523f8edcee4326cb8ad51a6b51bb9dae3159 (manirajd:weston_debug_support_v1) to GENIVI:master. Resolved the merge conflict present in ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c. Signed-off-by: Rajendraprasad K J <KarammelJayakumar.Rajendraprasad@in.bosch.com>
-rw-r--r--ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt4
-rw-r--r--ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c61
2 files changed, 48 insertions, 17 deletions
diff --git a/ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt b/ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt
index 45c8ca2..8264d3a 100644
--- a/ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt
+++ b/ivi-layermanagement-examples/simple-weston-client/CMakeLists.txt
@@ -118,6 +118,10 @@ add_dependencies(${PROJECT_NAME} ${LIBS})
add_definitions(${DLT_CFLAGS})
+if(${LIBWESTON_PROTOCOLS_FOUND})
+ add_definitions(-DLIBWESTON_DEBUG_PROTOCOL)
+endif(${LIBWESTON_PROTOCOLS_FOUND})
+
target_link_libraries(${PROJECT_NAME} ${LIBS})
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
diff --git a/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c b/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
index 66a1f99..9588361 100644
--- a/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
+++ b/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
@@ -32,14 +32,23 @@
#include <signal.h>
#include <poll.h>
-#include "dlt_common.h"
-#include "dlt_user.h"
-
#include <wayland-cursor.h>
#include <ivi-application-client-protocol.h>
+#ifdef LIBWESTON_DEBUG_PROTOCOL
+#include "dlt_common.h"
+#include "dlt_user.h"
#include "weston-debug-client-protocol.h"
+#define WESTON_DLT_APP_DESC "messages from weston debug protocol"
+#define WESTON_DLT_CONTEXT_DESC "weston debug context"
+
+#define WESTON_DLT_APP "WESN"
+#define WESTON_DLT_CONTEXT "WESC"
+
+#define MAXSTRLEN 1024
+#endif
+
#ifndef MIN
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#endif
@@ -60,7 +69,6 @@ typedef struct _WaylandContext {
struct wl_compositor *wl_compositor;
struct wl_shm *wl_shm;
struct wl_seat *wl_seat;
- struct weston_debug_v1 *debug_iface;
struct wl_pointer *wl_pointer;
struct wl_surface *wl_pointer_surface;
struct ivi_application *ivi_application;
@@ -72,11 +80,14 @@ typedef struct _WaylandContext {
struct wl_cursor *cursor;
void *bkgnddata;
uint32_t formats;
+#ifdef LIBWESTON_DEBUG_PROTOCOL
+ struct weston_debug_v1 *debug_iface;
struct wl_list stream_list;
int debug_fd;
char thread_running;
pthread_t dlt_ctx_thread;
int pipefd[2];
+#endif
}WaylandContextStruct;
struct debug_stream {
@@ -92,14 +103,6 @@ static const char *left_ptrs[] = {
"left-arrow"
};
-#define WESTON_DLT_APP_DESC "messages from weston debug protocol"
-#define WESTON_DLT_CONTEXT_DESC "weston debug context"
-
-#define WESTON_DLT_APP "WESN"
-#define WESTON_DLT_CONTEXT "WESC"
-
-#define MAXSTRLEN 1024
-
static BkGndSettingsStruct*
get_bkgnd_settings(void)
{
@@ -123,6 +126,7 @@ get_bkgnd_settings(void)
return bkgnd_settings;
}
+#ifdef LIBWESTON_DEBUG_PROTOCOL
static struct debug_stream *
stream_alloc(WaylandContextStruct* wlcontext, const char *name)
{
@@ -228,6 +232,7 @@ get_debug_streams(WaylandContextStruct* wlcontext)
stream = strtok(NULL, separator);
}
}
+#endif
static void
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
@@ -440,7 +445,8 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t name,
wl_registry_bind(registry, name, &wl_seat_interface, 1);
wl_seat_add_listener(wlcontext->wl_seat, &seat_Listener, data);
}
- if (!strcmp(interface, weston_debug_v1_interface.name)) {
+#ifdef LIBWESTON_DEBUG_PROTOCOL
+ else if (!strcmp(interface, weston_debug_v1_interface.name)) {
uint32_t myver;
if (wlcontext->debug_iface || wl_list_empty(&wlcontext->stream_list))
@@ -451,6 +457,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t name,
wl_registry_bind(registry, name,
&weston_debug_v1_interface, myver);
}
+#endif
}
static void
@@ -490,6 +497,14 @@ int init_wayland_context(WaylandContextStruct* wlcontext)
return -1;
}
+#ifdef LIBWESTON_DEBUG_PROTOCOL
+ if (!wl_list_empty(&wlcontext->stream_list) &&
+ (wlcontext->debug_iface == NULL)) {
+ fprintf(stderr, "WARNING: weston_debug protocol is not available,"
+ " missed enabling --debug option to weston ?\n");
+ }
+#endif
+
return 0;
}
@@ -501,8 +516,10 @@ void destroy_wayland_context(WaylandContextStruct* wlcontext)
if(wlcontext->wl_display)
wl_display_disconnect(wlcontext->wl_display);
+#ifdef LIBWESTON_DEBUG_PROTOCOL
if(wlcontext->debug_iface)
weston_debug_v1_destroy(wlcontext->debug_iface);
+#endif
}
int
@@ -643,6 +660,7 @@ void destroy_bkgnd_surface(WaylandContextStruct* wlcontext)
wl_surface_destroy(wlcontext->wlBkgndSurface);
}
+#ifdef LIBWESTON_DEBUG_PROTOCOL
static void *
weston_dlt_thread_function(void *data)
{
@@ -685,6 +703,7 @@ weston_dlt_thread_function(void *data)
DLT_UNREGISTER_APP();
pthread_exit(NULL);
}
+#endif
static void
signal_int(int signum)
@@ -773,10 +792,14 @@ int main (int argc, const char * argv[])
wlcontext = (WaylandContextStruct*)calloc(1, sizeof(WaylandContextStruct));
wlcontext->bkgnd_settings = bkgnd_settings;
+#ifdef LIBWESTON_DEBUG_PROTOCOL
/*init debug stream list*/
wl_list_init(&wlcontext->stream_list);
get_debug_streams(wlcontext);
wlcontext->debug_fd = STDOUT_FILENO;
+#else
+ fprintf(stderr, "WARNING: weston_debug protocol is not available\n");
+#endif
if (init_wayland_context(wlcontext)) {
fprintf(stderr, "init_wayland_context failed\n");
@@ -790,6 +813,7 @@ int main (int argc, const char * argv[])
wl_display_roundtrip(wlcontext->wl_display);
+#ifdef LIBWESTON_DEBUG_PROTOCOL
if (!wl_list_empty(&wlcontext->stream_list) &&
wlcontext->debug_iface) {
/* create the pipe b/w stdout and stdin
@@ -805,6 +829,7 @@ int main (int argc, const char * argv[])
weston_dlt_thread_function, wlcontext);
start_streams(wlcontext);
}
+#endif
/*draw the bkgnd display*/
draw_bkgnd_surface(wlcontext);
@@ -813,13 +838,10 @@ int main (int argc, const char * argv[])
ret = display_dispatch(wlcontext->wl_display);
Error:
+#ifdef LIBWESTON_DEBUG_PROTOCOL
destroy_streams(wlcontext);
wl_display_roundtrip(wlcontext->wl_display);
- destroy_bkgnd_surface(wlcontext);
-ErrorContext:
- destroy_wayland_context(wlcontext);
-
if(wlcontext->thread_running)
{
close(wlcontext->pipefd[1]);
@@ -828,6 +850,11 @@ ErrorContext:
pthread_join(wlcontext->dlt_ctx_thread, NULL);
close(wlcontext->pipefd[0]);
}
+#endif
+
+ destroy_bkgnd_surface(wlcontext);
+ErrorContext:
+ destroy_wayland_context(wlcontext);
free(bkgnd_settings);
free(wlcontext);