- We don't actually need to store the render task IDs in the
state structure; the only thing we actually care about is to
avoid multiple registration. We can use two otherwise-unused
bits of the render mask to track this.
- The window size tracking is no longer used, so these members
are just a waste of space and can be removed.
- The remaining members can be rearranged to avoid padding.
-Subproject commit a56b84487bb43c85cb36e5995c84006be8b81011
+Subproject commit 8cda0a6cc9cc31edf0fe94c470038f12c8dcc905
#define GOAL_SHIFT 6
#define GOAL_MASK 0x739c0ul
#define GOAL_SHIFT 6
#define GOAL_MASK 0x739c0ul
+#define GAME_MASK 0x1fffffful
static void set_view_goal(struct app_state *state, int view_goal)
{
static void set_view_goal(struct app_state *state, int view_goal)
{
- state->view_goal_on_game = view_goal;
+ state->view_goal_on_game = !!view_goal;
x11_redraw_game(state, game_check_goal(&state->board));
}
x11_redraw_game(state, game_check_goal(&state->board));
}
struct board board;
Widget game, goal;
struct board board;
Widget game, goal;
- /* Current window width/height for resize handling. */
- Dimension game_sz[2], goal_sz[2];
-
-
- XtIntervalId render_tick;
- XtWorkProcId render_proc;
+ Pixmap icon_pixmap;
+ GC tile_gc;
uint_least32_t render_game_mask;
uint_least16_t render_goal_mask;
uint_least16_t game_tile_sz, goal_tile_sz;
/* If true, the goal will be displayed over the main play area. */
uint_least32_t render_game_mask;
uint_least16_t render_goal_mask;
uint_least16_t game_tile_sz, goal_tile_sz;
/* If true, the goal will be displayed over the main play area. */
+ uint_least8_t view_goal_on_game;
/* Whether to set _NET_WM_ICON property on WMShell */
/* Whether to set _NET_WM_ICON property on WMShell */
+ uint_least8_t use_ewmh_icons;
- GC tile_gc;
- Pixmap icon_pixmap;
uint_least32_t tile_colour[TILE_MAX-1][3];
};
uint_least32_t tile_colour[TILE_MAX-1][3];
};
configure_mainwin(state, XtNameToWidget(shell, "*game"));
configure_mainwin(state, XtNameToWidget(shell, "*game"));
- XtVaGetValues(state->game, XmNwidth, &state->game_sz[0],
- XmNheight, &state->game_sz[1],
- (char *)NULL);
XtAddCallback(state->game, XmNresizeCallback, resize, state);
XtAddCallback(state->game, XmNexposeCallback, expose, state);
XtAddCallback(state->game, XmNresizeCallback, resize, state);
XtAddCallback(state->game, XmNexposeCallback, expose, state);
-
- XtVaGetValues(state->game, XmNwidth, &state->goal_sz[0],
- XmNheight, &state->goal_sz[1],
- (char *)NULL);
XtAddCallback(state->goal, XmNresizeCallback, resize, state);
XtAddCallback(state->goal, XmNexposeCallback, expose, state);
}
XtAddCallback(state->goal, XmNresizeCallback, resize, state);
XtAddCallback(state->goal, XmNexposeCallback, expose, state);
}
# include <unistd.h>
#endif
# include <unistd.h>
#endif
+/* status flags in the upper bits are ORed into the game mask which only
+ * needs the lower 25 bits */
+#define X11_TICK_INSTALLED (1ul << 31)
+#define X11_PROC_INSTALLED (1ul << 30)
+
enum {
NUM_TILE_COLOURS = COLOUR_MAX*(TILE_MAX-1),
COLOUR_UI_GAMEBG = NUM_TILE_COLOURS,
enum {
NUM_TILE_COLOURS = COLOUR_MAX*(TILE_MAX-1),
COLOUR_UI_GAMEBG = NUM_TILE_COLOURS,
x11_redraw_game(state, state->render_game_mask);
state->render_goal_mask = state->render_game_mask = 0;
x11_redraw_game(state, state->render_game_mask);
state->render_goal_mask = state->render_game_mask = 0;
- state->render_proc = 0;
- state->render_tick = 0;
struct app_state *state = data;
XtAppContext app;
struct app_state *state = data;
XtAppContext app;
- if (state->render_proc)
+ if (state->render_game_mask & X11_PROC_INSTALLED)
+ state->render_game_mask |= X11_PROC_INSTALLED;
app = XtWidgetToApplicationContext(state->game);
app = XtWidgetToApplicationContext(state->game);
- state->render_proc = XtAppAddWorkProc(app, do_render, state);
+ XtAppAddWorkProc(app, do_render, state);
}
void x11_queue_render(struct app_state *state, uint_fast32_t mask, int mode)
}
void x11_queue_render(struct app_state *state, uint_fast32_t mask, int mode)
uint_fast32_t changed = 0;
XtAppContext app;
uint_fast32_t changed = 0;
XtAppContext app;
if (mode & RENDER_MODE_GOAL)
changed |= state->render_goal_mask |= mask;
if (mode & RENDER_MODE_GAME)
changed |= state->render_game_mask |= mask;
if (mode & RENDER_MODE_GOAL)
changed |= state->render_goal_mask |= mask;
if (mode & RENDER_MODE_GAME)
changed |= state->render_game_mask |= mask;
- if (state->render_tick || !changed)
+ if (changed & X11_TICK_INSTALLED || !changed)
+ state->render_game_mask |= X11_TICK_INSTALLED;
app = XtWidgetToApplicationContext(state->game);
app = XtWidgetToApplicationContext(state->game);
- state->render_tick = XtAppAddTimeOut(app, 3, start_render, state);
+ XtAppAddTimeOut(app, 3, start_render, state);
board.x = get_seq(seq[i++]);
board.y = get_seq(seq[i++]);
board.x = get_seq(seq[i++]);
board.y = get_seq(seq[i++]);
- board.game[0] = 0x1ffffff ^ board_position(board.x, board.y);
+ board.game[0] = GAME_MASK ^ board_position(board.x, board.y);
board.game[1] = board.game[2] = board.game[3] = board.game[0];
while (1) {
board.game[1] = board.game[2] = board.game[3] = board.game[0];
while (1) {