| 1 | # -*- coding: utf-8 -*- |
| 2 | # |
| 3 | # QBrz - Qt frontend to Breezy commands |
| 4 | # Copyright (C) 2013 QBzr Developers |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU General Public License |
| 8 | # as published by the Free Software Foundation; either version 2 |
| 9 | # of the License, or (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | |
| 20 | """Only for Windows.""" |
| 21 | |
| 22 | import ctypes |
| 23 | import platform |
| 24 | |
| 25 | # Internal versions of Microsoft Windows |
| 26 | XP = '5.1' |
| 27 | Vista = '6.0' |
| 28 | Win7 = '6.1' |
| 29 | Win8 = '6.2' |
| 30 | |
| 31 | def is_vista_or_higher(): |
| 32 | win_ver = platform.win32_ver()[1] |
| 33 | if win_ver >= Vista: |
| 34 | return True |
| 35 | else: |
| 36 | return False |
| 37 | |
| 38 | def is_vista_or_win7(): |
| 39 | win_ver = platform.win32_ver()[1] |
| 40 | if win_ver >= Vista and win_ver < Win8: |
| 41 | return True |
| 42 | else: |
| 43 | return False |
| 44 | |
| 45 | def is_win8_or_higher(): |
| 46 | win_ver = platform.win32_ver()[1] |
| 47 | if win_ver >= Win8: |
| 48 | return True |
| 49 | else: |
| 50 | return False |
| 51 | |
| 52 | def is_aero_enabled(): |
| 53 | if not is_vista_or_higher(): |
| 54 | return False |
| 55 | try: |
| 56 | bResult = ctypes.c_int(0) |
| 57 | # DwmIsCompositionEnabled function should tell us whether aero is enabled |
| 58 | ctypes.windll.dwmapi.DwmIsCompositionEnabled(ctypes.byref(bResult)) |
| 59 | return bool(bResult.value) |
| 60 | except Exception as e: # that's really bad, I know, shame on me |
| 61 | print(e) # if we will be there somebody will let me know which exactly error there is |
| 62 | return False |