WindowServer: Remove Clock from server.

We have clock applet.
This commit is contained in:
Hüseyin ASLITÜRK 2019-12-27 21:32:52 +03:00 committed by Andreas Kling
parent 3d4dddd111
commit e50deb55d3
3 changed files with 6 additions and 36 deletions

View file

@ -24,6 +24,10 @@ Priority=high
KeepAlive=1
User=anon
[Clock.MenuApplet]
KeepAlive=1
User=anon
[CPUGraph.MenuApplet]
KeepAlive=1
User=anon

View file

@ -1,25 +1,14 @@
#include <LibCore/CTimer.h>
#include <LibDraw/Font.h>
#include <LibDraw/Painter.h>
#include <WindowServer/WSMenuManager.h>
#include <WindowServer/WSScreen.h>
#include <WindowServer/WSWindowManager.h>
#include <time.h>
#include <unistd.h>
WSMenuManager::WSMenuManager()
{
m_username = getlogin();
m_needs_window_resize = true;
m_timer = CTimer::construct(300, [this] {
static time_t last_update_time;
time_t now = time(nullptr);
if (now != last_update_time) {
tick_clock();
last_update_time = now;
}
});
}
WSMenuManager::~WSMenuManager()
@ -57,15 +46,7 @@ void WSMenuManager::draw()
menubar_rect.height()
};
int time_width = Font::default_font().width("2222-22-22 22:22:22");
m_time_rect = {
m_username_rect.left() - menubar_menu_margin() / 2 - time_width,
menubar_rect.y(),
time_width,
menubar_rect.height()
};
int right_edge_x = m_time_rect.left() - 4;
int right_edge_x = m_username_rect.left() - 4;
for (auto& existing_applet : m_applets) {
if (!existing_applet)
continue;
@ -106,18 +87,6 @@ void WSMenuManager::draw()
painter.draw_text(m_username_rect, m_username, Font::default_bold_font(), TextAlignment::CenterRight, palette.window_text());
time_t now = time(nullptr);
auto* tm = localtime(&now);
auto time_text = String::format("%4u-%02u-%02u %02u:%02u:%02u",
tm->tm_year + 1900,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
painter.draw_text(m_time_rect, time_text, wm.font(), TextAlignment::CenterRight, palette.window_text());
for (auto& applet : m_applets) {
if (!applet)
continue;
@ -282,7 +251,7 @@ void WSMenuManager::close_bar()
void WSMenuManager::add_applet(WSWindow& applet)
{
int right_edge_x = m_time_rect.left() - 4;
int right_edge_x = m_username_rect.left() - 4;
for (auto& existing_applet : m_applets) {
if (existing_applet)
right_edge_x = existing_applet->rect_in_menubar().x() - 4;

View file

@ -2,7 +2,6 @@
#include "WSMenu.h"
#include <LibCore/CObject.h>
#include <LibCore/CTimer.h>
#include <WindowServer/WSWindow.h>
class AClientConnection;
@ -53,7 +52,6 @@ private:
RefPtr<WSWindow> m_window;
String m_username;
RefPtr<CTimer> m_timer;
WeakPtr<WSMenu> m_current_menu;
Vector<WeakPtr<WSMenu>> m_open_menu_stack;
@ -61,7 +59,6 @@ private:
Vector<WeakPtr<WSWindow>> m_applets;
Rect m_username_rect;
Rect m_time_rect;
bool m_needs_window_resize { false };
bool m_bar_open { false };