1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unx/salunx.h>
21 #include <unx/salinst.h>
22 #include <unx/saldisp.hxx>
23 #include <unx/x11/x11sys.hxx>
25 #include <vcl/weld.hxx>
29 #include <rtl/ustrbuf.hxx>
30 #include <osl/thread.h>
32 SalSystem
* X11SalInstance::CreateSalSystem()
34 return new X11SalSystem();
37 X11SalSystem::~X11SalSystem()
41 // for the moment only handle xinerama case
42 unsigned int X11SalSystem::GetDisplayScreenCount()
44 SalDisplay
* pSalDisp
= vcl_sal::getSalDisplay(GetGenericUnixSalData());
45 return pSalDisp
->IsXinerama() ? pSalDisp
->GetXineramaScreens().size() :
46 pSalDisp
->GetXScreenCount();
49 bool X11SalSystem::IsUnifiedDisplay()
51 SalDisplay
* pSalDisp
= vcl_sal::getSalDisplay(GetGenericUnixSalData());
52 unsigned int nScreenCount
= pSalDisp
->GetXScreenCount();
53 return pSalDisp
->IsXinerama() || (nScreenCount
== 1);
56 unsigned int X11SalSystem::GetDisplayBuiltInScreen()
58 SalDisplay
* pSalDisp
= vcl_sal::getSalDisplay(GetGenericUnixSalData());
59 return pSalDisp
->GetDefaultXScreen().getXScreen();
62 tools::Rectangle
X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen
)
64 tools::Rectangle aRet
;
65 SalDisplay
* pSalDisp
= vcl_sal::getSalDisplay(GetGenericUnixSalData());
66 if( pSalDisp
->IsXinerama() )
68 const std::vector
< tools::Rectangle
>& rScreens
= pSalDisp
->GetXineramaScreens();
70 // we shouldn't be able to pick a screen > number of screens available
71 assert(nScreen
< rScreens
.size() );
73 if( nScreen
< rScreens
.size() )
74 aRet
= rScreens
[nScreen
];
78 const SalDisplay::ScreenData
& rScreen
=
79 pSalDisp
->getDataForScreen( SalX11Screen( nScreen
) );
80 aRet
= tools::Rectangle( Point( 0, 0 ), rScreen
.m_aSize
);
86 int X11SalSystem::ShowNativeDialog( const OUString
& rTitle
, const OUString
& rMessage
, const std::vector
< OUString
>& rButtons
)
88 ImplSVData
* pSVData
= ImplGetSVData();
89 if( pSVData
->mpIntroWindow
)
90 pSVData
->mpIntroWindow
->Hide();
92 std::unique_ptr
<weld::MessageDialog
> xWarn(Application::CreateMessageDialog(nullptr,
93 VclMessageType::Warning
, VclButtonsType::NONE
,
95 xWarn
->set_title(rTitle
);
97 sal_uInt16 nButton
= 0;
98 for (auto const& button
: rButtons
)
99 xWarn
->add_button(button
, nButton
++);
100 xWarn
->set_default_response(0);
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */