Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Suspend via logind over UPower if available. #4168

Closed
wants to merge 20 commits into from

9 participants

Joseph A. Yasi Peter Frühberger Trent Nelson Tobias Arrskog Martijn Kaijser jmarshallnz Wolfgang Schupp Karlson2k Memphiz
Joseph A. Yasi

The suspend feature of UPower is deprecated. XBMC supports suspending using systemd-logind, however it defaults to a few other UPower methods first before trying Logind. This patch checks for logind first, and uses it if available.

Joseph A. Yasi

@Anyone the UPower suspend methods will be removed from distros pretty soon. Logind should be the default choice for suspending on Linux when it exists. If the default order isn't changed, there should be a way to configure and force XBMC to use logind for suspend.

Peter Frühberger
Collaborator

@yasij: thanks for doing that PR. The dev in charge @topfs2 will be available next week again to review.

Martijn Kaijser MartijnKaijser added this to the Pending for inclusion milestone
Trent Nelson

@topfs2 I think I saw you active on the forums this morning. Any comments?

Tobias Arrskog
Collaborator

I haven't really kept myself up to date if logind is superseeding upower and such but the patch looks correct if thats true.
The one thing which strikes me is that isn't it possible to have logind without suspend capabilities but upower with? Have a small recollection that one ubuntu (latest?) behaved like that?

Joseph A. Yasi

Ubuntu supports suspend with logind. It uses upstart for init instead of systemd, and implements the part it needs through some extra scripts in the systemd-shim package. The problem is that UPower suspend can act weird in this case because the shim doesn't properly signal UPower on wakeup when UPower is used to suspend.

Actually, I think Debian with sysvinit does not have the shim scripts implemented, and thus suspend wouldn't work. It also won't work with systemd-logind versions before 183 because suspend/resume was added in that version. Maybe the suspend method should be configurable?

Joseph A. Yasi

The way KDE checks for it is here: https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/master/entry/powerdevil/daemon/backends/upower/powerdevilupowerbackend.cpp#L40

It checks the systemd version, and if the version API isn't implemented, it checks for upstart.

Trent Nelson

What's the potential for this affecting older distros? I'm more concerned about breaking people's current installs than new ones, for Gotham.

Joseph A. Yasi

The potential is certainly there for affecting older distros that are using systemd with logind before suspend/resume support was added. It looks like Fedora 17 and OpenSUSE 12.2 use systemd version 44 which doesn't support suspend. Ubuntu added systemd-logind in raring 13.04 and has the shim scripts for suspend. Before that, Ubuntu didn't have any piece of systemd, so the check for logind will fail.

There is a CanSuspend() method in the logind dbus API (as well as CanPowerOff(), CanReboot(), CanHibernate(), CanHybridSleep()). These might need to be checked with a transition over to the UPower method if they return no.

Trent Nelson

@topfs2 @yasij If you guys can work something out to minimize the potential effect on current installs, I'll consider this for Gotham.

Tobias Arrskog
Collaborator

Sorry for slow response from me, I've been sick so haven't touched the computer in a while :)
Anyways, so from what I understand the simplest solution would be to check for systemd and if version is > 183?

