mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
WindowServer+LibGUI: Pass window icons as shared buffers rather than paths.
Now that we support more than 2 clients per shared buffer, we can use them for window icons. I didn't do that previously since it would have made the Taskbar process unable to access the icons. This opens up some nice possibilities for programmatically generated icons.
This commit is contained in:
parent
63619b9f7c
commit
841b2e5d13
21 changed files with 193 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "DirectoryView.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <LibCore/CUserInfo.h>
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GActionGroup.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
|
@ -227,7 +228,7 @@ int main(int argc, char** argv)
|
|||
window->set_main_widget(widget);
|
||||
window->show();
|
||||
|
||||
window->set_icon_path("/res/icons/16x16/filetype-folder.png");
|
||||
window->set_icon(load_png("/res/icons/16x16/filetype-folder.png"));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "FontEditor.h"
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <stdio.h>
|
||||
|
@ -30,6 +31,6 @@ int main(int argc, char** argv)
|
|||
auto* font_editor = new FontEditorWidget(path, move(edited_font));
|
||||
window->set_main_widget(font_editor);
|
||||
window->show();
|
||||
window->set_icon_path("/res/icons/16x16/app-font-editor.png");
|
||||
window->set_icon(load_png("/res/icons/16x16/app-font-editor.png"));
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <LibAudio/AClientConnection.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <LibCore/CThread.h>
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
|
@ -23,7 +24,7 @@ int main(int argc, char** argv)
|
|||
auto* piano_widget = new PianoWidget;
|
||||
window->set_main_widget(piano_widget);
|
||||
window->show();
|
||||
window->set_icon_path("/res/icons/16x16/app-piano.png");
|
||||
window->set_icon(load_png("/res/icons/16x16/app-piano.png"));
|
||||
|
||||
CThread sound_thread([](void* context) -> int {
|
||||
auto* piano_widget = (PianoWidget*)context;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "ProcessStacksWidget.h"
|
||||
#include "ProcessTableView.h"
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
|
@ -168,7 +169,7 @@ int main(int argc, char** argv)
|
|||
|
||||
window->show();
|
||||
|
||||
window->set_icon_path("/res/icons/16x16/app-process-manager.png");
|
||||
window->set_icon(load_png("/res/icons/16x16/app-process-manager.png"));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "TaskbarWindow.h"
|
||||
#include "TaskbarButton.h"
|
||||
#include <LibC/SharedBuffer.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
|
@ -100,6 +101,22 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
|||
break;
|
||||
}
|
||||
|
||||
case GEvent::WM_WindowIconBitmapChanged: {
|
||||
auto& changed_event = static_cast<GWMWindowIconBitmapChangedEvent&>(event);
|
||||
#ifdef EVENT_DEBUG
|
||||
dbgprintf("WM_WindowIconChanged: client_id=%d, window_id=%d, icon_buffer_id=%d\n",
|
||||
changed_event.client_id(),
|
||||
changed_event.window_id(),
|
||||
changed_event.icon_buffer_id());
|
||||
#endif
|
||||
if (auto* window = WindowList::the().window(identifier)) {
|
||||
auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id());
|
||||
ASSERT(buffer);
|
||||
window->button()->set_icon(GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *buffer, changed_event.icon_size()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GEvent::WM_WindowStateChanged: {
|
||||
auto& changed_event = static_cast<GWMWindowStateChangedEvent&>(event);
|
||||
#ifdef EVENT_DEBUG
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Terminal.h"
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibCore/CUserInfo.h>
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
|
@ -154,7 +155,7 @@ int main(int argc, char** argv)
|
|||
window->move_to(300, 300);
|
||||
terminal.apply_size_increments_to_window(*window);
|
||||
window->show();
|
||||
window->set_icon_path("/res/icons/16x16/app-terminal.png");
|
||||
window->set_icon(load_png("/res/icons/16x16/app-terminal.png"));
|
||||
terminal.set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
||||
|
||||
WeakPtr<GWindow> settings_window;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "TextEditorWidget.h"
|
||||
#include <LibDraw/PNGLoader.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -15,7 +16,7 @@ int main(int argc, char** argv)
|
|||
text_widget->open_sesame(argv[1]);
|
||||
|
||||
window->show();
|
||||
window->set_icon_path("/res/icons/TextEditor16.png");
|
||||
window->set_icon(load_png("/res/icons/TextEditor16.png"));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue