Ejemplo n.º 1
0
int main(int argc, char **argv)
{
	int fd;
	int opt;
	const char *card = "/dev/dri/card0";

	while ((opt = getopt(argc, argv, "c:")) != -1) {
		switch (opt) {
		case 'c':
			card = optarg;
			break;
		}
	}

	// open the DRM device
	fd = drm_open_dev_dumb(card);

	// Prepare all connectors and CRTCs
	modeset_prepare(fd, &modeset_list);

	// Allocate buffers
	modeset_alloc_fbs(modeset_list, 2);

	// Allocate private data
	for_each_output(out, modeset_list)
		out->data = calloc(1, sizeof(struct flip_data));

	// Set modes
	modeset_set_modes(modeset_list);

	// Draw color bar
	modeset_main_loop(modeset_list, &page_flip_event);

	// Free private data
	for_each_output(out, modeset_list)
		free(out->data);

	// Free modeset data
	modeset_cleanup(modeset_list);

	close(fd);

	fprintf(stderr, "exiting\n");

	return 0;
}
Ejemplo n.º 2
0
void wayfire_core::wake()
{
    wl_event_loop_add_idle(ev_loop, refocus_idle_cb, 0);

    if (times_wake > 0)
    {
        for_each_output([] (wayfire_output *output)
                        { output->emit_signal("wake", nullptr); });
    }

    ++times_wake;
}
Ejemplo n.º 3
0
wayfire_output* wayfire_core::get_output_at(int x, int y)
{
    wayfire_output *target = nullptr;
    for_each_output([&] (wayfire_output *output)
    {
        if ((output->get_layout_geometry() & wf_point{x, y}) &&
                target == nullptr)
        {
            target = output;
        }
    });

    return target;
}
bool msh::GraphicsDisplayLayout::place_in_output(
    graphics::DisplayConfigurationOutputId id,
    geometry::Rectangle& rect)
{
    auto config = display->configuration();
    bool placed = false;

    /* Accept only fullscreen placements for now */
    config->for_each_output([&](mg::DisplayConfigurationOutput const& output)
    {
        if (output.id == id &&
            output.current_mode_index < output.modes.size())
        {
            rect.top_left = output.top_left;
            rect.size = output.extents().size;
            placed = true;
        }
    });

    return placed;
}
Ejemplo n.º 5
0
void wayfire_core::sleep()
{
    for_each_output([] (wayfire_output *output)
            { output->emit_signal("sleep", nullptr); });
}
Ejemplo n.º 6
0
bool me::WindowManager::handle_key_event(MirKeyboardEvent const* kev)
{
    // TODO: Fix android configuration and remove static hack ~racarr
    static bool display_off = false;

    if (mir_keyboard_event_action(kev) != mir_keyboard_action_down)
        return false;

    auto modifiers = mir_keyboard_event_modifiers(kev);
    auto scan_code = mir_keyboard_event_scan_code(kev);
    
    if (modifiers & mir_input_event_modifier_alt &&
        scan_code == KEY_TAB)  // TODO: Use keycode once we support keymapping on the server side
    {
        focus_controller->focus_next_session();
        if (auto const surface = focus_controller->focused_surface())
            focus_controller->raise({surface});
        return true;
    }
    else if (modifiers & mir_input_event_modifier_alt &&
             scan_code == KEY_GRAVE)
    {
        if (auto const prev = focus_controller->focused_surface())
        {
            auto const app = focus_controller->focused_session();
            auto const next = app->surface_after(prev);
            focus_controller->set_focus_to(app, next);
            focus_controller->raise({next});
        }
        return true;
    }
    else if (modifiers & mir_input_event_modifier_alt &&
             scan_code == KEY_F4)
    {
        auto const surf = focus_controller->focused_surface();
        if (surf)
            surf->request_client_surface_close();
        return true;
    }
    else if ((modifiers & mir_input_event_modifier_alt &&
              scan_code == KEY_P) ||
             (scan_code == KEY_POWER))
    {
        compositor->stop();
        auto conf = display->configuration();
        MirPowerMode new_power_mode = display_off ?
            mir_power_mode_on : mir_power_mode_off;
        conf->for_each_output(
            [&](mg::UserDisplayConfigurationOutput& output) -> void
            {
                output.power_mode = new_power_mode;
            });
        display_off = !display_off;

        display->configure(*conf.get());
        if (!display_off)
            compositor->start();
        return true;
    }
    else if ((modifiers & mir_input_event_modifier_alt) &&
             (modifiers & mir_input_event_modifier_ctrl) &&
             (scan_code == KEY_ESC))
    {
        std::abort();
        return true;
    }
    else if ((modifiers & mir_input_event_modifier_alt) &&
             (modifiers & mir_input_event_modifier_ctrl) &&
             (scan_code == KEY_L) &&
             focus_controller)
    {
        auto const app = focus_controller->focused_session();
        if (app)
        {
            app->set_lifecycle_state(mir_lifecycle_state_will_suspend);
        }
    }
    else if ((modifiers & mir_input_event_modifier_alt) &&
             (modifiers & mir_input_event_modifier_ctrl))
    {
        MirOrientation orientation = mir_orientation_normal;
        bool rotating = true;
        int mode_change = 0;
        bool preferred_mode = false;
        switch (scan_code)
        {
        case KEY_UP:    orientation = mir_orientation_normal; break;
        case KEY_DOWN:  orientation = mir_orientation_inverted; break;
        case KEY_LEFT:  orientation = mir_orientation_left; break;
        case KEY_RIGHT: orientation = mir_orientation_right; break;
        default:        rotating = false; break;
        }
        switch (scan_code)
        {
        case KEY_MINUS: mode_change = -1;      break;
        case KEY_EQUAL: mode_change = +1;      break;
        case KEY_0:     preferred_mode = true; break;
        default:                               break;
        }
        
        if (rotating || mode_change || preferred_mode)
        {
            compositor->stop();
            auto conf = display->configuration();
            conf->for_each_output(
                [&](mg::UserDisplayConfigurationOutput& output) -> void
                {
                    // Only apply changes to the monitor the cursor is on
                    if (!output.extents().contains(old_cursor))
                        return;
                    if (rotating)
                        output.orientation = orientation;
                    if (preferred_mode)
                    {
                        output.current_mode_index =
                            output.preferred_mode_index;
                    }
                    else if (mode_change)
                    {
                        size_t nmodes = output.modes.size();
                        if (nmodes)
                            output.current_mode_index =
                                (output.current_mode_index + nmodes +
                                 mode_change) % nmodes;
                    }
                });
                                  
            display->configure(*conf);
            compositor->start();
            return true;
        }
    }
    else if ((scan_code == KEY_VOLUMEDOWN ||
              scan_code == KEY_VOLUMEUP) &&
             max_fingers == 1)
    {
        int delta = (scan_code == KEY_VOLUMEDOWN) ? -1 : +1;
        static const MirOrientation order[4] =
        {
            mir_orientation_normal,
            mir_orientation_right,
            mir_orientation_inverted,
            mir_orientation_left
        };
        compositor->stop();
        auto conf = display->configuration();
        conf->for_each_output(
            [&](mg::UserDisplayConfigurationOutput& output)
            {
                int i = 0;
                for (; i < 4; ++i)
                {
                    if (output.orientation == order[i])
                        break;
                }
                output.orientation = order[(i+4+delta) % 4];
            });
        display->configure(*conf.get());
        compositor->start();
        return true;
    }
    else if (modifiers & mir_input_event_modifier_meta &&
             scan_code == KEY_N)
    {
        toggle(inverse);
        return true;
    }
    else if (modifiers & mir_input_event_modifier_meta &&
             scan_code == KEY_C)
    {
        toggle(contrast);
        return true;
    }
    return false;
}