├── Sources ├── Protocol │ ├── owl-mach-ipc-unstable-v1-mig-types.h │ ├── owl-iosurface-unstable-v1-mig.defs │ ├── owl-mach-ipc-unstable-v1-mig.defs │ ├── owl-iosurface-unstable-v1.xml │ └── owl-mach-ipc-unstable-v1.xml ├── App │ ├── OwlAppDelegate.h │ ├── OwlKnownClientsManager.h │ ├── OwlPreferences.h │ ├── OwlPreferences.m │ ├── OwlAppDelegate.m │ └── OwlKnownClientsManager.m ├── Server │ ├── main.m │ ├── OwlGlobal.h │ ├── OwlCallback.h │ ├── OwlServer.h │ ├── OwlRunLoopSource.h │ ├── OwlCallback.m │ └── OwlRunLoopSource.m ├── Data │ ├── OwlZwlrDataControlDeviceV1.h │ ├── OwlWlDataOffer.h │ ├── OwlWlDataSource.h │ ├── OwlZwlrDataControlOfferV1.h │ ├── OwlZwlrDataControlSourceV1.h │ ├── OwlWlDataDeviceManager.h │ ├── OwlZwlrDataControlManagerV1.h │ ├── OwlDataDevice.m │ ├── OwlPasteboardDataSource.h │ ├── OwlDataDevice.h │ ├── OwlPasteboardType.h │ ├── OwlWlDataDevice.h │ ├── OwlPasteboardDataOffer.h │ ├── OwlPasteboardDataDevice.h │ ├── OwlDataOffer.h │ ├── OwlSelection.h │ ├── OwlDataSource.m │ ├── OwlDataOffer.m │ ├── OwlWlDataOffer.m │ ├── OwlWlDataSource.m │ ├── OwlPasteboardDataSource.m │ ├── OwlZwlrDataControlOfferV1.m │ ├── OwlDataSource.h │ ├── OwlZwlrDataControlSourceV1.m │ ├── OwlPasteboardType.m │ ├── OwlSelection.m │ ├── OwlPasteboardDataOffer.m │ ├── OwlWlDataDeviceManager.m │ ├── OwlZwlrDataControlManagerV1.m │ ├── OwlPasteboardDataDevice.m │ ├── OwlWlDataDevice.m │ └── OwlZwlrDataControlDeviceV1.m ├── Shell │ ├── OwlWlShell.h │ ├── OwlXdgWmBase.h │ ├── OwlZxdgShellV6.h │ ├── OwlWindow.h │ ├── OwlXdgSurface.h │ ├── OwlZxdgSurfaceV6.h │ ├── OwlWindowWrapper.h │ ├── OwlXdgToplevel.h │ ├── OwlZxdgToplevelV6.h │ ├── OwlWlShellSurface.h │ ├── OwlWlShell.m │ ├── OwlWindowWrapper.m │ ├── OwlXdgWmBase.m │ ├── OwlZxdgShellV6.m │ ├── OwlWlShellSurface.m │ ├── OwlXdgSurface.m │ ├── OwlZxdgSurfaceV6.m │ └── OwlWindow.m ├── OwlFeatures.h ├── Compositor │ ├── OwlRegion.h │ ├── OwlCompositor.h │ ├── OwlSubcompositor.h │ ├── OwlShmBuffer.h │ ├── OwlZowlIOSurfaceManagerV1.h │ ├── OwlIOSurfaceBuffer.h │ ├── OwlSubsurface.h │ ├── OwlZowlIOSurfaceV1.h │ ├── OwlSurfaceState.h │ ├── OwlBuffer.h │ ├── OwlRegion.m │ ├── OwlSurfaceState.m │ ├── OwlSurface.h │ ├── OwlCompositor.m │ ├── OwlZowlIOSurfaceManagerV1.m │ ├── OwlBuffer.m │ ├── OwlSubcompositor.m │ ├── OwlIOSurfaceBuffer.m │ ├── OwlSubsurface.m │ ├── OwlZowlIOSurfaceV1.m │ └── OwlShmBuffer.m ├── Seat │ ├── OwlSeat.h │ ├── OwlKeyboard.h │ ├── OwlPointer.h │ ├── OwlSeat.m │ └── OwlPointer.m └── Mach │ ├── OwlZowlMachIpcV1.h │ ├── OwlZowlMachIpcPortV1.h │ ├── OwlMIG.m │ ├── OwlMIG.h │ ├── OwlZowlMachIpcPortV1.m │ └── OwlZowlMachIpcV1.m ├── Resources ├── Owl.icns ├── English.lproj │ └── InfoPlist.strings ├── Owl-Info-gnustep.plist └── Owl-Info.plist ├── .gitignore └── README.md /Sources/Protocol/owl-mach-ipc-unstable-v1-mig-types.h: -------------------------------------------------------------------------------- 1 | typedef const char *secret_t; 2 | -------------------------------------------------------------------------------- /Resources/Owl.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owl-compositor/owl/HEAD/Resources/Owl.icns -------------------------------------------------------------------------------- /Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | build/ 4 | DerivedData 5 | 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | 11 | xcuserdata 12 | -------------------------------------------------------------------------------- /Sources/Protocol/owl-iosurface-unstable-v1-mig.defs: -------------------------------------------------------------------------------- 1 | subsystem owl_iosurface_v1 35422; 2 | 3 | #include 4 | 5 | userprefix owl_iosurface_v1_; 6 | serverprefix owl_iosurface_v1_server_; 7 | 8 | routine set_surface_port( 9 | receiver_port: mach_port_t; 10 | iosurface_port: mach_port_t); 11 | -------------------------------------------------------------------------------- /Resources/Owl-Info-gnustep.plist: -------------------------------------------------------------------------------- 1 | { 2 | ApplicationDescription = "Owl, a Wayland compositor in Objective-C"; 3 | ApplicationName = Owl; 4 | ApplicationRelease = "Owl 0.9"; 5 | NSExecutable = Owl; 6 | NSIcon = "Owl.icns"; 7 | NSMainNibFile = "MainMenu"; 8 | NSPrincipalClass = NSApplication; 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Protocol/owl-mach-ipc-unstable-v1-mig.defs: -------------------------------------------------------------------------------- 1 | subsystem owl_mach_ipc_v1 35421; 2 | 3 | #include 4 | import "owl-mach-ipc-unstable-v1-mig-types.h"; 5 | 6 | userprefix owl_mach_ipc_v1_; 7 | serverprefix owl_mach_ipc_v1_server_; 8 | 9 | type secret_t = c_string[*:80]; 10 | 11 | routine retrieve_port( 12 | server_port: mach_port_t; 13 | secret: secret_t; 14 | out port: mach_port_make_send_t); 15 | -------------------------------------------------------------------------------- /Sources/App/OwlAppDelegate.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | @interface OwlAppDelegate : NSObject 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Server/main.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | int main(int argc, char *argv[]) { 22 | return NSApplicationMain(argc, (const char **) argv); 23 | } 24 | -------------------------------------------------------------------------------- /Sources/Server/OwlGlobal.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | 22 | @protocol OwlGlobal 23 | 24 | + (void) addGlobalToDisplay: (struct wl_display *) display; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlDeviceV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataDevice.h" 20 | #import 21 | 22 | 23 | @interface OwlZwlrDataControlDeviceV1 : OwlDataDevice 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataOffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataOffer.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlWlDataOffer : OwlDataOffer 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataSource.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlWlDataSource : OwlDataSource 25 | @end 26 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlOfferV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataOffer.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlZwlrDataControlOfferV1 : OwlDataOffer 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlSourceV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlZwlrDataControlSourceV1 : OwlDataSource 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Resources/Owl-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Owl 9 | CFBundleIconFile 10 | Owl 11 | CFBundleIdentifier 12 | io.github.bugaevc.Owl 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Owl 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | NSMainNibFile 26 | MainMenu 27 | NSPrincipalClass 28 | NSApplication 29 | 30 | 31 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWlShell.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | @interface OwlWlShell : NSObject { 24 | struct wl_resource *_resource; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Shell/OwlXdgWmBase.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | @interface OwlXdgWmBase : NSObject { 24 | struct wl_resource *_resource; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Shell/OwlZxdgShellV6.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlZxdgShellV6 : NSObject { 25 | struct wl_resource *_resource; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/OwlFeatures.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #ifdef __APPLE__ 20 | #define OWL_PLATFORM_APPLE 21 | #else 22 | #undef OWL_PLATFORM_APPLE 23 | #endif 24 | 25 | #ifdef GS_API_VERSION 26 | #define OWL_PLATFORM_GNUSTEP 27 | #else 28 | #undef OWL_PLATFORM_GNUSTEP 29 | #endif 30 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlRegion.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @interface OwlRegion : NSObject { 23 | struct wl_resource *_resource; 24 | // TODO 25 | } 26 | 27 | - (id) initWithResource: (struct wl_resource *) resource; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Seat/OwlSeat.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlSeat : NSObject { 25 | struct wl_resource *_resource; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlCompositor.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | @interface OwlCompositor : NSObject { 24 | struct wl_resource *_resource; 25 | } 26 | 27 | - (id) initWithResource: (struct wl_resource *) resource; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSubcompositor.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | @interface OwlSubcompositor : NSObject { 24 | struct wl_resource *_resource; 25 | } 26 | 27 | - (id) initWithResource: (struct wl_resource *) resource; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Server/OwlCallback.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @interface OwlCallback : NSObject { 23 | struct wl_resource *_resource; 24 | } 25 | 26 | - (id) initWithResource: (struct wl_resource *) resource; 27 | 28 | - (void) sendDoneWithData: (uint32_t) data; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataDeviceManager.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlWlDataDeviceManager : NSObject { 25 | struct wl_resource *_resource; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlManagerV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlZwlrDataControlManagerV1 : NSObject { 25 | struct wl_resource *_resource; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataDevice.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataDevice.h" 20 | #import "OwlDataSource.h" 21 | #import "OwlSelection.h" 22 | #import 23 | 24 | 25 | @implementation OwlDataDevice 26 | 27 | - (id) initWithResource: (struct wl_resource *) resource { 28 | _resource = resource; 29 | return self; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataSource.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | #import 21 | 22 | // A data source that is backed by pasteboard contents. 23 | @interface OwlPasteboardDataSource : OwlDataSource { 24 | NSPasteboard *_pasteboard; 25 | } 26 | 27 | - (id) initWithPasteboard: (NSPasteboard *) pasteboard; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/App/OwlKnownClientsManager.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | 22 | @interface OwlKnownClientsManager : NSObject { 23 | IBOutlet NSMenu *_clientsMenu; 24 | NSArray *_defaultClients; 25 | NSArray *_clients; 26 | } 27 | 28 | - (IBAction) startClient: (id) sender; 29 | - (IBAction) configureClients: (id) sender; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/Mach/OwlZowlMachIpcV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlGlobal.h" 20 | #import 21 | #import 22 | #import "owl-mach-ipc-unstable-v1.h" 23 | 24 | 25 | @interface OwlZowlMachIpcV1 : NSObject { 26 | struct wl_resource *_resource; 27 | } 28 | 29 | + (BOOL) bootstrapCheckInWithName: (NSString *) name; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/App/OwlPreferences.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | 22 | @interface OwlPreferences : NSObject { 23 | IBOutlet NSButton *_preferSSDButton; 24 | } 25 | 26 | + (OwlPreferences *) sharedPreferences; 27 | 28 | - (IBAction) openPreferencesWindow: (id) sender; 29 | - (IBAction) takePreferSSD: (id) sender; 30 | 31 | - (BOOL) preferSSD; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataDevice.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlSelection; 23 | 24 | 25 | @interface OwlDataDevice : NSObject { 26 | struct wl_resource *_resource; 27 | } 28 | 29 | - (id) initWithResource: (struct wl_resource *) resource; 30 | 31 | - (void) selectionChanged: (OwlSelection *) selection; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlShmBuffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | #import "OwlBuffer.h" 22 | #import "OwlFeatures.h" 23 | 24 | 25 | @interface OwlShmBuffer : OwlBuffer { 26 | struct wl_shm_buffer *_buffer; 27 | 28 | #ifdef OWL_PLATFORM_APPLE 29 | CGImageRef _image; 30 | #else 31 | NSBitmapImageRep *_rep; 32 | #endif 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlZowlIOSurfaceManagerV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import "OwlGlobal.h" 23 | #import 24 | #import 25 | 26 | 27 | @interface OwlZowlIOSurfaceManagerV1 : NSObject { 28 | struct wl_resource *_resource; 29 | } 30 | 31 | @end 32 | 33 | #endif /* OWL_PLATFORM_APPLE */ 34 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardType.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | 22 | @interface OwlPasteboardType : NSObject { 23 | NSString *_mimeType; 24 | NSString *_uti; 25 | } 26 | 27 | - (id) initWithMimeType: (NSString *) mimeType; 28 | - (id) initWithUTI: (NSString *) UTI; 29 | 30 | - (NSString *) mimeType; 31 | - (NSString *) UTI; 32 | 33 | - (BOOL) isText; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Mach/OwlZowlMachIpcPortV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlZowlMachIpcPortV1 : NSObject { 25 | struct wl_resource *_resource; 26 | mach_port_t _port; 27 | } 28 | 29 | - (id) initWithResource: (struct wl_resource *) resource; 30 | 31 | - (void) setPort: (mach_port_t) port; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWindow.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | 22 | @interface OwlWindow : NSWindow { 23 | NSString *_title; 24 | } 25 | 26 | - (id) initWithSize: (NSSize) size displaySSD: (BOOL) displaySSD; 27 | 28 | - (BOOL) displaySSD; 29 | - (void) setDisplaySSD: (BOOL) value; 30 | 31 | - (IBAction) toggleDisplaySSD: (NSMenuItem *) sender; 32 | 33 | - (void) runInteractiveMove; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataDevice.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataDevice.h" 20 | #import 21 | #import 22 | 23 | 24 | @interface OwlWlDataDevice : OwlDataDevice { 25 | NSUInteger _focusCount; 26 | BOOL _selectionHasChangedSinceLastFocused; 27 | } 28 | 29 | + (OwlWlDataDevice *) dataDeviceForClient: (struct wl_client *) client; 30 | 31 | - (void) focused; 32 | - (void) unfocused; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Sources/Server/OwlServer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlRunLoopSource; 23 | 24 | @interface OwlServer : NSObject { 25 | struct wl_display *_display; 26 | OwlRunLoopSource *_runLoopSource; 27 | } 28 | 29 | + (OwlServer *) sharedServer; 30 | 31 | - (uint32_t) nextSerial; 32 | + (uint32_t) timestamp; 33 | 34 | - (void) flushClients; 35 | - (void) flushClientsLater; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Sources/Shell/OwlXdgSurface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import 21 | #import 22 | 23 | @interface OwlXdgSurface : NSObject { 24 | struct wl_resource *_resource; 25 | OwlSurface *_surface; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource 29 | surface: (OwlSurface *) surface; 30 | 31 | - (void) sendConfigure; 32 | 33 | - (NSSize) geometrySizeForBufferSize: (NSSize) size; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Shell/OwlZxdgSurfaceV6.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import 21 | #import 22 | 23 | @interface OwlZxdgSurfaceV6 : NSObject { 24 | struct wl_resource *_resource; 25 | OwlSurface *_surface; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource 29 | surface: (OwlSurface *) surface; 30 | 31 | - (void) sendConfigure; 32 | 33 | - (NSSize) geometrySizeForBufferSize: (NSSize) size; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlIOSurfaceBuffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import "OwlBuffer.h" 23 | #import 24 | #import 25 | 26 | 27 | @interface OwlIOSurfaceBuffer : OwlBuffer { 28 | IOSurfaceRef _surface; 29 | GLuint _tex; 30 | } 31 | 32 | - (id) initWithResource: (struct wl_resource *) resource 33 | surfacePort: (mach_port_t) surfacePort; 34 | 35 | @end 36 | 37 | #endif /* OWL_PLATFORM_APPLE */ 38 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSubsurface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import 21 | #import 22 | 23 | @interface OwlSubsurface : NSObject { 24 | struct wl_resource *_resource; 25 | OwlSurface *_surface; 26 | OwlSurface *_parent; 27 | NSPoint _position; 28 | BOOL _sync; 29 | } 30 | 31 | - (id) initWithResource: (struct wl_resource *) resource 32 | surface: (OwlSurface *) surface 33 | parent: (OwlSurface *) parent; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlZowlIOSurfaceV1.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import 23 | #import 24 | #import 25 | 26 | 27 | @interface OwlZowlIOSurfaceV1 : NSObject { 28 | struct wl_resource *_resource; 29 | mach_port_t _receiverPort; 30 | mach_port_t _surfacePort; 31 | } 32 | 33 | - (id) initWithResource: (struct wl_resource *) resource; 34 | 35 | - (mach_port_t) receiverPort; 36 | 37 | @end 38 | 39 | #endif /* OWL_PLATFORM_APPLE */ 40 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataOffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataOffer.h" 20 | #import 21 | #import 22 | 23 | @class OwlPasteboardDataDevice; 24 | @class OwlDataSource; 25 | 26 | // Data offer to a pasteboard. Serves both as an Owl data offer 27 | // and as a pasteboard "owner". 28 | @interface OwlPasteboardDataOffer : OwlDataOffer { 29 | NSMutableArray *_types; 30 | OwlPasteboardDataDevice *_dataDevice; 31 | } 32 | 33 | - (id) initWithDataDevice: (OwlPasteboardDataDevice *) device 34 | dataSource: (OwlDataSource *) source; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Sources/Mach/OwlMIG.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlMIG.h" 20 | 21 | 22 | @implementation OwlMIG 23 | 24 | + (void) serveOnPort: (mach_port_t) port 25 | usingCallback: (dispatch_mig_callback_t) 26 | callback maxSize: (size_t) maxSize 27 | { 28 | dispatch_source_t source = dispatch_source_create( 29 | DISPATCH_SOURCE_TYPE_MACH_RECV, 30 | port, 31 | 0, 32 | dispatch_get_main_queue() 33 | ); 34 | 35 | dispatch_source_set_event_handler(source, ^{ 36 | dispatch_mig_server(source, maxSize, callback); 37 | }); 38 | dispatch_resume(source); 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Sources/Server/OwlRunLoopSource.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | #import "OwlFeatures.h" 22 | 23 | #ifdef OWL_PLATFORM_GNUSTEP 24 | @interface OwlRunLoopSource : NSObject { 25 | #else 26 | @interface OwlRunLoopSource : NSObject { 27 | #endif 28 | 29 | struct wl_event_loop *_event_loop; 30 | 31 | #ifndef OWL_PLATFORM_GNUSTEP 32 | CFSocketRef _socket; 33 | CFRunLoopSourceRef _source; 34 | #endif 35 | } 36 | 37 | - (id) initWithEventLoop: (struct wl_event_loop *) event_loop; 38 | 39 | - (void) addToRunLoop; 40 | - (void) removeFromRunLoop; 41 | 42 | @end 43 | 44 | -------------------------------------------------------------------------------- /Sources/Seat/OwlKeyboard.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlSurface; 23 | 24 | @interface OwlKeyboard : NSObject { 25 | struct wl_resource *_resource; 26 | } 27 | 28 | - (id) initWithResource: (struct wl_resource *) resource; 29 | 30 | - (struct wl_resource *) resource; 31 | 32 | + (OwlKeyboard *) keyboardForClient: (struct wl_client *) client; 33 | 34 | - (void) sendEnterSurface: (OwlSurface *) surface; 35 | - (void) sendLeaveSurface: (OwlSurface *) surface; 36 | - (void) sendKey: (unsigned short) keyCode isPressed: (BOOL) isPressed; 37 | - (void) sendModifiers: (uint32_t) modifiers; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Sources/Mach/OwlMIG.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | #import 22 | 23 | 24 | 25 | // From source_private.h 26 | 27 | typedef boolean_t (*dispatch_mig_callback_t)( 28 | mach_msg_header_t *message, 29 | mach_msg_header_t *reply 30 | ); 31 | 32 | extern mach_msg_return_t dispatch_mig_server( 33 | dispatch_source_t source, 34 | size_t max_message_size, 35 | dispatch_mig_callback_t callback 36 | ); 37 | 38 | 39 | @interface OwlMIG : NSObject 40 | 41 | + (void) serveOnPort: (mach_port_t) port 42 | usingCallback: (dispatch_mig_callback_t) callback 43 | maxSize: (size_t) maxSize; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWindowWrapper.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import "OwlWindow.h" 21 | 22 | @interface OwlWindowWrapper : NSObject { 23 | NSString *_title; 24 | OwlWindow *_window; 25 | NSView *_view; 26 | NSSize _size; 27 | id _windowDelegate; 28 | } 29 | 30 | - (OwlWindow *) window; 31 | 32 | - (void) map; 33 | - (void) unmap; 34 | - (void) close; 35 | 36 | - (void) minimize; 37 | - (void) maximize; 38 | - (void) unmaximize; 39 | 40 | - (void) setContentSize: (NSSize) size; 41 | - (void) setTitle: (NSString *) title; 42 | - (void) setView: (NSView *) view; 43 | - (void) setWindowDelegate: (id) delegate; 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Sources/Shell/OwlXdgToplevel.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import "OwlWindowWrapper.h" 21 | #import 22 | #import 23 | 24 | @class OwlXdgSurface; 25 | 26 | @interface OwlXdgToplevel : NSObject { 27 | struct wl_resource *_resource; 28 | OwlSurface *_surface; 29 | OwlXdgSurface *_xdgSurface; 30 | BOOL _configured; 31 | BOOL _activated, _fullscreen, _resizing, _maximized; 32 | OwlWindowWrapper *_window; 33 | } 34 | 35 | - (id) initWithResource: (struct wl_resource *) resource 36 | surface: (OwlSurface *) surface 37 | xdgSurface: (OwlXdgSurface *) xdgSurface; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Sources/Shell/OwlZxdgToplevelV6.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import "OwlWindowWrapper.h" 21 | #import 22 | #import 23 | 24 | @class OwlZxdgSurfaceV6; 25 | 26 | @interface OwlZxdgToplevelV6 : NSObject { 27 | struct wl_resource *_resource; 28 | OwlSurface *_surface; 29 | OwlZxdgSurfaceV6 *_xdgSurface; 30 | BOOL _configured; 31 | BOOL _activated, _fullscreen, _resizing, _maximized; 32 | OwlWindowWrapper *_window; 33 | } 34 | 35 | - (id) initWithResource: (struct wl_resource *) resource 36 | surface: (OwlSurface *) surface 37 | xdgSurface: (OwlZxdgSurfaceV6 *) xdgSurface; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Owl 2 | 3 | Owl is a portable [Wayland] compositor written in Objective-C, using Cocoa as 4 | its backend. Owl primarily targets Mac OS X, but also supports a variety of 5 | other operating systems thanks to [GNUstep]. 6 | 7 | [Wayland]: https://wayland.freedesktop.org/ 8 | [GNUstep]: http://www.gnustep.org/ 9 | 10 | Owl makes it possible to run Wayland clients inside OS X's native Quartz 11 | graphics environment. In that sense, Owl plays a role similar to the [XQuartz] 12 | and [XWayland] compatibility layers. 13 | 14 | [XQuartz]: https://www.xquartz.org/ 15 | [XWayland]: https://wayland.freedesktop.org/xserver.html 16 | 17 | # Work in progress 18 | 19 | Owl is a work in progress. Some things work, many don't. There's a lot to 20 | improve and figure out! 21 | 22 | # Building 23 | 24 | First, make sure you have Wayland installed. Please see the other repositories 25 | in [this GitHub organization] for ports of Wayland and related software to 26 | systems that they don't normally support. 27 | 28 | [this GitHub organization]: https://github.com/owl-compositor 29 | 30 | To build Owl, create a build directory, then run `configure`, then `make`: 31 | 32 | ``` 33 | $ mkdir build 34 | $ cd build 35 | $ ../configure 36 | Owl root directory detected as .. 37 | $ make 38 | ``` 39 | 40 | If the build succeeds, you should find `Owl.app` in the build directory. 41 | 42 | # License 43 | 44 | Owl is free software, available under the GNU General Public License version 3 45 | or later. 46 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataDevice.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataDevice.h" 20 | #import 21 | 22 | @class OwlSelection; 23 | @class OwlPasteboardDataOffer; 24 | 25 | // Data device that is backed by a pasteboard, not a Wayland client. 26 | @interface OwlPasteboardDataDevice : OwlDataDevice { 27 | NSPasteboard *_pasteboard; 28 | OwlSelection *_selection; 29 | OwlPasteboardDataOffer *_currentOffer; 30 | BOOL _ignoreRefreshes; 31 | } 32 | 33 | - (id) initWithPasteboard: (NSPasteboard *) pasteboard 34 | selection: (OwlSelection *) selection; 35 | 36 | - (NSPasteboard *) pasteboard; 37 | 38 | // Notify this data device that the pasteboard may have been refreshed. 39 | - (void) pasteboardRefreshed; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSurfaceState.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | 21 | @class OwlBuffer; 22 | @class OwlCallback; 23 | 24 | @interface OwlSurfaceState : NSObject { 25 | OwlBuffer *_buffer; 26 | // TODO: dx, dy 27 | NSMutableArray *_callbacks; 28 | NSMutableArray *_damage; 29 | NSRect _geometry; 30 | } 31 | 32 | - (id) init; 33 | - (id) initWithPreviousState: (OwlSurfaceState *) previousState; 34 | 35 | - (OwlBuffer *) buffer; 36 | - (void) setBuffer: (OwlBuffer *) buffer; 37 | 38 | - (NSArray *) callbacks; 39 | - (void) addCallback: (OwlCallback *) callback; 40 | 41 | - (NSArray *) damage; 42 | - (void) addDamage: (NSRect) damageRect; 43 | 44 | - (NSRect) geometry; 45 | - (void) setGeometry: (NSRect) geometry; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlBuffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | 23 | @interface OwlBuffer : NSObject { 24 | struct wl_resource *_resource; 25 | } 26 | 27 | - (id) initWithResource: (struct wl_resource *) resource; 28 | - (id) initWithExternallyImplementedResource: (struct wl_resource *) resource; 29 | 30 | + (OwlBuffer *) bufferForResource: (struct wl_resource *) resource; 31 | 32 | // Must be called after creating a buffer before calling any of the methods 33 | // below, as well as each time the buffer contents are known to change. 34 | - (void) invalidate; 35 | 36 | - (NSSize) size; 37 | 38 | - (BOOL) needsGLForRendering; 39 | - (void) drawInRect: (NSRect) rect; 40 | 41 | - (void) sendRelease; 42 | - (void) notifyDetached; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Sources/Server/OwlCallback.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlCallback.h" 20 | #import 21 | 22 | @implementation OwlCallback 23 | 24 | static void callback_destroy(struct wl_resource *resource) { 25 | OwlCallback *self = wl_resource_get_user_data(resource); 26 | [self release]; 27 | } 28 | 29 | - (id) initWithResource: (struct wl_resource *) resource { 30 | _resource = resource; 31 | wl_resource_set_implementation( 32 | resource, 33 | NULL, 34 | [self retain], 35 | callback_destroy 36 | ); 37 | return self; 38 | } 39 | 40 | - (void) sendDoneWithData: (uint32_t) data { 41 | wl_callback_send_done(_resource, data); 42 | // Sending a callback also implicitly destroys it. 43 | wl_resource_destroy(_resource); 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWlShellSurface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurface.h" 20 | #import "OwlWindowWrapper.h" 21 | #import 22 | #import 23 | 24 | enum OwlWlShellSurfaceMode { 25 | OWL_WL_SHELL_SURFACE_MODE_NONE = 0, 26 | OWL_WL_SHELL_SURFACE_MODE_TOPLEVEL, 27 | OWL_WL_SHELL_SURFACE_MODE_TRANSIENT, 28 | OWL_WL_SHELL_SURFACE_MODE_FULLSCREEN, 29 | OWL_WL_SHELL_SURFACE_MODE_POPUP, 30 | OWL_WL_SHELL_SURFACE_MODE_MAXIMIZED 31 | }; 32 | 33 | @interface OwlWlShellSurface : NSObject { 34 | struct wl_resource *_resource; 35 | OwlSurface *_surface; 36 | OwlWindowWrapper *_window; 37 | enum OwlWlShellSurfaceMode _mode; 38 | } 39 | 40 | - (id) initWithResource: (struct wl_resource *) resource 41 | surface: (OwlSurface *) surface; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Sources/Seat/OwlPointer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlSurface; 23 | 24 | // These come from linux/event.h 25 | 26 | #define BTN_LEFT 0x100 27 | #define BTN_RIGHT 0x111 28 | #define BTN_MIDDLE 0x112 29 | 30 | 31 | @interface OwlPointer : NSObject { 32 | struct wl_resource *_resource; 33 | } 34 | 35 | - (id) initWithResource: (struct wl_resource *) resource; 36 | 37 | + (OwlPointer *) pointerForClient: (struct wl_client *) client; 38 | 39 | - (void) sendEnterSurface: (OwlSurface *) surface atPoint: (NSPoint) point; 40 | - (void) sendMotionAtPoint: (NSPoint) point; 41 | - (void) sendLeaveSurface: (OwlSurface *) surface; 42 | - (void) sendScrollByX: (CGFloat) deltaX byY: (CGFloat) deltaY; 43 | - (void) sendButton: (uint32_t) button isPressed: (BOOL) isPressed; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Sources/App/OwlPreferences.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPreferences.h" 20 | 21 | 22 | @implementation OwlPreferences 23 | 24 | static OwlPreferences *shared; 25 | 26 | - (void) awakeFromNib { 27 | shared = self; 28 | } 29 | 30 | + (OwlPreferences *) sharedPreferences { 31 | return shared; 32 | } 33 | 34 | - (IBAction) openPreferencesWindow: (id) sender { 35 | [NSBundle loadNibNamed: @"OwlPreferences" owner: self]; 36 | [_preferSSDButton setState: [self preferSSD]]; 37 | } 38 | 39 | - (IBAction) takePreferSSD: (id) sender { 40 | BOOL preferSSD = [sender state]; 41 | [[NSUserDefaults standardUserDefaults] setBool: preferSSD 42 | forKey: @"PreferSSD"]; 43 | } 44 | 45 | - (BOOL) preferSSD { 46 | return [[NSUserDefaults standardUserDefaults] boolForKey: @"PreferSSD"]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Sources/App/OwlAppDelegate.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlAppDelegate.h" 20 | #import "OwlServer.h" 21 | 22 | @implementation OwlAppDelegate 23 | 24 | - (void) applicationDidFinishLaunching: (NSNotification *) notification { 25 | // Instantiate the server. If sucessful, this will 26 | // automatically start serving the clients. 27 | OwlServer *server = [OwlServer sharedServer]; 28 | if (server == nil) { 29 | // It should have already displayed an error message, 30 | // so we just to have to exit. We call exit() directly 31 | // instead of using -[NSApp terminate:] in order to 32 | // have it return the non-zero exit code. We should 33 | // not have any unsaved documents anyway. 34 | exit(1); 35 | } 36 | } 37 | 38 | - (void) applicationWillBecomeActive: (NSNotification *) notification { 39 | // Force the pasteboard to reload its contents. 40 | [[NSPasteboard generalPasteboard] types]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataOffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | #import 21 | #import 22 | 23 | // Data offers are sent to clients to represent a data source that they 24 | // can request data from. There can be multiple data offers representing 25 | // one data source (typically, one per data device). 26 | // 27 | // A data offer and the data source it represents need not use the same 28 | // protocol: a client can ask to recevive data from a data offer using 29 | // one protocol, and Owl will ask the backing client to send the data for 30 | // the data source using another one. 31 | @interface OwlDataOffer : NSObject { 32 | struct wl_resource *_resource; 33 | OwlDataSource *_dataSource; 34 | } 35 | 36 | - (id) initWithResource: (struct wl_resource *) resource 37 | dataSource: (OwlDataSource *) dataSource; 38 | 39 | - (struct wl_resource *) resource; 40 | 41 | - (void) receiveContentOfMimeType: (const char *) mime_type 42 | intoFileDescriptor: (int) fd; 43 | 44 | // Subclasses should override this. 45 | - (void) addMimeType: (NSString *) mimeType; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Sources/Data/OwlSelection.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | #import "OwlFeatures.h" 21 | #import 22 | 23 | @class OwlDataDevice; 24 | 25 | // A selection represents a "place" or a "slot" where data can be copied to 26 | // and pasted from. One selection can only hold one data source at a time. 27 | // 28 | // There's a single global selection that represents the system clipboard. 29 | // On GNUstep, there's additionally the primary selection. 30 | @interface OwlSelection : NSObject { 31 | OwlDataSource *_dataSource; 32 | NSMutableArray *_dataDevices; 33 | } 34 | 35 | + (OwlSelection *) clipboard; 36 | #ifdef OWL_PLATFORM_GNUSTEP 37 | + (OwlSelection *) primary; 38 | #endif 39 | 40 | // Get and set the contents of the selction, as a data source. 41 | - (OwlDataSource *) dataSource; 42 | - (void) setDataSource: (OwlDataSource *) dataSource; 43 | 44 | // Subscribe and unsubscribe data devices. 45 | // OwlSelection will call -selectionChanged: on the registered data devices. 46 | - (void) addDataDevice: (OwlDataDevice *) dataDevice; 47 | - (void) removeDataDevice: (OwlDataDevice *) dataDevice; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataSource.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataSource.h" 20 | 21 | 22 | @implementation OwlDataSource 23 | 24 | - (id) initWithResource: (struct wl_resource *) resource { 25 | _resource = resource; 26 | _mimeTypes = [NSMutableArray new]; 27 | _holders = [NSMutableArray new]; 28 | return self; 29 | } 30 | 31 | - (void) dealloc { 32 | [_mimeTypes release]; 33 | [_holders release]; 34 | [super dealloc]; 35 | } 36 | 37 | - (NSArray *) mimeTypes { 38 | return _mimeTypes; 39 | } 40 | 41 | - (void) addHolder: (id) holder { 42 | NSValue *value = [NSValue valueWithNonretainedObject: holder]; 43 | [_holders addObject: value]; 44 | } 45 | 46 | - (void) removeHolder: (id) holder { 47 | NSValue *value = [NSValue valueWithNonretainedObject: holder]; 48 | [_holders removeObject: value]; 49 | } 50 | 51 | // Ask all holders to release their references to this data source. 52 | - (void) releaseFromHolders { 53 | for (NSValue *value in _holders) { 54 | id holder = [value nonretainedObjectValue]; 55 | [holder releaseDataSource: self]; 56 | } 57 | [_holders removeAllObjects]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataOffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlDataOffer.h" 20 | #import "OwlDataSource.h" 21 | #import 22 | 23 | 24 | @implementation OwlDataOffer 25 | 26 | - (id) initWithResource: (struct wl_resource *) resource 27 | dataSource: (OwlDataSource *) source 28 | { 29 | _resource = resource; 30 | _dataSource = [source retain]; 31 | [source addHolder: self]; 32 | for (NSString *mimeType in [source mimeTypes]) { 33 | [self addMimeType: mimeType]; 34 | } 35 | return self; 36 | } 37 | 38 | - (struct wl_resource *) resource { 39 | return _resource; 40 | } 41 | 42 | - (void) dealloc { 43 | [_dataSource removeHolder: self]; 44 | [_dataSource release]; 45 | [super dealloc]; 46 | } 47 | 48 | - (void) receiveContentOfMimeType: (const char *) mime_type 49 | intoFileDescriptor: (int) fd 50 | { 51 | NSFileHandle *fileHandle = [[NSFileHandle alloc] initWithFileDescriptor: fd]; 52 | NSString *mimeType = [NSString stringWithUTF8String: mime_type]; 53 | 54 | [_dataSource sendContentOfMimeType: mimeType toFileHandle: fileHandle]; 55 | 56 | // Make sure not to delay closing the file. 57 | [fileHandle closeFile]; 58 | [fileHandle release]; 59 | } 60 | 61 | - (void) releaseDataSource: (OwlDataSource *) source { 62 | [_dataSource release]; 63 | _dataSource = nil; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlRegion.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlRegion.h" 20 | #import 21 | 22 | @implementation OwlRegion 23 | 24 | static void region_destroy(struct wl_resource *resource) { 25 | OwlRegion *self = wl_resource_get_user_data(resource); 26 | [self release]; 27 | } 28 | 29 | static void region_destroy_handler( 30 | struct wl_client *client, 31 | struct wl_resource *resource 32 | ) { 33 | wl_resource_destroy(resource); 34 | } 35 | 36 | static void region_add_handler( 37 | struct wl_client *client, 38 | struct wl_resource *resource, 39 | int32_t x, 40 | int32_t y, 41 | int32_t width, 42 | int32_t height 43 | ) { 44 | // TODO 45 | } 46 | 47 | static void region_subtract_handler( 48 | struct wl_client *client, 49 | struct wl_resource *resource, 50 | int32_t x, 51 | int32_t y, 52 | int32_t width, 53 | int32_t height 54 | ) { 55 | // TODO 56 | } 57 | 58 | static const struct wl_region_interface region_impl = { 59 | .destroy = region_destroy_handler, 60 | .add = region_add_handler, 61 | .subtract = region_subtract_handler 62 | }; 63 | 64 | 65 | - (id) initWithResource: (struct wl_resource *) resource { 66 | _resource = resource; 67 | wl_resource_set_implementation( 68 | resource, 69 | ®ion_impl, 70 | [self retain], 71 | region_destroy 72 | ); 73 | return self; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSurfaceState.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSurfaceState.h" 20 | #import "OwlBuffer.h" 21 | 22 | 23 | @implementation OwlSurfaceState 24 | 25 | - (id) init { 26 | _callbacks = [NSMutableArray new]; 27 | _damage = [NSMutableArray new]; 28 | return self; 29 | } 30 | 31 | // Make a new state to succeed the given previous state. 32 | // 33 | // This copies over parts of the previous state that should 34 | // be copied over, namely the attached buffer and geometry, 35 | // and initializes other state to empty values. 36 | - (id) initWithPreviousState: (OwlSurfaceState *) previousState { 37 | self = [self init]; 38 | _buffer = [previousState->_buffer retain]; 39 | _geometry = previousState->_geometry; 40 | return self; 41 | } 42 | 43 | - (void) dealloc { 44 | [_buffer release]; 45 | [_callbacks release]; 46 | [_damage release]; 47 | [super dealloc]; 48 | } 49 | 50 | - (OwlBuffer *) buffer { 51 | return _buffer; 52 | } 53 | 54 | - (void) setBuffer: (OwlBuffer *) buffer { 55 | [buffer retain]; 56 | [_buffer release]; 57 | _buffer = buffer; 58 | } 59 | 60 | - (NSArray *) callbacks { 61 | return _callbacks; 62 | } 63 | 64 | - (void) addCallback: (OwlCallback *) callback { 65 | [_callbacks addObject: callback]; 66 | } 67 | 68 | - (NSArray *) damage { 69 | return _damage; 70 | } 71 | 72 | - (void) addDamage: (NSRect) damageRect { 73 | NSValue *value = [NSValue valueWithRect: damageRect]; 74 | [_damage addObject: value]; 75 | } 76 | 77 | - (NSRect) geometry { 78 | return _geometry; 79 | } 80 | 81 | - (void) setGeometry: (NSRect) geometry { 82 | _geometry = geometry; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataOffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlDataOffer.h" 20 | 21 | 22 | @implementation OwlWlDataOffer 23 | 24 | static void data_offer_destroy(struct wl_resource *resource) { 25 | OwlWlDataOffer *self = wl_resource_get_user_data(resource); 26 | [self release]; 27 | } 28 | 29 | static void data_offer_destroy_handler( 30 | struct wl_client *client, 31 | struct wl_resource *resource 32 | ) { 33 | wl_resource_destroy(resource); 34 | } 35 | 36 | static void data_offer_accept( 37 | struct wl_client *client, 38 | struct wl_resource *resource, 39 | uint32_t serial, 40 | const char *mime_type 41 | ) { 42 | // TODO 43 | } 44 | 45 | static void data_offer_receive_handler( 46 | struct wl_client *client, 47 | struct wl_resource *resource, 48 | const char *mime_type, 49 | int fd 50 | ) { 51 | OwlWlDataOffer *self = wl_resource_get_user_data(resource); 52 | [self receiveContentOfMimeType: mime_type intoFileDescriptor: fd]; 53 | } 54 | 55 | static const struct wl_data_offer_interface data_offer_impl = { 56 | .destroy = data_offer_destroy_handler, 57 | .receive = data_offer_receive_handler 58 | }; 59 | 60 | - (id) initWithResource: (struct wl_resource *) resource 61 | dataSource: (OwlDataSource *) source 62 | { 63 | self = [super initWithResource: resource dataSource: source]; 64 | wl_resource_set_implementation( 65 | resource, 66 | &data_offer_impl, 67 | [self retain], 68 | data_offer_destroy 69 | ); 70 | return self; 71 | } 72 | 73 | - (void) addMimeType: (NSString *) mimeType { 74 | wl_data_offer_send_offer(_resource, [mimeType UTF8String]); 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataSource.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlDataSource.h" 20 | 21 | 22 | @implementation OwlWlDataSource 23 | 24 | static void data_source_destroy(struct wl_resource *resource) { 25 | OwlWlDataSource *self = wl_resource_get_user_data(resource); 26 | [self releaseFromHolders]; 27 | [self release]; 28 | } 29 | 30 | static void data_source_destroy_handler( 31 | struct wl_client *client, 32 | struct wl_resource *resource 33 | ) { 34 | wl_resource_destroy(resource); 35 | } 36 | 37 | static void data_source_offer_handler( 38 | struct wl_client *client, 39 | struct wl_resource *resource, 40 | const char *mime_type 41 | ) { 42 | OwlWlDataSource *self = wl_resource_get_user_data(resource); 43 | [self->_mimeTypes addObject: [NSString stringWithUTF8String: mime_type]]; 44 | } 45 | 46 | static const struct wl_data_source_interface data_source_impl = { 47 | .destroy = data_source_destroy_handler, 48 | .offer = data_source_offer_handler 49 | }; 50 | 51 | - (id) initWithResource: (struct wl_resource *) resource { 52 | self = [super initWithResource: resource]; 53 | wl_resource_set_implementation( 54 | resource, 55 | &data_source_impl, 56 | [self retain], 57 | data_source_destroy 58 | ); 59 | return self; 60 | } 61 | 62 | - (void) sendContentOfMimeType: (NSString *) mimeType 63 | toFileHandle: (NSFileHandle *) fileHandle 64 | { 65 | wl_data_source_send_send( 66 | _resource, 67 | [mimeType UTF8String], 68 | [fileHandle fileDescriptor] 69 | ); 70 | } 71 | 72 | - (void) sendCancelled { 73 | wl_data_source_send_cancelled(_resource); 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataSource.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPasteboardDataSource.h" 20 | #import "OwlPasteboardType.h" 21 | #import 22 | 23 | 24 | @implementation OwlPasteboardDataSource 25 | 26 | - (id) initWithPasteboard: (NSPasteboard *) pboard { 27 | self = [super initWithResource: NULL]; 28 | _pasteboard = [pboard retain]; 29 | 30 | // Make a copy of the types array first. 31 | // Otherwise we run into a crash on GNUstep 32 | // while trying to use NSFastEnumeration 33 | // with distributed objects. 34 | NSArray *types = [NSArray arrayWithArray: [pboard types]]; 35 | for (NSString *uti in types) { 36 | OwlPasteboardType *type = [[OwlPasteboardType alloc] initWithUTI: uti]; 37 | NSString *mimeType = [type mimeType]; 38 | if (mimeType != nil) { 39 | [_mimeTypes addObject: mimeType]; 40 | } 41 | [type release]; 42 | } 43 | 44 | return self; 45 | } 46 | 47 | - (void) dealloc { 48 | [_pasteboard release]; 49 | [super dealloc]; 50 | } 51 | 52 | - (void) sendContentOfMimeType: (NSString *) mimeType 53 | toFileHandle: (NSFileHandle *) fileHandle 54 | { 55 | OwlPasteboardType *type = [[OwlPasteboardType alloc] initWithMimeType: mimeType]; 56 | NSData *data; 57 | NSString *uti = [type UTI]; 58 | if ([type isText]) { 59 | NSString *s = [_pasteboard stringForType: uti]; 60 | data = [s dataUsingEncoding: NSUTF8StringEncoding]; 61 | } else { 62 | data = [_pasteboard dataForType: uti]; 63 | } 64 | [type release]; 65 | [fileHandle writeData: data]; 66 | } 67 | 68 | - (void) sendCancelled { 69 | // Do nothing. 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlOfferV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZwlrDataControlOfferV1.h" 20 | #import "wlr-data-control-unstable-v1.h" 21 | #import 22 | 23 | 24 | @implementation OwlZwlrDataControlOfferV1 25 | 26 | static void data_control_offer_destroy(struct wl_resource *resource) { 27 | OwlZwlrDataControlOfferV1 *self = wl_resource_get_user_data(resource); 28 | [self release]; 29 | } 30 | 31 | static void data_control_offer_destroy_handler( 32 | struct wl_client *client, 33 | struct wl_resource *resource 34 | ) { 35 | wl_resource_destroy(resource); 36 | } 37 | 38 | static void data_control_offer_receive_handler( 39 | struct wl_client *client, 40 | struct wl_resource *resource, 41 | const char *mime_type, 42 | int fd 43 | ) { 44 | OwlZwlrDataControlOfferV1 *self = wl_resource_get_user_data(resource); 45 | [self receiveContentOfMimeType: mime_type intoFileDescriptor: fd]; 46 | } 47 | 48 | static const struct zwlr_data_control_offer_v1_interface data_control_offer_impl = { 49 | .destroy = data_control_offer_destroy_handler, 50 | .receive = data_control_offer_receive_handler 51 | }; 52 | 53 | - (id) initWithResource: (struct wl_resource *) resource 54 | dataSource: (OwlDataSource *) source 55 | { 56 | self = [super initWithResource: resource dataSource: source]; 57 | wl_resource_set_implementation( 58 | resource, 59 | &data_control_offer_impl, 60 | [self retain], 61 | data_control_offer_destroy 62 | ); 63 | return self; 64 | } 65 | 66 | - (void) addMimeType: (NSString *) mimeType { 67 | zwlr_data_control_offer_v1_send_offer(_resource, [mimeType UTF8String]); 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Sources/Data/OwlDataSource.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlDataSource; 23 | 24 | // Something that keeps a reference to a data source. 25 | // 26 | // A data source can conceptually die at any moment, but the object 27 | // can only be deallocated once all the references to it are gone. 28 | // To make this work, data sources notify the interested parties of their 29 | // death, asking them to drop their reference. Once they all do, the data 30 | // source gets deallocated. 31 | // 32 | // In addition to implementing -releaseDataSource:, data source holders 33 | // should call -addHolder: and -removeHolder: as appropriate, to help the 34 | // data source maintain an up-to-date list of its holders. 35 | @protocol OwlDataSourceHolder 36 | - (void) releaseDataSource: (OwlDataSource *) source; 37 | @end 38 | 39 | 40 | // A data source represents a lazily-received piece of data, perhaps 41 | // available in several formats, such as plain and rich text. 42 | // 43 | // Typically, it's a client that actually has the data represented by a 44 | // data source. 45 | @interface OwlDataSource : NSObject { 46 | struct wl_resource *_resource; 47 | NSMutableArray *_mimeTypes; 48 | NSMutableArray *_holders; 49 | } 50 | 51 | - (id) initWithResource: (struct wl_resource *) resource; 52 | 53 | - (NSArray *) mimeTypes; 54 | 55 | // Data source holder management. 56 | - (void) addHolder: (id) holder; 57 | - (void) removeHolder: (id) holder; 58 | - (void) releaseFromHolders; 59 | 60 | // Subclasses should override these. 61 | - (void) sendContentOfMimeType: (NSString *) mimeType 62 | toFileHandle: (NSFileHandle *) fileHandle; 63 | - (void) sendCancelled; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSurface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @class OwlBuffer; 23 | @class OwlSurfaceState; 24 | 25 | @protocol OwlSurfaceRole 26 | 27 | - (void) map; 28 | - (void) unmap; 29 | - (void) update; 30 | 31 | @end 32 | 33 | @interface OwlSurface : NSView { 34 | struct wl_resource *_resource; 35 | NSOpenGLContext *_openGLContext; 36 | 37 | // Mouse tracking rectangle. 38 | NSTrackingRectTag _trackingRectTag; 39 | // Sadly, we cannot trust Cocoa to always deliver us 40 | // -mouseEntered: before -mouseMoved:, so keep our 41 | // own track of whether we think the mouse is inside. 42 | BOOL _mouseIsInside; 43 | 44 | // Callbacks to be sent when we draw a frame. 45 | // These are first collected as a part of a pending 46 | // state, and added to this array on a commit. Once 47 | // added, the callbacks stay in this array no matter 48 | // further state changes and commits, only to be sent 49 | // out during the next -drawRect: call. 50 | NSMutableArray *_callbacks; 51 | 52 | // The current state of this surface. This includes 53 | // things such as the attached buffer and an array 54 | // of damaged rects (compared to the previous frame). 55 | OwlSurfaceState *_currentState; 56 | // As the surface state in Wayland is double-buffered, 57 | // we store the pending state separately while it is 58 | // being built. This will become the new current state 59 | // on the next commit. 60 | OwlSurfaceState *_pendingState; 61 | id _role; 62 | } 63 | 64 | - (id) initWithResource: (struct wl_resource *) resource; 65 | 66 | - (struct wl_resource *) resource; 67 | 68 | - (id) role; 69 | - (void) setRole: (id) newRole; 70 | 71 | - (void) setPendingGeometry: (NSRect) geometry; 72 | 73 | - (NSSize) geometrySizeAdjustements; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlSourceV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZwlrDataControlSourceV1.h" 20 | #import 21 | #import "wlr-data-control-unstable-v1.h" 22 | 23 | 24 | @implementation OwlZwlrDataControlSourceV1 25 | 26 | static void data_control_source_destroy(struct wl_resource *resource) { 27 | OwlZwlrDataControlSourceV1 *self = wl_resource_get_user_data(resource); 28 | [self releaseFromHolders]; 29 | [self release]; 30 | } 31 | 32 | static void data_control_source_destroy_handler( 33 | struct wl_client *client, 34 | struct wl_resource *resource 35 | ) { 36 | wl_resource_destroy(resource); 37 | } 38 | 39 | static void data_control_source_offer_handler( 40 | struct wl_client *client, 41 | struct wl_resource *resource, 42 | const char *mime_type 43 | ) { 44 | OwlZwlrDataControlSourceV1 *self = wl_resource_get_user_data(resource); 45 | [self->_mimeTypes addObject: [NSString stringWithUTF8String: mime_type]]; 46 | } 47 | 48 | static const struct zwlr_data_control_source_v1_interface data_control_source_impl = { 49 | .destroy = data_control_source_destroy_handler, 50 | .offer = data_control_source_offer_handler 51 | }; 52 | 53 | - (id) initWithResource: (struct wl_resource *) resource { 54 | self = [super initWithResource: resource]; 55 | wl_resource_set_implementation( 56 | resource, 57 | &data_control_source_impl, 58 | [self retain], 59 | data_control_source_destroy 60 | ); 61 | return self; 62 | } 63 | 64 | - (void) sendContentOfMimeType: (NSString *) mimeType 65 | toFileHandle: (NSFileHandle *) fileHandle 66 | { 67 | zwlr_data_control_source_v1_send_send( 68 | _resource, 69 | [mimeType UTF8String], 70 | [fileHandle fileDescriptor] 71 | ); 72 | } 73 | 74 | - (void) sendCancelled { 75 | zwlr_data_control_source_v1_send_cancelled(_resource); 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWlShell.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlShell.h" 20 | #import 21 | #import "OwlSurface.h" 22 | #import "OwlWlShellSurface.h" 23 | 24 | @implementation OwlWlShell 25 | 26 | static void shell_get_shell_surface_handler( 27 | struct wl_client *client, 28 | struct wl_resource *resource, 29 | uint32_t id, 30 | struct wl_resource *surface_resource 31 | ) { 32 | struct wl_resource *shell_surface_resource = wl_resource_create( 33 | client, 34 | &wl_shell_surface_interface, 35 | 1, 36 | id 37 | ); 38 | 39 | OwlSurface *surface = wl_resource_get_user_data(surface_resource); 40 | [[[OwlWlShellSurface alloc] initWithResource: shell_surface_resource 41 | surface: surface] release]; 42 | } 43 | 44 | static const struct wl_shell_interface shell_impl = { 45 | .get_shell_surface = shell_get_shell_surface_handler 46 | }; 47 | 48 | static void wl_shell_destroy(struct wl_resource *resource) { 49 | OwlWlShell *self = wl_resource_get_user_data(resource); 50 | [self release]; 51 | } 52 | 53 | - (id) initWithResource: (struct wl_resource *) resource { 54 | _resource = resource; 55 | wl_resource_set_implementation( 56 | resource, 57 | &shell_impl, 58 | [self retain], 59 | wl_shell_destroy 60 | ); 61 | return self; 62 | } 63 | 64 | static void shell_bind( 65 | struct wl_client *client, 66 | void *data, 67 | uint32_t version, 68 | uint32_t id 69 | ) { 70 | struct wl_resource *resource = wl_resource_create( 71 | client, 72 | &wl_shell_interface, 73 | version, 74 | id 75 | ); 76 | [[[OwlWlShell alloc] initWithResource: resource] release]; 77 | } 78 | 79 | + (void) addGlobalToDisplay: (struct wl_display *) display { 80 | wl_global_create(display, &wl_shell_interface, 1, NULL, shell_bind); 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Sources/App/OwlKnownClientsManager.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlKnownClientsManager.h" 20 | 21 | 22 | @implementation OwlKnownClientsManager 23 | 24 | - (void) createMenuItemForIndex: (NSUInteger) index 25 | clientPath: (NSString *) clientPath 26 | { 27 | NSString *title = [clientPath lastPathComponent]; 28 | NSMenuItem *item = [[NSMenuItem alloc] initWithTitle: title 29 | action: @selector(startClient:) 30 | keyEquivalent: @""]; 31 | [item setTarget: self]; 32 | [item setTag: index]; 33 | [_clientsMenu addItem: item]; 34 | [item release]; 35 | } 36 | 37 | - (void) update { 38 | [_clients release]; 39 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 40 | NSArray *customClients = [defaults arrayForKey: @"CustomClients"]; 41 | _clients = [[_defaultClients arrayByAddingObjectsFromArray: customClients] retain]; 42 | 43 | [_clientsMenu removeAllItems]; 44 | 45 | NSUInteger size = [_clients count]; 46 | for (NSUInteger i = 0; i < size; i++) { 47 | NSString *clientPath = [_clients objectAtIndex: i]; 48 | [self createMenuItemForIndex: i clientPath: clientPath]; 49 | } 50 | } 51 | 52 | - (void) awakeFromNib { 53 | NSString *path = [[NSBundle mainBundle] resourcePath]; 54 | _defaultClients = [[NSArray alloc] initWithObjects: 55 | [path stringByAppendingPathComponent: @"weston-terminal"], 56 | [path stringByAppendingPathComponent: @"weston-flower"], 57 | [path stringByAppendingPathComponent: @"weston-smoke"], 58 | nil 59 | ]; 60 | 61 | [self update]; 62 | } 63 | 64 | - (void) dealloc { 65 | [_clientsMenu removeAllItems]; 66 | [_defaultClients release]; 67 | [_clients release]; 68 | [super dealloc]; 69 | } 70 | 71 | - (IBAction) startClient: (id) sender { 72 | NSUInteger index = [sender tag]; 73 | NSString *path = [_clients objectAtIndex: index]; 74 | [NSTask launchedTaskWithLaunchPath: path arguments: [NSArray array]]; 75 | } 76 | 77 | - (IBAction) configureClients: (id) sender { 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWindowWrapper.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWindowWrapper.h" 20 | #import "OwlWindow.h" 21 | #import 22 | 23 | @implementation OwlWindowWrapper 24 | 25 | - (void) dealloc { 26 | [_window release]; 27 | [_title release]; 28 | [_view release]; 29 | [_windowDelegate release]; 30 | [super dealloc]; 31 | } 32 | 33 | - (void) createWindow { 34 | _window = [[OwlWindow alloc] initWithSize: _size displaySSD: NO]; 35 | 36 | if (_title != nil) { 37 | [_window setTitle: _title]; 38 | } 39 | if (_view != nil) { 40 | [[_window contentView] addSubview: _view]; 41 | [_window makeFirstResponder: _view]; 42 | } 43 | [_window setDelegate: _windowDelegate]; 44 | } 45 | 46 | - (void) map { 47 | if (_window == nil) { 48 | [self createWindow]; 49 | } 50 | [_window makeKeyAndOrderFront: self]; 51 | } 52 | 53 | - (void) unmap { 54 | [_window orderOut: self]; 55 | } 56 | 57 | - (void) close { 58 | [_window close]; 59 | } 60 | 61 | - (void) minimize { 62 | [_window miniaturize: self]; 63 | } 64 | 65 | - (void) maximize { 66 | if (![_window isZoomed]) { 67 | [_window zoom: self]; 68 | } 69 | } 70 | 71 | - (void) unmaximize { 72 | if ([_window isZoomed]) { 73 | [_window zoom: self]; 74 | } 75 | } 76 | 77 | - (OwlWindow *) window { 78 | return _window; 79 | } 80 | 81 | - (void) setContentSize: (NSSize) size { 82 | _size = size; 83 | [_window setContentSize: _size]; 84 | } 85 | 86 | - (void) setTitle: (NSString *) title { 87 | [title retain]; 88 | [_title release]; 89 | _title = title; 90 | [_window setTitle: title]; 91 | } 92 | 93 | - (void) setView: (NSView *) view { 94 | [view retain]; 95 | [_view removeFromSuperview]; 96 | [_view release]; 97 | _view = view; 98 | [[_window contentView] addSubview: view]; 99 | [_window makeFirstResponder: view]; 100 | } 101 | 102 | - (void) setWindowDelegate: (id) delegate { 103 | [delegate retain]; 104 | [_windowDelegate release]; 105 | _windowDelegate = delegate; 106 | [_window setDelegate: delegate]; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardType.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPasteboardType.h" 20 | #import "OwlFeatures.h" 21 | 22 | 23 | @implementation OwlPasteboardType 24 | 25 | static NSArray *extraTextTypes; 26 | 27 | + (void) initialize { 28 | if (extraTextTypes == nil) { 29 | extraTextTypes = [[NSArray alloc] initWithObjects: 30 | @"TEXT", 31 | @"STRING", 32 | @"UTF8_STRING", 33 | nil 34 | ]; 35 | } 36 | } 37 | 38 | - (id) initWithMimeType: (NSString *) type { 39 | _mimeType = [type retain]; 40 | return self; 41 | } 42 | 43 | - (id) initWithUTI: (NSString *) UTI { 44 | _uti = [UTI retain]; 45 | return self; 46 | } 47 | 48 | - (void) dealloc { 49 | [_mimeType release]; 50 | [_uti release]; 51 | [super dealloc]; 52 | } 53 | 54 | - (NSString *) mimeType { 55 | if (_mimeType == nil) { 56 | if ([_uti isEqual: NSStringPboardType]) { 57 | _mimeType = [@"text/plain" retain]; 58 | } else if ([_uti isEqual: @"public.utf8-plain-text"]) { 59 | _mimeType = [@"text/plain;charset=utf-8" retain]; 60 | } else { 61 | #ifdef OWL_PLATFORM_APPLE 62 | _mimeType = (NSString *) UTTypeCopyPreferredTagWithClass( 63 | (CFStringRef) _uti, 64 | kUTTagClassMIMEType 65 | ); 66 | #else 67 | _mimeType = [_uti retain]; 68 | #endif 69 | } 70 | } 71 | 72 | return _mimeType; 73 | } 74 | 75 | - (NSString *) UTI { 76 | if (_uti == nil) { 77 | if ( 78 | [_mimeType hasPrefix: @"text/plain"] || 79 | [extraTextTypes containsObject: _mimeType] 80 | ) { 81 | _uti = [NSStringPboardType retain]; 82 | } else { 83 | #ifdef OWL_PLATFORM_APPLE 84 | _uti = (NSString *) UTTypeCreatePreferredIdentifierForTag( 85 | kUTTagClassMIMEType, 86 | (CFStringRef) _mimeType, 87 | NULL 88 | ); 89 | #else 90 | _uti = [_mimeType retain]; 91 | #endif 92 | } 93 | } 94 | 95 | return _uti; 96 | } 97 | 98 | - (BOOL) isText { 99 | NSString *m = [self mimeType]; 100 | return [m hasPrefix: @"text/"] || [extraTextTypes containsObject: m]; 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Sources/Data/OwlSelection.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSelection.h" 20 | #import "OwlDataSource.h" 21 | #import "OwlDataDevice.h" 22 | #import "OwlFeatures.h" 23 | 24 | 25 | @implementation OwlSelection 26 | 27 | - (id) init { 28 | _dataDevices = [NSMutableArray new]; 29 | return self; 30 | } 31 | 32 | - (void) dealloc { 33 | [_dataDevices release]; 34 | [_dataSource removeHolder: self]; 35 | [_dataSource release]; 36 | [super dealloc]; 37 | } 38 | 39 | + (OwlSelection *) clipboard { 40 | static OwlSelection *clipboard; 41 | if (clipboard == nil) { 42 | clipboard = [[OwlSelection alloc] init]; 43 | } 44 | return clipboard; 45 | } 46 | 47 | #ifdef OWL_PLATFORM_GNUSTEP 48 | + (OwlSelection *) primary { 49 | static OwlSelection *primary; 50 | if (primary == nil) { 51 | primary = [[OwlSelection alloc] init]; 52 | } 53 | return primary; 54 | } 55 | #endif 56 | 57 | // Get the current data source. 58 | - (OwlDataSource *) dataSource { 59 | return _dataSource; 60 | } 61 | 62 | - (void) setDataSource: (OwlDataSource *) source { 63 | if (source == _dataSource) { 64 | return; 65 | } 66 | 67 | // Clean up the old data source. 68 | [_dataSource sendCancelled]; 69 | [_dataSource removeHolder: self]; 70 | [_dataSource release]; 71 | 72 | // Set up the new one. 73 | _dataSource = [source retain]; 74 | [_dataSource addHolder: self]; 75 | 76 | // Broadcast it to the data devices that we have a new data source. 77 | for (NSValue *value in _dataDevices) { 78 | OwlDataDevice *dataDevice = [value nonretainedObjectValue]; 79 | [dataDevice selectionChanged: self]; 80 | } 81 | } 82 | 83 | - (void) addDataDevice: (OwlDataDevice *) dataDevice { 84 | NSValue *value = [NSValue valueWithNonretainedObject: dataDevice]; 85 | [_dataDevices addObject: value]; 86 | } 87 | 88 | - (void) removeDataDevice: (OwlDataDevice *) dataDevice { 89 | NSValue *value = [NSValue valueWithNonretainedObject: dataDevice]; 90 | [_dataDevices removeObject: value]; 91 | } 92 | 93 | - (void) releaseDataSource: (OwlDataSource *) source { 94 | if (_dataSource == source) { 95 | [_dataSource release]; 96 | _dataSource = nil; 97 | } 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /Sources/Mach/OwlZowlMachIpcPortV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZowlMachIpcPortV1.h" 20 | #import 21 | #import 22 | #import "owl-mach-ipc-unstable-v1.h" 23 | #import "owl-mach-ipc-unstable-v1-mig.h" 24 | 25 | 26 | @implementation OwlZowlMachIpcPortV1 27 | 28 | static NSMutableDictionary *secretToPort; 29 | 30 | + (void) initialize { 31 | if (secretToPort == nil) { 32 | secretToPort = [[NSMutableDictionary alloc] init]; 33 | } 34 | } 35 | 36 | static void mach_ipc_port_destroy_handler( 37 | struct wl_client *client, 38 | struct wl_resource *resource 39 | ) { 40 | wl_resource_destroy(resource); 41 | } 42 | 43 | static const struct zowl_mach_ipc_port_v1_interface mach_ipc_port_impl = { 44 | .destroy = mach_ipc_port_destroy_handler 45 | }; 46 | 47 | static void mach_ipc_port_destroy(struct wl_resource *resource) { 48 | OwlZowlMachIpcPortV1 *self = wl_resource_get_user_data(resource); 49 | [secretToPort removeObjectsForKeys: [secretToPort allKeysForObject: self]]; 50 | [self release]; 51 | } 52 | 53 | - (id) initWithResource: (struct wl_resource *) resource { 54 | _resource = resource; 55 | wl_resource_set_implementation( 56 | resource, 57 | &mach_ipc_port_impl, 58 | [self retain], 59 | mach_ipc_port_destroy 60 | ); 61 | 62 | // Cannot use NSUUID, as it's 10.8+. 63 | CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); 64 | NSString *secret = (NSString *) CFUUIDCreateString(kCFAllocatorDefault, uuid); 65 | CFRelease(uuid); 66 | 67 | zowl_mach_ipc_port_v1_send_secret(resource, [secret UTF8String]); 68 | [secretToPort setObject: self forKey: secret]; 69 | [secret release]; 70 | return self; 71 | } 72 | 73 | - (void) setPort: (mach_port_t) port { 74 | _port = port; 75 | } 76 | 77 | // FIXME: deallocate the port in dealloc? 78 | 79 | kern_return_t owl_mach_ipc_v1_server_retrieve_port( 80 | mach_port_t server_port, 81 | secret_t raw_secret, 82 | mach_port_t *port 83 | ) { 84 | NSString *secret = [NSString stringWithUTF8String: raw_secret]; 85 | OwlZowlMachIpcPortV1 *self = [secretToPort objectForKey: secret]; 86 | if (self == nil) { 87 | return KERN_INVALID_ARGUMENT; 88 | } 89 | [secretToPort removeObjectForKey: secret]; 90 | *port = self->_port; 91 | return KERN_SUCCESS; 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /Sources/Shell/OwlXdgWmBase.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlXdgWmBase.h" 20 | #import "OwlSurface.h" 21 | #import "OwlXdgSurface.h" 22 | #import "xdg-shell.h" 23 | #import 24 | 25 | @implementation OwlXdgWmBase 26 | 27 | static void xdg_wm_base_destroy_handler( 28 | struct wl_client *client, 29 | struct wl_resource *resource 30 | ) { 31 | wl_resource_destroy(resource); 32 | } 33 | 34 | static void xdg_wm_base_destroy( 35 | struct wl_resource *resource 36 | ) { 37 | OwlXdgWmBase *self = wl_resource_get_user_data(resource); 38 | [self release]; 39 | } 40 | 41 | static void xdg_wm_base_get_xdg_surface( 42 | struct wl_client *client, 43 | struct wl_resource *resource, 44 | uint32_t id, 45 | struct wl_resource *surface_resource 46 | ) { 47 | struct wl_resource *xdg_surface_resource = wl_resource_create( 48 | client, 49 | &xdg_surface_interface, 50 | 1, 51 | id 52 | ); 53 | 54 | OwlSurface *surface = wl_resource_get_user_data(surface_resource); 55 | [[[OwlXdgSurface alloc] initWithResource: xdg_surface_resource 56 | surface: surface] release]; 57 | } 58 | 59 | static const struct xdg_wm_base_interface xdg_wm_base_impl = { 60 | .destroy = xdg_wm_base_destroy_handler, 61 | .get_xdg_surface = xdg_wm_base_get_xdg_surface 62 | // TODO 63 | }; 64 | 65 | - (id) initWithResource: (struct wl_resource *) resource { 66 | _resource = resource; 67 | wl_resource_set_implementation( 68 | resource, 69 | &xdg_wm_base_impl, 70 | [self retain], 71 | NULL 72 | ); 73 | return self; 74 | } 75 | 76 | static void xdg_wm_base_bind( 77 | struct wl_client *client, 78 | void *data, 79 | uint32_t version, 80 | uint32_t id 81 | ) { 82 | struct wl_resource *resource = wl_resource_create( 83 | client, 84 | &xdg_wm_base_interface, 85 | version, 86 | id 87 | ); 88 | [[[OwlXdgWmBase alloc] initWithResource: resource] release]; 89 | } 90 | 91 | + (void) addGlobalToDisplay: (struct wl_display *) display { 92 | wl_global_create( 93 | display, 94 | &xdg_wm_base_interface, 95 | 1, 96 | NULL, 97 | xdg_wm_base_bind 98 | ); 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /Sources/Shell/OwlZxdgShellV6.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZxdgShellV6.h" 20 | #import "OwlSurface.h" 21 | #import "OwlZxdgSurfaceV6.h" 22 | #import "xdg-shell-unstable-v6.h" 23 | #import 24 | 25 | @implementation OwlZxdgShellV6 26 | 27 | static void xdg_shell_v6_destroy_handler( 28 | struct wl_client *client, 29 | struct wl_resource *resource 30 | ) { 31 | wl_resource_destroy(resource); 32 | } 33 | 34 | static void xdg_shell_v6_destroy( 35 | struct wl_resource *resource 36 | ) { 37 | OwlZxdgShellV6 *self = wl_resource_get_user_data(resource); 38 | [self release]; 39 | } 40 | 41 | static void xdg_shell_v6_get_xdg_surface( 42 | struct wl_client *client, 43 | struct wl_resource *resource, 44 | uint32_t id, 45 | struct wl_resource *surface_resource 46 | ) { 47 | struct wl_resource *xdg_surface_resource = wl_resource_create( 48 | client, 49 | &zxdg_surface_v6_interface, 50 | 1, 51 | id 52 | ); 53 | 54 | OwlSurface *surface = wl_resource_get_user_data(surface_resource); 55 | [[[OwlZxdgSurfaceV6 alloc] initWithResource: xdg_surface_resource 56 | surface: surface] release]; 57 | } 58 | 59 | static const struct zxdg_shell_v6_interface xdg_shell_v6_impl = { 60 | .destroy = xdg_shell_v6_destroy_handler, 61 | .get_xdg_surface = xdg_shell_v6_get_xdg_surface 62 | // TODO 63 | }; 64 | 65 | 66 | - (id) initWithResource: (struct wl_resource *) resource { 67 | _resource = resource; 68 | wl_resource_set_implementation( 69 | resource, 70 | &xdg_shell_v6_impl, 71 | [self retain], 72 | NULL 73 | ); 74 | return self; 75 | } 76 | 77 | static void xdg_shell_v6_bind( 78 | struct wl_client *client, 79 | void *data, 80 | uint32_t version, 81 | uint32_t id 82 | ) { 83 | struct wl_resource *resource = wl_resource_create( 84 | client, 85 | &zxdg_shell_v6_interface, 86 | version, 87 | id 88 | ); 89 | [[[OwlZxdgShellV6 alloc] initWithResource: resource] release]; 90 | // TODO: destroy? 91 | } 92 | 93 | + (void) addGlobalToDisplay: (struct wl_display *) display { 94 | wl_global_create( 95 | display, 96 | &zxdg_shell_v6_interface, 97 | 1, 98 | NULL, 99 | xdg_shell_v6_bind 100 | ); 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataOffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPasteboardDataOffer.h" 20 | #import "OwlDataOffer.h" 21 | #import "OwlPasteboardDataDevice.h" 22 | #import "OwlPasteboardType.h" 23 | #import "OwlServer.h" 24 | #import "OwlDataDevice.h" 25 | #import "OwlSelection.h" 26 | #import 27 | 28 | 29 | @implementation OwlPasteboardDataOffer 30 | 31 | - (id) initWithDataDevice: (OwlPasteboardDataDevice *) device 32 | dataSource: (OwlDataSource *) dataSource 33 | { 34 | _types = [NSMutableArray new]; 35 | _dataDevice = [device retain]; 36 | // The parent constructor fills in types. 37 | [super initWithResource: NULL dataSource: dataSource]; 38 | [[device pasteboard] declareTypes: _types owner: self]; 39 | return self; 40 | } 41 | 42 | - (void) dealloc { 43 | [_types release]; 44 | [_dataDevice release]; 45 | [super dealloc]; 46 | } 47 | 48 | - (void) addMimeType: (NSString *) mimeType { 49 | OwlPasteboardType *type = [[OwlPasteboardType alloc] initWithMimeType: mimeType]; 50 | [_types addObject: [type UTI]]; 51 | [type release]; 52 | } 53 | 54 | - (void) pasteboard: (NSPasteboard *) pasteboard 55 | provideDataForType: (NSString *) uti 56 | { 57 | OwlPasteboardType *type = [[[OwlPasteboardType alloc] initWithUTI: uti] autorelease]; 58 | NSString *mimeType = [type mimeType]; 59 | if (mimeType == nil) { 60 | // We can't meaningfully convert this UTI to a MIME type. 61 | // Refuse to provide the data, and hope for the better. 62 | return; 63 | } 64 | 65 | NSPipe *pipe = [NSPipe pipe]; 66 | NSFileHandle *writingHandle = [pipe fileHandleForWriting]; 67 | [_dataSource sendContentOfMimeType: mimeType 68 | toFileHandle: writingHandle]; 69 | [writingHandle closeFile]; 70 | [[OwlServer sharedServer] flushClients]; 71 | 72 | // Sigh, it seems there's no other way but to do this synchronously. 73 | NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile]; 74 | if ([type isText]) { 75 | NSString *s = [[NSString alloc] initWithData: data 76 | encoding: NSUTF8StringEncoding]; 77 | [pasteboard setString: s forType: uti]; 78 | [s release]; 79 | } else { 80 | [pasteboard setData: data forType: uti]; 81 | } 82 | } 83 | 84 | - (void) pasteboardChangedOwner: (NSPasteboard *) pasteboard { 85 | [_dataDevice pasteboardRefreshed]; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlCompositor.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlCompositor.h" 20 | #import "OwlSurface.h" 21 | #import "OwlRegion.h" 22 | #import 23 | 24 | @implementation OwlCompositor 25 | 26 | static void compositor_create_surface_handler( 27 | struct wl_client *client, 28 | struct wl_resource *resource, 29 | uint32_t id 30 | ) { 31 | uint32_t version = wl_resource_get_version(resource); 32 | struct wl_resource *surface_resource = wl_resource_create( 33 | client, 34 | &wl_surface_interface, 35 | version, 36 | id 37 | ); 38 | [[[OwlSurface alloc] initWithResource: surface_resource] release]; 39 | } 40 | 41 | static void compositor_create_region_handler( 42 | struct wl_client *client, 43 | struct wl_resource *resource, 44 | uint32_t id 45 | ) { 46 | uint32_t version = wl_resource_get_version(resource); 47 | struct wl_resource *region_resource = wl_resource_create( 48 | client, 49 | &wl_region_interface, 50 | version, 51 | id 52 | ); 53 | [[[OwlRegion alloc] initWithResource: region_resource] release]; 54 | } 55 | 56 | static const struct wl_compositor_interface compositor_interface = { 57 | .create_surface = compositor_create_surface_handler, 58 | .create_region = compositor_create_region_handler 59 | }; 60 | 61 | static void compositor_destroy(struct wl_resource *resource) { 62 | OwlCompositor *self = wl_resource_get_user_data(resource); 63 | [self release]; 64 | } 65 | 66 | - (id) initWithResource: (struct wl_resource *) resource { 67 | _resource = resource; 68 | wl_resource_set_implementation( 69 | resource, 70 | &compositor_interface, 71 | [self retain], 72 | compositor_destroy 73 | ); 74 | return self; 75 | } 76 | 77 | static void compositor_bind( 78 | struct wl_client *client, 79 | void *data, 80 | uint32_t version, 81 | uint32_t id 82 | ) { 83 | struct wl_resource *resource = wl_resource_create( 84 | client, 85 | &wl_compositor_interface, 86 | version, 87 | id 88 | ); 89 | [[[OwlCompositor alloc] initWithResource: resource] release]; 90 | } 91 | 92 | + (void) addGlobalToDisplay: (struct wl_display *) display { 93 | wl_global_create( 94 | display, 95 | &wl_compositor_interface, 96 | 4, 97 | NULL, 98 | compositor_bind 99 | ); 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWlShellSurface.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlShellSurface.h" 20 | #import "OwlSurface.h" 21 | #import "OwlWindowWrapper.h" 22 | #import 23 | 24 | @implementation OwlWlShellSurface 25 | 26 | static void shell_surface_destroy(struct wl_resource *resource) { 27 | OwlWlShellSurface *self = wl_resource_get_user_data(resource); 28 | [self->_window close]; 29 | [self release]; 30 | } 31 | 32 | static void shell_surface_move_handler( 33 | struct wl_client *client, 34 | struct wl_resource *resource, 35 | struct wl_resource *seat_resource, 36 | uint32_t serial 37 | ) { 38 | OwlWlShellSurface *self = wl_resource_get_user_data(resource); 39 | [[self->_window window] runInteractiveMove]; 40 | } 41 | 42 | static void shell_surface_set_toplevel_handler( 43 | struct wl_client *client, 44 | struct wl_resource *resource 45 | ) { 46 | OwlWlShellSurface *self = wl_resource_get_user_data(resource); 47 | self->_mode = OWL_WL_SHELL_SURFACE_MODE_TOPLEVEL; 48 | } 49 | 50 | static void shell_surface_set_title_handler( 51 | struct wl_client *client, 52 | struct wl_resource *resource, 53 | const char *raw_title 54 | ) { 55 | OwlWlShellSurface *self = wl_resource_get_user_data(resource); 56 | [self->_window setTitle: [NSString stringWithUTF8String: raw_title]]; 57 | } 58 | 59 | static const struct wl_shell_surface_interface shell_surface_interface = { 60 | .set_toplevel = shell_surface_set_toplevel_handler, 61 | .set_title = shell_surface_set_title_handler 62 | // TODO 63 | }; 64 | 65 | - (id) initWithResource: (struct wl_resource *) resource 66 | surface: (OwlSurface *) surface 67 | { 68 | _resource = resource; 69 | _surface = [surface retain]; 70 | 71 | [surface setRole: self]; 72 | _window = [OwlWindowWrapper new]; 73 | [_window setView: surface]; 74 | 75 | wl_resource_set_implementation( 76 | resource, 77 | &shell_surface_interface, 78 | [self retain], 79 | shell_surface_destroy 80 | ); 81 | return self; 82 | } 83 | 84 | - (void) dealloc { 85 | [_surface release]; 86 | [_window release]; 87 | [super dealloc]; 88 | } 89 | 90 | - (void) map { 91 | [self update]; 92 | [_window map]; 93 | } 94 | 95 | - (void) unmap { 96 | [_window unmap]; 97 | } 98 | 99 | - (void) update { 100 | [_window setContentSize: [_surface bounds].size]; 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Sources/Seat/OwlSeat.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSeat.h" 20 | #import "OwlPointer.h" 21 | #import "OwlKeyboard.h" 22 | #import 23 | 24 | @implementation OwlSeat 25 | 26 | static void seat_get_pointer( 27 | struct wl_client *client, 28 | struct wl_resource *resource, 29 | uint32_t id 30 | ) { 31 | uint32_t version = wl_resource_get_version(resource); 32 | struct wl_resource *pointer_resource = wl_resource_create( 33 | client, 34 | &wl_pointer_interface, 35 | version, 36 | id 37 | ); 38 | [[[OwlPointer alloc] initWithResource: pointer_resource] release]; 39 | } 40 | 41 | static void seat_get_keyboard( 42 | struct wl_client *client, 43 | struct wl_resource *resource, 44 | uint32_t id 45 | ) { 46 | uint32_t version = wl_resource_get_version(resource); 47 | struct wl_resource *keyboard_resource = wl_resource_create( 48 | client, 49 | &wl_keyboard_interface, 50 | version, 51 | id 52 | ); 53 | [[[OwlKeyboard alloc] initWithResource: keyboard_resource] release]; 54 | } 55 | 56 | static const struct wl_seat_interface seat_impl = { 57 | .get_pointer = seat_get_pointer, 58 | .get_keyboard = seat_get_keyboard 59 | }; 60 | 61 | static void seat_destroy(struct wl_resource *resource) { 62 | OwlSeat *self = wl_resource_get_user_data(resource); 63 | [self release]; 64 | } 65 | 66 | - (id) initWithResource: (struct wl_resource *) resource { 67 | _resource = resource; 68 | 69 | wl_resource_set_implementation( 70 | resource, 71 | &seat_impl, 72 | [self retain], 73 | seat_destroy 74 | ); 75 | 76 | wl_seat_send_capabilities( 77 | resource, 78 | WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD 79 | ); 80 | 81 | if (wl_resource_get_version(resource) >= 2) { 82 | wl_seat_send_name(resource, "seat0"); 83 | } 84 | 85 | return self; 86 | } 87 | 88 | static void seat_bind( 89 | struct wl_client *client, 90 | void *data, 91 | uint32_t version, 92 | uint32_t id 93 | ) { 94 | struct wl_resource *resource = wl_resource_create( 95 | client, 96 | &wl_seat_interface, 97 | version, 98 | id 99 | ); 100 | [[[OwlSeat alloc] initWithResource: resource] release]; 101 | } 102 | 103 | + (void) addGlobalToDisplay: (struct wl_display *) display { 104 | wl_global_create(display, &wl_seat_interface, 2, NULL, seat_bind); 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataDeviceManager.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlDataDeviceManager.h" 20 | #import "OwlWlDataSource.h" 21 | #import "OwlWlDataDevice.h" 22 | 23 | 24 | @implementation OwlWlDataDeviceManager 25 | 26 | static void data_device_manager_destroy(struct wl_resource *resource) { 27 | OwlWlDataDeviceManager *self = wl_resource_get_user_data(resource); 28 | [self release]; 29 | } 30 | 31 | static void data_device_manager_create_data_source_handler( 32 | struct wl_client *client, 33 | struct wl_resource *resource, 34 | uint32_t id 35 | ) { 36 | struct wl_resource *data_source_resource = wl_resource_create( 37 | client, 38 | &wl_data_source_interface, 39 | 2, 40 | id 41 | ); 42 | [[[OwlWlDataSource alloc] initWithResource: data_source_resource] release]; 43 | } 44 | 45 | static void data_device_manager_get_data_device_handler( 46 | struct wl_client *client, 47 | struct wl_resource *resource, 48 | uint32_t id, 49 | struct wl_resource *seat_resource 50 | ) { 51 | struct wl_resource *data_device_resource = wl_resource_create( 52 | client, 53 | &wl_data_device_interface, 54 | 2, 55 | id 56 | ); 57 | [[[OwlWlDataDevice alloc] initWithResource: data_device_resource] release]; 58 | } 59 | 60 | static const struct wl_data_device_manager_interface data_device_manager_impl = { 61 | .create_data_source = data_device_manager_create_data_source_handler, 62 | .get_data_device = data_device_manager_get_data_device_handler 63 | }; 64 | 65 | - (id) initWithResource: (struct wl_resource *) resource { 66 | _resource = resource; 67 | wl_resource_set_implementation( 68 | resource, 69 | &data_device_manager_impl, 70 | [self retain], 71 | data_device_manager_destroy 72 | ); 73 | return self; 74 | } 75 | 76 | static void data_device_manager_bind( 77 | struct wl_client *client, 78 | void *data, 79 | uint32_t version, 80 | uint32_t id 81 | ) { 82 | struct wl_resource *resource = wl_resource_create( 83 | client, 84 | &wl_data_device_manager_interface, 85 | version, 86 | id 87 | ); 88 | [[[OwlWlDataDeviceManager alloc] initWithResource: resource] release]; 89 | } 90 | 91 | + (void) addGlobalToDisplay: (struct wl_display *) display { 92 | wl_global_create( 93 | display, 94 | &wl_data_device_manager_interface, 95 | 2, 96 | NULL, 97 | data_device_manager_bind 98 | ); 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /Sources/Protocol/owl-iosurface-unstable-v1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Copyright © 2019-2021 Sergey Bugaev 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a 8 | copy of this software and associated documentation files (the "Software"), 9 | to deal in the Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | and/or sell copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice (including the next 15 | paragraph) shall be included in all copies or substantial portions of the 16 | Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | 27 | 28 | 29 | TODO 30 | 31 | 32 | 33 | 34 | This request assigns the zowl_mach_ipc_port_v1 object a role of the IOSurface 35 | receiver. After sending this request, it is possible to call the 36 | owl_iosurface_v1_set_surface_port() MIG routine on its underlying Mach port. 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Destroy this zowl_iosurface_manager_v1 object and all the resources associated 45 | with it. Destroying a zowl_iosurface_manager_v1 object while an IOSurface that 46 | was created using it is in use is an error. 47 | 48 | 49 | 50 | 51 | 52 | 53 | TODO 54 | 55 | 56 | 57 | 58 | Create a wl_buffer out of this zowl_iosurface_v1 object. This request must be 59 | preceeded by the client creating an IOSurface object with the desired size 60 | and sending its Mach port using the owl_iosurface_v1_set_surface_port() MIG 61 | routine on the Mach port that was used to create this zowl_iosurface_v1 object. 62 | 63 | 64 | 65 | 66 | 67 | 68 | Destroy this zowl_iosurface_v1 object and all the resources associated 69 | with it, including the underlying IOSurface. 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlZowlIOSurfaceManagerV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import "OwlZowlIOSurfaceManagerV1.h" 23 | #import "OwlZowlIOSurfaceV1.h" 24 | #import 25 | #import "OwlGlobal.h" 26 | #import "owl-iosurface-unstable-v1.h" 27 | #import "OwlZowlMachIpcPortV1.h" 28 | 29 | 30 | @implementation OwlZowlIOSurfaceManagerV1 31 | 32 | static void iosurface_manager_destroy_handler( 33 | struct wl_client *client, 34 | struct wl_resource *resource 35 | ) { 36 | wl_resource_destroy(resource); 37 | } 38 | 39 | static void iosurface_manager_create_surface_handler( 40 | struct wl_client *client, 41 | struct wl_resource *resource, 42 | struct wl_resource *port_resource, 43 | uint32_t id 44 | ) { 45 | struct wl_resource *iosurface_resource = wl_resource_create( 46 | client, 47 | &zowl_iosurface_v1_interface, 48 | 1, 49 | id 50 | ); 51 | OwlZowlIOSurfaceV1 *iosurface = [[OwlZowlIOSurfaceV1 alloc] initWithResource: iosurface_resource]; 52 | OwlZowlMachIpcPortV1 *port = wl_resource_get_user_data(port_resource); 53 | [port setPort: [iosurface receiverPort]]; 54 | [iosurface release]; 55 | } 56 | 57 | static const struct zowl_iosurface_manager_v1_interface iosurface_manager_impl = { 58 | .create_surface = iosurface_manager_create_surface_handler, 59 | .destroy = iosurface_manager_destroy_handler 60 | }; 61 | 62 | static void iosurface_manager_destroy(struct wl_resource *resource) { 63 | OwlZowlIOSurfaceManagerV1 *self = wl_resource_get_user_data(resource); 64 | [self release]; 65 | } 66 | 67 | - (id) initWithResource: (struct wl_resource *) resource { 68 | _resource = resource; 69 | wl_resource_set_implementation( 70 | resource, 71 | &iosurface_manager_impl, 72 | [self retain], 73 | iosurface_manager_destroy 74 | ); 75 | return self; 76 | } 77 | 78 | static void iosurface_manager_bind( 79 | struct wl_client *client, 80 | void *data, 81 | uint32_t version, 82 | uint32_t id 83 | ) { 84 | struct wl_resource *resource = wl_resource_create( 85 | client, 86 | &zowl_iosurface_manager_v1_interface, 87 | version, 88 | id 89 | ); 90 | [[[OwlZowlIOSurfaceManagerV1 alloc] initWithResource: resource] release]; 91 | } 92 | 93 | + (void) addGlobalToDisplay: (struct wl_display *) display { 94 | wl_global_create( 95 | display, 96 | &zowl_iosurface_manager_v1_interface, 97 | 1, 98 | NULL, 99 | iosurface_manager_bind 100 | ); 101 | } 102 | 103 | @end 104 | 105 | #endif /* OWL_PLATFORM_APPLE */ 106 | -------------------------------------------------------------------------------- /Sources/Server/OwlRunLoopSource.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlRunLoopSource.h" 20 | #import "OwlServer.h" 21 | #import "OwlFeatures.h" 22 | #import 23 | 24 | @implementation OwlRunLoopSource 25 | 26 | #ifndef OWL_PLATFORM_GNUSTEP 27 | static void socketCallback( 28 | CFSocketRef socket, 29 | CFSocketCallBackType type, 30 | CFDataRef address, 31 | const void *data, 32 | void *info 33 | ) { 34 | OwlRunLoopSource *self = info; 35 | #else 36 | - (void) receivedEvent: (void *) data 37 | type: (RunLoopEventType) type 38 | extra: (void *) extra 39 | forMode: (NSString *) mode 40 | { 41 | #endif 42 | 43 | @try { 44 | wl_event_loop_dispatch(self->_event_loop, 0); 45 | } @catch (NSException *ex) { 46 | NSLog(@"Internal error during wl_event_loop_dispatch(): %@", ex); 47 | } 48 | 49 | [[OwlServer sharedServer] flushClients]; 50 | } 51 | 52 | - (id) initWithEventLoop: (struct wl_event_loop *) event_loop { 53 | _event_loop = event_loop; 54 | 55 | #ifndef OWL_PLATFORM_GNUSTEP 56 | int fd = wl_event_loop_get_fd(_event_loop); 57 | 58 | CFSocketContext context = { 59 | .version = 0, 60 | .info = self, 61 | .retain = NULL, 62 | .release = NULL, 63 | .copyDescription = NULL 64 | }; 65 | 66 | _socket = CFSocketCreateWithNative( 67 | NULL, 68 | fd, 69 | kCFSocketReadCallBack, 70 | socketCallback, 71 | &context 72 | ); 73 | _source = CFSocketCreateRunLoopSource(NULL, _socket, 0); 74 | #endif 75 | 76 | return self; 77 | } 78 | 79 | - (void) dealloc { 80 | #ifndef OWL_PLATFORM_GNUSTEP 81 | CFRelease(_source); 82 | CFRelease(_socket); 83 | #endif 84 | [super dealloc]; 85 | } 86 | 87 | - (void) addToRunLoop { 88 | #ifndef OWL_PLATFORM_GNUSTEP 89 | CFRunLoopAddSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode); 90 | #else 91 | int fd = wl_event_loop_get_fd(_event_loop); 92 | 93 | [[NSRunLoop currentRunLoop] addEvent: (void *) fd 94 | type: ET_RDESC 95 | watcher: self 96 | forMode: NSDefaultRunLoopMode]; 97 | #endif 98 | } 99 | 100 | - (void) removeFromRunLoop { 101 | #ifndef OWL_PLATFORM_GNUSTEP 102 | CFRunLoopRemoveSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode); 103 | #else 104 | int fd = wl_event_loop_get_fd(_event_loop); 105 | 106 | [[NSRunLoop currentRunLoop] removeEvent: (void *) fd 107 | type: ET_RDESC 108 | forMode: NSDefaultRunLoopMode 109 | all: YES]; 110 | #endif 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlBuffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlBuffer.h" 20 | #import "OwlShmBuffer.h" 21 | 22 | 23 | @implementation OwlBuffer 24 | 25 | static NSMutableArray *buffers; 26 | 27 | + (void) initialize { 28 | if (buffers == nil) { 29 | buffers = [NSMutableArray new]; 30 | } 31 | } 32 | 33 | static void buffer_destroy(struct wl_resource *resource) { 34 | OwlBuffer *self = wl_resource_get_user_data(resource); 35 | [self release]; 36 | } 37 | 38 | static void buffer_destroy_handler( 39 | struct wl_client *client, 40 | struct wl_resource *resource 41 | ) { 42 | wl_resource_destroy(resource); 43 | } 44 | 45 | static const struct wl_buffer_interface buffer_impl = { 46 | .destroy = buffer_destroy_handler 47 | }; 48 | 49 | - (id) initWithExternallyImplementedResource: (struct wl_resource *) resource { 50 | _resource = resource; 51 | [buffers addObject: self]; 52 | return self; 53 | } 54 | 55 | - (id) initWithResource: (struct wl_resource *) resource { 56 | self = [self initWithExternallyImplementedResource: resource]; 57 | wl_resource_set_implementation( 58 | resource, 59 | &buffer_impl, 60 | [self retain], 61 | buffer_destroy 62 | ); 63 | return self; 64 | } 65 | 66 | - (void) dealloc { 67 | [buffers removeObject: self]; 68 | [super dealloc]; 69 | } 70 | 71 | + (OwlBuffer *) bufferForResource: (struct wl_resource *) resource { 72 | if (resource == NULL) { 73 | return nil; 74 | } 75 | // All buffer factories register their resources with us immediately on creation, 76 | // except wl_shm, which is implemented outside of Owl (in wayland-server). 77 | for (OwlBuffer *buffer in buffers) { 78 | if (buffer->_resource == resource) { 79 | return buffer; 80 | } 81 | } 82 | return [[[OwlShmBuffer alloc] initWithResource: resource] autorelease]; 83 | } 84 | 85 | - (void) invalidate { 86 | // Do nothing, subclasses may override this to recompute their data. 87 | } 88 | 89 | - (NSSize) size { 90 | // Subclasses need to override this. 91 | return NSZeroSize; 92 | } 93 | 94 | - (BOOL) needsGLForRendering { 95 | // Subclasses may override this if they need OpenGL. 96 | return NO; 97 | } 98 | 99 | - (void) drawInRect: (NSRect) rect { 100 | // Do nothing, subclasses override this. 101 | } 102 | 103 | - (void) sendRelease { 104 | wl_buffer_send_release(_resource); 105 | } 106 | 107 | - (void) notifyDetached { 108 | // This method is invoked when the buffer is detached from a surface, 109 | // The base implementation does nothing, subclasses may want to override 110 | // it and call [self sendRelease] if they don't already call that at a 111 | // different time. 112 | } 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSubcompositor.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSubcompositor.h" 20 | #import "OwlSurface.h" 21 | #import "OwlSubsurface.h" 22 | 23 | 24 | @implementation OwlSubcompositor 25 | 26 | static void subcompositor_destroy_handler( 27 | struct wl_client *client, 28 | struct wl_resource *resource 29 | ) { 30 | wl_resource_destroy(resource); 31 | } 32 | 33 | static void subcompositor_destroy(struct wl_resource *resource) { 34 | OwlSubcompositor *self = wl_resource_get_user_data(resource); 35 | [self release]; 36 | } 37 | 38 | static void subcompositor_get_subsurface_handler( 39 | struct wl_client *client, 40 | struct wl_resource *resource, 41 | uint32_t id, 42 | struct wl_resource *surface_resource, 43 | struct wl_resource *parent_resource 44 | ) { 45 | struct wl_resource *subsurface_resource = wl_resource_create( 46 | client, 47 | &wl_subsurface_interface, 48 | 1, 49 | id 50 | ); 51 | OwlSurface *surface = wl_resource_get_user_data(surface_resource); 52 | OwlSurface *parent = wl_resource_get_user_data(parent_resource); 53 | 54 | #if 0 55 | // FIXME: This line doesn't compile anymore on Hurd for some reason, WTF? 56 | if ([surface role] != nil) { 57 | const char *role = [[[surface role] description] UTF8String]; 58 | wl_resource_post_error( 59 | resource, 60 | WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, 61 | "Surface already has another role: %s", 62 | role 63 | ); 64 | return; 65 | } 66 | #endif 67 | [[[OwlSubsurface alloc] initWithResource: subsurface_resource 68 | surface: surface 69 | parent: parent] release]; 70 | } 71 | 72 | static const struct wl_subcompositor_interface subcompositor_impl = { 73 | .destroy = subcompositor_destroy_handler, 74 | .get_subsurface = subcompositor_get_subsurface_handler 75 | }; 76 | 77 | - (id) initWithResource: (struct wl_resource *) resource { 78 | _resource = resource; 79 | wl_resource_set_implementation( 80 | resource, 81 | &subcompositor_impl, 82 | [self retain], 83 | subcompositor_destroy 84 | ); 85 | return self; 86 | } 87 | 88 | static void subcompositor_bind( 89 | struct wl_client *client, 90 | void *data, 91 | uint32_t version, 92 | uint32_t id 93 | ) { 94 | struct wl_resource *resource = wl_resource_create( 95 | client, 96 | &wl_subcompositor_interface, 97 | version, 98 | id 99 | ); 100 | [[[OwlSubcompositor alloc] initWithResource: resource] release]; 101 | } 102 | 103 | + (void) addGlobalToDisplay: (struct wl_display *) display { 104 | wl_global_create( 105 | display, 106 | &wl_subcompositor_interface, 107 | 1, 108 | NULL, 109 | subcompositor_bind 110 | ); 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Sources/Mach/OwlZowlMachIpcV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZowlMachIpcV1.h" 20 | #import 21 | #import 22 | #import "owl-mach-ipc-unstable-v1.h" 23 | #import "owl-mach-ipc-unstable-v1-mig.h" 24 | #import 25 | #import 26 | #import "OwlZowlMachIpcPortV1.h" 27 | #import "OwlMIG.h" 28 | 29 | @implementation OwlZowlMachIpcV1 30 | 31 | static NSString *globalName; 32 | static mach_port_t port; 33 | 34 | + (BOOL) bootstrapCheckInWithName: (NSString *) name { 35 | globalName = [name retain]; 36 | const char *raw_name = [name UTF8String]; 37 | kern_return_t kr = bootstrap_check_in(bootstrap_port, raw_name, &port); 38 | if (kr != KERN_SUCCESS) { 39 | NSLog(@"bootstrap_check_in(%@) = %x", name, kr); 40 | return NO; 41 | } else { 42 | NSLog(@"Checked in with the bootstrap server as %@", name); 43 | } 44 | 45 | [OwlMIG serveOnPort: port 46 | usingCallback: owl_mach_ipc_v1_server 47 | maxSize: 100]; 48 | return YES; 49 | } 50 | 51 | static void mach_ipc_destroy(struct wl_resource *resource) { 52 | OwlZowlMachIpcV1 *self = wl_resource_get_user_data(resource); 53 | [self release]; 54 | } 55 | 56 | static void mach_ipc_create_port_handler( 57 | struct wl_client *client, 58 | struct wl_resource *resource, 59 | uint32_t id 60 | ) { 61 | struct wl_resource *port_resource = wl_resource_create( 62 | client, 63 | &zowl_mach_ipc_port_v1_interface, 64 | 1, 65 | id 66 | ); 67 | [[[OwlZowlMachIpcPortV1 alloc] initWithResource: port_resource] release]; 68 | } 69 | 70 | static void mach_ipc_destroy_handler( 71 | struct wl_client *client, 72 | struct wl_resource *resource 73 | ) { 74 | wl_resource_destroy(resource); 75 | } 76 | 77 | static const struct zowl_mach_ipc_v1_interface mach_ipc_impl = { 78 | .create_port = mach_ipc_create_port_handler, 79 | .destroy = mach_ipc_destroy_handler 80 | }; 81 | 82 | - (id) initWithResource: (struct wl_resource *) resource { 83 | _resource = resource; 84 | wl_resource_set_implementation( 85 | resource, 86 | &mach_ipc_impl, 87 | [self retain], 88 | mach_ipc_destroy 89 | ); 90 | zowl_mach_ipc_v1_send_bootstrap_name(resource, [globalName UTF8String]); 91 | return self; 92 | } 93 | 94 | static void mach_ipc_bind( 95 | struct wl_client *client, 96 | void *data, 97 | uint32_t version, 98 | uint32_t id 99 | ) { 100 | struct wl_resource *resource = wl_resource_create( 101 | client, 102 | &zowl_mach_ipc_v1_interface, 103 | version, 104 | id 105 | ); 106 | [[[OwlZowlMachIpcV1 alloc] initWithResource: resource] release]; 107 | } 108 | 109 | + (void) addGlobalToDisplay: (struct wl_display *) display { 110 | wl_global_create( 111 | display, 112 | &zowl_mach_ipc_v1_interface, 113 | 1, 114 | NULL, 115 | mach_ipc_bind 116 | ); 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlManagerV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZwlrDataControlManagerV1.h" 20 | #import "OwlZwlrDataControlDeviceV1.h" 21 | #import "OwlZwlrDataControlSourceV1.h" 22 | #import "wlr-data-control-unstable-v1.h" 23 | #import 24 | 25 | 26 | @implementation OwlZwlrDataControlManagerV1 27 | 28 | static void data_control_manager_destroy(struct wl_resource *resource) { 29 | OwlZwlrDataControlManagerV1 *self = wl_resource_get_user_data(resource); 30 | [self release]; 31 | } 32 | 33 | static void data_control_manager_destroy_handler( 34 | struct wl_client *client, 35 | struct wl_resource *resource 36 | ) { 37 | wl_resource_destroy(resource); 38 | } 39 | 40 | static void data_control_manager_create_data_source_handler( 41 | struct wl_client *client, 42 | struct wl_resource *resource, 43 | uint32_t id 44 | ) { 45 | uint32_t version = wl_resource_get_version(resource); 46 | struct wl_resource *data_source_resource = wl_resource_create( 47 | client, 48 | &zwlr_data_control_source_v1_interface, 49 | version, 50 | id 51 | ); 52 | [[[OwlZwlrDataControlSourceV1 alloc] initWithResource: data_source_resource] release]; 53 | } 54 | 55 | static void data_control_manager_get_data_device_handler( 56 | struct wl_client *client, 57 | struct wl_resource *resource, 58 | uint32_t id, 59 | struct wl_resource *seat_resource 60 | ) { 61 | uint32_t version = wl_resource_get_version(resource); 62 | struct wl_resource *data_device_resource = wl_resource_create( 63 | client, 64 | &zwlr_data_control_device_v1_interface, 65 | version, 66 | id 67 | ); 68 | [[[OwlZwlrDataControlDeviceV1 alloc] initWithResource: data_device_resource] release]; 69 | } 70 | 71 | static const struct zwlr_data_control_manager_v1_interface data_control_manager_impl = { 72 | .create_data_source = data_control_manager_create_data_source_handler, 73 | .get_data_device = data_control_manager_get_data_device_handler, 74 | .destroy = data_control_manager_destroy_handler 75 | }; 76 | 77 | - (id) initWithResource: (struct wl_resource *) resource { 78 | _resource = resource; 79 | wl_resource_set_implementation( 80 | resource, 81 | &data_control_manager_impl, 82 | [self retain], 83 | data_control_manager_destroy 84 | ); 85 | return self; 86 | } 87 | 88 | static void data_control_manager_bind( 89 | struct wl_client *client, 90 | void *data, 91 | uint32_t version, 92 | uint32_t id 93 | ) { 94 | struct wl_resource *resource = wl_resource_create( 95 | client, 96 | &zwlr_data_control_manager_v1_interface, 97 | version, 98 | id 99 | ); 100 | [[[OwlZwlrDataControlManagerV1 alloc] initWithResource: resource] release]; 101 | } 102 | 103 | + (void) addGlobalToDisplay: (struct wl_display *) display { 104 | wl_global_create( 105 | display, 106 | &zwlr_data_control_manager_v1_interface, 107 | 2, 108 | NULL, 109 | data_control_manager_bind 110 | ); 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Sources/Shell/OwlXdgSurface.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlXdgSurface.h" 20 | #import "OwlSurface.h" 21 | #import "OwlXdgToplevel.h" 22 | #import "xdg-shell.h" 23 | #import 24 | 25 | 26 | @implementation OwlXdgSurface 27 | 28 | static void xdg_surface_destroy(struct wl_resource *resource) { 29 | OwlXdgSurface *self = wl_resource_get_user_data(resource); 30 | [self release]; 31 | } 32 | 33 | static void xdg_surface_destroy_handler( 34 | struct wl_client *client, 35 | struct wl_resource *resource 36 | ) { 37 | wl_resource_destroy(resource); 38 | } 39 | 40 | static void xdg_surface_get_xdg_toplevel_handler( 41 | struct wl_client *client, 42 | struct wl_resource *resource, 43 | uint32_t id 44 | ) { 45 | OwlXdgSurface *self = wl_resource_get_user_data(resource); 46 | struct wl_resource *xdg_toplevel_resource = wl_resource_create( 47 | client, 48 | &xdg_toplevel_interface, 49 | 1, 50 | id 51 | ); 52 | [[[OwlXdgToplevel alloc] initWithResource: xdg_toplevel_resource 53 | surface: self->_surface 54 | xdgSurface: self] release]; 55 | } 56 | 57 | static void xdg_surface_ack_configure_handler( 58 | struct wl_client *client, 59 | struct wl_resource *resource, 60 | uint32_t serial 61 | ) { 62 | // TODO 63 | } 64 | 65 | static void xdg_surface_set_window_geometry_handler( 66 | struct wl_client *client, 67 | struct wl_resource *resource, 68 | int32_t x, 69 | int32_t y, 70 | int32_t width, 71 | int32_t height 72 | ) { 73 | OwlXdgSurface *self = wl_resource_get_user_data(resource); 74 | NSRect rect = NSMakeRect(x, y, width, height); 75 | [self->_surface setPendingGeometry: rect]; 76 | } 77 | 78 | static const struct xdg_surface_interface xdg_surface_impl = { 79 | .destroy = xdg_surface_destroy_handler, 80 | .get_toplevel = xdg_surface_get_xdg_toplevel_handler, 81 | .ack_configure = xdg_surface_ack_configure_handler, 82 | .set_window_geometry = xdg_surface_set_window_geometry_handler 83 | // TODO 84 | }; 85 | 86 | - (id) initWithResource: (struct wl_resource *) resource 87 | surface: (OwlSurface *) surface 88 | { 89 | _resource = resource; 90 | _surface = [surface retain]; 91 | wl_resource_set_implementation( 92 | resource, 93 | &xdg_surface_impl, 94 | [self retain], 95 | xdg_surface_destroy 96 | ); 97 | return self; 98 | } 99 | 100 | - (void) dealloc { 101 | [_surface release]; 102 | [super dealloc]; 103 | } 104 | 105 | - (void) sendConfigure { 106 | struct wl_client *client = wl_resource_get_client(_resource); 107 | struct wl_display *display = wl_client_get_display(client); 108 | uint32_t serial = wl_display_next_serial(display); 109 | xdg_surface_send_configure(_resource, serial); 110 | } 111 | 112 | - (NSSize) geometrySizeForBufferSize: (NSSize) size { 113 | NSSize adj = [_surface geometrySizeAdjustements]; 114 | size.width -= adj.width; 115 | size.height -= adj.height; 116 | return size; 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Sources/Shell/OwlZxdgSurfaceV6.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZxdgSurfaceV6.h" 20 | #import "OwlSurface.h" 21 | #import "OwlZxdgToplevelV6.h" 22 | #import "xdg-shell-unstable-v6.h" 23 | #import 24 | 25 | 26 | @implementation OwlZxdgSurfaceV6 27 | 28 | static void xdg_surface_v6_destroy(struct wl_resource *resource) { 29 | OwlZxdgSurfaceV6 *self = wl_resource_get_user_data(resource); 30 | [self release]; 31 | } 32 | 33 | static void xdg_surface_v6_destroy_handler( 34 | struct wl_client *client, 35 | struct wl_resource *resource 36 | ) { 37 | wl_resource_destroy(resource); 38 | } 39 | 40 | static void xdg_surface_v6_get_xdg_toplevel_handler( 41 | struct wl_client *client, 42 | struct wl_resource *resource, 43 | uint32_t id 44 | ) { 45 | OwlZxdgSurfaceV6 *self = wl_resource_get_user_data(resource); 46 | struct wl_resource *xdg_toplevel_resource = wl_resource_create( 47 | client, 48 | &zxdg_toplevel_v6_interface, 49 | 1, 50 | id 51 | ); 52 | [[[OwlZxdgToplevelV6 alloc] initWithResource: xdg_toplevel_resource 53 | surface: self->_surface 54 | xdgSurface: self] release]; 55 | } 56 | 57 | static void xdg_surface_v6_ack_configure_handler( 58 | struct wl_client *client, 59 | struct wl_resource *resource, 60 | uint32_t serial 61 | ) { 62 | // TODO 63 | } 64 | 65 | static void xdg_surface_v6_set_window_geometry_handler( 66 | struct wl_client *client, 67 | struct wl_resource *resource, 68 | int32_t x, 69 | int32_t y, 70 | int32_t width, 71 | int32_t height 72 | ) { 73 | OwlZxdgSurfaceV6 *self = wl_resource_get_user_data(resource); 74 | NSRect rect = NSMakeRect(x, y, width, height); 75 | [self->_surface setPendingGeometry: rect]; 76 | } 77 | 78 | static const struct zxdg_surface_v6_interface xdg_surface_v6_impl = { 79 | .destroy = xdg_surface_v6_destroy_handler, 80 | .get_toplevel = xdg_surface_v6_get_xdg_toplevel_handler, 81 | .ack_configure = xdg_surface_v6_ack_configure_handler, 82 | .set_window_geometry = xdg_surface_v6_set_window_geometry_handler 83 | // TODO 84 | }; 85 | 86 | - (id) initWithResource: (struct wl_resource *) resource 87 | surface: (OwlSurface *) surface 88 | { 89 | _resource = resource; 90 | _surface = [surface retain]; 91 | wl_resource_set_implementation( 92 | resource, 93 | &xdg_surface_v6_impl, 94 | [self retain], 95 | xdg_surface_v6_destroy 96 | ); 97 | return self; 98 | } 99 | 100 | - (void) dealloc { 101 | [_surface release]; 102 | [super dealloc]; 103 | } 104 | 105 | - (void) sendConfigure { 106 | struct wl_client *client = wl_resource_get_client(_resource); 107 | struct wl_display *display = wl_client_get_display(client); 108 | uint32_t serial = wl_display_next_serial(display); 109 | zxdg_surface_v6_send_configure(_resource, serial); 110 | } 111 | 112 | - (NSSize) geometrySizeForBufferSize: (NSSize) size { 113 | NSSize adj = [_surface geometrySizeAdjustements]; 114 | size.width -= adj.width; 115 | size.height -= adj.height; 116 | return size; 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Sources/Shell/OwlWindow.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWindow.h" 20 | #import 21 | 22 | @implementation OwlWindow 23 | 24 | + (NSUInteger) styleMaskWhenDisplayingSSD: (BOOL) displaySSD { 25 | if (!displaySSD) { 26 | return NSBorderlessWindowMask; 27 | } 28 | return NSTitledWindowMask | NSClosableWindowMask | 29 | NSMiniaturizableWindowMask | NSResizableWindowMask; 30 | } 31 | 32 | - (id) initWithSize: (NSSize) size displaySSD: (BOOL) displaySSD { 33 | NSRect contentRect; 34 | contentRect.origin = NSMakePoint(500, 500); 35 | contentRect.size = size; 36 | 37 | NSUInteger styleMask = [OwlWindow styleMaskWhenDisplayingSSD: displaySSD]; 38 | self = [super initWithContentRect: contentRect 39 | styleMask: styleMask 40 | backing: NSBackingStoreBuffered 41 | defer: NO]; 42 | 43 | [self setOpaque: NO]; 44 | [self setBackgroundColor: [NSColor clearColor]]; 45 | [self setReleasedWhenClosed: NO]; 46 | [self setAcceptsMouseMovedEvents: YES]; 47 | 48 | // Does not automatically happen for borderless windows. 49 | [NSApp addWindowsItem: self title: @"Window" filename: NO]; 50 | 51 | return self; 52 | } 53 | 54 | - (void) setTitle: (NSString *) newTitle { 55 | newTitle = [newTitle retain]; 56 | [_title release]; 57 | _title = newTitle; 58 | [super setTitle: newTitle]; 59 | [NSApp changeWindowsItem: self title: newTitle filename: NO]; 60 | } 61 | 62 | - (void) dealloc { 63 | [_title release]; 64 | [super dealloc]; 65 | } 66 | 67 | - (BOOL) displaySSD { 68 | return ([self styleMask] & NSTitledWindowMask) != 0; 69 | } 70 | 71 | - (void) setDisplaySSD: (BOOL) displaySSD { 72 | [self setStyleMask: [OwlWindow styleMaskWhenDisplayingSSD: displaySSD]]; 73 | if (_title != nil) { 74 | [self setTitle: _title]; 75 | } 76 | } 77 | 78 | - (IBAction) toggleDisplaySSD: (NSMenuItem *) sender { 79 | BOOL displaySSD = ![self displaySSD]; 80 | [self setDisplaySSD: displaySSD]; 81 | [sender setState: displaySSD]; 82 | } 83 | 84 | - (BOOL) canBecomeKeyWindow { 85 | return YES; 86 | } 87 | 88 | - (BOOL) canBecomeMainWindow { 89 | return YES; 90 | } 91 | 92 | - (void) runInteractiveMove { 93 | NSPoint originalMouseLocation = [NSEvent mouseLocation]; 94 | NSPoint originalOrigin = [self frame].origin; 95 | NSEventMask mask = NSLeftMouseUpMask | NSMouseMovedMask | NSLeftMouseDraggedMask; 96 | 97 | while (YES) { 98 | NSEvent *event = [NSApp nextEventMatchingMask: mask 99 | untilDate: [NSDate distantFuture] 100 | inMode: NSEventTrackingRunLoopMode 101 | dequeue: YES]; 102 | 103 | if ([event type] == NSLeftMouseUp) { 104 | break; 105 | } 106 | 107 | NSPoint mouseLocation = [NSEvent mouseLocation]; 108 | 109 | NSPoint origin = originalOrigin; 110 | origin.x += mouseLocation.x - originalMouseLocation.x; 111 | origin.y += mouseLocation.y - originalMouseLocation.y; 112 | [self setFrameOrigin: origin]; 113 | } 114 | } 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlIOSurfaceBuffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import "OwlIOSurfaceBuffer.h" 23 | #import 24 | #import 25 | 26 | 27 | @implementation OwlIOSurfaceBuffer 28 | 29 | - (id) initWithResource: (struct wl_resource *) resource 30 | surfacePort: (mach_port_t) surfacePort 31 | { 32 | self = [super initWithResource: resource]; 33 | _surface = IOSurfaceLookupFromMachPort(surfacePort); 34 | return self; 35 | } 36 | 37 | - (void) dealloc { 38 | IOSurfaceDecrementUseCount(_surface); 39 | [super dealloc]; 40 | } 41 | 42 | - (void) invalidate { 43 | // ??? 44 | } 45 | 46 | - (NSSize) size { 47 | size_t width = IOSurfaceGetWidth(_surface); 48 | size_t height = IOSurfaceGetHeight(_surface); 49 | return NSMakeSize(width, height); 50 | } 51 | 52 | - (BOOL) needsGLForRendering { 53 | return YES; 54 | } 55 | 56 | - (void) setupTextureWithCGLContext: (CGLContextObj) context { 57 | glGenTextures(1, &_tex); 58 | glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _tex); 59 | 60 | size_t width = IOSurfaceGetWidth(_surface); 61 | size_t height = IOSurfaceGetHeight(_surface); 62 | 63 | CGLTexImageIOSurface2D( 64 | context, 65 | GL_TEXTURE_RECTANGLE_ARB, // target 66 | GL_RGBA, // internal_format 67 | width, 68 | height, 69 | GL_BGRA, // format 70 | GL_UNSIGNED_INT_8_8_8_8_REV, // type 71 | _surface, 72 | 0 // plane 73 | ); 74 | 75 | glTexParameteri( 76 | GL_TEXTURE_RECTANGLE_ARB, 77 | GL_TEXTURE_MIN_FILTER, 78 | GL_LINEAR 79 | ); 80 | glTexParameteri( 81 | GL_TEXTURE_RECTANGLE_ARB, 82 | GL_TEXTURE_MAG_FILTER, 83 | GL_LINEAR 84 | ); 85 | glTexParameteri( 86 | GL_TEXTURE_RECTANGLE_ARB, 87 | GL_TEXTURE_WRAP_S, 88 | GL_CLAMP_TO_EDGE 89 | ); 90 | glTexParameteri( 91 | GL_TEXTURE_RECTANGLE_ARB, 92 | GL_TEXTURE_WRAP_T, 93 | GL_CLAMP_TO_EDGE 94 | ); 95 | } 96 | 97 | - (void) drawInRect: (NSRect) rect { 98 | glViewport(0, 0, rect.size.width, rect.size.height); 99 | glMatrixMode(GL_PROJECTION); 100 | glLoadIdentity(); 101 | glOrtho(0, rect.size.width, 0, rect.size.height, -1, 1); 102 | 103 | glMatrixMode(GL_MODELVIEW); 104 | glLoadIdentity(); 105 | 106 | struct { 107 | GLfloat x, y; 108 | } coord[4] = { 109 | {0, 0}, 110 | {rect.size.width, 0}, 111 | {0, rect.size.height}, 112 | {rect.size.width, rect.size.height} 113 | }; 114 | 115 | glEnable(GL_TEXTURE_RECTANGLE_ARB); 116 | 117 | NSOpenGLContext *currentContext = [NSOpenGLContext currentContext]; 118 | [self setupTextureWithCGLContext: [currentContext CGLContextObj]]; 119 | 120 | glEnableClientState(GL_VERTEX_ARRAY); 121 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); 122 | 123 | glPushMatrix(); 124 | glTexCoordPointer(2, GL_FLOAT, 0, coord); 125 | glVertexPointer(2, GL_FLOAT, 0, coord); 126 | 127 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 128 | 129 | glPopMatrix(); 130 | 131 | glFlush(); 132 | } 133 | 134 | - (void) notifyDetached { 135 | [self sendRelease]; 136 | } 137 | 138 | @end 139 | 140 | #endif /* OWL_PLATFORM_APPLE */ 141 | -------------------------------------------------------------------------------- /Sources/Data/OwlPasteboardDataDevice.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPasteboardDataDevice.h" 20 | #import "OwlPasteboardDataOffer.h" 21 | #import "OwlPasteboardDataSource.h" 22 | #import "OwlServer.h" 23 | #import "OwlSelection.h" 24 | 25 | 26 | @implementation OwlPasteboardDataDevice 27 | 28 | // Publish a fresh data source representing our pasteboard 29 | // as the selection content. 30 | - (void) publishDataSource { 31 | OwlPasteboardDataSource *dataSource = [OwlPasteboardDataSource alloc]; 32 | dataSource = [dataSource initWithPasteboard: _pasteboard]; 33 | 34 | [_selection setDataSource: dataSource]; 35 | [dataSource release]; 36 | [[OwlServer sharedServer] flushClientsLater]; 37 | } 38 | 39 | // FIXME: This is only called by our own offers when they get cancelled, 40 | // which means we miss refreshes when we don't own the pasteboard. 41 | - (void) pasteboardRefreshed { 42 | if (_ignoreRefreshes) { 43 | return; 44 | } 45 | // We have to do this asynchronously, otherwise NSPasteboard gets confused over 46 | // accessing pasteboard contents from the pasteboardChangedOwner handler, and 47 | // sends the same notification again and again, recursively. 48 | // The order argument below represents which order these delayed selectors should 49 | // be executed in; lower values go first. We do not care, so pass some large number. 50 | NSArray *modes = [NSArray arrayWithObject: NSDefaultRunLoopMode]; 51 | [[NSRunLoop currentRunLoop] performSelector: @selector(publishDataSource) 52 | target: self 53 | argument: nil 54 | order: 1000 55 | modes: modes]; 56 | } 57 | 58 | - (id) initWithPasteboard: (NSPasteboard *) pboard 59 | selection: (OwlSelection *) selection 60 | { 61 | self = [super initWithResource: NULL]; 62 | _pasteboard = [pboard retain]; 63 | _selection = [selection retain]; 64 | [selection addDataDevice: self]; 65 | // On startup, initialize selection with pasteboard contents. 66 | // We assume no clients have connected yet. 67 | [self pasteboardRefreshed]; 68 | return self; 69 | } 70 | 71 | - (void) dealloc { 72 | [_pasteboard release]; 73 | [_selection removeDataDevice: self]; 74 | [_selection release]; 75 | [_currentOffer release]; 76 | [super dealloc]; 77 | } 78 | 79 | - (NSPasteboard *) pasteboard { 80 | return _pasteboard; 81 | } 82 | 83 | // Selection has changed; proxy the new contents to the pasteboard. 84 | - (void) selectionChanged: (OwlSelection *) selection { 85 | OwlDataSource *dataSource = [selection dataSource]; 86 | [_currentOffer release]; 87 | _currentOffer = nil; 88 | 89 | if (dataSource == nil) { 90 | [_pasteboard clearContents]; 91 | return; 92 | } 93 | 94 | // Don't proxy pasteboard contents back to the pasteboard. 95 | if ([dataSource isKindOfClass: [OwlPasteboardDataSource class]]) { 96 | return; 97 | } 98 | 99 | _ignoreRefreshes = YES; 100 | _currentOffer = [OwlPasteboardDataOffer alloc]; 101 | _currentOffer = [_currentOffer initWithDataDevice: self 102 | dataSource: dataSource]; 103 | _ignoreRefreshes = NO; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlSubsurface.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlSubsurface.h" 20 | #import "OwlSurface.h" 21 | #import "OwlServer.h" 22 | #import 23 | 24 | @implementation OwlSubsurface 25 | 26 | static void subsurface_destroy_handler( 27 | struct wl_client *client, 28 | struct wl_resource *resource 29 | ) { 30 | wl_resource_destroy(resource); 31 | } 32 | 33 | static void subsurface_destroy(struct wl_resource *resource) { 34 | OwlSubsurface *self = wl_resource_get_user_data(resource); 35 | [self unmap]; 36 | [self->_surface setRole: nil]; 37 | [self release]; 38 | } 39 | 40 | static void subsurface_set_position_handler( 41 | struct wl_client *client, 42 | struct wl_resource *resource, 43 | int32_t x, 44 | int32_t y 45 | ) { 46 | OwlSubsurface *self = wl_resource_get_user_data(resource); 47 | self->_position = NSMakePoint(x, y); 48 | } 49 | 50 | static void subsurface_place_above_handler( 51 | struct wl_client *client, 52 | struct wl_resource *resource, 53 | struct wl_resource *sibling_resource 54 | ) { 55 | OwlSubsurface *self = wl_resource_get_user_data(resource); 56 | // TODO 57 | } 58 | 59 | static void subsurface_place_below_handler( 60 | struct wl_client *client, 61 | struct wl_resource *resource, 62 | struct wl_resource *sibling_resource 63 | ) { 64 | OwlSubsurface *self = wl_resource_get_user_data(resource); 65 | // TODO 66 | } 67 | 68 | static void subsurface_set_sync_handler( 69 | struct wl_client *client, 70 | struct wl_resource *resource 71 | ) { 72 | OwlSubsurface *self = wl_resource_get_user_data(resource); 73 | // TODO 74 | } 75 | 76 | static void subsurface_set_desync_handler( 77 | struct wl_client *client, 78 | struct wl_resource *resource 79 | ) { 80 | OwlSubsurface *self = wl_resource_get_user_data(resource); 81 | // TODO 82 | } 83 | 84 | static const struct wl_subsurface_interface subsurface_impl = { 85 | .destroy = subsurface_destroy_handler, 86 | .set_position = subsurface_set_position_handler, 87 | .place_above = subsurface_place_above_handler, 88 | .place_below = subsurface_place_below_handler, 89 | .set_sync = subsurface_set_sync_handler, 90 | .set_desync = subsurface_set_desync_handler 91 | }; 92 | 93 | - (id) initWithResource: (struct wl_resource *) resource 94 | surface: (OwlSurface *) surface 95 | parent: (OwlSurface *) parent 96 | { 97 | _resource = resource; 98 | _surface = [surface retain]; 99 | _parent = [parent retain]; 100 | [surface setRole: self]; 101 | 102 | wl_resource_set_implementation( 103 | resource, 104 | &subsurface_impl, 105 | [self retain], 106 | subsurface_destroy 107 | ); 108 | 109 | return self; 110 | } 111 | 112 | - (void) dealloc { 113 | [self unmap]; 114 | [_surface release]; 115 | [_parent release]; 116 | [super dealloc]; 117 | } 118 | 119 | // FIXME: These are supposed to be applied on parent's next commit. 120 | - (void) map { 121 | [_parent addSubview: _surface]; 122 | [self update]; 123 | } 124 | 125 | - (void) unmap { 126 | [_surface removeFromSuperview]; 127 | } 128 | 129 | - (void) update { 130 | NSPoint origin; 131 | origin.x = _position.x; 132 | origin.y = [_parent frame].size.height - [_surface frame].size.height - _position.y; 133 | [_surface setFrameOrigin: origin]; 134 | } 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlZowlIOSurfaceV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlFeatures.h" 20 | #ifdef OWL_PLATFORM_APPLE 21 | 22 | #import "OwlZowlIOSurfaceV1.h" 23 | #import "owl-iosurface-unstable-v1.h" 24 | #import "owl-iosurface-unstable-v1-mig.h" 25 | #import "OwlMIG.h" 26 | #import "OwlIOSurfaceBuffer.h" 27 | 28 | @implementation OwlZowlIOSurfaceV1 29 | 30 | static NSMutableArray *instances; 31 | 32 | + (void) initialize { 33 | if (instances == nil) { 34 | instances = [[NSMutableArray alloc] init]; 35 | } 36 | } 37 | 38 | static void iosurface_destroy_handler( 39 | struct wl_client *client, 40 | struct wl_resource *resource 41 | ) { 42 | wl_resource_destroy(resource); 43 | } 44 | 45 | static void iosurface_destroy(struct wl_resource *resource) { 46 | OwlZowlIOSurfaceV1 *self = wl_resource_get_user_data(resource); 47 | [self release]; 48 | } 49 | 50 | static void iosurface_create_buffer_handler( 51 | struct wl_client *client, 52 | struct wl_resource *resource, 53 | uint32_t id 54 | ) { 55 | OwlZowlIOSurfaceV1 *self = wl_resource_get_user_data(resource); 56 | struct wl_resource *buffer_resource = wl_resource_create( 57 | client, 58 | &wl_buffer_interface, 59 | 1, 60 | id 61 | ); 62 | [[[OwlIOSurfaceBuffer alloc] initWithResource: buffer_resource 63 | surfacePort: self->_surfacePort] release]; 64 | } 65 | 66 | static const struct zowl_iosurface_v1_interface iosurface_impl = { 67 | .create_buffer = iosurface_create_buffer_handler, 68 | .destroy = iosurface_destroy_handler 69 | }; 70 | 71 | - (id) initWithResource: (struct wl_resource *) resource { 72 | [instances addObject: self]; 73 | _resource = resource; 74 | wl_resource_set_implementation( 75 | resource, 76 | &iosurface_impl, 77 | [self retain], 78 | iosurface_destroy 79 | ); 80 | 81 | // Create the receiver port and serve owl_iosurface_v1 on it. 82 | mach_port_allocate( 83 | mach_task_self(), 84 | MACH_PORT_RIGHT_RECEIVE, 85 | &_receiverPort 86 | ); 87 | [OwlMIG serveOnPort: _receiverPort 88 | usingCallback: owl_iosurface_v1_server 89 | maxSize: 100]; 90 | 91 | return self; 92 | } 93 | 94 | - (void) dealloc { 95 | mach_port_deallocate(mach_task_self(), _receiverPort); 96 | if (MACH_PORT_VALID (_surfacePort)) { 97 | mach_port_deallocate(mach_task_self(), _surfacePort); 98 | } 99 | [instances removeObject: self]; 100 | [super dealloc]; 101 | } 102 | 103 | - (mach_port_t) receiverPort { 104 | return _receiverPort; 105 | } 106 | 107 | + (OwlZowlIOSurfaceV1 *) surfaceByReceiverPort: (mach_port_t) port { 108 | for (OwlZowlIOSurfaceV1 *surface in instances) { 109 | if (surface->_receiverPort == port) { 110 | return surface; 111 | } 112 | } 113 | return nil; 114 | } 115 | 116 | kern_return_t owl_iosurface_v1_server_set_surface_port( 117 | mach_port_t receiver_port, 118 | mach_port_t iosurface_port 119 | ) { 120 | OwlZowlIOSurfaceV1 *surface = [OwlZowlIOSurfaceV1 surfaceByReceiverPort: receiver_port]; 121 | if (surface == nil) { 122 | NSLog(@"Failed to find the surface the receiver port belongs to"); 123 | return KERN_INVALID_ARGUMENT; 124 | } 125 | surface->_surfacePort = iosurface_port; 126 | return KERN_SUCCESS; 127 | } 128 | 129 | @end 130 | 131 | #endif /* OWL_PLATFORM_APPLE */ 132 | -------------------------------------------------------------------------------- /Sources/Seat/OwlPointer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlPointer.h" 20 | #import 21 | #import "OwlServer.h" 22 | #import "OwlSurface.h" 23 | 24 | 25 | @implementation OwlPointer 26 | 27 | static NSMutableArray *pointers; 28 | 29 | + (void) initialize { 30 | if (pointers == nil) { 31 | pointers = [[NSMutableArray alloc] initWithCapacity: 1]; 32 | } 33 | } 34 | 35 | + (OwlPointer *) pointerForClient: (struct wl_client *) client { 36 | for (OwlPointer *pointer in pointers) { 37 | struct wl_resource *resource = pointer->_resource; 38 | if (client == wl_resource_get_client(resource)) { 39 | return pointer; 40 | } 41 | } 42 | return nil; 43 | } 44 | 45 | static void pointer_set_cursor( 46 | struct wl_client *client, 47 | struct wl_resource *resource, 48 | uint32_t serial, 49 | struct wl_resource *surface_resource, 50 | int32_t hotspot_x, 51 | int32_t hotspot_y 52 | ) { 53 | // TODO 54 | } 55 | 56 | static const struct wl_pointer_interface pointer_impl = { 57 | .set_cursor = pointer_set_cursor 58 | }; 59 | 60 | static void pointer_destroy(struct wl_resource *resource) { 61 | OwlPointer *self = wl_resource_get_user_data(resource); 62 | [pointers removeObjectIdenticalTo: self]; 63 | [self release]; 64 | } 65 | 66 | - (id) initWithResource: (struct wl_resource *) resource { 67 | _resource = resource; 68 | [pointers addObject: self]; 69 | wl_resource_set_implementation( 70 | resource, 71 | &pointer_impl, 72 | [self retain], 73 | pointer_destroy 74 | ); 75 | return self; 76 | } 77 | 78 | - (struct wl_resource *) resource { 79 | return _resource; 80 | } 81 | 82 | - (void) sendEnterSurface: (OwlSurface *) surface atPoint: (NSPoint) point { 83 | wl_pointer_send_enter( 84 | _resource, 85 | [[OwlServer sharedServer] nextSerial], 86 | [surface resource], 87 | wl_fixed_from_double(point.x), 88 | wl_fixed_from_double(point.y) 89 | ); 90 | } 91 | 92 | - (void) sendMotionAtPoint: (NSPoint) point { 93 | wl_pointer_send_motion( 94 | _resource, 95 | [OwlServer timestamp], 96 | wl_fixed_from_double(point.x), 97 | wl_fixed_from_double(point.y) 98 | ); 99 | } 100 | 101 | - (void) sendLeaveSurface: (OwlSurface *) surface { 102 | wl_pointer_send_leave( 103 | _resource, 104 | [[OwlServer sharedServer] nextSerial], 105 | [surface resource] 106 | ); 107 | } 108 | 109 | - (void) sendScrollByX: (CGFloat) deltaX byY: (CGFloat) deltaY { 110 | uint32_t timestamp = [OwlServer timestamp]; 111 | 112 | if (deltaX != 0.0) { 113 | wl_pointer_send_axis( 114 | _resource, 115 | timestamp, 116 | WL_POINTER_AXIS_HORIZONTAL_SCROLL, 117 | wl_fixed_from_double(deltaX) 118 | ); 119 | } 120 | 121 | if (deltaY != 0.0) { 122 | wl_pointer_send_axis( 123 | _resource, 124 | timestamp, 125 | WL_POINTER_AXIS_VERTICAL_SCROLL, 126 | wl_fixed_from_double(-deltaY) 127 | ); 128 | } 129 | } 130 | 131 | - (void) sendButton: (uint32_t) button isPressed: (BOOL) isPressed { 132 | enum wl_pointer_button_state state = isPressed 133 | ? WL_POINTER_BUTTON_STATE_PRESSED 134 | : WL_POINTER_BUTTON_STATE_RELEASED; 135 | 136 | wl_pointer_send_button( 137 | _resource, 138 | [[OwlServer sharedServer] nextSerial], 139 | [OwlServer timestamp], 140 | button, 141 | state 142 | ); 143 | } 144 | 145 | @end 146 | -------------------------------------------------------------------------------- /Sources/Data/OwlWlDataDevice.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlWlDataDevice.h" 20 | #import 21 | #import "OwlWlDataSource.h" 22 | #import "OwlWlDataOffer.h" 23 | #import "OwlSelection.h" 24 | 25 | 26 | @implementation OwlWlDataDevice 27 | 28 | static NSMutableArray *dataDevices; 29 | 30 | + (void) initialize { 31 | if (dataDevices == nil) { 32 | dataDevices = [[NSMutableArray alloc] initWithCapacity: 1]; 33 | } 34 | } 35 | 36 | + (OwlWlDataDevice *) dataDeviceForClient: (struct wl_client *) client { 37 | for (OwlWlDataDevice *dataDevice in dataDevices) { 38 | struct wl_resource *resource = dataDevice->_resource; 39 | if (client == wl_resource_get_client(resource)) { 40 | return dataDevice; 41 | } 42 | } 43 | return nil; 44 | } 45 | 46 | static void data_device_destroy(struct wl_resource *resource) { 47 | OwlWlDataDevice *self = wl_resource_get_user_data(resource); 48 | [dataDevices removeObjectIdenticalTo: self]; 49 | [self release]; 50 | } 51 | 52 | static void data_device_set_selection_handler( 53 | struct wl_client *client, 54 | struct wl_resource *resource, 55 | struct wl_resource *source_resource, 56 | uint32_t serial 57 | ) { 58 | // TODO: Check the serial corresponds to an event of the focused surface 59 | // and the event is not it gaining focus. 60 | OwlWlDataDevice *self = wl_resource_get_user_data(resource); 61 | OwlWlDataSource *dataSource = nil; 62 | if (source_resource != NULL) { 63 | dataSource = wl_resource_get_user_data(source_resource); 64 | } 65 | [[OwlSelection clipboard] setDataSource: dataSource]; 66 | } 67 | 68 | static void data_device_release_handler( 69 | struct wl_client *client, 70 | struct wl_resource *resource 71 | ) { 72 | wl_resource_destroy(resource); 73 | } 74 | 75 | static const struct wl_data_device_interface data_device_impl = { 76 | .set_selection = data_device_set_selection_handler, 77 | .release = data_device_release_handler 78 | }; 79 | 80 | - (id) initWithResource: (struct wl_resource *) resource { 81 | self = [super initWithResource: resource]; 82 | wl_resource_set_implementation( 83 | resource, 84 | &data_device_impl, 85 | [self retain], 86 | data_device_destroy 87 | ); 88 | [dataDevices addObject: self]; 89 | [[OwlSelection clipboard] addDataDevice: self]; 90 | // FIXME: Call [self focused] here if we already have focus. 91 | [self selectionChanged: [OwlSelection clipboard]]; 92 | return self; 93 | } 94 | 95 | - (void) dealloc { 96 | [[OwlSelection clipboard] removeDataDevice: self]; 97 | [super dealloc]; 98 | } 99 | 100 | - (void) sendSelection { 101 | _selectionHasChangedSinceLastFocused = NO; 102 | OwlDataSource *dataSource = [[OwlSelection clipboard] dataSource]; 103 | 104 | if (dataSource == nil) { 105 | wl_data_device_send_selection(_resource, NULL); 106 | return; 107 | } 108 | 109 | struct wl_resource *offer_resource = wl_resource_create( 110 | wl_resource_get_client(_resource), 111 | &wl_data_offer_interface, 112 | 2, 113 | 0 114 | ); 115 | wl_data_device_send_data_offer(_resource, offer_resource); 116 | // Creating an OwlDataOffer sends out the MIME types automatically. 117 | OwlWlDataOffer *offer = 118 | [[OwlWlDataOffer alloc] initWithResource: offer_resource 119 | dataSource: dataSource]; 120 | wl_data_device_send_selection(_resource, offer_resource); 121 | [offer release]; 122 | } 123 | 124 | - (void) selectionChanged: (OwlSelection *) selection { 125 | if (_focusCount > 0) { 126 | [self sendSelection]; 127 | } else { 128 | _selectionHasChangedSinceLastFocused = YES; 129 | } 130 | } 131 | 132 | - (void) focused { 133 | _focusCount++; 134 | if (_focusCount == 1 && _selectionHasChangedSinceLastFocused) { 135 | [self sendSelection]; 136 | } 137 | } 138 | 139 | - (void) unfocused { 140 | _focusCount--; 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Sources/Protocol/owl-mach-ipc-unstable-v1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Copyright © 2019-2021 Sergey Bugaev 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a 8 | copy of this software and associated documentation files (the "Software"), 9 | to deal in the Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | and/or sell copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice (including the next 15 | paragraph) shall be included in all copies or substantial portions of the 16 | Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | 27 | 28 | 29 | This protocol allows the client and the compositor to set up a connection over 30 | Mach IPC using the Mach bootstrap server. This may be useful for a number of 31 | reasons, including sharing resources that can only be shared over a Mach IPC-based 32 | API. 33 | 34 | This protocol does not, by itself, assign any meaning or semantics to the Mach ports 35 | it creates. In order for any port to be actually used for any concrete task, it needs 36 | to be assigned a role, which determines what other operations (such as MIG routines) 37 | are valid to be used on it. 38 | 39 | See owl-iosurface for an example of a protocol that makes use of owl-mach-ipc. 40 | 41 | 42 | 43 | 44 | By sending this event, the compositor announces the bootstrap service name 45 | it uses. The client is then expected to look up the compositor's Mach port 46 | using a call such as bootstrap_look_up(). 47 | 48 | 49 | 50 | 51 | 52 | 53 | This request creates a zowl_mach_ipc_port_v1 object that wraps a Mach port 54 | that is usable for communication between the server and the client. This request 55 | by itself does not create the underlying Mach port of the zowl_mach_ipc_port_v1 56 | object. In order to create or otherwise get the underlying Mach port, the 57 | zowl_mach_ipc_port_v1 needs to be assigned a role first. 58 | 59 | 60 | 61 | 62 | 63 | 64 | Destroy this zowl_mach_ipc_v1 object and all the resources associated with 65 | it. Destroying a zowl_mach_ipc_v1 object while a Mach port that was created 66 | using it is in use is an error. 67 | 68 | 69 | 70 | 71 | 72 | 73 | This interface represents a Mach IPC port. To create or otherwise get the underlying 74 | Mach port, as well as to make use of it, this object needs to be assigned a role 75 | using some other protocol (such as owl-iosurface). 76 | 77 | After this object has been assigned a role, the client can retrieve the underlying 78 | mach_port_t (as a send right) using the owl_mach_ipc_v1_retrieve_port() MIG routine, 79 | passing the port obtained from the bootstrap server and the secret sent by the server 80 | in the zowl_mach_ipc_port_v1.secret event. 81 | 82 | 83 | 84 | 85 | This event announces the secret key that the client can pass into the 86 | owl_mach_ipc_v1_retrieve_port() MIG routine in order to retrieve the underlying 87 | mach_port_t of this zowl_mach_ipc_port_v1. 88 | 89 | The secret key is both a security measure that prevents other processes from 90 | impersonating the client, and a way for the compositor to know which 91 | zowl_mach_ipc_port_v1 instance the port is requested for. 92 | 93 | 94 | 95 | 96 | 97 | 98 | Destroy this zowl_mach_ipc_port_v1 object and all the resources associated 99 | with it, including the underlying Mach port, if it is still valid. 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /Sources/Data/OwlZwlrDataControlDeviceV1.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlZwlrDataControlDeviceV1.h" 20 | #import "wlr-data-control-unstable-v1.h" 21 | #import "OwlZwlrDataControlSourceV1.h" 22 | #import "OwlZwlrDataControlOfferV1.h" 23 | #import "OwlSelection.h" 24 | #import "OwlFeatures.h" 25 | #import 26 | 27 | 28 | @implementation OwlZwlrDataControlDeviceV1 29 | 30 | static void data_control_device_destroy(struct wl_resource *resource) { 31 | OwlZwlrDataControlDeviceV1 *self = wl_resource_get_user_data(resource); 32 | [self release]; 33 | } 34 | 35 | static void data_control_device_set_selection_handler( 36 | struct wl_client *client, 37 | struct wl_resource *resource, 38 | struct wl_resource *source_resource 39 | ) { 40 | OwlZwlrDataControlDeviceV1 *self = wl_resource_get_user_data(resource); 41 | OwlZwlrDataControlSourceV1 *dataSource = nil; 42 | if (source_resource != NULL) { 43 | dataSource = (OwlZwlrDataControlSourceV1 *) wl_resource_get_user_data(source_resource); 44 | } 45 | [[OwlSelection clipboard] setDataSource: dataSource]; 46 | } 47 | 48 | #ifdef OWL_PLATFORM_GNUSTEP 49 | static void data_control_device_set_primary_selection_handler( 50 | struct wl_client *client, 51 | struct wl_resource *resource, 52 | struct wl_resource *source_resource 53 | ) { 54 | OwlZwlrDataControlDeviceV1 *self = wl_resource_get_user_data(resource); 55 | OwlZwlrDataControlSourceV1 *dataSource = nil; 56 | if (source_resource != NULL) { 57 | dataSource = (OwlZwlrDataControlSourceV1 *) wl_resource_get_user_data(source_resource); 58 | } 59 | [[OwlSelection primary] setDataSource: dataSource]; 60 | } 61 | #endif 62 | 63 | static void data_control_device_destroy_handler( 64 | struct wl_client *client, 65 | struct wl_resource *resource 66 | ) { 67 | wl_resource_destroy(resource); 68 | } 69 | 70 | static const struct zwlr_data_control_device_v1_interface data_control_device_impl = { 71 | .set_selection = data_control_device_set_selection_handler, 72 | #ifdef OWL_PLATFORM_GNUSTEP 73 | .set_primary_selection = data_control_device_set_primary_selection_handler, 74 | #endif 75 | .destroy = data_control_device_destroy_handler 76 | }; 77 | 78 | - (id) initWithResource: (struct wl_resource *) resource { 79 | self = [super initWithResource: resource]; 80 | wl_resource_set_implementation( 81 | resource, 82 | &data_control_device_impl, 83 | [self retain], 84 | data_control_device_destroy 85 | ); 86 | 87 | [[OwlSelection clipboard] addDataDevice: self]; 88 | [self selectionChanged: [OwlSelection clipboard]]; 89 | #ifdef OWL_PLATFORM_GNUSTEP 90 | [[OwlSelection primary] addDataDevice: self]; 91 | [self selectionChanged: [OwlSelection primary]]; 92 | #endif 93 | 94 | return self; 95 | } 96 | 97 | - (void) dealloc { 98 | [[OwlSelection clipboard] removeDataDevice: self]; 99 | #ifdef OWL_PLATFORM_GNUSTEP 100 | [[OwlSelection primary] removeDataDevice: self]; 101 | #endif 102 | [super dealloc]; 103 | } 104 | 105 | - (void) sendOffer: (OwlZwlrDataControlOfferV1 *) offer 106 | forSelection: (OwlSelection *) selection 107 | { 108 | struct wl_resource *offer_resource = [offer resource]; 109 | 110 | if (selection == [OwlSelection clipboard]) { 111 | zwlr_data_control_device_v1_send_selection(_resource, offer_resource); 112 | #ifdef OWL_PLATFORM_GNUSTEP 113 | } else if (selection == [OwlSelection primary]) { 114 | if (wl_resource_get_version(_resource) >= 2) { 115 | zwlr_data_control_device_v1_send_primary_selection( 116 | _resource, 117 | offer_resource 118 | ); 119 | } 120 | #endif 121 | } else { 122 | [NSException raise: NSInternalInconsistencyException 123 | format: @"Unexpected selection: %@", selection]; 124 | } 125 | } 126 | 127 | - (void) selectionChanged: (OwlSelection *) selection { 128 | OwlDataSource *dataSource = [selection dataSource]; 129 | 130 | if (dataSource == nil) { 131 | [self sendOffer: nil forSelection: selection]; 132 | return; 133 | } 134 | 135 | // Introduce a new offer to the client. 136 | struct wl_resource *offer_resource = wl_resource_create( 137 | wl_resource_get_client(_resource), 138 | &zwlr_data_control_offer_v1_interface, 139 | wl_resource_get_version(_resource), 140 | 0 141 | ); 142 | zwlr_data_control_device_v1_send_data_offer(_resource, offer_resource); 143 | // Creating an OwlDataOffer sends out the MIME types automatically. 144 | OwlZwlrDataControlOfferV1 *offer = 145 | [[OwlZwlrDataControlOfferV1 alloc] initWithResource: offer_resource 146 | dataSource: dataSource]; 147 | [self sendOffer: offer forSelection: selection]; 148 | [offer release]; 149 | } 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /Sources/Compositor/OwlShmBuffer.m: -------------------------------------------------------------------------------- 1 | /* This file is part of Owl. 2 | * 3 | * Copyright © 2019-2021 Sergey Bugaev 4 | * 5 | * Owl is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, 8 | * or (at your option) any later version. 9 | * 10 | * Owl is distributed in the hope that it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Owl. If not, see . 17 | */ 18 | 19 | #import "OwlShmBuffer.h" 20 | #import "OwlFeatures.h" 21 | 22 | 23 | @implementation OwlShmBuffer 24 | 25 | #ifdef OWL_PLATFORM_APPLE 26 | 27 | - (CGBitmapInfo) bitmapInfoForWlShmFormat: (enum wl_shm_format) shmFormat { 28 | switch (shmFormat) { 29 | case WL_SHM_FORMAT_XRGB8888: 30 | return kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; 31 | case WL_SHM_FORMAT_ARGB8888: 32 | return kCGImageAlphaFirst | kCGBitmapByteOrder32Little; 33 | default: 34 | NSLog(@"Unknown shm format"); 35 | return 0; 36 | } 37 | } 38 | 39 | static void dataReleaseCallback(void *info, const void *data, size_t size) { 40 | free((void *) data); 41 | } 42 | 43 | #endif /* OWL_PLATFORM_APPLE */ 44 | 45 | - (void) releaseImage { 46 | #ifdef OWL_PLATFORM_APPLE 47 | if (_image != NULL) { 48 | CGImageRelease(_image); 49 | _image = NULL; 50 | } 51 | #else 52 | [_rep release]; 53 | _rep = nil; 54 | #endif 55 | } 56 | 57 | - (void) invalidate { 58 | [self releaseImage]; 59 | 60 | enum wl_shm_format format = wl_shm_buffer_get_format(_buffer); 61 | size_t width = wl_shm_buffer_get_width(_buffer); 62 | size_t height = wl_shm_buffer_get_height(_buffer); 63 | size_t stride = wl_shm_buffer_get_stride(_buffer); 64 | void *data = wl_shm_buffer_get_data(_buffer); 65 | size_t size = height * stride; 66 | 67 | #ifdef OWL_PLATFORM_APPLE 68 | CGBitmapInfo bitmapInfo = [self bitmapInfoForWlShmFormat: format]; 69 | 70 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 71 | 72 | void *dataCopy = malloc(size); 73 | wl_shm_buffer_begin_access(_buffer); 74 | memcpy(dataCopy, data, size); 75 | wl_shm_buffer_end_access(_buffer); 76 | [self sendRelease]; 77 | 78 | CGDataProviderRef provider = CGDataProviderCreateWithData( 79 | NULL, 80 | dataCopy, 81 | size, 82 | dataReleaseCallback 83 | ); 84 | _image = CGImageCreate( 85 | width, 86 | height, 87 | 8, // bitsPerComponent 88 | 32, // bitsPerPixel 89 | stride, 90 | colorSpace, 91 | bitmapInfo, 92 | provider, 93 | NULL, // decode 94 | YES, // shouldInterpolate 95 | kCGRenderingIntentDefault 96 | ); 97 | CGDataProviderRelease(provider); 98 | 99 | CGColorSpaceRelease(colorSpace); 100 | #else /* OWL_PLATFORM_APPLE */ 101 | BOOL hasAlpha = format == WL_SHM_FORMAT_ARGB8888; 102 | size_t samplesPerPixel = hasAlpha ? 4 : 3; 103 | size_t destStride = samplesPerPixel * width; 104 | 105 | _rep = [NSBitmapImageRep alloc]; 106 | _rep = [_rep initWithBitmapDataPlanes: NULL 107 | pixelsWide: width 108 | pixelsHigh: height 109 | bitsPerSample: 8 110 | samplesPerPixel: samplesPerPixel 111 | hasAlpha: hasAlpha 112 | isPlanar: NO 113 | colorSpaceName: NSCalibratedRGBColorSpace 114 | bitmapFormat: 0 115 | bytesPerRow: destStride 116 | bitsPerPixel: 8 * samplesPerPixel]; 117 | 118 | void *destData = [_rep bitmapData]; 119 | wl_shm_buffer_begin_access(_buffer); 120 | 121 | struct bgra { 122 | unsigned char b, g, r, a; 123 | }; 124 | struct rgba { 125 | unsigned char r, g, b, a; 126 | }; 127 | 128 | for (size_t row = 0; row < height; row++) { 129 | for (size_t col = 0; col < width; col++) { 130 | struct bgra *source = data + row * stride + col * 4; 131 | struct rgba *dest = destData + row * destStride + col * samplesPerPixel; 132 | dest->r = source->r; 133 | dest->g = source->g; 134 | dest->b = source->b; 135 | if (hasAlpha) { 136 | dest->a = source->a; 137 | } 138 | } 139 | } 140 | 141 | wl_shm_buffer_end_access(_buffer); 142 | [self sendRelease]; 143 | #endif /* OWL_PLATFORM_APPLE */ 144 | } 145 | 146 | - (id) initWithResource: (struct wl_resource *) resource { 147 | self = [super initWithExternallyImplementedResource: resource]; 148 | 149 | _buffer = wl_shm_buffer_get(resource); 150 | if (_buffer == NULL) { 151 | [NSException raise: NSInternalInconsistencyException 152 | format: @"wl_shm_buffer_get(wl_buffer@%u) == NULL", 153 | wl_resource_get_id(resource)]; 154 | return nil; 155 | } 156 | 157 | return self; 158 | } 159 | 160 | - (void) dealloc { 161 | [self releaseImage]; 162 | [super dealloc]; 163 | } 164 | 165 | - (NSSize) size { 166 | size_t width = wl_shm_buffer_get_width(_buffer); 167 | size_t height = wl_shm_buffer_get_height(_buffer); 168 | return NSMakeSize(width, height); 169 | } 170 | 171 | - (void) drawInRect: (NSRect) rect { 172 | #ifdef OWL_PLATFORM_APPLE 173 | CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; 174 | CGContextSetBlendMode(context, kCGBlendModeCopy); 175 | CGContextDrawImage(context, rect, _image); 176 | #else 177 | [_rep drawInRect: rect 178 | fromRect: rect 179 | operation: NSCompositeSourceOver 180 | fraction: 1.0 181 | respectFlipped: NO 182 | hints: nil]; 183 | #endif 184 | } 185 | 186 | @end 187 | --------------------------------------------------------------------------------