Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / unx / gtk / window / xid_fullscreen_on_all_monitors.c
blob00554b1df0214d6ea19555e7e0a2cd6fcf69b80b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <dlfcn.h>
11 #include <stdlib.h>
13 typedef int Window;
14 typedef union _GdkEvent GdkEvent;
15 typedef struct _GdkWindow GdkWindow;
16 typedef struct _GdkDisplay GdkDisplay;
17 typedef struct _GdkScreen GdkScreen;
19 typedef enum
21 GDK_FULLSCREEN_ON_CURRENT_MONITOR,
22 GDK_FULLSCREEN_ON_ALL_MONITORS
23 } GdkFullscreenMode;
25 int main(int argc, char *argv[])
27 void *handle;
28 void (*gtk_init)(int*, char***);
29 GdkWindow* (*gdk_x11_window_foreign_new_for_display)(GdkDisplay*, Window);
30 GdkDisplay* (*gdk_display_get_default)(void);
31 GdkEvent* (*gdk_event_get)(void);
32 void (*gtk_main_do_event)(GdkEvent*);
33 void (*gdk_event_free)(GdkEvent*);
34 void (*gdk_window_fullscreen)(GdkWindow *);
35 void (*gdk_window_set_fullscreen_mode)(GdkWindow *, GdkFullscreenMode);
37 GdkEvent *event;
38 GdkWindow *window;
39 int windowid;
41 handle = dlopen("libgtk-3.so.0", RTLD_LAZY);
42 if( NULL == handle )
43 return -1;
45 gtk_init = (void (*) (int*, char***))
46 dlsym(handle, "gtk_init");
47 gdk_x11_window_foreign_new_for_display = (GdkWindow* (*)(GdkDisplay*, Window))
48 dlsym(handle, "gdk_x11_window_foreign_new_for_display");
49 gdk_display_get_default = (GdkDisplay* (*)(void))
50 dlsym(handle, "gdk_display_get_default");
51 gdk_event_get = (GdkEvent* (*)(void))
52 dlsym(handle, "gdk_event_get");
53 gtk_main_do_event = (void (*)(GdkEvent*))
54 dlsym(handle, "gtk_main_do_event");
55 gdk_event_free = (void (*)(GdkEvent*))
56 dlsym(handle, "gdk_event_free");
57 gdk_window_fullscreen = (void (*)(GdkWindow *))
58 dlsym(handle, "gdk_window_fullscreen");
59 gdk_window_set_fullscreen_mode = (void (*)(GdkWindow *, GdkFullscreenMode))
60 dlsym(handle, "gdk_window_set_fullscreen_mode");
62 if (!gtk_init ||
63 !gdk_x11_window_foreign_new_for_display ||
64 !gdk_display_get_default ||
65 !gdk_event_get ||
66 !gtk_main_do_event ||
67 !gdk_event_free ||
68 !gdk_window_fullscreen ||
69 !gdk_window_set_fullscreen_mode)
71 dlclose(handle);
72 return -1;
75 gtk_init(&argc, &argv);
77 windowid = atoi(argv[1]);
79 window = gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), windowid);
80 if (!window)
82 dlclose(handle);
83 return -1;
86 gdk_window_set_fullscreen_mode(window, GDK_FULLSCREEN_ON_ALL_MONITORS);
87 gdk_window_fullscreen(window);
89 while ((event = gdk_event_get()) != NULL)
91 gtk_main_do_event(event);
92 gdk_event_free(event);
95 dlclose(handle);
96 return 0;
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */