grim/guifications2
Clone
Summary
Browse
Changes
Graph
removed an unused variable
2011-12-04, Gary Kramlich
8dc511042f99
removed an unused variable
/*
* Guifications - The end all, be all, toaster popup plugin
* Copyright (C) 2003-2011 Gary Kramlich
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
*/
#include
<glib.h>
#include
<gtk/gtk.h>
#include
<gdk/gdk.h>
#ifndef WINVER
# define WINVER 0x0500
/* This is Windows 2000 */
#endif
/* WINVER */
#include
<windows.h>
typedef
HMONITOR
WINAPI
GF_MonitorFromRect
(
LPCRECT
,
DWORD
);
typedef
BOOL
WINAPI
GF_GetMonitorInfo
(
HMONITOR
,
LPMONITORINFO
);
/*******************************************************************************
* Uses _NET_WORKAREA or SPI_GETWORKAREA to get the geometry of a screen
******************************************************************************/
static
gboolean
win32_get_workarea_fallback
(
GdkRectangle
*
rect
)
{
RECT
rcWork
;
if
(
SystemParametersInfo
(
SPI_GETWORKAREA
,
0
,
&
rcWork
,
FALSE
))
{
rect
->
x
=
rcWork
.
left
;
rect
->
y
=
rcWork
.
top
;
rect
->
width
=
rcWork
.
right
-
rcWork
.
left
;
rect
->
height
=
rcWork
.
bottom
-
rcWork
.
top
;
return
TRUE
;
}
return
FALSE
;
}
/**
* This will only work on Win98+ and Win2K+
*/
static
gboolean
win32_adjust_workarea_multi_monitor
(
GdkRectangle
*
rect
)
{
GF_GetMonitorInfo
*
the_GetMonitorInfo
;
GF_MonitorFromRect
*
the_MonitorFromRect
;
HMODULE
hmod
;
HMONITOR
monitor
;
MONITORINFO
info
;
RECT
monitorRect
;
gint
virtual_screen_x
,
virtual_screen_y
;
monitorRect
.
left
=
rect
->
x
;
monitorRect
.
right
=
rect
->
x
+
rect
->
width
;
monitorRect
.
top
=
rect
->
y
;
monitorRect
.
bottom
=
rect
->
y
+
rect
->
height
;
/* Convert the coordinates so that 0, 0 is the top left of the Primary
* Monitor, not the top left of the virtual screen
*/
virtual_screen_x
=
GetSystemMetrics
(
SM_XVIRTUALSCREEN
);
virtual_screen_y
=
GetSystemMetrics
(
SM_YVIRTUALSCREEN
);
if
(
virtual_screen_x
!=
0
)
{
monitorRect
.
left
+=
virtual_screen_x
;
monitorRect
.
right
+=
virtual_screen_x
;
}
if
(
virtual_screen_y
!=
0
)
{
monitorRect
.
top
+=
virtual_screen_y
;
monitorRect
.
bottom
+=
virtual_screen_y
;
}
if
(
!
(
hmod
=
GetModuleHandle
(
"user32"
)))
{
return
FALSE
;
}
if
(
!
(
the_MonitorFromRect
=
(
GF_MonitorFromRect
*
)
GetProcAddress
(
hmod
,
"MonitorFromRect"
)))
{
return
FALSE
;
}
if
(
!
(
the_GetMonitorInfo
=
(
GF_GetMonitorInfo
*
)
GetProcAddress
(
hmod
,
"GetMonitorInfoA"
)))
{
return
FALSE
;
}
monitor
=
the_MonitorFromRect
(
&
monitorRect
,
MONITOR_DEFAULTTONEAREST
);
info
.
cbSize
=
sizeof
(
info
);
if
(
!
the_GetMonitorInfo
(
monitor
,
&
info
))
{
return
FALSE
;
}
rect
->
x
=
info
.
rcWork
.
left
;
rect
->
y
=
info
.
rcWork
.
top
;
rect
->
width
=
info
.
rcWork
.
right
-
info
.
rcWork
.
left
;
rect
->
height
=
info
.
rcWork
.
bottom
-
info
.
rcWork
.
top
;
/** Convert the coordinates so that 0, 0 is the top left of the virtual screen,
* not the top left of the primary monitor */
if
(
virtual_screen_x
!=
0
)
{
rect
->
x
+=
-
virtual_screen_x
;
}
if
(
virtual_screen_y
!=
0
)
{
rect
->
y
+=
-
virtual_screen_y
;
}
return
TRUE
;
}
static
void
win32_adjust_workarea
(
GdkRectangle
*
rect
)
{
if
(
!
win32_adjust_workarea_multi_monitor
(
rect
))
{
if
(
!
win32_get_workarea_fallback
(
rect
))
{
/* I don't think this will ever happen */
rect
->
x
=
0
;
rect
->
y
=
0
;
rect
->
height
=
GetSystemMetrics
(
SM_CXSCREEN
);
rect
->
width
=
GetSystemMetrics
(
SM_CYSCREEN
);
}
}
}
gboolean
gf_display_get_workarea
(
GdkRectangle
*
rect
)
{
GdkDisplay
*
display
=
NULL
;
GdkScreen
*
screen
=
NULL
;
display
=
gdk_display_get_default
();
screen
=
gdk_display_get_screen
(
display
,
disp_screen
);
gdk_screen_get_monitor_geometry
(
screen
,
disp_monitor
,
rect
);
win32_adjust_workarea
(
rect
);
return
TRUE
;
}
gboolean
gf_display_screen_saver_is_running
(
void
)
{
gboolean
ret
=
FALSE
;
if
(
!
SystemParametersInfo
(
SPI_GETSCREENSAVERRUNNING
,
(
unsigned
int
)
NULL
,
&
ret
,
FALSE
))
{
ret
=
FALSE
;
}
return
ret
;
}