add single instance mode
[uwplayer.git] / application / window.h
1 /*
2  * Copyright 2022 Olaf Wintermann
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a 
5  * copy of this software and associated documentation files (the "Software"), 
6  * to deal in the Software without restriction, including without limitation 
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
8  * and/or sell copies of the Software, and to permit persons to whom the 
9  * Software is furnished to do so, subject to the following conditions:
10  * 
11  * The above copyright notice and this permission notice shall be included in 
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
20  * DEALINGS IN THE SOFTWARE.
21  */
22
23
24 #ifndef UWP_WINDOW_H
25 #define UWP_WINDOW_H
26
27 #include <Xm/XmAll.h>
28 #include <stdbool.h>
29 #include <unistd.h>
30 #include <cx/list.h>
31 #include <cx/linked_list.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 typedef struct Player {
38     char *tmp;
39     pid_t process;
40     int log;
41     int ipc;
42     int status;
43     bool isactive;
44     bool isstarted;
45     Window window;
46     double playback_time;
47     int width;
48     int height;
49     int osd_height;
50 } Player;
51
52 typedef struct {
53     CxList *tracks;
54     int current_track;
55     
56     Boolean repeatTrack;
57     Boolean repeatList;
58     Boolean autoplayFolder;
59     Boolean random;
60 } PlayList;
61
62 typedef struct MainWindow {
63     Widget window;
64     Widget menubar;
65     Widget player_widget;
66     Widget sidebar_scrolledwindow;
67     Widget sidebar;
68     char *file;
69     Player *player;
70     bool fullscreen;
71     bool mbvisible;
72     bool sidebarvisible;
73     bool cursorhidden;
74     bool buttongrab;
75     bool pwbuttonpressed;
76     
77     Widget playRepeatTrackButton;
78     Widget playRepeatListButton;
79     Widget playAutoPlayButton;
80     Widget playRandom;
81     Widget viewSidebarButton;
82     Widget viewAdjustWindowSize;
83     Widget prefSingleInstanceButton;
84     
85     PlayList playlist;
86     
87     bool adjustWindowSize;
88     bool singleInstance;
89     
90     Time player_event_time;
91     Time button_press_time;
92     double motion_playback_time;
93     int mouse_x;
94     int mouse_y;
95     
96     
97 } MainWindow;
98
99 MainWindow* WindowCreate(Display *dp);
100
101 MainWindow* GetMainWindow(void);
102
103 void WindowShow(MainWindow *win);
104
105 void WindowFullscreen(MainWindow *win, bool enableFullscreen);
106
107 void WindowMenubarSetVisible(MainWindow *win, bool visible);
108
109 void WindowAdjustAspectRatio(MainWindow *win);
110
111 void WindowClosePlayer(MainWindow *win);
112
113 void WindowHidePlayerCursor(MainWindow *win);
114 void WindowShowPlayerCursor(MainWindow *win);
115
116 void WindowHandlePlayerEvent(MainWindow *win, XEvent *event);
117
118 void WindowShowSidebar(MainWindow *win, bool visible);
119
120 void WindowUpdate(MainWindow *win);
121
122
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif /* UWP_WINDOW_H */
128