Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using kayak-ui without primary window? #202

Open
laundmo opened this issue Dec 21, 2022 · 2 comments
Open

Using kayak-ui without primary window? #202

laundmo opened this issue Dec 21, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@laundmo
Copy link

laundmo commented Dec 21, 2022

I'm working on a application which doesn't use a primary window, and instead relies on running in the background and sometimes opening other windows.

Kayak doesn't seem to allow for this, as it .unwrap()s on trying to get the primary window.

Error:

2022-12-21T22:38:26.846011Z  WARN kayak_ui::input: Couldn't find primiary window!    
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\laundmo\.cargo\git\checkouts\kayak_ui-299a0b6ac8320811\910a00c\src\widgets\app.rs:63:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Due to:

let primary_window = windows.get_primary().unwrap();

Is this something which is planned to be supported?

Hello World based minimal reproduction
use bevy::prelude::*;
use kayak_ui::prelude::{widgets::*, *};

fn startup(
    mut commands: Commands,
    mut font_mapping: ResMut<FontMapping>,
    asset_server: Res<AssetServer>,
) {
    font_mapping.set_default(asset_server.load("roboto.kayak_font"));

    let mut widget_context = KayakRootContext::new();
    widget_context.add_plugin(KayakWidgetsContextPlugin);
    let parent_id = None;
    rsx! {
        <KayakAppBundle>
            <TextWidgetBundle
                text={TextProps {
                    content: "Hello World".into(),
                    size: 20.0,
                    ..Default::default()
                }}
            />
        </KayakAppBundle>
    };

    commands.spawn(UICameraBundle::new(widget_context));
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            add_primary_window: false,
            exit_on_all_closed: false,
            ..default()
        }))
        .add_plugin(KayakContextPlugin)
        .add_plugin(KayakWidgets)
        .add_startup_system(startup)
        .run()
}
@StarArawn StarArawn added the bug Something isn't working label Dec 26, 2022
@RaminKav
Copy link
Contributor

I noticed this happens when i run any of the examples now, cloning main.

@StarArawn
Copy link
Owner

I noticed this happens when i run any of the examples now, cloning main.

I think this is an issue with linux, but I don't have a linux setup to test right now, and is likely related to this:
#215

Instead of assuming the primary window exists we should check to see. I think if you need a more complicated windowing setup the default App probably will not work well for you as it'll always only check the primary window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants