nxterm_resize.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /****************************************************************************
  2. * graphics/nxterm/nxterm_resize.c
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. /****************************************************************************
  21. * Included Files
  22. ****************************************************************************/
  23. #include <nuttx/config.h>
  24. #include <stdint.h>
  25. #include <assert.h>
  26. #include <errno.h>
  27. #include <debug.h>
  28. #include <nuttx/nx/nx.h>
  29. #include <nuttx/nx/nxglib.h>
  30. #include "nxterm.h"
  31. /****************************************************************************
  32. * Public Functions
  33. ****************************************************************************/
  34. /****************************************************************************
  35. * Name: nxterm_resize
  36. *
  37. * Description:
  38. * This function handles the IOCTL resize command. It indicates that the
  39. * size of the NxTerm window has changed and needs to be updated.
  40. *
  41. * Input Parameters:
  42. * handle - A handle previously returned by nx_register, nxtk_register, or
  43. * nxtool_register.
  44. * size - The new window size
  45. *
  46. * Returned Value:
  47. * None
  48. *
  49. ****************************************************************************/
  50. int nxterm_resize(NXTERM handle, FAR const struct nxgl_size_s *size)
  51. {
  52. FAR struct nxterm_state_s *priv;
  53. int ret;
  54. DEBUGASSERT(handle != NULL && size != NULL);
  55. ginfo("size={%d,%d)\n", size->w, size->h);
  56. /* Recover our private state structure */
  57. priv = (FAR struct nxterm_state_s *)handle;
  58. /* Get exclusive access to the state structure */
  59. ret = nxterm_semwait(priv);
  60. if (ret < 0)
  61. {
  62. return ret;
  63. }
  64. /* Set the new window size.
  65. * REVISIT: Should other things be reset as well?
  66. */
  67. priv->wndo.wsize.w = size->w;
  68. priv->wndo.wsize.h = size->h;
  69. nxterm_sempost(priv);
  70. return true;
  71. }