Example #1
0
static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent *ui_event, void *user_data) {

	ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_RESIZE, false);

	OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data);
	// The order of the fullscreen change event and the window size change
	// event varies, even within just one browser, so defer handling
	os->request_canvas_size_adjustment();
	return false;
}
Example #2
0
static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) {

	ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false);

	OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data);
	String id = String::utf8(event->id);
	// empty id is canvas
	if (id.empty() || id == "canvas") {

		OS::VideoMode vm = os->get_video_mode();
		// this event property is the only reliable information on
		// browser fullscreen state
		vm.fullscreen = event->isFullscreen;
		os->set_video_mode(vm);
		os->request_canvas_size_adjustment();
	}
	return false;
}