]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_api.cpp
8f794a30b8d59684563d2aa16d06c939fd3f114f
[vlc] / modules / gui / skins / x11 / x11_api.cpp
1 /*****************************************************************************
2  * x11_api.cpp: Various x11-specific functions
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_api.cpp,v 1.2 2003/05/19 21:39:34 asmax Exp $
6  *
7  * Authors: Cyril Deguet  <asmax@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
22  * USA.
23  *****************************************************************************/
24
25 #ifdef X11_SKINS
26
27 //--- X11 -------------------------------------------------------------------
28 #include <X11/Xlib.h>
29
30 //--- SKIN ------------------------------------------------------------------
31 #include <vlc/intf.h>
32 #include "../src/skin_common.h"
33 #include "../src/window.h"
34 #include "../os_window.h"
35 #include "../os_api.h"
36 #include "../src/event.h"       // for MAX_PARAM_SIZE
37
38 extern intf_thread_t *g_pIntf;  // ugly, but it's not my fault ;)
39
40 //---------------------------------------------------------------------------
41 // Event API
42 //---------------------------------------------------------------------------
43 void OSAPI_SendMessage( SkinWindow *win, unsigned int message, unsigned int param1,
44                         long param2 )
45 {
46 /*    if( win == NULL )
47         SendMessage( NULL, message, param1, param2 );
48     else
49         SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
50                      param2 );*/
51 }
52 //---------------------------------------------------------------------------
53 void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int param1,
54                         long param2 )
55 {
56     XEvent event;
57     
58     event.type = ClientMessage;
59     event.xclient.display = g_pIntf->p_sys->display;
60     if( win == NULL )
61         event.xclient.window = NULL;
62     else
63         event.xclient.window = (( X11Window *)win)->GetHandle();
64     event.xclient.send_event = 0;
65     event.xclient.message_type = NULL;
66     event.xclient.format = 32;
67     event.xclient.data.l[0] = message;
68     event.xclient.data.l[1] = param1;
69     event.xclient.data.l[2] = param2;
70     XSendEvent( g_pIntf->p_sys->display, event.xclient.window, False, 0, &event );
71 }
72 //---------------------------------------------------------------------------
73
74
75
76
77 //---------------------------------------------------------------------------
78 // Graphic API
79 //---------------------------------------------------------------------------
80 int OSAPI_GetNonTransparentColor( int c )
81 {
82 /*    // Get desktop device context
83     HDC DeskDC = GetWindowDC( GetDesktopWindow() );
84
85     // If color is black or color is same as black wether pixel color depth
86     if( c == 0 || SetPixel( DeskDC, 0, 0, c ) == 0 )
87     {
88         if( GetDeviceCaps( DeskDC, BITSPIXEL ) < 24 )
89             c = RGB(8, 0, 0);
90         else
91             c = RGB(1, 0, 0);
92     }
93     ReleaseDC( GetDesktopWindow(), DeskDC );
94     return c;*/
95 }
96 //---------------------------------------------------------------------------
97
98
99
100
101 //---------------------------------------------------------------------------
102 // General
103 //---------------------------------------------------------------------------
104 int OSAPI_GetTime()
105 {
106 /*    GTimeVal time;
107     g_get_current_time( &time );
108     return ( time.tv_sec * 1000 + time.tv_usec / 1000 );*/
109 }
110 //---------------------------------------------------------------------------
111 void OSAPI_GetScreenSize( int &w, int &h )
112 {
113 /*    w = GetSystemMetrics(SM_CXSCREEN);
114     h = GetSystemMetrics(SM_CYSCREEN);*/
115 }
116 //---------------------------------------------------------------------------
117 void OSAPI_GetMousePos( int &x, int &y )
118 {
119     Window rootReturn, childReturn;
120     int rootx, rooty;
121     int winx, winy;
122     unsigned int xmask;
123     
124     Window root = DefaultRootWindow( g_pIntf->p_sys->display );
125     XQueryPointer( g_pIntf->p_sys->display, root, &rootReturn, &childReturn, 
126                    &rootx, &rooty, &winx, &winy, &xmask );
127     x = rootx;
128     y = rooty;
129 }
130 //---------------------------------------------------------------------------
131 string OSAPI_GetWindowTitle( SkinWindow *win )
132 {
133     return ( (X11Window *)win )->GetName();
134 }
135 //---------------------------------------------------------------------------
136 bool OSAPI_RmDir( string path )
137 {
138 /*    WIN32_FIND_DATA find;
139     string File;
140     string FindFiles = path + "\\*.*";
141     HANDLE handle    = FindFirstFile( (char *)FindFiles.c_str(), &find );
142
143     while( handle != INVALID_HANDLE_VALUE )
144     {
145         // If file is neither "." nor ".."
146         if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
147         {
148             // Set file name
149             File = path + "\\" + (string)find.cFileName;
150
151             // If file is a directory, delete it recursively
152             if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
153             {
154                 OSAPI_RmDir( File );
155             }
156             // Else, it is a file so simply delete it
157             else
158             {
159                 DeleteFile( (char *)File.c_str() );
160             }
161         }
162
163         // If no more file in directory, exit while
164         if( !FindNextFile( handle, &find ) )
165             break;
166     }
167
168     // Now directory is empty so can be removed
169     FindClose( handle );
170     RemoveDirectory( (char *)path.c_str() );
171
172     return true;*/
173 }
174 //---------------------------------------------------------------------------
175
176 #endif