static XtAppContext app;
static Display *display;
+static Widget toplevel_window;
static String fallback[] = {
"*renderTable: rt",
XtSetLanguageProc(NULL, langProc, NULL);
app = XtCreateApplicationContext();
XtAppSetFallbackResources(app, fallback);
-
+
display = XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv);
// load settings
}
MainWindow *window = WindowCreate(display);
+ toplevel_window = window->window;
// random numbers only used for creating tmp dirs
srand(time(NULL));
void AppAddTimeOut(unsigned long interval, XtTimerCallbackProc proc, XtPointer data) {
XtAppAddTimeOut(app, interval, proc, data);
+
+ if(!toplevel_window) return;
+
+ // send a dummy X11 event, because the event loop may be waiting
+ // and the timeout proc is only called when an event is processed
+ XClientMessageEvent event;
+ memset(&event, 0, sizeof(XClientMessageEvent));
+ event.type = ClientMessage;
+ event.window = XtWindow(toplevel_window);
+ event.format = 32;
+ XSendEvent(display, XtWindow(toplevel_window), 0, 0, (XEvent*)&event);
+ XFlush(display);
}
*/
#include "player.h"
+#include "main.h"
#include <stdio.h>
#include <stdlib.h>
int status = 0;
waitpid(player->process, &status, 0);
- //player->isactive = FALSE;
+ player->isactive = FALSE;
player->status = status;
return NULL;
fflush(stdout);
}
+static void player_widget_set_size(XtPointer data, XtIntervalId *id) {
+ Player *player = data;
+ MainWindow *win = GetMainWindow();
+
+ Dimension win_width, win_height;
+ XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
+ Dimension player_width, player_height;
+ XtVaGetValues(win->player_widget, XmNwidth, &player_width, XmNheight, &player_height, NULL);
+
+ Dimension new_width = player->width + win_width - player_width;
+ Dimension new_height = player->height + win_height - player_height;
+
+ XtVaSetValues(win->window, XmNwidth, new_width, XmNheight, new_height, NULL);
+
+}
+
+
+
static void player_set_size(Player *player, int width, int height) {
if(width >= 0) {
player->width = width;
player->height = height;
}
if(player->width > 0 && player->height > 0) {
- printf("TODO: set player size\n");
+ AppAddTimeOut(0, player_widget_set_size, player);
}
}
return window;
}
+MainWindow* GetMainWindow(void) {
+ return main_window;
+}
+
void WindowShow(MainWindow *win) {
XtRealizeWidget(win->window);
}
MainWindow* WindowCreate(Display *dp);
+MainWindow* GetMainWindow(void);
+
void WindowShow(MainWindow *win);
void WindowFullscreen(MainWindow *win, bool enableFullscreen);