Joseph A. Yasi
Tobias Arrskog
Collaborator
Joseph A. Yasi
Shine and others added some commits
Shine Prevent unnecessary colorspace conversions 0369b8c
Jonathan Marshall [settings] implement OnSettingsUnloaded, fixes various advancedsettin…
…gs leaking from profile to profile (e.g. mysql database config)
20fcc00
Jonathan Marshall [settings] switch zeroconf setting to standard 2e6fe26
jmarshallnz jmarshallnz Merge pull request #4254 from jmarshallnz/onsettingsunloaded
Implements OnSettingsUnloaded
2547096
jmarshallnz jmarshallnz Merge pull request #4192 from Shine-/dxvarenderer
Prevent unnecessary colorspace conversions (regression in #4163)
62d6cff
jmarshallnz jmarshallnz Merge pull request #4057 from Karlson2k/win32_fix_nonutf8
[win32] fix ANSI used as UTF-8
99461eb
jmarshallnz jmarshallnz Merge pull request #4259 from phate89/master
Allow xbmc to handle cue tags without quotes
090710f
Jonathan Marshall [gui] scrollbar didn't scroll properly with the mouse. fixes #14873 f3530bd
Jonathan Marshall [addons] ensure we reload the current skin if it's updated via a .zip…
… file. fixes #14890
7f2dda3
Martijn Kaijser MartijnKaijser [language] fix inconsistent add-on state description. fixes #14851 d688682
Memphiz Memphiz Merge pull request #4261 from jmarshallnz/zeroconf_level
[settings] switch zeroconf setting to standard level
d4c0cd9
Trent Nelson Merge pull request #4007 from wsnipex/crashlog
[linux] allow override of crashlog directory
7926079
Trent Nelson Merge pull request #3640 from wsnipex/joystick-fix
Input: fix Accelerometer being detected as joystick
7035048
ronie [Confluence] don't crop 'local subs..' label 3c0d901
jmarshallnz

24023 is also used as an error message (triggered from content dialog) on disabled scrapers. This now doesn't make as much sense as all you get is "Disabled" "Name of scraper". A better solution would be to add a new label with the same context string you've used here.

hmm thought it was only used in the manager

Joseph A. Yasi yasij closed this
Joseph A. Yasi yasij deleted the branch
Joseph A. Yasi

Superceded by pull request #4273.

Joseph A. Yasi yasij reopened this
Joseph A. Yasi yasij closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 13, 2013
  1. Wolfgang Schupp
Commits on Jan 11, 2014
  1. Wolfgang Schupp
Commits on Jan 20, 2014
  1. Karlson2k
  2. Karlson2k
Commits on Feb 19, 2014
  1. Prevent unnecessary colorspace conversions

    Shine authored
Commits on Feb 22, 2014
  1. [settings] implement OnSettingsUnloaded, fixes various advancedsettin…

    Jonathan Marshall authored
    …gs leaking from profile to profile (e.g. mysql database config)
Commits on Feb 23, 2014
  1. [settings] switch zeroconf setting to standard

    Jonathan Marshall authored
  2. jmarshallnz

    Merge pull request #4254 from jmarshallnz/onsettingsunloaded

    jmarshallnz authored
    Implements OnSettingsUnloaded
  3. jmarshallnz

    Merge pull request #4192 from Shine-/dxvarenderer

    jmarshallnz authored
    Prevent unnecessary colorspace conversions (regression in #4163)
  4. jmarshallnz

    Merge pull request #4057 from Karlson2k/win32_fix_nonutf8

    jmarshallnz authored
    [win32] fix ANSI used as UTF-8
  5. jmarshallnz

    Merge pull request #4259 from phate89/master

    jmarshallnz authored
    Allow xbmc to handle cue tags without quotes
  6. [addons] ensure we reload the current skin if it's updated via a .zip…

    Jonathan Marshall authored
    … file. fixes #14890
  7. Martijn Kaijser
  8. Memphiz

    Merge pull request #4261 from jmarshallnz/zeroconf_level

    Memphiz authored
    [settings] switch zeroconf setting to standard level
  9. Merge pull request #4007 from wsnipex/crashlog

    Trent Nelson authored
    [linux] allow override of crashlog directory
  10. Merge pull request #3640 from wsnipex/joystick-fix

    Trent Nelson authored
    Input: fix Accelerometer being detected as joystick
  11. [Confluence] don't crop 'local subs..' label

    ronie authored
Commits on Feb 24, 2014
  1. Joseph A. Yasi

    Make sure that systemd is at least version 183 or Upstart is at least…

    yasij authored
    … version 1.11 for logind suspend/resume support.
  2. Joseph A. Yasi
This page is out of date. Refresh to see the latest.
20 addons/skin.confluence/720p/DialogSubtitles.xml
View
@@ -284,27 +284,25 @@
</control>
<control type="group" id="130">
<control type="grouplist">
- <left>20</left>
- <top>660</top>
- <width>305</width>
- <height>40</height>
- <align>right</align>
+ <left>50</left>
+ <top>659</top>
+ <width>605</width>
+ <height>30</height>
<orientation>horizontal</orientation>
<itemgap>5</itemgap>
<control type="image">
- <width>40</width>
- <height>40</height>
+ <width>30</width>
+ <height>30</height>
<texture>DefaultIconInfo.png</texture>
</control>
<control type="label">
<description>notification</description>
- <width min="10" max="260">auto</width>
- <height>40</height>
+ <width min="10" max="560">auto</width>
+ <height>30</height>
<font>font13</font>
<textcolor>white</textcolor>
- <label>31413</label>
+ <label>$LOCALIZE[31413]</label>
<aligny>center</aligny>
- <wrapmultiline>true</wrapmultiline>
</control>
</control>
</control>
3  language/English/strings.po
View
@@ -11832,9 +11832,10 @@ msgctxt "#24022"
msgid "Enable"
msgstr ""
+#. Defines the state of the add-on in the add-on manager window
#: xbmc/filesystem/AddonsDirectory.cpp
msgctxt "#24023"
-msgid "Add-on disabled"
+msgid "Disabled"
msgstr ""
#empty strings from id 24024 to 24026
2  system/settings/settings.xml
View
@@ -2100,7 +2100,7 @@
<requirement>HAS_ZEROCONF</requirement>
<group id="1">
<setting id="services.zeroconf" type="boolean" label="1260" help="36342">
- <level>2</level>
+ <level>1</level>
<default>true</default>
<control type="toggle" />
</setting>
3  tools/Linux/xbmc.sh.in
View
@@ -23,6 +23,7 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
LIBDIR="@libdir@"
+CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
# Check for some options used by this script
while [ "$#" -gt "0" ]
@@ -52,7 +53,7 @@ single_stacktrace()
print_crash_report()
{
- FILE="$HOME/xbmc_crashlog-`date +%Y%m%d_%H%M%S`.log"
+ FILE="$CRASHLOG_DIR/xbmc_crashlog-`date +%Y%m%d_%H%M%S`.log"
echo "############## XBMC CRASH LOG ###############" >> $FILE
echo >> $FILE
echo "################ SYSTEM INFO ################" >> $FILE
5 xbmc/addons/AddonInstaller.cpp
View
@@ -733,7 +733,10 @@ void CAddonInstallJob::OnPostInstall(bool reloadAddon)
toast->ResetTimer();
toast->Close(true);
}
- CSettings::Get().SetString("lookandfeel.skin",m_addon->ID().c_str());
+ if (CSettings::Get().GetString("lookandfeel.skin") == m_addon->ID())
+ CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin", true);
+ else
+ CSettings::Get().SetString("lookandfeel.skin",m_addon->ID().c_str());
}
}
58 xbmc/cores/VideoRenderers/WinRenderer.cpp
View
@@ -140,10 +140,11 @@ void CWinRenderer::SelectRenderMethod()
{
CLog::Log(LOGNOTICE, "D3D: rendering method forced to DXVA processor");
m_renderMethod = RENDER_DXVA;
- if (!m_processor->Open(m_sourceWidth, m_sourceHeight, m_iFlags, m_format, m_extended_format))
+ if (!m_processor || !m_processor->Open(m_sourceWidth, m_sourceHeight, m_iFlags, m_format, m_extended_format))
{
CLog::Log(LOGNOTICE, "D3D: unable to open DXVA processor");
- m_processor->Close();
+ if (m_processor)
+ m_processor->Close();
m_renderMethod = RENDER_INVALID;
}
}
@@ -155,13 +156,16 @@ void CWinRenderer::SelectRenderMethod()
{
case RENDER_METHOD_DXVAHD:
case RENDER_METHOD_DXVA:
- m_renderMethod = RENDER_DXVA;
- if (m_processor->Open(m_sourceWidth, m_sourceHeight, m_iFlags, m_format, m_extended_format))
- break;
- else
+ if (!m_processor || !m_processor->Open(m_sourceWidth, m_sourceHeight, m_iFlags, m_format, m_extended_format))
{
CLog::Log(LOGNOTICE, "D3D: unable to open DXVA processor");
- m_processor->Close();
+ if (m_processor)
+ m_processor->Close();
+ }
+ else
+ {
+ m_renderMethod = RENDER_DXVA;
+ break;
}
// Drop through to pixel shader
case RENDER_METHOD_AUTO:
@@ -397,8 +401,9 @@ unsigned int CWinRenderer::PreInit()
m_iRequestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod");
- if (g_advancedSettings.m_DXVAForceProcessorRenderer || m_iRequestedMethod == RENDER_METHOD_DXVA
- || m_iRequestedMethod == RENDER_METHOD_DXVAHD)
+ if (g_advancedSettings.m_DXVAForceProcessorRenderer
+ || m_iRequestedMethod == RENDER_METHOD_DXVA
+ || m_iRequestedMethod == RENDER_METHOD_DXVAHD)
{
if (m_iRequestedMethod != RENDER_METHOD_DXVA && CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionWin7))
{
@@ -407,29 +412,30 @@ unsigned int CWinRenderer::PreInit()
{
CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA-HD processor - skipping");
SAFE_DELETE(m_processor);
- m_processor = new DXVA::CProcessor();
}
- else
- return 0;
}
- else
+ if (!m_processor)
+ {
m_processor = new DXVA::CProcessor();
-
- if (!m_processor->PreInit())
- CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA2 processor - skipping");
- else
- return 0;
+ if (!m_processor->PreInit())
+ {
+ CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA2 processor - skipping");
+ SAFE_DELETE(m_processor);
+ }
+ }
}
-
- if (g_Windowing.IsTextureFormatOk(D3DFMT_L16, 0))
+ // allow other color spaces besides YV12 in case DXVA rendering is not used or not available
+ if (!m_processor || (m_iRequestedMethod != RENDER_METHOD_DXVA && m_iRequestedMethod != RENDER_METHOD_DXVAHD))
{
- m_formats.push_back(RENDER_FMT_YUV420P10);
- m_formats.push_back(RENDER_FMT_YUV420P16);
+ if (g_Windowing.IsTextureFormatOk(D3DFMT_L16, 0))
+ {
+ m_formats.push_back(RENDER_FMT_YUV420P10);
+ m_formats.push_back(RENDER_FMT_YUV420P16);
+ }
+ m_formats.push_back(RENDER_FMT_NV12);
+ m_formats.push_back(RENDER_FMT_YUYV422);
+ m_formats.push_back(RENDER_FMT_UYVY422);
}
- m_formats.push_back(RENDER_FMT_NV12);
- m_formats.push_back(RENDER_FMT_YUYV422);
- m_formats.push_back(RENDER_FMT_UYVY422);
-
return 0;
}
6 xbmc/guilib/GUIScrollBarControl.cpp
View
@@ -286,13 +286,13 @@ void CGUIScrollBar::SetFromPosition(const CPoint &point)
{
float fPercent;
if (m_orientation == VERTICAL)
- fPercent = (point.y - m_guiBackground.GetYPosition() - 0.5f*m_guiBarFocus.GetHeight()) / m_guiBackground.GetHeight();
+ fPercent = (point.y - m_guiBackground.GetYPosition() - 0.5f*m_guiBarFocus.GetHeight()) / (m_guiBackground.GetHeight() - m_guiBarFocus.GetHeight());
else
- fPercent = (point.x - m_guiBackground.GetXPosition() - 0.5f*m_guiBarFocus.GetWidth()) / m_guiBackground.GetWidth();
+ fPercent = (point.x - m_guiBackground.GetXPosition() - 0.5f*m_guiBarFocus.GetWidth()) / (m_guiBackground.GetWidth() - m_guiBarFocus.GetWidth());
if (fPercent < 0) fPercent = 0;
if (fPercent > 1) fPercent = 1;
- int offset = (int)(floor(fPercent * m_numItems + 0.5f));
+ int offset = (int)(floor(fPercent * (m_numItems - m_pageSize) + 0.5f));
if (m_offset != offset)
{
11 xbmc/input/SDLJoystick.cpp
View
@@ -115,11 +115,16 @@ void CJoystick::Initialize()
// Details: Total Axis: 37 Total Hats: 0 Total Buttons: 57
// NOTICE: Enabled Joystick: Microsoft Microsoft® 2.4GHz Transceiver v6.0
// Details: Total Axis: 37 Total Hats: 0 Total Buttons: 57
+ // also checks if we have at least 1 button, fixes
+ // NOTICE: Enabled Joystick: ST LIS3LV02DL Accelerometer
+ // Details: Total Axis: 3 Total Hats: 0 Total Buttons: 0
int num_axis = SDL_JoystickNumAxes(joy);
int num_buttons = SDL_JoystickNumButtons(joy);
- if (num_axis > 20 && num_buttons > 50)
- CLog::Log(LOGNOTICE, "Your Joystick seems to be a Keyboard, ignoring it: %s Axis: %d Buttons: %d",
- SDL_JoystickName(i), num_axis, num_buttons);
+ if ((num_axis > 20 && num_buttons > 50) || num_buttons == 0)
+ {
+ CLog::Log(LOGNOTICE, "Ignoring Joystick %s Axis: %d Buttons: %d: invalid device properties",
+ SDL_JoystickName(i), num_axis, num_buttons);
+ }
else
{
m_JoystickNames.push_back(string(SDL_JoystickName(i)));
11 xbmc/network/Network.cpp
View
@@ -29,6 +29,7 @@
#ifdef TARGET_WINDOWS
#include "utils/SystemInfo.h"
#include "win32/WIN32Util.h"
+#include "utils/CharsetConverter.h"
#endif
/* slightly modified in_ether taken from the etherboot project (http://sourceforge.net/projects/etherboot) */
@@ -162,8 +163,14 @@ CStdString CNetwork::GetHostName(void)
char hostName[128];
if (gethostname(hostName, sizeof(hostName)))
return CStdString("unknown");
- else
- return CStdString(hostName);
+
+ std::string hostStr;
+#ifdef TARGET_WINDOWS
+ g_charsetConverter.systemToUtf8(hostName, hostStr);
+#else
+ hostStr = hostName;
+#endif
+ return hostStr;
}
CNetworkInterface* CNetwork::GetFirstConnectedInterface()
6 xbmc/powermanagement/PowerManager.cpp
View
@@ -78,12 +78,12 @@ void CPowerManager::Initialize()
m_instance = new CAndroidPowerSyscall();
#elif defined(TARGET_POSIX)
#if defined(HAS_DBUS)
- if (CConsoleUPowerSyscall::HasConsoleKitAndUPower())
+ if (CLogindUPowerSyscall::HasLogind())
+ m_instance = new CLogindUPowerSyscall();
+ else if (CConsoleUPowerSyscall::HasConsoleKitAndUPower())
m_instance = new CConsoleUPowerSyscall();
else if (CConsoleDeviceKitPowerSyscall::HasDeviceConsoleKit())
m_instance = new CConsoleDeviceKitPowerSyscall();
- else if (CLogindUPowerSyscall::HasLogind())
- m_instance = new CLogindUPowerSyscall();
else if (CUPowerSyscall::HasUPower())
m_instance = new CUPowerSyscall();
#if defined(HAS_HAL)
34 xbmc/powermanagement/linux/LogindUPowerSyscall.cpp
View
@@ -23,6 +23,9 @@
#include "system.h"
#include "LogindUPowerSyscall.h"
#include "utils/log.h"
+#include "utils/RegExp.h"
+#include "utils/StringUtils.h"
+#include "utils/Variant.h"
#ifdef HAS_DBUS
@@ -140,7 +143,36 @@ bool CLogindUPowerSyscall::HasLogind()
// recommended method by systemd devs. The seats directory
// doesn't exist unless logind created it and therefore is running.
// see also https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html
- return (access("/run/systemd/seats/", F_OK) >= 0);
+ if(access("/run/systemd/seats/", F_OK) < 0)
+ return false;
+
+ // systemd supports suspend and resume as of version 183.
+ // Thus, check that the installed systemd is >= 183.
+ // see the changelog entry in:
+ // http://cgit.freedesktop.org/systemd/systemd/tree/NEWS
+ CVariant properties = CDBusUtil::GetAll("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
+ if(properties.isMember("Version"))
+ {
+ CStdStringArray s;
+ StringUtils::SplitString(properties["Version"].asString(), " ", s, 2);
+ return (str2uint64(s[1],0u) >= 183u);
+ }
+
+ // systems without systemd as PID 1 such as Ubuntu do not implement all
+ // of the systemd API including the version API.
+ // Upstart implements the same API as logind as of version 1.11
+ CVariant upstartVer = CDBusUtil::GetVariant("com.ubuntu.Upstart", "/com/ubuntu/Upstart", "com.ubuntu.Upstart0_6", "version");
+ if(!upstartVer.isNull())
+ {
+ CRegExp re;
+ re.RegComp("init \\(upstart ([0-9.]+)\\)");
+ if(re.RegFind(upstartVer.asString()) != -1)
+ {
+ return (str2double(re.GetReplaceString("\\1")) >= 1.11);
+ }
+ }
+
+ return false;
}
bool CLogindUPowerSyscall::LogindSetPowerState(const char *state)
7 xbmc/settings/lib/SettingsManager.cpp
View
@@ -860,6 +860,13 @@ bool CSettingsManager::OnSettingsLoading()
return true;
}
+void CSettingsManager::OnSettingsUnloaded()
+{
+ CSharedLock lock(m_critical);
+ for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); ++it)
+ (*it)->OnSettingsUnloaded();
+}
+
void CSettingsManager::OnSettingsLoaded()
{
CSharedLock lock(m_critical);
1  xbmc/settings/lib/SettingsManager.h
View
@@ -393,6 +393,7 @@ class CSettingsManager : public ISettingCreator, public ISettingControlCreator,
// implementation of ISettingsHandler
virtual bool OnSettingsLoading();
virtual void OnSettingsLoaded();
+ virtual void OnSettingsUnloaded();
virtual bool OnSettingsSaving() const;
virtual void OnSettingsSaved() const;
virtual void OnSettingsCleared();
45 xbmc/windowing/windows/WinSystemWin32.cpp
View
@@ -26,6 +26,7 @@
#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "utils/log.h"
+#include "utils/CharsetConverter.h"
#ifdef TARGET_WINDOWS
#include <tpcshrd.h>
@@ -356,10 +357,10 @@ RECT CWinSystemWin32::ScreenRect(int screen)
{
const MONITOR_DETAILS &details = GetMonitor(screen);
- DEVMODE sDevMode;
+ DEVMODEW sDevMode;
ZeroMemory(&sDevMode, sizeof(DEVMODE));
sDevMode.dmSize = sizeof(DEVMODE);
- if(!EnumDisplaySettings(details.DeviceName, ENUM_CURRENT_SETTINGS, &sDevMode))
+ if(!EnumDisplaySettingsW(details.DeviceNameW.c_str(), ENUM_CURRENT_SETTINGS, &sDevMode))
CLog::Log(LOGERROR, "%s : EnumDisplaySettings failed with %d", __FUNCTION__, GetLastError());
RECT rc;
@@ -443,12 +444,12 @@ bool CWinSystemWin32::ChangeResolution(RESOLUTION_INFO res)
{
const MONITOR_DETAILS &details = GetMonitor(res.iScreen);
- DEVMODE sDevMode;
+ DEVMODEW sDevMode;
ZeroMemory(&sDevMode, sizeof(DEVMODE));
sDevMode.dmSize = sizeof(DEVMODE);
// If we can't read the current resolution or any detail of the resolution is different than res
- if (!EnumDisplaySettings(details.DeviceName, ENUM_CURRENT_SETTINGS, &sDevMode) ||
+ if (!EnumDisplaySettingsW(details.DeviceNameW.c_str(), ENUM_CURRENT_SETTINGS, &sDevMode) ||
sDevMode.dmPelsWidth != res.iWidth || sDevMode.dmPelsHeight != res.iHeight ||
sDevMode.dmDisplayFrequency != (int)res.fRefreshRate ||
((sDevMode.dmDisplayFlags & DM_INTERLACED) && !(res.dwFlags & D3DPRESENTFLAG_INTERLACED)) ||
@@ -465,7 +466,7 @@ bool CWinSystemWin32::ChangeResolution(RESOLUTION_INFO res)
// CDS_FULLSCREEN is for temporary fullscreen mode and prevents icons and windows from moving
// to fit within the new dimensions of the desktop
- LONG rc = ChangeDisplaySettingsEx(details.DeviceName, &sDevMode, NULL, CDS_FULLSCREEN, NULL);
+ LONG rc = ChangeDisplaySettingsExW(details.DeviceNameW.c_str(), &sDevMode, NULL, CDS_FULLSCREEN, NULL);
if (rc != DISP_CHANGE_SUCCESSFUL)
{
CLog::Log(LOGERROR, "%s : ChangeDisplaySettingsEx failed with %d", __FUNCTION__, rc);
@@ -540,10 +541,10 @@ void CWinSystemWin32::UpdateResolutions()
{
for(int mode = 0;; mode++)
{
- DEVMODE devmode;
+ DEVMODEW devmode;
ZeroMemory(&devmode, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
- if(EnumDisplaySettings(m_MonitorsInfo[monitor].DeviceName, mode, &devmode) == 0)
+ if(EnumDisplaySettingsW(m_MonitorsInfo[monitor].DeviceNameW.c_str(), mode, &devmode) == 0)
break;
if(devmode.dmBitsPerPel != 32)
continue;
@@ -583,25 +584,25 @@ void CWinSystemWin32::AddResolution(const RESOLUTION_INFO &res)
bool CWinSystemWin32::UpdateResolutionsInternal()
{
- DISPLAY_DEVICE ddAdapter;
+ DISPLAY_DEVICEW ddAdapter;
ZeroMemory(&ddAdapter, sizeof(ddAdapter));
ddAdapter.cb = sizeof(ddAdapter);
DWORD adapter = 0;
- while (EnumDisplayDevices(NULL, adapter, &ddAdapter, 0))
+ while (EnumDisplayDevicesW(NULL, adapter, &ddAdapter, 0))
{
// Exclude displays that are not part of the windows desktop. Using them is too different: no windows,
// direct access with GDI CreateDC() or DirectDraw for example. So it may be possible to play video, but GUI?
if (!(ddAdapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) && (ddAdapter.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
{
- DISPLAY_DEVICE ddMon;
+ DISPLAY_DEVICEW ddMon;
ZeroMemory(&ddMon, sizeof(ddMon));
ddMon.cb = sizeof(ddMon);
bool foundScreen = false;
DWORD screen = 0;
// Just look for the first active output, we're actually only interested in the information at the adapter level.
- while (EnumDisplayDevices(ddAdapter.DeviceName, screen, &ddMon, 0))
+ while (EnumDisplayDevicesW(ddAdapter.DeviceName, screen, &ddMon, 0))
{
if (ddMon.StateFlags & (DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED))
{
@@ -615,33 +616,35 @@ bool CWinSystemWin32::UpdateResolutionsInternal()
// Remoting returns no screens. Handle with a dummy screen.
if (!foundScreen && screen == 0)
{
- lstrcpy(ddMon.DeviceString, _T("Dummy Monitor")); // safe: large static array
+ lstrcpyW(ddMon.DeviceString, L"Dummy Monitor"); // safe: large static array
foundScreen = true;
}
if (foundScreen)
{
- CLog::Log(LOGNOTICE, "Found screen: %s on %s, adapter %d.", ddMon.DeviceString, ddAdapter.DeviceString, adapter);
+ std::string monitorStr, adapterStr;
+ g_charsetConverter.wToUTF8(ddMon.DeviceString, monitorStr);
+ g_charsetConverter.wToUTF8(ddAdapter.DeviceString, adapterStr);
+ CLog::Log(LOGNOTICE, "Found screen: %s on %s, adapter %d.", monitorStr.c_str(), adapterStr.c_str(), adapter);
// get information about the display's current position and display mode
// TODO: for Windows 7/Server 2008 and up, Microsoft recommends QueryDisplayConfig() instead, the API used by the control panel.
- DEVMODE dm;
+ DEVMODEW dm;
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
- if (EnumDisplaySettingsEx(ddAdapter.DeviceName, ENUM_CURRENT_SETTINGS, &dm, 0) == FALSE)
- EnumDisplaySettingsEx(ddAdapter.DeviceName, ENUM_REGISTRY_SETTINGS, &dm, 0);
+ if (EnumDisplaySettingsExW(ddAdapter.DeviceName, ENUM_CURRENT_SETTINGS, &dm, 0) == FALSE)
+ EnumDisplaySettingsExW(ddAdapter.DeviceName, ENUM_REGISTRY_SETTINGS, &dm, 0);
// get the monitor handle and workspace
HMONITOR hm = 0;
POINT pt = { dm.dmPosition.x, dm.dmPosition.y };
hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
- MONITOR_DETAILS md;
- memset(&md, 0, sizeof(MONITOR_DETAILS));
+ MONITOR_DETAILS md = {};
- strcpy(md.MonitorName, ddMon.DeviceString);
- strcpy(md.CardName, ddAdapter.DeviceString);
- strcpy(md.DeviceName, ddAdapter.DeviceName);
+ md.MonitorNameW = ddMon.DeviceString;
+ md.CardNameW = ddAdapter.DeviceString;
+ md.DeviceNameW = ddAdapter.DeviceName;
// width x height @ x,y - bpp - refresh rate
// note that refresh rate information is not available on Win9x
7 xbmc/windowing/windows/WinSystemWin32.h
View
@@ -22,6 +22,7 @@
#define WINDOW_SYSTEM_WIN32_H
#include "windowing/WinSystem.h"
+#include <string>
struct MONITOR_DETAILS
{
@@ -33,9 +34,9 @@ struct MONITOR_DETAILS
bool Interlaced;
HMONITOR hMonitor;
- char MonitorName[128];
- char CardName[128];
- char DeviceName[128];
+ std::wstring MonitorNameW;
+ std::wstring CardNameW;
+ std::wstring DeviceNameW;
int ScreenNumber; // XBMC POV, not Windows. Windows primary is XBMC #0, then each secondary is +1.
};
Something went wrong with that request. Please try again.