Changeset View
Changeset View
Standalone View
Standalone View
main_wayland.cpp
Show First 20 Lines • Show All 521 Lines • ▼ Show 20 Line(s) | 500 | #endif | |||
---|---|---|---|---|---|
522 | QCommandLineOption widthOption(QStringLiteral("width"), | 522 | QCommandLineOption widthOption(QStringLiteral("width"), | ||
523 | i18n("The width for windowed mode. Default width is 1024."), | 523 | i18n("The width for windowed mode. Default width is 1024."), | ||
524 | QStringLiteral("width")); | 524 | QStringLiteral("width")); | ||
525 | widthOption.setDefaultValue(QString::number(1024)); | 525 | widthOption.setDefaultValue(QString::number(1024)); | ||
526 | QCommandLineOption heightOption(QStringLiteral("height"), | 526 | QCommandLineOption heightOption(QStringLiteral("height"), | ||
527 | i18n("The height for windowed mode. Default height is 768."), | 527 | i18n("The height for windowed mode. Default height is 768."), | ||
528 | QStringLiteral("height")); | 528 | QStringLiteral("height")); | ||
529 | heightOption.setDefaultValue(QString::number(768)); | 529 | heightOption.setDefaultValue(QString::number(768)); | ||
530 | | ||||
531 | QCommandLineOption scaleOption(QStringLiteral("scale"), | ||||
532 | i18n("The scale for windowed mode. Default value is 1."), | ||||
533 | QStringLiteral("scale")); | ||||
graesslin: careful here: copy and paste error | |||||
534 | scaleOption.setDefaultValue(QString::number(1)); | ||||
535 | | ||||
530 | QCommandLineOption outputCountOption(QStringLiteral("output-count"), | 536 | QCommandLineOption outputCountOption(QStringLiteral("output-count"), | ||
531 | i18n("The number of windows to open as outputs in windowed mode. Default value is 1"), | 537 | i18n("The number of windows to open as outputs in windowed mode. Default value is 1"), | ||
532 | QStringLiteral("height")); | 538 | QStringLiteral("height")); | ||
533 | outputCountOption.setDefaultValue(QString::number(1)); | 539 | outputCountOption.setDefaultValue(QString::number(1)); | ||
534 | 540 | | |||
535 | QCommandLineParser parser; | 541 | QCommandLineParser parser; | ||
536 | a.setupCommandLine(&parser); | 542 | a.setupCommandLine(&parser); | ||
537 | parser.addOption(xwaylandOption); | 543 | parser.addOption(xwaylandOption); | ||
Show All 12 Lines | 554 | if (hasFramebufferOption) { | |||
550 | parser.addOption(framebufferDeviceOption); | 556 | parser.addOption(framebufferDeviceOption); | ||
551 | } | 557 | } | ||
552 | if (hasVirtualOption) { | 558 | if (hasVirtualOption) { | ||
553 | parser.addOption(virtualFbOption); | 559 | parser.addOption(virtualFbOption); | ||
554 | } | 560 | } | ||
555 | if (hasSizeOption) { | 561 | if (hasSizeOption) { | ||
556 | parser.addOption(widthOption); | 562 | parser.addOption(widthOption); | ||
557 | parser.addOption(heightOption); | 563 | parser.addOption(heightOption); | ||
564 | parser.addOption(scaleOption); | ||||
558 | } | 565 | } | ||
559 | if (hasOutputCountOption) { | 566 | if (hasOutputCountOption) { | ||
560 | parser.addOption(outputCountOption); | 567 | parser.addOption(outputCountOption); | ||
561 | } | 568 | } | ||
562 | #if HAVE_LIBHYBRIS | 569 | #if HAVE_LIBHYBRIS | ||
563 | QCommandLineOption hwcomposerOption(QStringLiteral("hwcomposer"), i18n("Use libhybris hwcomposer")); | 570 | QCommandLineOption hwcomposerOption(QStringLiteral("hwcomposer"), i18n("Use libhybris hwcomposer")); | ||
564 | if (hasHwcomposerOption) { | 571 | if (hasHwcomposerOption) { | ||
565 | parser.addOption(hwcomposerOption); | 572 | parser.addOption(hwcomposerOption); | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
628 | #if HAVE_INPUT | 635 | #if HAVE_INPUT | ||
629 | KWin::Application::setUseLibinput(parser.isSet(libinputOption)); | 636 | KWin::Application::setUseLibinput(parser.isSet(libinputOption)); | ||
630 | #endif | 637 | #endif | ||
631 | 638 | | |||
632 | QString pluginName; | 639 | QString pluginName; | ||
633 | QSize initialWindowSize; | 640 | QSize initialWindowSize; | ||
634 | QByteArray deviceIdentifier; | 641 | QByteArray deviceIdentifier; | ||
635 | int outputCount = 1; | 642 | int outputCount = 1; | ||
643 | qreal outputScale = 1; | ||||
hmm I'm not sure whether we should implement it as an int factor. Even if Wayland only supports integer scaling, I think that's a bad idea and we should rather go with fractal scaling from the start. Of course towards Wayland we need to expose it as integer scaling. But in case Wayland gets an update we would be prepared. graesslin: hmm I'm not sure whether we should implement it as an int factor. Even if Wayland only supports… | |||||
davidedmundson: Makes sense to me. I'll do that change. | |||||
636 | 644 | | |||
637 | #if HAVE_DRM | 645 | #if HAVE_DRM | ||
638 | if (hasDrmOption && parser.isSet(drmOption)) { | 646 | if (hasDrmOption && parser.isSet(drmOption)) { | ||
639 | pluginName = KWin::s_drmPlugin; | 647 | pluginName = KWin::s_drmPlugin; | ||
640 | } | 648 | } | ||
641 | #endif | 649 | #endif | ||
642 | 650 | | |||
643 | if (hasSizeOption) { | 651 | if (hasSizeOption) { | ||
644 | bool ok = false; | 652 | bool ok = false; | ||
645 | const int width = parser.value(widthOption).toInt(&ok); | 653 | const int width = parser.value(widthOption).toInt(&ok); | ||
646 | if (!ok) { | 654 | if (!ok) { | ||
647 | std::cerr << "FATAL ERROR incorrect value for width" << std::endl; | 655 | std::cerr << "FATAL ERROR incorrect value for width" << std::endl; | ||
648 | return 1; | 656 | return 1; | ||
649 | } | 657 | } | ||
650 | const int height = parser.value(heightOption).toInt(&ok); | 658 | const int height = parser.value(heightOption).toInt(&ok); | ||
651 | if (!ok) { | 659 | if (!ok) { | ||
652 | std::cerr << "FATAL ERROR incorrect value for height" << std::endl; | 660 | std::cerr << "FATAL ERROR incorrect value for height" << std::endl; | ||
653 | return 1; | 661 | return 1; | ||
654 | } | 662 | } | ||
663 | const qreal scale = parser.value(scaleOption).toDouble(&ok); | ||||
664 | if (!ok || scale < 1) { | ||||
665 | std::cerr << "FATAL ERROR incorrect value for scale" << std::endl; | ||||
666 | return 1; | ||||
667 | } | ||||
668 | | ||||
669 | outputScale = scale; | ||||
655 | initialWindowSize = QSize(width, height); | 670 | initialWindowSize = QSize(width, height); | ||
656 | } | 671 | } | ||
657 | 672 | | |||
658 | if (hasOutputCountOption) { | 673 | if (hasOutputCountOption) { | ||
659 | bool ok = false; | 674 | bool ok = false; | ||
660 | const int count = parser.value(outputCountOption).toInt(&ok); | 675 | const int count = parser.value(outputCountOption).toInt(&ok); | ||
661 | if (ok) { | 676 | if (ok) { | ||
662 | outputCount = qMax(1, count); | 677 | outputCount = qMax(1, count); | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 741 | if (!a.platform()) { | |||
728 | return 1; | 743 | return 1; | ||
729 | } | 744 | } | ||
730 | if (!deviceIdentifier.isEmpty()) { | 745 | if (!deviceIdentifier.isEmpty()) { | ||
731 | a.platform()->setDeviceIdentifier(deviceIdentifier); | 746 | a.platform()->setDeviceIdentifier(deviceIdentifier); | ||
732 | } | 747 | } | ||
733 | if (initialWindowSize.isValid()) { | 748 | if (initialWindowSize.isValid()) { | ||
734 | a.platform()->setInitialWindowSize(initialWindowSize); | 749 | a.platform()->setInitialWindowSize(initialWindowSize); | ||
735 | } | 750 | } | ||
751 | a.platform()->setInitialOutputScale(outputScale); | ||||
736 | a.platform()->setInitialOutputCount(outputCount); | 752 | a.platform()->setInitialOutputCount(outputCount); | ||
737 | 753 | | |||
738 | QObject::connect(&a, &KWin::Application::workspaceCreated, server, &KWin::WaylandServer::initWorkspace); | 754 | QObject::connect(&a, &KWin::Application::workspaceCreated, server, &KWin::WaylandServer::initWorkspace); | ||
739 | environment.insert(QStringLiteral("WAYLAND_DISPLAY"), server->display()->socketName()); | 755 | environment.insert(QStringLiteral("WAYLAND_DISPLAY"), server->display()->socketName()); | ||
740 | a.setProcessStartupEnvironment(environment); | 756 | a.setProcessStartupEnvironment(environment); | ||
741 | a.setStartXwayland(parser.isSet(xwaylandOption)); | 757 | a.setStartXwayland(parser.isSet(xwaylandOption)); | ||
742 | a.setApplicationsToStart(parser.positionalArguments()); | 758 | a.setApplicationsToStart(parser.positionalArguments()); | ||
743 | a.setInputMethodServerToStart(parser.value(inputMethodOption)); | 759 | a.setInputMethodServerToStart(parser.value(inputMethodOption)); | ||
744 | a.start(); | 760 | a.start(); | ||
745 | 761 | | |||
746 | return a.exec(); | 762 | return a.exec(); | ||
747 | } | 763 | } |
careful here: copy and paste error