1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

WindowServer: Show PID and window ID in title bars for now.

This is useful for debugging since I'm often wondering which process some
window belongs to (and what the window ID is.)
This commit is contained in:
Andreas Kling 2019-01-21 02:42:29 +01:00
parent e6fc84e234
commit 291922b1af
5 changed files with 13 additions and 1 deletions

View file

@ -138,6 +138,9 @@ void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alig
point = rect.location();
} else if (alignment == TextAlignment::CenterLeft) {
point = { rect.x(), rect.center().y() - (font().glyph_height() / 2) };
} else if (alignment == TextAlignment::CenterRight) {
int text_width = text.length() * font().glyph_width();
point = { rect.right() - text_width, rect.center().y() - (font().glyph_height() / 2) };
} else if (alignment == TextAlignment::Center) {
int textWidth = text.length() * font().glyph_width();
point = rect.center();

View file

@ -30,7 +30,7 @@ public:
void draw_focus_rect(const Rect&);
void blit(const Point&, const GraphicsBitmap&, const Rect& src_rect);
enum class TextAlignment { TopLeft, CenterLeft, Center };
enum class TextAlignment { TopLeft, CenterLeft, Center, CenterRight };
void draw_text(const Rect&, const String&, TextAlignment = TextAlignment::TopLeft, Color = Color());
void draw_glyph(const Point&, char, Color);

View file

@ -7,6 +7,7 @@
WSWindow::WSWindow(Process& process, int window_id)
: m_process(process)
, m_window_id(window_id)
, m_pid(process.pid())
{
WSWindowManager::the().add_window(*this);
}

View file

@ -38,6 +38,8 @@ public:
GraphicsBitmap* backing() { return m_backing.ptr(); }
pid_t pid() const { return m_pid; }
// For InlineLinkedList.
// FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
WSWindow* m_next { nullptr };
@ -51,5 +53,6 @@ private:
RetainPtr<GraphicsBitmap> m_backing;
Process& m_process;
int m_window_id { -1 };
pid_t m_pid { -1 };
};

View file

@ -179,6 +179,11 @@ void WSWindowManager::paint_window_frame(WSWindow& window)
m_back_painter->draw_rect(outerRect, border_color);
m_back_painter->draw_rect(inner_border_rect, border_color);
m_back_painter->draw_text(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, title_color);
Color metadata_color(204, 204, 204);
char buffer[64];
ksprintf(buffer, "%d:%d", window.pid(), window.window_id());
m_back_painter->draw_text(titleBarTitleRect, buffer, Painter::TextAlignment::CenterRight, metadata_color);
}
void WSWindowManager::add_window(WSWindow& window)