Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #259

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ ${PROG}: $(OBJS) $(ALLDEPS) ${BUILDDIR}/support/dataroot/wd.o
${PROG}.bundle: $(OBJS) $(BUNDLE_OBJS) $(ALLDEPS) ${BUILDDIR}/support/dataroot/bundle.o
$(LINKER) -o $@ $(OBJS) ${BUILDDIR}/support/dataroot/bundle.o $(BUNDLE_OBJS) $(LDFLAGS) ${LDFLAGS_cfg}

${PROG}.sbundle: ${PROG}.bundle $(ALLDEPS)
$(STRIP) -o $@ $<

${PROG}.datadir: $(OBJS) $(ALLDEPS) ${BUILDDIR}/support/dataroot/datadir.o
$(LINKER) -o $@ $(OBJS) ${BUILDDIR}/support/dataroot/datadir.o $(LDFLAGS) ${LDFLAGS_cfg}

Expand Down
68 changes: 0 additions & 68 deletions configure.linux
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ enable libfontconfig
enable libpulse
enable lirc
enable stdin
enable gu
enable avahi
enable libxss
enable libxv
enable openssl
enable locatedb
enable vdpau
Expand Down Expand Up @@ -385,57 +383,6 @@ if enabled libpulse; then
fi


#
# GTK2 UI
#
if enabled gu; then
if pkg-config gtk+-2.0 && pkg-config gthread-2.0; then

if disabled libx11; then
echo "GU depends on libx11"
die
fi

if disabled libxext; then
echo "GU depends on libxext"
die
fi


echo >>${CONFIG_MAK} "LDFLAGS_cfg += " `pkg-config --libs gtk+-2.0`
echo >>${CONFIG_MAK} "CFLAGS_GTK += " `pkg-config --cflags gtk+-2.0`
echo "Using GTK+: `pkg-config --modversion gtk+-2.0`"

echo >>${CONFIG_MAK} "LDFLAGS_cfg += " `pkg-config --libs gthread-2.0`
echo >>${CONFIG_MAK} "CFLAGS_GTK += " `pkg-config --cflags gthread-2.0`
echo "Using GTK Threading: `pkg-config --modversion gthread-2.0`"

else
echo "GTK2 not found. Unable to build GU (GTK user interface)."
echo "To compile without it, configure with: --disable-gu"
die
fi
else
disable libxv
fi

#
# webkit
#
if enabled webkit; then
if pkg-config webkit-1.0; then
echo >>${CONFIG_MAK} "LDFLAGS_cfg += " `pkg-config --libs webkit-1.0`
echo >>${CONFIG_MAK} "CFLAGS_GTK += " `pkg-config --cflags webkit-1.0`
echo "Using WebKit: `pkg-config --modversion webkit-1.0`"
enable webpopup
else
echo "libwebkitgtk development files not found."
echo "To compile without it, configure with: --disable-webkit"
die
fi
fi


#
# libXss (Screen saver control library)
#
Expand Down Expand Up @@ -481,21 +428,6 @@ if enabled libxrandr; then
fi


#
# libxv (Xvideo)
#
if enabled libxv; then
if pkg-config xv; then
echo >>${CONFIG_MAK} "CFLAGS_cfg += " `pkg-config --cflags xv`
echo >>${CONFIG_MAK} "LDFLAGS_cfg += " `pkg-config --libs xv`
echo "Using libXv: `pkg-config --modversion xv`"
else
echo "libXv not found. Unable to build with Xv support."
die
fi
fi


#
# AVAHI
#
Expand Down
7 changes: 1 addition & 6 deletions src/arch/linux/linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ void linux_webpopup_check(void);

void linux_init_monitors(void);

struct prop;

typedef struct linux_ui {
void *(*start)(struct prop *nav);
struct prop *(*stop)(void *ui);
} linux_ui_t;
void glw_x11_main(int *running);
47 changes: 46 additions & 1 deletion src/arch/linux/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SRCS += src/arch/linux/linux_main.c \
src/networking/net_ifaddr.c \
src/fileaccess/fa_opencookie.c \
src/fileaccess/fa_fs.c \
src/prop/prop_glib_courier.c \
src/arch/linux/linux_process_monitor.c \

SRCS += src/htsmsg/persistent_file.c
Expand Down Expand Up @@ -67,3 +66,49 @@ uninstall:

# gtk-update-icon-cache $(prefix)/share/icons/hicolor/

#
#
#

SNAPROOT=$(BUILDDIR)/snaproot

SNAPDEPS = \
$(SNAPROOT)/bin/movian \
$(SNAPROOT)/meta/snap.yaml \
$(SNAPROOT)/meta/gui/movian.desktop \
$(SNAPROOT)/usr/share/movian/icons/movian-128.png \
$(SNAPROOT)/command-movian.wrapper \
$(SNAPROOT)/lib/libXss.so.1 \

$(SNAPROOT)/meta/snap.yaml: support/snap.yaml
@mkdir -p $(dir $@)
sed >$@ -e s/@@VERSION@@/${VERSION}/g -e s/@@APPNAME@@/${APPNAMEUSER}/g -e s/@@VERCODE@@/${NUMVER}/g $<


$(SNAPROOT)/lib/%: /usr/lib/x86_64-linux-gnu/%
@mkdir -p $(dir $@)
cp $< $@

$(SNAPROOT)/bin/movian: $(BUILDDIR)/movian.sbundle
@mkdir -p $(dir $@)
cp $< $@

$(SNAPROOT)/command-movian.wrapper: support/command-movian.wrapper
@mkdir -p $(dir $@)
cp $< $@

$(SNAPROOT)/meta/gui/movian.desktop: support/movian.desktop
@mkdir -p $(dir $@)
cp $< $@

$(SNAPROOT)/usr/share/movian/icons/movian-128.png: support/artwork/movian-128.png
@mkdir -p $(dir $@)
cp $< $@


$(BUILDDIR)/movian.snap: $(SNAPDEPS)
rm -f $@
mksquashfs $(SNAPROOT) $@ -comp xz

snap: $(BUILDDIR)/movian.snap

137 changes: 13 additions & 124 deletions src/arch/linux/linux_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* For more information, contact [email protected]
*/
#include <X11/Xlib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "main.h"
#include "arch/arch.h"
Expand All @@ -28,113 +26,12 @@
#include "prop/prop.h"
#include "navigator.h"
#include "service.h"
#include "prop/prop_glib_courier.h"

hts_mutex_t gdk_mutex;
prop_courier_t *glibcourier;
// https://www.uninformativ.de/blog/postings/2017-04-02/0/POSTING-en.html

static void add_xdg_paths(void);

/**
*
*/
static void
gdk_obtain(void)
{
hts_mutex_lock(&gdk_mutex);
}


/**
*
*/
static void
gdk_release(void)
{
hts_mutex_unlock(&gdk_mutex);
}

static int running;
extern const linux_ui_t ui_glw, ui_gu;
static const linux_ui_t *ui_wanted = &ui_glw, *ui_current;


/**
*
*/
int
arch_stop_req(void)
{
running = 0;
g_main_context_wakeup(g_main_context_default());
return 0;
}


/**
*
*/
static void
switch_ui(void)
{
if(ui_current == &ui_glw)
ui_wanted = &ui_gu;
else
ui_wanted = &ui_glw;
}


/**
*
*/
static void
mainloop(void)
{
void *aux = NULL;

running = 1;

while(running) {

if(ui_current != ui_wanted) {

prop_t *nav;

if(ui_current != NULL) {
nav = ui_current->stop(aux);
} else {
nav = NULL;
}

ui_current = ui_wanted;

aux= ui_current->start(nav);
}

#if ENABLE_WEBPOPUP
linux_webpopup_check();
#endif
gtk_main_iteration();
}

if(ui_current != NULL) {
prop_t *nav = ui_current->stop(aux);
if(nav != NULL)
prop_destroy(nav);
}
}


/**
*
*/
static void
linux_global_eventsink(void *opaque, event_t *e)
{
if(event_is_action(e, ACTION_SWITCH_UI))
switch_ui();
}

static int running = 1;

/**
* Linux main
Expand All @@ -147,35 +44,18 @@ main(int argc, char **argv)
posix_init();

XInitThreads();
hts_mutex_init(&gdk_mutex);

g_thread_init(NULL);
gdk_threads_set_lock_functions(gdk_obtain, gdk_release);

gdk_threads_init();
gdk_threads_enter();
gtk_init(&argc, &argv);
// g_thread_init(NULL);

parse_opts(argc, argv);

linux_init();

main_init();

if(gconf.ui && !strcmp(gconf.ui, "gu"))
ui_wanted = &ui_gu;

glibcourier = glib_courier_create(g_main_context_default());

prop_subscribe(0,
PROP_TAG_NAME("global", "eventSink"),
PROP_TAG_CALLBACK_EVENT, linux_global_eventsink, NULL,
PROP_TAG_COURIER, glibcourier,
NULL);

add_xdg_paths();

mainloop();
glw_x11_main(&running);

main_fini();

Expand All @@ -193,6 +73,15 @@ arch_exit(void)
}


int
arch_stop_req(void)
{
running = 0;
return 0;
}



/**
*
*/
Expand Down
13 changes: 12 additions & 1 deletion src/arch/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,25 @@ posix_init(void)
}
}

#ifdef linux
const char *snap_user_common = getenv("SNAP_USER_COMMON");
if(snap_user_common != NULL) {
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/cache", snap_user_common);
gconf.cache_path = strdup(buf);

snprintf(buf, sizeof(buf), "%s/persistent", snap_user_common);
gconf.persistent_path = strdup(buf);
}
#endif
setlocale(LC_ALL, "");

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
decorate_trace = 0;
#else
decorate_trace = isatty(2);
#endif

signal(SIGPIPE, SIG_IGN);

#ifdef RLIMIT_AS
Expand Down
2 changes: 1 addition & 1 deletion src/blobcache_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ blobcache_init(void)


prop_t *dir = setting_get_dir("general:resets");
settings_create_action(dir, _p("Clear cached files"),
settings_create_action(dir, _p("Clear cached files"), NULL,
cache_clear, NULL, 0, NULL);

hts_thread_create_joinable("blobcache", &bcthread, flushthread, NULL,
Expand Down
Loading