Commit fa4bd94d authored by Gustavo Carneiro's avatar Gustavo Carneiro Committed by Tomaz Canabrava
Browse files

Remove RandomSeed on TerminalDisplay.

parent 78394332
......@@ -656,7 +656,7 @@ TerminalDisplay *ViewManager::createView(Session *session)
// Use Qt::UniqueConnection to avoid duplicate connection
connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished,
Qt::UniqueConnection);
TerminalDisplay *display = createTerminalDisplay(session);
TerminalDisplay *display = createTerminalDisplay();
const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
applyProfileToView(display, profile);
......@@ -786,10 +786,9 @@ void ViewManager::viewDestroyed(QWidget *view)
// emit unplugController(_pluggedController);
}
TerminalDisplay *ViewManager::createTerminalDisplay(Session *session)
TerminalDisplay *ViewManager::createTerminalDisplay()
{
auto display = new TerminalDisplay(nullptr);
display->setRandomSeed(session->sessionId() | (qApp->applicationPid() << 10));
connect(display, &TerminalDisplay::requestToggleExpansion,
_viewContainer, &TabbedViewContainer::toggleMaximizeCurrentTerminal);
......
......@@ -403,7 +403,7 @@ private:
// creates a new terminal display
// the 'session' is used so that the terminal display's random seed
// can be set to something which depends uniquely on that session
TerminalDisplay *createTerminalDisplay(Session *session = nullptr);
TerminalDisplay *createTerminalDisplay();
// creates a new controller for a session/display pair which provides the menu
// actions associated with that view, and exposes basic information
......
......@@ -12,6 +12,7 @@
// Qt
#include <QPainter>
#include <QApplication>
// KDE
#include <KConfig>
......@@ -244,13 +245,13 @@ void ColorScheme::setColorTableEntry(int index, const ColorEntry &entry)
}
}
ColorEntry ColorScheme::colorEntry(int index, uint randomSeed) const
ColorEntry ColorScheme::colorEntry(int index, uint sessionId) const
{
Q_ASSERT(index >= 0 && index < TABLE_COLORS);
ColorEntry entry = colorTable()[index];
if (!_colorRandomization || randomSeed == 0 || _randomTable == nullptr
if (!_colorRandomization || sessionId == 0 || _randomTable == nullptr
|| _randomTable[index].isNull()) {
return entry;
}
......@@ -266,7 +267,7 @@ ColorEntry ColorScheme::colorEntry(int index, uint randomSeed) const
// 32-bit Mersenne Twister
// Can't use default_random_engine, because in GCC this maps to
// minstd_rand0 which always gives us 0 on the first number.
std::mt19937 randomEngine(randomSeed);
std::mt19937 randomEngine(sessionId | qApp->applicationPid() << 10);
// Use hues located around base color's hue.
// H=0 [|= =] H=128 [ =|= ] H=360 [= =|]
......@@ -320,10 +321,10 @@ ColorEntry ColorScheme::colorEntry(int index, uint randomSeed) const
return {qRound(red * 255), qRound(green * 255), qRound(blue * 255)};
}
void ColorScheme::getColorTable(ColorEntry *table, uint randomSeed) const
void ColorScheme::getColorTable(ColorEntry *table, uint sessionId) const
{
for (int i = 0; i < TABLE_COLORS; i++) {
table[i] = colorEntry(i, randomSeed);
table[i] = colorEntry(i, sessionId);
}
}
......
......@@ -65,17 +65,15 @@ public:
*
* @param table Array into which the color entries for this color scheme
* are copied.
* @param randomSeed Color schemes may allow certain colors in their
* palette to be randomized. The seed is used to pick the random color.
*/
void getColorTable(ColorEntry *table, uint randomSeed = 0) const;
void getColorTable(ColorEntry *table, uint sessionId = 0) const;
/**
* Retrieves a single color entry from the table.
*
* See getColorTable()
*/
ColorEntry colorEntry(int index, uint randomSeed = 0) const;
ColorEntry colorEntry(int index, uint sessionId = 0) const;
/**
* Convenience method. Returns the
......
......@@ -30,10 +30,10 @@ namespace Konsole
setColorTable(ColorScheme::defaultTable);
}
void TerminalColor::applyProfile(const Profile::Ptr &profile, ColorScheme const *colorScheme, int randomSeed)
void TerminalColor::applyProfile(const Profile::Ptr &profile, ColorScheme const *colorScheme, uint sessionId)
{
ColorEntry table[TABLE_COLORS];
colorScheme->getColorTable(table, randomSeed);
colorScheme->getColorTable(table, sessionId);
setColorTable(table);
setOpacity(colorScheme->opacity());
......
......@@ -30,7 +30,7 @@ namespace Konsole
public:
explicit TerminalColor(QWidget *parent);
void applyProfile(const Profile::Ptr &profile, ColorScheme const *colorScheme, int randomSeed);
void applyProfile(const Profile::Ptr &profile, ColorScheme const *colorScheme, uint sessionId);
QColor backgroundColor() const;
QColor foregroundColor() const;
......
......@@ -361,7 +361,6 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
, _image(nullptr)
, _imageSize(0)
, _lineProperties(QVector<LineProperty>())
, _randomSeed(0)
, _resizing(false)
, _showTerminalSizeHint(true)
, _bidiEnabled(false)
......@@ -621,15 +620,6 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m
viewScrolledByUser();
}
void TerminalDisplay::setRandomSeed(uint randomSeed)
{
_randomSeed = randomSeed;
}
uint TerminalDisplay::randomSeed() const
{
return _randomSeed;
}
void TerminalDisplay::processFilters()
{
......@@ -2978,7 +2968,7 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
{
// load color scheme
_colorScheme = ViewManager::colorSchemeForProfile(profile);
_terminalColor->applyProfile(profile, _colorScheme, randomSeed());
_terminalColor->applyProfile(profile, _colorScheme, sessionController()->session()->sessionId());
setWallpaper(_colorScheme->wallpaper());
// load font
......
......@@ -75,17 +75,6 @@ public:
void applyProfile(const QExplicitlySharedDataPointer<Profile>& profile);
/**
* Sets the seed used to generate random colors for the display
* (in color schemes that support them).
*/
void setRandomSeed(uint randomSeed);
/**
* Returns the seed used to generate random colors for the display
* (in color schemes that support them).
*/
uint randomSeed() const;
/** Sets the opacity of the terminal display. */
void setOpacity(qreal opacity);
......@@ -704,8 +693,6 @@ private:
ColorEntry _colorTable[TABLE_COLORS];
uint _randomSeed;
bool _resizing;
bool _showTerminalSizeHint;
bool _bidiEnabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment