Resolve a TODO and fix another ancient bug, #386. Print Screen is now handled

by BWindow, no longer by the app_server. This should stop the "screen freeze"
effect.

This adds a dependency on libpng.so and libz.so to libbe.so. The same
dependencies and the PNGDump code added here can be removed from the
app_server. I am just waiting for a code review of this before doing that.

This implementation still does not give the client a chance to handle it
differently.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25269 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2008-04-30 02:55:15 +00:00
parent 2428097297
commit 6aede71c0c
6 changed files with 184 additions and 20 deletions
+36
View File
@@ -17,6 +17,7 @@
#include <Application.h>
#include <Autolock.h>
#include <Bitmap.h>
#include <Button.h>
#include <MenuBar.h>
#include <MenuItem.h>
@@ -41,6 +42,8 @@
#include <tracker_private.h>
#include <WindowPrivate.h>
#include "PNGDump.h"
//#define DEBUG_WIN
#ifdef DEBUG_WIN
@@ -3239,6 +3242,39 @@ BWindow::_HandleKeyDown(BMessage* event)
PostMessage(&message);
return true;
}
if (key == B_FUNCTION_KEY) {
// Check for Print Screen
int32 rawKey;
if (event->FindInt32("key", &rawKey) == B_OK && rawKey == B_PRINT_KEY) {
// Get filename
char filename[128];
BEntry entry;
int32 index = 1;
do {
// TODO: Use find_directory(B_USER_DIRECTORY, ...)
sprintf(filename, "/boot/home/screen%ld.png", index++);
entry.SetTo(filename);
} while(entry.Exists());
// Get the screen bitmap
BScreen screen(this);
BBitmap* screenDump;
screen.GetBitmap(&screenDump, false);
// Dump to PNG
SaveToPNG(filename, screen.Frame(), screenDump->ColorSpace(),
screenDump->Bits(),
screenDump->BitsLength(),
screenDump->BytesPerRow());
// Free the bitmap allocated by BScreen.GetBitmap
delete screenDump;
return true;
}
}
// Handle shortcuts
if ((modifiers & B_COMMAND_KEY) != 0) {