Skip to content

Commit dc4f8e0

Browse files
authored
Merge pull request #2 from libnativeapi/copilot/fix-769eebe8-4376-465b-ba57-982433f00bba
[Linux] Implement WindowManager class with GTK backend
2 parents 088c3ec + 9c53c70 commit dc4f8e0

File tree

5 files changed

+504
-11
lines changed

5 files changed

+504
-11
lines changed

examples/nswindow_example/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ project(nswindow_example VERSION 0.0.1 LANGUAGES CXX)
66
set(CMAKE_CXX_STANDARD 11)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)
88

9-
# Enable Objective-C++
10-
enable_language(OBJCXX)
9+
# Enable Objective-C++ (macOS only)
10+
if(APPLE)
11+
enable_language(OBJCXX)
12+
endif()
1113

1214
# Add example program
1315
add_executable(nswindow_example

src/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ file(GLOB COMMON_SOURCES "*.cpp")
1919
list(FILTER COMMON_SOURCES EXCLUDE REGEX "platform/*")
2020

2121
# Platform-specific source files
22-
if(LINUX)
22+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2323
file(GLOB PLATFORM_SOURCES "platform/linux/*_linux.cpp")
2424
# Find GTK package for Linux
2525
find_package(PkgConfig REQUIRED)
@@ -49,14 +49,14 @@ target_include_directories(libnativeapi PUBLIC
4949
$<INSTALL_INTERFACE:include>
5050
)
5151

52-
if (LINUX)
52+
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
5353
target_include_directories(libnativeapi PUBLIC ${GTK_INCLUDE_DIRS})
5454
endif ()
5555

5656
# Link required frameworks and libraries
5757
if(APPLE)
5858
target_link_libraries(libnativeapi PUBLIC "-framework Cocoa")
5959
target_compile_options(libnativeapi PRIVATE "-x" "objective-c++")
60-
elseif (LINUX)
60+
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
6161
target_link_libraries(libnativeapi PUBLIC PkgConfig::GTK)
6262
endif ()

src/platform/linux/display_manager_linux.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ static Display CreateDisplayFromGdkMonitor(GdkMonitor* monitor,
1414
GdkRectangle frame;
1515
gdk_monitor_get_geometry(monitor, &frame);
1616

17-
display.width = frame.width;
18-
display.height = frame.height;
17+
display.size.width = frame.width;
18+
display.size.height = frame.height;
19+
display.position.x = frame.x;
20+
display.position.y = frame.y;
1921

2022
GdkRectangle workarea_rect;
2123
gdk_monitor_get_workarea(monitor, &workarea_rect);
2224

23-
display.visibleSizeWidth = workarea_rect.width;
24-
display.visibleSizeHeight = workarea_rect.height;
25-
display.visiblePositionX = workarea_rect.x;
26-
display.visiblePositionY = workarea_rect.y;
25+
display.workArea.width = workarea_rect.width;
26+
display.workArea.height = workarea_rect.height;
27+
display.workArea.x = workarea_rect.x;
28+
display.workArea.y = workarea_rect.y;
2729

2830
display.scaleFactor = gdk_monitor_get_scale_factor(monitor);
2931

0 commit comments

Comments
 (0)